mwg API
    Preparing search index...

    Type Alias EntityId

    EntityId: string

    A logical identity for a live object, so events, saves, AI targets and buffs can name a creature or item without holding the object itself - a sprite can be swapped, a save can be reloaded into fresh objects, but the id names the same thing across both.

    import { EntityRegistry, type EntityId } from '@datamoc/mw_games/core';

    interface Monster { name: string }

    const monsters = new EntityRegistry<Monster>();
    const rat: EntityId = monsters.add({ name: 'rat' });

    console.log(monsters.get(rat)?.name); // 'rat'
    console.log(monsters.idOf(monsters.get(rat)!)); // same id back - the reverse lookup a
    // game passes as `SimulationRuntime`'s or `Scheduler`'s `actorId`