Entity.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include <Model3D.h>
  3. #include <Either.h>
  4. #include "EntityType.h"
  5. #include "Inventory.h"
  6. class Block;
  7. class ActionTarget
  8. {
  9. private:
  10. Framework::Vec3<int> blockPos;
  11. Direction targetBlockSide;
  12. int entityId;
  13. public:
  14. ActionTarget( Framework::Vec3<int> blockPos, Direction blockSide );
  15. ActionTarget( int entityId );
  16. static ActionTarget* load( Framework::StreamReader* zReader );
  17. bool isBlock() const;
  18. bool isEntity() const;
  19. int getEntityId() const;
  20. Framework::Vec3<int> getBlockPos() const;
  21. Direction getBlockSide() const;
  22. Framework::Either<Block*, Entity*> zTarget( int dimensionId ) const;
  23. };
  24. class Entity : public Framework::Model3D, public Inventory
  25. {
  26. protected:
  27. float maxHP;
  28. float currentHP;
  29. float stamina;
  30. float maxStamina;
  31. float hunger;
  32. float maxHunger;
  33. float thirst;
  34. float maxThirst;
  35. float targetDistanceLimit;
  36. Framework::Vec3<float> speed;
  37. Framework::Vec3<float> faceDir;
  38. const EntityType* zEntityType;
  39. int currentDimensionId;
  40. float gravityMultiplier;
  41. int id;
  42. ActionTarget* target;
  43. public:
  44. Entity( const EntityType* zType, bool hasInventory );
  45. ~Entity();
  46. virtual bool tick( double time ) override;
  47. int getId() const;
  48. const EntityType* zType() const;
  49. int getCurrentDimension() const;
  50. friend EntityType;
  51. };