Player.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 LEFT_HAND_ACTION = 0x100;
  14. const static __int64 RIGHT_HAND_ACTION = 0x200;
  15. };
  16. private:
  17. Framework::Text name;
  18. Framework::Array<ItemSlot*> itemBar;
  19. Framework::Array<ItemSlot*> crafting;
  20. int leftHandPosition;
  21. bool jumping;
  22. __int64 keyState;
  23. void useItemSlot(ItemSlot* zSlot);
  24. Player(Framework::Vec3<float> location, int dimensionId, int entityId);
  25. virtual void onTargetChange() override;
  26. Framework::Text getInventoryUIML();
  27. Framework::Text getPlayerGUI();
  28. public:
  29. void setName(Framework::Text name);
  30. const char* getName() const;
  31. void tick(const Dimension* zDimension) override;
  32. void playerApi(Framework::StreamReader* zRequest, NetworkMessage* zResponse);
  33. void onFall(float collisionSpeed) override;
  34. friend PlayerEntityType;
  35. };
  36. class PlayerEntityType : public EntityType
  37. {
  38. REGISTRABLE(PlayerEntityType)
  39. protected:
  40. virtual void loadSuperEntity(Entity* zEntity, Framework::StreamReader* zReader) const override;
  41. virtual void saveSuperEntity(Entity* zEntity, Framework::StreamWriter* zWriter) const override;
  42. public:
  43. PlayerEntityType();
  44. virtual Entity* createEntity(Framework::Vec3<float> position, int dimensionId, int entityId) const override;
  45. };
  46. REGISTER(PlayerEntityType, EntityType)