Player.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. #include "Entity.h"
  3. #include "EntityType.h"
  4. class PlayerEntityType;
  5. class Player : public Entity
  6. {
  7. public:
  8. class Key
  9. {
  10. public:
  11. const static __int64 MOVE_FRONT = 0x1;
  12. const static __int64 MOVE_BACK = 0x2;
  13. const static __int64 MOVE_LEFT = 0x4;
  14. const static __int64 MOVE_RIGHT = 0x8;
  15. const static __int64 MOVE_UP = 0x10;
  16. const static __int64 MOVE_DOWN = 0x20;
  17. const static __int64 ROTATE_LEFT = 0x40;
  18. const static __int64 ROTATE_RIGHT = 0x80;
  19. };
  20. private:
  21. Framework::Text name;
  22. bool jumping;
  23. __int64 keyState;
  24. public:
  25. Player( Framework::Vec3<float> location, int dimensionId, int entityId );
  26. void setName( Framework::Text name );
  27. const char* getName() const;
  28. void tick( const Dimension* zDimension, Game* zGame ) override;
  29. void api( Framework::StreamReader* zRequest, NetworkResponse* zResponse ) override;
  30. void onFall( float collisionSpeed ) override;
  31. friend PlayerEntityType;
  32. };
  33. class PlayerEntityType : public EntityType
  34. {
  35. REGISTRABLE( PlayerEntityType )
  36. protected:
  37. virtual void loadSuperEntity( Entity* zEntity, Framework::StreamReader* zReader ) const override;
  38. virtual void saveSuperEntity( Entity* zEntity, Framework::StreamWriter* zWriter ) const override;
  39. public:
  40. PlayerEntityType();
  41. virtual Entity* createEntity( Framework::Vec3<float> position, int dimensionId, Game* zTarget, int entityId ) const override;
  42. };
  43. REGISTER( PlayerEntityType, EntityType )