defineEvent
Function of @v12-engine/engine
ts
export declare function defineEvent<T>(def: {
id: string;
replicate?: EventAudience<T>;
}): EventKey<T>;An event of a game's own: const through = defineEvent<{ unit: string }>({ id: 'td.invaderThrough', replicate: 'everyone' }). Emitted on world.events like the engine's (world.events.emit(through, { unit })), held to the end of the tick like them, and listened to with defineListener. Ids are shared by every game: give them a prefix of the game's.
A replicated event goes to the players' screens, where GameView.on and the renderers get it: what it says has to be plain data then (numbers, text, lists, plain objects), with entities by id, as it may cross a network