Behaviour · class
BehaviorRunner
One agent running one tree.
Explained in Agents and behaviour.
class BehaviorRunner<Context>import { BehaviorRunner } from '@driftengine/core';In depth
A character per agent and one tree between them: the tree is read-only after building, and everything that differs between two villagers following the same routine is here.
Constructor
new
constructor(tree: BehaviorTree)| Parameter | Type | Description |
|---|---|---|
tree | BehaviorTree |
Properties
| Name | Type | Description |
|---|---|---|
treereadonly | BehaviorTree | |
paused | boolean | When true, tick does nothing and reports the last status.MorePaused rather than not-called, so a debugger can hold one agent while the world runs — and so
|
Accessors
| Name | Type | Description |
|---|---|---|
statusget | BehaviorStatus |
Methods
tick
tick(context: Context): BehaviorStatusAdvance one tick, unless paused.
| Parameter | Type | Description |
|---|---|---|
context | Context |
stepOnce
stepOnce(context: Context): BehaviorStatusAdvance one tick even while paused. What a step button is wired to.
| Parameter | Type | Description |
|---|---|---|
context | Context |
reset
reset(): voidForget everything: the next tick starts the routine from the beginning.
activePath
activePath(out: Uint32Array): numberThe chain of nodes the last tick was inside, root first, filled into out.
| Parameter | Type | Description |
|---|---|---|
out | Uint32Array |
More
This is the inspection the report asked for, and it costs nothing to keep: the chain is
recorded as the tick descends, so asking for it later is a copy rather than a second walk.
nameOf turns the indices into the names the tree was written with.
nameOf
nameOf(node: number): string| Parameter | Type | Description |
|---|---|---|
node | number |