Player.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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(
  37. Entity* zActor, Item* zUsedItem, ItemSkill* zUsedSkill) override;
  38. friend PlayerEntityType;
  39. };
  40. class PlayerEntityType : public EntityType
  41. {
  42. protected:
  43. virtual void loadSuperEntity(
  44. Entity* zEntity, Framework::StreamReader* zReader) const override;
  45. virtual void saveSuperEntity(
  46. Entity* zEntity, Framework::StreamWriter* zWriter) const override;
  47. public:
  48. PlayerEntityType();
  49. virtual Entity* createEntity(Framework::Vec3<float> position,
  50. int dimensionId,
  51. int entityId) const override;
  52. };