Player.h 1.9 KB

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