#pragma once #include #include #include #include #include "BlockType.h" #include "Effect.h" #include "ModelInfo.h" class Item; class ItemStack; class ItemSkill; class ItemSkillLevelUpRule; class ItemTypeEnum { public: static const int PLAYER_HAND = 0; }; class ItemType : public virtual Framework::ReferenceCounter { protected: int id; const Framework::Text name; Framework::Text tooltipUIML; ModelInfo *model; int maxStackSize; Framework::RCArray groups; ItemType(Framework::Text name, ModelInfo* model, int maxStackSize, Framework::RCArray groups); virtual void loadSuperItem( Item* zItem, Framework::StreamReader* zReader) const; virtual void saveSuperItem( const Item* zItem, Framework::StreamWriter* zWriter) const; public: ~ItemType(); virtual bool initialize(Game* zGame); int getId() const; const Framework::Text& getName() const; const Framework::Text& getTooltipUIML() const; virtual const ItemType* zBrokenItemType() const; virtual Item* createItem() const = 0; virtual ItemStack* createItemStack(int size) const; virtual ItemSkill* createDefaultItemSkill() const; virtual void levelUpItemSkill(ItemSkill* zSkill) const; virtual Item* loadItem(Framework::StreamReader* zReader) const; virtual void saveItem( const Item* zItem, Framework::StreamWriter* zWriter) const; virtual Item* cloneItem(const Item* zItem) const; virtual Item* breakItem(const Item* zItem) const; ModelInfo* zModel() const; virtual void setItemAttribute(Item* zItem, Framework::Text name, Framework::JSON::JSONValue* zValue) const; virtual void addItemAttributes( Item* zItem, Framework::JSON::JSONObject* zItemObjet) const; void setTypeId(int id); int getMaxStackSize() const; const Framework::RCArray& getGroups() const; static Item* createBasicItem(int id, const char* name, float hp, float maxHp, float durability, float maxDurability, bool eatable, bool placeable, bool equippable, bool solid, bool usable); static int getTypeId(const char* name); static const ItemType* zByName(const char* name); };