Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

definePlugin

definePlugin<Schema, Scope, Input, Motion, Rules, Physics, Inputs, Actions, Layers, Commands, Contexts>(config): Plugin<SystemHandles<Input, Motion, Rules, Physics>, Inputs, Actions, Layers, Commands, Contexts>

Makes a plugin, checking what one plugin can know at the call: its name, its phases, that each system has a name and no two share one, that each anchor names a system of its phase, that each replacement matches what it replaces, and that it does not require itself. What needs the whole list, a missing requirement, an anchor’s plugin, a clash between plugins, the composer checks as the world is made. Generic over the commands, the inputs and the systems’ keys, so siege.commands.pick is typed by its payload, siege.systems.spawn by its phase, predicted and runsOn, and siege.commands.unknown fails to typecheck.

Type Parameter Default type
Schema extends SaveSchema SaveSchema
Scope extends "entity" | "world" | "player" "player"
Input extends object Record<never, never>
Motion extends object Record<never, never>
Rules extends object Record<never, never>
Physics extends object Record<never, never>
Inputs extends Readonly<Record<string, VectorInputDeclaration | AngleInputDeclaration | ButtonInputDeclaration | AxisInputDeclaration>> Readonly<Record<never, never>>
Actions extends Readonly<Record<string, PageActionDeclaration>> Readonly<Record<never, never>>
Layers extends string never
Commands extends Readonly<Record<string, CommandDeclaration<Readonly<Record<string, CommandField>>, string, Readonly<Record<string, ReturnField>> | undefined, boolean, boolean, boolean>>> Readonly<Record<never, never>>
Contexts extends Readonly<Record<string, InputContextDeclaration>> Readonly<Record<never, never>>
Parameter Type
config PluginConfig<Schema, Scope, PluginSystems<Input, Motion, Rules, Physics, Extract<keyof Commands, string>>, Inputs, Actions, Layers, Commands, Contexts>

Plugin<SystemHandles<Input, Motion, Rules, Physics>, Inputs, Actions, Layers, Commands, Contexts>