ItemType.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include <Text.h>
  3. #include <JSON.h>
  4. #include <Trie.h>
  5. #include <Writer.h>
  6. #include "Effect.h"
  7. #include "StaticRegistry.h"
  8. #include "ModelInfo.h"
  9. class Item;
  10. class ItemStack;
  11. class ItemSkill;
  12. class ItemSkillLevelUpRule;
  13. class ItemType : public virtual Framework::ReferenceCounter
  14. {
  15. protected:
  16. const int id;
  17. const Framework::Text name;
  18. ItemSkillLevelUpRule* levelUpRule;
  19. const ItemType* zBrokenType;
  20. const ModelInfo model;
  21. ItemType(int id, const char* name, ItemSkillLevelUpRule* levelUpRule, const ItemType* zBrokenType, ModelInfo model);
  22. virtual void loadSuperItem(Item* zItem, Framework::StreamReader* zReader) const;
  23. virtual void saveSuperItem(const Item* zItem, Framework::StreamWriter* zWriter) const;
  24. virtual void loadSuperItemSkill(ItemSkill* zSkill, Framework::StreamReader* zReader) const;
  25. virtual void saveSuperItemSkill(const ItemSkill* zSkill, Framework::StreamWriter* zWriter) const;
  26. Item* createBasicItem(const char* name, float hp, float maxHp, float durability, float maxDurability, bool eatable, bool placeable, bool equippable, bool solid, bool usable, int maxStackSize) const;
  27. public:
  28. ~ItemType();
  29. int getId() const;
  30. const Framework::Text& getName() const;
  31. const ItemType* zBrokenItemType() const;
  32. virtual Item* createItem() const = 0;
  33. virtual ItemStack* createItemStack(int size) const;
  34. virtual ItemSkill* createDefaultItemSkill() const;
  35. virtual void levelUpItemSkill(ItemSkill* zSkill) const;
  36. virtual Item* loadItem(Framework::StreamReader* zReader) const;
  37. virtual void saveItem(const Item* zItem, Framework::StreamWriter* zWriter) const;
  38. virtual ItemSkill* loadItemSkill(Framework::StreamReader* zReader) const;
  39. virtual void saveItemSkill(const ItemSkill* zSkill, Framework::StreamWriter* zWriter) const;
  40. virtual Item* cloneItem(const Item* zItem) const;
  41. virtual Item* breakItem(const Item* zItem) const;
  42. const ModelInfo& getModel() const;
  43. };