123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #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"
- 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;
- 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<float> direction;
- Framework::Vec3<float> 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<float> speed;
- Framework::Vec3<float> faceDir;
- Framework::Vec3<float> faceOffset;
- Framework::RCArray<ItemSkill> skills;
- ActionTarget* target;
- int typeId;
- int currentDimensionId;
- bool removed;
- float gravityMultiplier;
- int id;
- Framework::ZeitMesser time;
- Framework::Array<MovementFrame> movements;
- Framework::Critical cs;
- virtual void onDeath();
- virtual void useItem(int typeId, Item* zItem);
- Entity(int typeId,
- Framework::Vec3<float> location,
- int dimensionId,
- int entityId);
- virtual void onTargetChange();
- void addMovementFrame(MovementFrame& frame);
- void calculateTarget(
- Framework::Vec3<float> basePos, Framework::Vec3<float> 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<float> 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<float> getSpeed() const;
- Framework::Vec3<float> getFaceDir() const;
- Framework::Vec3<float> 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;
- bool isMoving() const;
- friend Effect;
- friend EntityType;
- };
|