Lost Lily/Grid ToolkitDocs 1.0
Table of Contents

Save and restore Inventory

When to use

Add the Inventory snapshot resolvers when a board snapshot must preserve definition metadata and per-instance quantity in addition to ordinary structure placement.

Before you start

  1. Create Assets > Create > Lost Lily > Grid Toolkit > Configuration > Resolver Profile.
  2. Add GridInventoryItemDefinitionSnapshotResolver and GridInventoryItemInstanceSnapshotResolver.
  3. Assign the profile to the authored board asset.

The definition resolver preserves item ID, display metadata, stackability, and maximum stack. The instance resolver preserves quantity.

Ordinary snapshot data already preserves structure instance ID, definition ID, anchor, orientation, footprint, and layer.

Procedure

Save the board

Create the snapshot only after the current action or operation has committed.

Excerpt — save Inventory state after a committed action. Tested using public APIs.

public static GridBoardStateSnapshot SaveInventory(GridBoardState state)
{
    return state.CreateSnapshotOrThrow();
}

Restore the board

Apply restoration to the live board so validation, atomicity, revision, and the restoration event follow the standard action workflow.

Excerpt — restore item identity, placement, and quantity. Tested using public APIs.

public static GridActionResult RestoreInventory(
    GridBoardState state,
    GridBoardStateSnapshot snapshot)
{
    return GridActionRunner.ApplySnapshot(state, snapshot);
}

Result

The restored item has the same structure instance ID, item definition metadata, anchor, orientation, and quantity as the snapshot. Every successful restoration advances the live revision once and publishes a restoration event batch, including an identical restore.

Troubleshooting

Symptom Check
Item metadata is rejected. Add the Inventory definition resolver to the profile used by the live board.
Quantity returns as 1. Add the Inventory instance resolver and confirm the saved instance had a quantity extension.
Restore fails without partial changes. Read the restore diagnostics; resolver or policy failure rejects the complete restoration atomically.