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

Behaviour

A behaviour’s trait and where its consequences are trusted. Its system is a plugin’s system, whose entry says where the step runs it: the engine’s run on both ends unless they decide an outcome. A game makes one with defineBehaviour.

Type Parameter Default type
T extends Trait Trait
Property Type Description
ai? AiDescriber<T> What it is, its state and what can be done with it, in words, from its props: its entity’s node in the AI tree.
description? string One line on what it does, which the inspector shows under its name.
handles? readonly EventHandle<unknown, EventDelivery, EventScope>[] The events its system reads with readEvents or its view hears with useEvent, each made by defineEvent, which the devtools’ wiki links it to.
plugin? string The name of the plugin whose system runs it, such as "behaviours" for the engine’s or lamps.name for a game’s own plugin: its component throws where the game does not list that plugin, naming what to add. Left out, the component checks no plugin.
ranges? Partial<Record<keyof TraitRecord<T>, PropRange>> A slider’s bounds, by number prop; a prop left out has no slider.
runsOn? RunContext Where a consequence of it is trusted: Server or Both for one the room decides, whose component takes no callback, and Client, where undeclared, for one a page may hear and answer. A system’s runsOn is its entry’s, not this.
source? string The file that declares it, for a game’s own behaviour, from the game’s own folder, where its dev server opens a file in the editor; the engine’s are documented by their wiki page instead.
trait T -
wiki? string The wiki route that documents it, which describe() hands an agent.