Doloro GDK 22 .1.0 Beta
by Tauri Interactive
Item

About

Item is a one of the core resources implemented within the module.
The objects with implemented component considering as instances of DynamicResource and automatically handling with the ddm-navigator module features.

Item resource works as a source resource that instantiates each time when the instance has been requested. Entire changes and session data related to a certain instance share with Storages Database in case the item located within some storage or manually via crating of ItemContainer from configurated Item instance.

Explore API:


Resource

To create a new Item resource you need to:

  1. Create a new game object on a scene.
  2. Add Item component or its derived variant over it.
  3. Define resource signature that will allow to access the resource via Dynamic Resource Tools API.
    1. (Optional) Setup item tags related to resource categorization of resource using Tags Tool features.
  4. Add custom AItemFeature derived component to extend item's logic.
  5. Drag and drop the game object to any Resources folder to make it accessible to search.
  6. (Optional) Define asset bundle parameters in case you plan to distribute the resource via AssetBundle packages using Asset Bundles Tools features.

Asset Properties

As soon as normally in-game items share some parameters (damage, integrity, weight, price, etc.) the Item component also has bond with the Asset Properties System. That allows flexible extending of the object parameters without changes in the source of items.

Some of GUI controls and systems may automatically search for values stored within the AssetPropertiesCollection attached to the Item. Normally the search goes within public domain, but the handlers must provide you with API to manage this option.

Read also: Asset Property


Item Features

You may need to extend regular custom logic with a custom behavior logic that may both moderate exited one or implement a new. The module offers you to handle this task via implementation of AItemFeature derived components that dully integrates to internal services in encapsulated way and save you time on development.

As soon as Item by itself is a resource that instantiates each time it's requested its entire session data you need a standardized way to store those features game state for cross-session using. The features implemented along with requested members description will automatically store\load features state during ItemContainer-to-Item operation.

Explore API:


Item is a Dynamic Resource it can be extended with new features via distributing packages that allows to change gameplay dynamically via mods or etc.

Read more:


Development

To develop a new Item feature you need to create a class derived from AItemFeature. Such a class is a Component and has to be added over the destination Item holding game object. Component integration with the item instance will be made automatically, you no need any manual assignation calls.

Following example demonstrates template of Item feature class implementation.

using Doloro.InvetorySystem;
using Doloro.DataManagement.Serialization;
using System;
public class CUSTOM_ITEM_FEATURE : AItemFeature
{
public override string title { get => _title; set => _title = value; }
string _title = "Feature title";
public override string description { get => _title; set => _title = value; }
string _description = "Feature description that could be shown as tooltip.";
[UnityEngine.SerializeField]
private CrossSessionData _data = new CrossSessionData();
private void Start()
{
// Initializing feature environment objects.
}
private void FixedUpdate()
{
// Updating feature along with physics.
}
private void Update()
{
// Updating feature GUI related data.
}
private void OnDestroy()
{
// Releasing events subscription.
// Releasing unmanaged memory.
}
// Converts runtime session data to binary view.
public override byte[] SaveSession()
{
BinarySerializationTool.Serialize(_data, out byte[] output);
return output;
}
// Releases feature setting do default state.
public override void SetDefault()
{
// Creating new clear session data.
_data = new CrossSessionData();
}
// Loading cross session data container from binary to instance.
public override void LoadSession(byte[] data)
{
try
{
_data = BinarySerializationTool.Deserialize<CrossSessionData>(data);
}
catch (Exception ex)
{
UnityEngine.Debug.LogError(
"`" + GetType().Name +
"` related binary data corrupted and can't be loaded.\n" +
ex.Message + "\n\n");
}
}
// Serializable data container that can be used as personalized
// session data of the feature.
// The container may be loaded to the feature instance during next call
// of the same item from database.
[Serializable]
private class CrossSessionData
{
// Default constructor.
public CrossSessionData() { }
// Add serializable members here
}
}

You may access Item instance bond with the feature using the item property.

Cross-session data is optional and required only for non-static features that has difference from one Item instance to other. In case of implementation the feature data will be stored at StoragesDatabase.FeatureContainer related to certain StoragesDatabase.ItemContainer automatically during item save process and be restored a next time the Item resource be instantiated from the same item container.


GUI

Inventory system implements list of controls and extension based on dui2 features.

Subject Brief description
Item GUI control Base ItemContainer inspector and following extension.
Items GUI Collections Elements Collection extension controls.
Items Virtual Hub extension Virtual UI Hub compatibility components.