Doloro GDK 22 .1.0 Beta
by Tauri Interactive
Storage

About

A Storage object allows to create a model of in-game storage implements its own features and receives database entry as content.
The storage resource by itself an entity of Entity Component System implemented with the Storages Service. When you load any StorageContainer from Storages Database on scene via the service, you'll get an instance of Storage bond with the container.

Such an instance will receive saved session data provided with the loaded data container.
The changes in the container will be automatically saved to the database as soon as the Storage instance has been released via the service.

Simply it’s enough to have a single Storage resource that will be a default container used all around the game, but normally you may need to implement custom features over the storages, like a lock, or ownership rights. For such cases you may need to create extra variants of base Starage resource and extend they with special logic. More about in Features section.

Explore API:

Resource

To create a new Storage resource you need to:

  1. Create a new game object on a scene.
  2. Add Storage 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 AStorageFeature 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.

Features

A storage interaction behavior can be extended from base one by adding of new components derived from the AStorageFeature class over the object with defined Storage component. The feature component will be automatically integrated within internal systems, you no need to make any manual assignments.

Explore API: Doloro.InvetorySystem.AStorageFeature


Storage 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:

In-box

The package supplies you with several pre-implemented storage features those extends its behavior and features.

Feature Purpose
StorageInfo Implements extra properties over the storage like a
Title, Description and Owner ID.
Allows to personalize the storage among others.
StorageLock Adds ability to lock a storage on a key with defined signature.
StorageItemsTagsFilter Alows adding to the storage only items with
tags mask passing defined patterns.
Read more: Tags Tool.
StorageContentSpawner Defines storage content spawn policy.
Provides API to manage the spawn process.
StorageSlotsLimiter Limits count of different resource containers that
allowed to place within the same storage.
StorageWeightLimiter Implements concept of storage weigh and
allows to limit upper bound.

Development

To create a new Storage Feature enough to create a new component class derived from the AStorageFeature.
Then the instance of the component has to be added to the game object with Storage component.

In common the feature class will follow the next pattern:

using Doloro.DataManagement.Serialization;
using Doloro.InvetorySystem.Features;
using System;
using UnityEngine;
public class STORAGE_FEATURE : AStorageFeature
{
// Data container that defined personalized
// storage session members that different for each
// unique `Storage`.
[SerializeField]
private Info _data = new CrossSessionData();
public override void LoadSession(byte[] data)
{
base.LoadSession(data);
// Attempting to read binary data to the session container.
try { _data = BinarySerializationTool.Deserialize<Info>(data); }
catch (Exception ex)
{
// Data read failed.
Debug.LogError(
"`" + GetType().Name +
"` related binary data corrupted and can't be loaded.\n" +
ex.Message + "\n\n");
}
}
// Converting session data to binary format.
// Using Doloro Data Management module's features.
public override byte[] SaveSession()
{
BinarySerializationTool.Serialize(_data, out byte[] output);
return output;
}
public override void SetDefault()
{
// Creating a new clear data container.
_data = new CrossSessionData();
}
public override void OnStorageRented()
{
// Assigning handlers related to
// `StorageContainer` renting the
// Storage instance
}
public override void OnStorageRentOver()
{
// Releasing data related to previous
// `StorageContainer` that had been using
// the Storage entity.
}
// Class that declares cross session data
// applicable toward the feature.
// The data will be different for each `StorageContainer`
// at the `StoragesDatabase`.
[Serializable]
private class CrossSessionData
{
public CrossSessionData()
{
// Applying default values
// over session data.
}
// Your serializable members here.
}
}

CrossSessionData is an optional implementation. It’s not required in case the feature is uniform and has no difference from one Storage instance to other.

You also may find useful deriving the component from AMaskStorageFeature instead of regular AStorageFeature in case you has to prevent performing not permitted transactions between storages via the ref dinv_trasaction_service. Such feature will validate is the transaction passes defined rules that allows to block the order from execution.

The class derived from AMaskStorageFeature has only one difference from previous pattern:

public class STORAGE_FEATURE : AMaskStorageFeature
{
... THE SAME MEMBERS MAP ...
public override bool OnTrasactionMask(TransactionService.TransactionOrder order)
{
// Validate the order and make the conclusion
// is it pass the masking rules.
// You also may set `message` property that can be used
// at a GUI to let the player know the issue with
// the transaction.
message = "Transaction passed.";
return true;
}
}

GUI

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

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