#pragma once #include #include #include #include #include #include "Effect.h" #include "Inventory.h" #include "NetworkMessage.h" #include "ItemSkill.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; void applyItemSkillOnTarget(Entity* zActor, ItemSkill* zItemSkill, Item* zUsedItem); void placeBlock(Entity* zActor, Item* zItem); static void toMessage(const ActionTarget* zTarget, 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 { protected: float maxHP; float currentHP; float stamina; float maxStamina; float hunger; float maxHunger; float thirst; float maxThirst; float targetDistanceLimit; float maxMovementSpeed; Framework::Vec3 speed; Framework::Vec3 faceDir; Framework::Vec3 faceOffset; Framework::RCArray skills; ActionTarget* target; const EntityType* zEntityType; int currentDimensionId; bool removed; float gravityMultiplier; int id; Framework::ZeitMesser time; Framework::Array movements; Framework::Critical cs; virtual void onDeath(); virtual void useItem(const ItemType* zType, Item* zItem); Entity(const EntityType* zType, Framework::Vec3 location, int dimensionId, int entityId); virtual void onTargetChange(); void addMovementFrame(MovementFrame& frame); void calculateTarget(Framework::Vec3 basePos, Framework::Vec3 direction); public: virtual void prepareTick(const Dimension* zDimension); virtual void tick(const Dimension* zDimension); virtual void api(Framework::StreamReader* zRequest, NetworkMessage* zResponse); virtual void onFall(float collisionSpeed); void setPosition(Framework::Vec3 pos); 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; int getCurrentDimensionId() const; bool isRemoved() const; const EntityType* zType() const; const ActionTarget* zTarget() const; int getId() const; virtual bool hasDefaultModel() const; virtual ModelInfo getSpecialModel() const; float getMaxSpeed() const; friend Effect; friend EntityType; };