123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- #pragma once
- #include <ReferenceCounter.h>
- #include <Vec2.h>
- #include <Vec3.h>
- #include <Writer.h>
- #include <Zeit.h>
- #include "Effect.h"
- #include "Inventory.h"
- #include "ItemSkill.h"
- #include "NetworkMessage.h"
- #include "ModelInfo.h"
- class EntityType;
- class Dimension;
- class ActionTarget
- {
- private:
- Framework::Vec3<int> blockPos;
- Direction targetBlockSide;
- int entityId;
- public:
- ActionTarget(Framework::Vec3<int> blockPos, Direction blockSide);
- ActionTarget(int entityId);
- bool isBlock(Framework::Vec3<int> 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<float> direction;
- Framework::Vec3<float> targetPosition;
- int movementFlags;
- double duration;
- };
- class Entity : public Inventory
- {
- private:
- float stamina;
- float hunger;
- float currentHP;
- float thirst;
- int chatSecurityLevel;
- protected:
- float maxHP;
- float maxStamina;
- float maxHunger;
- float maxThirst;
- float targetDistanceLimit;
- float maxMovementSpeed;
- Framework::Vec3<float> speed;
- Framework::Vec3<float> faceDir;
- Framework::Vec3<float> faceOffset;
- Framework::RCArray<ItemSkill> skills;
- ActionTarget* target;
- int typeId;
- bool removed;
- float gravityMultiplier;
- float jumpSpeed;
- int id;
- int placeBlockCooldown;
- Framework::ZeitMesser time;
- Framework::Array<MovementFrame> movements;
- Framework::Critical cs;
- Framework::Array<Framework::ImmutablePair<int, Framework::Text>>
- statusBarObservers;
- virtual void onDeath();
- virtual bool useItem(int typeId, ItemStack* zStack, bool left);
- Entity(int typeId,
- Framework::Vec3<float> location,
- int dimensionId,
- int entityId);
- void addMovementFrame(MovementFrame& frame);
- void calculateTarget(Framework::Vec3<float> basePos,
- Framework::Vec3<float> 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<float> pos);
- 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<float> getSpeed() const;
- Framework::Vec3<float> getFaceDir() const;
- Framework::Vec3<float> 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;
- };
|