Player.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. virtual void onTargetChange() override;
  36. Framework::Text getInventoryUIML();
  37. Framework::Text getPlayerGUI();
  38. public:
  39. void setName(Framework::Text name);
  40. const char* getName() const;
  41. void tick(const Dimension* zDimension) override;
  42. void playerApi(Framework::StreamReader* zRequest, NetworkMessage* zResponse);
  43. void onFall(float collisionSpeed) override;
  44. friend PlayerEntityType;
  45. };
  46. class PlayerEntityType : public EntityType
  47. {
  48. REGISTRABLE(PlayerEntityType)
  49. protected:
  50. virtual void loadSuperEntity(Entity* zEntity, Framework::StreamReader* zReader) const override;
  51. virtual void saveSuperEntity(Entity* zEntity, Framework::StreamWriter* zWriter) const override;
  52. public:
  53. PlayerEntityType();
  54. virtual Entity* createEntity(Framework::Vec3<float> position, int dimensionId, int entityId) const override;
  55. };
  56. REGISTER(PlayerEntityType, EntityType)