pub enum BehaviorNode {
Show 16 variants
If {
cond: BehaviorExpr,
then: Vec<BehaviorNode>,
otherwise: Vec<BehaviorNode>,
},
ForEach {
query: String,
bind: String,
body: Vec<BehaviorNode>,
},
Let {
name: String,
value: BehaviorExpr,
},
Set {
var: String,
value: BehaviorExpr,
add: bool,
},
SetLocal {
local: String,
value: BehaviorExpr,
add: bool,
},
SetTransform {
entity: BehaviorExpr,
position: Option<BehaviorExpr>,
rotation_deg: Option<BehaviorExpr>,
scale: Option<BehaviorExpr>,
},
Spawn {
template: Option<AssetId>,
position: [f32; 3],
rotation_deg: [f32; 3],
scale: [f32; 3],
lifetime: f32,
bind: Option<String>,
},
Despawn {
target: BehaviorExpr,
},
Reparent {
child: BehaviorExpr,
parent: Option<BehaviorExpr>,
},
Show {
target: BehaviorExpr,
},
Hide {
target: BehaviorExpr,
},
Sound {
clip: Option<AudioClipHandle>,
kind: CueKind,
volume: f32,
},
Scene {
scene: Option<AssetId>,
transition: String,
},
Screen {
screen: Option<AssetId>,
},
Story(StoryPlayback),
Save,
}Expand description
One node run by a firing Behavior.
Nodes are the only way a behavior changes the world. There is no unbounded loop and no recursion, so a behavior body always terminates.
Variants§
If
Runs then when cond holds, else otherwise.
Fields
cond: BehaviorExprThe tested expression.
then: Vec<BehaviorNode>Nodes run when cond holds.
otherwise: Vec<BehaviorNode>Nodes run when cond does not hold.
ForEach
Runs do once per entity a declared query matched, binding each to
bind.
Fields
body: Vec<BehaviorNode>Nodes run per entity.
Let
Binds an expression to a name for the rest of the body.
Set
Writes a world variable: assign value, or add it to the current value
when add is true.
Fields
value: BehaviorExprThe value assigned (or added).
SetLocal
Writes one of this behavior’s per-entity locals.
Fields
value: BehaviorExprThe value assigned (or added).
SetTransform
Writes an entity’s transform. An omitted field is left unchanged.
Fields
entity: BehaviorExprThe entity moved.
position: Option<BehaviorExpr>New world-space position.
rotation_deg: Option<BehaviorExpr>New Euler rotation in degrees.
scale: Option<BehaviorExpr>New scale.
Spawn
Creates a copy of an existing placement at a world position. Binding
bind makes the copy addressable for the rest of the body.
Fields
Despawn
Removes an entity and its children from the world.
Fields
target: BehaviorExprThe entity removed.
Reparent
Re-points an entity’s parent edge.
Fields
child: BehaviorExprThe entity moved.
parent: Option<BehaviorExpr>The new parent, or unset to detach to a root.
Show
Makes a hidden entity (and its children) visible again.
Fields
target: BehaviorExprThe entity revealed.
Hide
Makes an entity (and its children) invisible without removing it. A
hidden entity keeps simulating; show reverses this.
Fields
target: BehaviorExprThe entity hidden.
Sound
Plays an AudioClip flat on the main mix (no 3D position).
Fields
clip: Option<AudioClipHandle>The clip played.
Scene
Jumps the world to a named Scene.
Fields
Screen
Shows a Screen, replacing the top of the screen stack.
Story(StoryPlayback)
Controls the world’s Story playback.
Save
Writes the world’s logic state to disk: every world variable, plus
which once behaviors have fired. Per-entity locals are not saved. The
state is restored the next time the world starts, so a behavior gated
on a saved variable carries across runs. Timers, delays, and cooldowns
restart fresh; entities are not saved. A world with no save node
never reads or writes state.
Trait Implementations§
Source§impl Clone for BehaviorNode
impl Clone for BehaviorNode
Source§fn clone(&self) -> BehaviorNode
fn clone(&self) -> BehaviorNode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more