Player.h 2.0 KB

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