Player.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include <Array.h>
  3. #include "CraftingStorage.h"
  4. #include "Entity.h"
  5. #include "EntityType.h"
  6. class PlayerEntityType;
  7. class Player : public Entity,
  8. public BasicShapedCrafter
  9. {
  10. public:
  11. class Key
  12. {
  13. public:
  14. static const __int64 LEFT_HAND_ACTION = 0x100;
  15. static const __int64 RIGHT_HAND_ACTION = 0x200;
  16. };
  17. private:
  18. Framework::Text name;
  19. Framework::Array<ItemSlot*> itemBar;
  20. Framework::Array<ItemSlot*> crafting;
  21. int leftHandPosition;
  22. bool jumping;
  23. __int64 keyState;
  24. void useItemSlot(ItemSlot* zSlot, bool left);
  25. Player(Framework::Vec3<float> location, int dimensionId, int entityId);
  26. Framework::Text getInventoryUIML();
  27. Framework::Text getPlayerGUI();
  28. public:
  29. virtual void onTargetChange() override;
  30. void setName(Framework::Text name);
  31. const char* getName() const;
  32. void tick(const Dimension* zDimension) override;
  33. void playerApi(
  34. Framework::StreamReader* zRequest, NetworkMessage* zResponse);
  35. void onFall(float collisionSpeed) override;
  36. void onDeath() override;
  37. friend PlayerEntityType;
  38. };
  39. class PlayerEntityType : public EntityType
  40. {
  41. protected:
  42. virtual void loadSuperEntity(
  43. Entity* zEntity, Framework::StreamReader* zReader) const override;
  44. virtual void saveSuperEntity(
  45. Entity* zEntity, Framework::StreamWriter* zWriter) const override;
  46. public:
  47. PlayerEntityType();
  48. virtual Entity* createEntity(Framework::Vec3<float> position,
  49. int dimensionId,
  50. int entityId) const override;
  51. };