mwg API
    Preparing search index...

    Class StateRegistry

    Coordinates game-owned save state without knowing its schema.

    Each extension owns its data and restore logic. transaction captures all registered extensions before running work and restores that snapshot if work throws, which prevents half-applied saves when one subsystem rejects an update.

    import { StateRegistry } from '@datamoc/mw_games/core';

    let inventory = { gold: 10 };
    const state = new StateRegistry();
    state.register({ id: 'inventory', capture: () => inventory, restore: (saved) => { inventory = saved; } });
    state.transaction(() => { inventory.gold -= 5; });
    const save = state.snapshot();
    Index