Doloro GDK 22 .1.0 Beta
by Tauri Interactive
Trasaction Service

About

A service that manages entire operation with Storage content, both for isolated storages and in cross-storages operation.

The service prevents operation from popular bugs like references forge or items dupe, by encapsulated tracking process of entire content during in-game actions.

Read also: Storage

Usage

The service implemented as a static API class that always available to access. You may reach it via TransactionService class call. More details about usage practices you may find in How to ... category at the Transaction Service section.

Explore API: Doloro.InvetorySystem.TransactionService

Reservation Agent

Reservation is the one of main core operation of the services that guaranties that the items can't be used by not authorized requesters. It allows to proof that the operating items exists from the transaction beginning to its end and never appears / disappears from nowhere.

As soon as Storage can be extended with Features implementations it also may require custom reservation operations to embed the features to the transaction service logic.

Explore API: Doloro.InvetorySystem.IReservationAgent

Development

At the moment reservation agents can be connect to the service via AStorageFeature with implemented IReservationAgent interface added to a Storage game object.

During transaction operations the service looking for agents over the order participating Storage instances. According with order stage it calls related agent handlers to perform they internal logic.

To create a new feature with reservation operation you need to follow next template:

using Doloro.InvetorySystem.Features;
public class RESERVATION_STORAGE_FEATURE : AStorageFeature, IReservationAgent
{
// Occurs when some order has been placed.
// Shares placed order to make a reservation conclusion.
public void Reserve(TransactionService.TransactionOrder order)
{
// Made a record in internal registry
// that the order reserves some
// `space` here.
// Record entry should be placed as temporal,
// because it still can be canceled later.
....
}
// Occurs when a transaction order has been canceled.
// Must release reservation record.
public void CancelReservation(TransactionService.TransactionOrder order)
{
// Release entire data related to
// reservation caused by the order instance
// at during `Reserve` hadnler call.
....
}
// Occurs when a transaction order for the storage has been confirmed.
public void ConfirmReservation(TransactionService.TransactionOrder order)
{
// Move temporal reservation record
// to serializable container used
// at `SaveSession` and `LoadSession`
// of the feature to maintain used
// space record at cross-session.
....
}
// Occurs when `Storage` entity has been released from rent
// by database entry.
public override void OnStorageRented()
{
// Calling base rent finalizer.
base.OnStorageRented();
// Release your reservation data related to
// a storage data source that no longer uses the
// entity with defined agent.
....
}
}

A common practice you may require a way to decline order placement in case if reservation isn't possible.

For that instead of deriving the AStorageFeature class, derive you class from AMaskStorageFeature where you may implement a custom OnTrasactionMask logic.

using Doloro.InvetorySystem.Features;
public class MASKABLE_RESERVATION_STORAGE_FEATURE :
AMaskStorageFeature, IReservationAgent
{
// The same implementation as in the previous example.
....
// Occurs before transaction order placement.
public bool OnTrasactionMask(TransactionService.TransactionOrder order)
{
// Conclude is the order can be placed along with
// your reservation rules here.
// Return `true` in case the order valid.
// `false` to block the order placement.
...
}
}

Examples

The package has several implementations of reservation agent features. We recommend exploring the source of following components to ramp up with implementation practices.

Feature Reservation practice
StorageWeightLimiter Reserves weight of storage along with entire incomplete operations,
preventing from placing new order that will lead to storage overflow.
StorageSlotsLimiter Reserves item slots in Storage for entire incomplete operations
preventing from usage of extra over the defined limit.
StorageVolume Reserves volumetric space required from transaction items placement.

Explore API: