BehaviorContext
此内容尚不支持你的语言。
Defined in: behavior.ts:34
The per-entity handle passed to a behavior’s lifecycle hooks. self is the
behavior’s own component data — mutate it freely, the change persists. The
object is REUSED across entities and frames (zero per-entity allocation): do
not retain it past the hook call; copy what you need.
Type Parameters
Section titled “Type Parameters”S extends object
Properties
Section titled “Properties”commands
Section titled “commands”
readonlycommands:CommandsInstance
Defined in: behavior.ts:44
Deferred structural ops (spawn / despawn / insert) — safe mid-iteration.
entity
Section titled “entity”
readonlyentity:number
Defined in: behavior.ts:36
The entity this behavior instance is attached to.
readonlyinput:InputState
Defined in: behavior.ts:42
Runtime input (keyboard / mouse / touch).
readonlyself:S
Defined in: behavior.ts:38
This behavior’s own component data — mutate freely (persists).
readonlytime:TimeData
Defined in: behavior.ts:40
Frame timing (delta seconds, elapsed, …).
readonlyworld:World
Defined in: behavior.ts:46
The world, for cross-entity access.
Methods
Section titled “Methods”get<
C>(component):ComponentData<C>
Defined in: behavior.ts:55
Read another component on THIS entity.
For a script component this IS the stored object, so mutating it sticks. For an ENGINE component (Transform, Sprite, RigidBody2D — anything C++-backed) it is a copy decoded out of the wasm heap: mutating it changes nothing. Read it, change it, and hand it back through set.
Type Parameters
Section titled “Type Parameters”C extends AnyComponentDef
Parameters
Section titled “Parameters”component
Section titled “component”C
Returns
Section titled “Returns”has(
component):boolean
Defined in: behavior.ts:59
Whether THIS entity has component.
Parameters
Section titled “Parameters”component
Section titled “component”Returns
Section titled “Returns”boolean
set<
C>(component,data):void
Defined in: behavior.ts:57
Write another component on THIS entity — how an engine component is changed.
Type Parameters
Section titled “Type Parameters”C extends AnyComponentDef
Parameters
Section titled “Parameters”component
Section titled “component”C
Returns
Section titled “Returns”void