Entity.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. #include <Critical.h>
  3. #include <Either.h>
  4. #include <Model3D.h>
  5. #include "Area.h"
  6. #include "EntityType.h"
  7. #include "FactoryCraftModel.h"
  8. class Block;
  9. struct MovementFrame
  10. {
  11. Framework::Vec3<float> direction;
  12. Framework::Vec3<float> targetPosition;
  13. int movementFlags = 0;
  14. double duration = 0;
  15. };
  16. class Entity : public FactoryCraftModel
  17. {
  18. private:
  19. int id;
  20. const EntityType* zType;
  21. Framework::Critical cs;
  22. bool playerControlled;
  23. float maxMovementSpeed;
  24. int lastFlags;
  25. double timeSinceSync;
  26. Framework::Vec3<float> lastDirection;
  27. Framework::Array<MovementFrame> movements;
  28. Framework::Vec3<float> speed;
  29. MovementFrame currentFrame;
  30. public:
  31. Entity(const EntityType* zType,
  32. Framework::Model3DData* model,
  33. Framework::Model3DTextur* texture,
  34. int id,
  35. Framework::Vec3<float> position,
  36. float maxMovementSpeed,
  37. float size);
  38. ~Entity();
  39. void api(char* message);
  40. bool tick(double time) override;
  41. int getId() const;
  42. const EntityType* zEntityType() const;
  43. void lock();
  44. void unlock();
  45. void setPlayerControlled();
  46. };