Player.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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::Array<ItemSlot*> itemBar;
  27. Framework::Array<ItemSlot*> crafting;
  28. int leftHandPosition;
  29. bool jumping;
  30. __int64 keyState;
  31. void useItemSlot(ItemSlot* zSlot);
  32. Player(Framework::Vec3<float> location, int dimensionId, int entityId);
  33. virtual void afterPullStack(ItemSlot* zSlot, Direction dir, const Item* zItem, int count) override;
  34. virtual void afterPushStack(ItemSlot* zSlot, Direction dir, const Item* zItem, int count) override;
  35. Framework::Text getInventoryUIML();
  36. public:
  37. void setName(Framework::Text name);
  38. const char* getName() const;
  39. void tick(const Dimension* zDimension) override;
  40. void playerApi(Framework::StreamReader* zRequest, NetworkResponse* zResponse);
  41. void onFall(float collisionSpeed) override;
  42. friend PlayerEntityType;
  43. };
  44. class PlayerEntityType : public EntityType
  45. {
  46. REGISTRABLE(PlayerEntityType)
  47. protected:
  48. virtual void loadSuperEntity(Entity* zEntity, Framework::StreamReader* zReader) const override;
  49. virtual void saveSuperEntity(Entity* zEntity, Framework::StreamWriter* zWriter) const override;
  50. public:
  51. PlayerEntityType();
  52. virtual Entity* createEntity(Framework::Vec3<float> position, int dimensionId, int entityId) const override;
  53. };
  54. REGISTER(PlayerEntityType, EntityType)