Skip to main content

ItemObject

class SoftKitty.ItemObject : DataObject

ItemObject is a DataObject that manages Attribute settings within the system.

You can create this object via the context menu in any Project folder:

Create → SoftKitty → Data Objects → Item Data

You can assign the created asset to the database in: Project Settings → SoftKitty → Data Settings → Data

After assigned the data object, a editor interface can be found at:

Project Settings → SoftKitty → SubData - Items

Where you can easily manage attributes with convenient editor interface.


Data Mode Options: Unified vs ScriptableObject

To enhance flexibility in managing item data, we've introduced a feature allowing you to choose between two data storage modes: Unified and ScriptableObject. This change gives you more control over how items are structured and stored in your project.

  • Unified: The default mode, where all item data is stored together in a single array within the ItemObject ScriptableObject. This mode is ideal for simple setups and offers cleaner structures for smaller projects.
  • ScriptableObject: This mode stores each item as an individual ScriptableObject. It's perfect for larger projects that require better version control and item-specific customization. Storing items as separate ScriptableObjects makes it easier to track changes and manage assets across different versions of your project.

Switching Data Modes

You can easily switch between these two modes using the Data Mode dropdown. Additionally, a new Clone to ScriptableObject mode button has been added to help you migrate item data from one mode to the other, making transitions between different storage methods seamless.


Properties

public static ItemObject instance

Retrieve the instance of the ItemObject instance assigned in SoftKitty Data Settings.


public static InventoryEngine.InventoryData PlayerInventoryData

Retrieve the InventoryData class for player's invetory.


public static InventoryEngine.InventoryData PlayerEquipmentData

Retrieve the InventoryData class for player's equipments.


public List<StringColorData> itemTypes = new List<StringColorData>();

List of item category.


public List<StringColorData> itemQuality = new List<StringColorData>();

List of item quality levels.


private ConcurrentDictionary<int, Item> ItemDic = new ConcurrentDictionary<int, Item>();

Access the item data by its UID. Use itemDic[_uid].Copy() to get an instance of the Item data with specified UID.


public List<Enchantment> itemEnchantments = new List<Enchantment>();

List of Enchantments.


public ConcurrentDictionary<int, Enchantment> enchantmentDic = new ConcurrentDictionary<int, Enchantment>();

Access the Enchantment data by its id.


public List<Currency> currencies = new List<Currency>();

List of currencies.


public string[] ItemCategoryNames

An array of Item category names. This provides a simple list of the Item category names for quick reference.


public string[] ItemQualityNames

An array of Item quality level names. This provides a simple list of the Item quality level names for quick reference.


public string[] ItemNames

An array of Item names. This provides a simple list of the Item names for quick reference.


public string[] ItemUidArray

An array of Item UIDs. This contains the unique identifiers for each Item, allowing for direct reference by UID.


public List<string> ItemUidList

A List of Item UIDs. This contains the unique identifiers for each Item, allowing for direct reference by UID.


public List<int> ItemIdList

A List of Item IDs. This contains the unique identifiers for each Item, allowing for direct reference by ID.


Methods

public bool ItemExist(int _id)

Retrieves whether the Item with unique integer ID exists.


public Item GetItem(string _uid)

Retrieves the Item setting based on its unique string UID. This is used for fetching specific Item data efficiently.


public Item GetItem(int _id)

Retrieves the Item setting based on its integer ID. This method allows for fetching by index for faster lookups in certain use cases.


public StringColorData TryGetItemTypesById(int _id)

Try get the Item Catogory data by the id.(thread-safe)


public StringColorData TryGetItemQualityById(int _id)

Try get the Item Quality data by the id.(thread-safe)


public Enchantment TryGetEnchantmentById(int _id)

Try get the Enchantment data by the id.(thread-safe)


public void SetCoolDownForAll(float _coolDownTime, bool _onlyUseableItem = true)

Set cool down time for all items, this can be used for global shared cool down timer.


public void AddCoolDownForAll(float _addValue, bool _onlyUseableItem = true)

Add cool down time for all items, this can be used for global shared cool down timer.


public void SetSharedGlobalCoolDown(float _coolDownTime, bool _onlyUseableItem = true)

Quick method to set global shared cool down timer.


public void ExportItemDataToJson(string _path)

Export the Item data into a json txt file.


public void ImportItemDataFromJson(string _path)

Import Item data from a json txt file. You can store the json file in your game install folder and let modder to modify it, then import it back when game launch.


public void ExportEnchantmentDataToJson(string _path)

Export the Enchantment data into a json txt file.


public void ImportEnchantmentDataFromJson(string _path)

Import Enchantment data from a json txt file. You can store the json file in your game install folder and let modder to modify it, then import it back when game launch.


public static InventoryEngine.LootPack DropLootPack(Vector3 _pos, string _uid)

Drop a Loot Pack at the providing position via the unique string id..