ItemType.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #pragma once
  2. #include <JSON.h>
  3. #include <Text.h>
  4. #include <Trie.h>
  5. #include <Writer.h>
  6. #include "BlockType.h"
  7. #include "Effect.h"
  8. #include "ModelInfo.h"
  9. #include "StaticRegistry.h"
  10. class Item;
  11. class ItemStack;
  12. class ItemSkill;
  13. class ItemSkillLevelUpRule;
  14. class ItemTypeEnum : public BlockTypeEnum
  15. {
  16. public:
  17. static const int WOOD_STICK = BlockTypeEnum::MAX_VALUE + 1;
  18. static const int AXE = BlockTypeEnum::MAX_VALUE + 2;
  19. static const int RESIN = BlockTypeEnum::MAX_VALUE + 3;
  20. static const int PLAYER_HAND = BlockTypeEnum::MAX_VALUE + 4;
  21. static const int AXE_BROKEN = BlockTypeEnum::MAX_VALUE + 5;
  22. static const int HOE = BlockTypeEnum::MAX_VALUE + 6;
  23. static const int BROKEN_HOE = BlockTypeEnum::MAX_VALUE + 7;
  24. static const int FLINT = BlockTypeEnum::MAX_VALUE + 8;
  25. };
  26. class ItemType : public virtual Framework::ReferenceCounter
  27. {
  28. protected:
  29. const int id;
  30. const Framework::Text name;
  31. Framework::Text tooltipUIML;
  32. ItemSkillLevelUpRule* levelUpRule;
  33. int brokenTypeId;
  34. const ModelInfo model;
  35. ItemType(int id,
  36. const char* name,
  37. ItemSkillLevelUpRule* levelUpRule,
  38. int brokenTypeId,
  39. ModelInfo model);
  40. virtual void loadSuperItem(
  41. Item* zItem, Framework::StreamReader* zReader) const;
  42. virtual void saveSuperItem(
  43. const Item* zItem, Framework::StreamWriter* zWriter) const;
  44. virtual void loadSuperItemSkill(
  45. ItemSkill* zSkill, Framework::StreamReader* zReader) const;
  46. virtual void saveSuperItemSkill(
  47. const ItemSkill* zSkill, Framework::StreamWriter* zWriter) const;
  48. public:
  49. ~ItemType();
  50. int getId() const;
  51. const Framework::Text& getName() const;
  52. const Framework::Text& getTooltipUIML() const;
  53. const ItemType* zBrokenItemType() const;
  54. virtual Item* createItem() const = 0;
  55. virtual ItemStack* createItemStack(int size) const;
  56. virtual ItemSkill* createDefaultItemSkill() const;
  57. virtual void levelUpItemSkill(ItemSkill* zSkill) const;
  58. virtual Item* loadItem(Framework::StreamReader* zReader) const;
  59. virtual void saveItem(
  60. const Item* zItem, Framework::StreamWriter* zWriter) const;
  61. virtual ItemSkill* loadItemSkill(Framework::StreamReader* zReader) const;
  62. virtual void saveItemSkill(
  63. const ItemSkill* zSkill, Framework::StreamWriter* zWriter) const;
  64. virtual Item* cloneItem(const Item* zItem) const;
  65. virtual Item* breakItem(const Item* zItem) const;
  66. const ModelInfo& getModel() const;
  67. static Item* createBasicItem(int id,
  68. const char* name,
  69. float hp,
  70. float maxHp,
  71. float durability,
  72. float maxDurability,
  73. bool eatable,
  74. bool placeable,
  75. bool equippable,
  76. bool solid,
  77. bool usable,
  78. int maxStackSize);
  79. };