1681-engine / index / BtAgent
Class: BtAgent<C> ​
Defined in: src/ai/behaviorTree.ts:51
One agent running a tree: its memory, and the tick that drives it.
Type Parameters ​
| Type Parameter |
|---|
C |
Implements ​
BtRun<C>
Constructors ​
Constructor ​
new BtAgent<C>(root): BtAgent<C>;Defined in: src/ai/behaviorTree.ts:60
Parameters ​
| Parameter | Type |
|---|---|
root | BtNode<C> |
Returns ​
BtAgent<C>
Properties ​
now ​
now: number = 0;Defined in: src/ai/behaviorTree.ts:52
The time this tick was given (ms), for waits, cooldowns and timeouts.
Implementation of ​
root ​
readonly root: BtNode<C>;Defined in: src/ai/behaviorTree.ts:60
Methods ​
halt() ​
halt(child, ctx): void;Defined in: src/ai/behaviorTree.ts:107
Stops a child that was left running, and everything under it.
Parameters ​
| Parameter | Type |
|---|---|
child | BtNode<C> |
ctx | C |
Returns ​
void
Implementation of ​
isRunning() ​
isRunning(node): boolean;Defined in: src/ai/behaviorTree.ts:81
Whether a node is running for this agent now.
Parameters ​
| Parameter | Type |
|---|---|
node | BtNode<C> |
Returns ​
boolean
lasting() ​
lasting<T>(node, init): T;Defined in: src/ai/behaviorTree.ts:90
Memory that outlives the node finishing (a cooldown's ready time); only reset clears it.
Type Parameters ​
| Type Parameter |
|---|
T |
Parameters ​
| Parameter | Type |
|---|---|
node | BtNode<C> |
init | () => T |
Returns ​
T
Implementation of ​
reset() ​
reset(ctx): void;Defined in: src/ai/behaviorTree.ts:72
Halts whatever is running and forgets all memory: the agent starts the tree afresh (it died, it was stunned).
Parameters ​
| Parameter | Type |
|---|---|
ctx | C |
Returns ​
void
state() ​
state<T>(node, init): T;Defined in: src/ai/behaviorTree.ts:85
This node's memory for this agent, made by init the first time and after a halt.
Type Parameters ​
| Type Parameter |
|---|
T |
Parameters ​
| Parameter | Type |
|---|---|
node | BtNode<C> |
init | () => T |
Returns ​
T
Implementation of ​
tick() ​
tick(child, ctx): BtStatus;Defined in: src/ai/behaviorTree.ts:95
Ticks a child; use this, never child.tick, so it is traced and halted right.
Parameters ​
| Parameter | Type |
|---|---|
child | BtNode<C> |
ctx | C |
Returns ​
Implementation of ​
trace() ​
trace(): BtTraceLine[];Defined in: src/ai/behaviorTree.ts:116
The tree as it ran on the last tick, depth first: for a debug overlay.
Returns ​
update() ​
update(ctx, now): BtStatus;Defined in: src/ai/behaviorTree.ts:63
Ticks the tree once at time now (ms) and returns the root's answer.
Parameters ​
| Parameter | Type |
|---|---|
ctx | C |
now | number |