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