Skip to content

defineComponent ​

Function of @v12-engine/engine

ts
export declare function defineComponent<T, S = T>(def: {
    id: string;
} & ComponentOptions<T, S>): Component<T, S>;

A typed key for state of a game's own: const wave = defineComponent<WaveState>({ id: 'td.waves', default: () => ... }). Give it a prefix of the game's or the mod's: the engine's own are core.. A game lists its own (Rules.components), and its world finds them by id in its registry: another game of the process may have one of the same id, and a module loaded again (as a dev server does) defines it again.

With snapshot and same the component shapes what players are sent of it and how a change is found; with index it is filed for systems to go through; with field the map editor sets it