#pragma once #include #include #include #include #include #include "Effect.h" #include "Inventory.h" #include "ItemSkill.h" #include "ModelInfo.h" #include "NetworkMessage.h" class EntityType; class Dimension; class ActionTarget { private: Framework::Vec3 blockPos; Direction targetBlockSide; int entityId; public: ActionTarget(Framework::Vec3 blockPos, Direction blockSide); ActionTarget(int entityId); bool isBlock(Framework::Vec3 blockPos, Direction blockSide) const; bool isEntity(int entityId) const; bool useItemSkillOnTarget( Entity* zActor, ItemSkill* zItemSkill, Item* zUsedItem); bool interactItemSkillOnTarget( Entity* zActor, ItemSkill* zItemSkill, Item* zUsedItem); bool placeBlock(Entity* zActor, Item* zItem); static void toMessage( const ActionTarget* zTarget, int dimensionId, NetworkMessage* zMsg); static void save(ActionTarget* zTarget, Framework::StreamWriter* zWriter); static ActionTarget* load(Framework::StreamReader* zReader); }; struct MovementFrame { Framework::Vec3 direction; Framework::Vec3 targetPosition; int movementFlags; double duration; }; class Entity : public Inventory { private: float stamina; float hunger; float currentHP; float thirst; int chatSecurityLevel; Framework::Punkt lastChunkCenter; int lastDimensionId; protected: float maxHP; float maxStamina; float maxHunger; float maxThirst; float targetDistanceLimit; float maxMovementSpeed; Framework::Vec3 speed; Framework::Vec3 faceDir; Framework::Vec3 faceOffset; Framework::RCArray skills; ActionTarget* target; int typeId; bool removed; float gravityMultiplier; float jumpSpeed; int id; int placeBlockCooldown; Framework::ZeitMesser time; Framework::Array movements; Framework::Critical cs; Framework::Array> statusBarObservers; virtual void onDeath(); virtual bool useItem(int typeId, ItemStack* zStack, bool left); Entity(int typeId, Framework::Vec3 location, int dimensionId, int entityId); void addMovementFrame(MovementFrame& frame); void calculateTarget(Framework::Vec3 basePos, Framework::Vec3 direction, const Item* zItem); void removeStatusBarObserver(Entity* zSource, Framework::Text id); void addStatusBarObserver(Entity* zSource, Framework::Text id); void notifyStatusBarObservers(NetworkMessage* msg); ItemSkill* zSkill(int itemType); public: virtual void prepareTick(const Dimension* zDimension); virtual void tick(const Dimension* zDimension); virtual void api(Framework::StreamReader* zRequest, NetworkMessage* zResponse, Entity* zSource); virtual void onTargetChange(); virtual bool interact(Item* zItem, Entity* zActor); virtual void onFall(float collisionSpeed); void setChatSecurityLevel(int level); void setPosition(Framework::Vec3 pos); virtual void takeDamage(Entity* zSource, float damage); void setHP(float hp); void setStamina(float stamina); void setHunger(float hunger); void setThirst(float thirst); void setGravityMultiplier(float multiplier); void setJumpSpeed(float speed); float getMaxHP() const; float getCurrentHP() const; float getStamina() const; float getMaxStamina() const; float getHunger() const; float getMaxHunger() const; float getThirst() const; float getMaxThirst() const; Framework::Vec3 getSpeed() const; Framework::Vec3 getFaceDir() const; Framework::Vec3 getPosition() const; float getGravityMultiplier() const; float getJumpSpeed() const; bool isRemoved() const; const EntityType* zType() const; const ActionTarget* zTarget() const; int getId() const; virtual bool hasDefaultModel() const; virtual ModelInfo* zSpecialModel() const; float getMaxSpeed() const; bool isMoving() const; int getChatSecurityLevel() const; friend Effect; friend EntityType; };