Entity.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #pragma once
  2. #include <ReferenceCounter.h>
  3. #include <Vec3.h>
  4. #include <Vec2.h>
  5. #include <Writer.h>
  6. #include "Effect.h"
  7. #include "Inventory.h"
  8. #include "NetworkResponse.h"
  9. #include "ItemSkill.h"
  10. class EntityType;
  11. class Dimension;
  12. class ActionTarget
  13. {
  14. private:
  15. Framework::Vec3<int> blockPos;
  16. Direction targetBlockSide;
  17. int entityId;
  18. public:
  19. ActionTarget( Framework::Vec3<int> blockPos, Direction blockSide );
  20. ActionTarget( int entityId );
  21. void applyItemSkillOnTarget( Entity* zActor, ItemSkill* zItemSkill, Item* zUsedItem );
  22. void placeBlock( Entity* zActor, Item* zItem );
  23. void save( Framework::StreamWriter* zWriter ) const;
  24. };
  25. class Entity : public Inventory
  26. {
  27. protected:
  28. float maxHP;
  29. float currentHP;
  30. float stamina;
  31. float maxStamina;
  32. float hunger;
  33. float maxHunger;
  34. float thirst;
  35. float maxThirst;
  36. float targetDistanceLimit;
  37. Framework::Vec3<float> speed;
  38. Framework::Vec3<float> faceDir;
  39. Framework::Vec3<float> faceOffset;
  40. Framework::RCArray<ItemSkill> skills;
  41. ActionTarget* target;
  42. const EntityType* zEntityType;
  43. int currentDimensionId;
  44. bool removed;
  45. float gravityMultiplier;
  46. int id;
  47. virtual void onDeath();
  48. virtual void useItem( const ItemType* zType, Item* zItem );
  49. Entity( const EntityType* zType, Framework::Vec3<float> location, int dimensionId, int entityId );
  50. public:
  51. void prepareTick( const Dimension* zDimension );
  52. virtual void tick( const Dimension* zDimension );
  53. virtual void api( Framework::StreamReader* zRequest, NetworkResponse* zResponse );
  54. virtual void onFall( float collisionSpeed );
  55. void setPosition( Framework::Vec3<float> pos );
  56. float getMaxHP() const;
  57. float getCurrentHP() const;
  58. float getStamina() const;
  59. float getMaxStamina() const;
  60. float getHunger() const;
  61. float getMaxHunger() const;
  62. float getThirst() const;
  63. float getMaxThirst() const;
  64. Framework::Vec3<float> getSpeed() const;
  65. Framework::Vec3<float> getFaceDir() const;
  66. Framework::Vec3<float> getPosition() const;
  67. float getGravityMultiplier() const;
  68. int getCurrentDimensionId() const;
  69. bool isRemoved() const;
  70. const EntityType* zType() const;
  71. const ActionTarget* zTarget() const;
  72. int getId() const;
  73. friend Effect;
  74. friend EntityType;
  75. };