Skip to main content

BehaviorNode

Enum BehaviorNode 

Source
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: BehaviorExpr

The 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

§query: String

The declared query iterated.

§bind: String

The name each entity is bound to.

§body: Vec<BehaviorNode>

Nodes run per entity.

§

Let

Binds an expression to a name for the rest of the body.

Fields

§name: String

The bound name.

§value: BehaviorExpr

The bound expression.

§

Set

Writes a world variable: assign value, or add it to the current value when add is true.

Fields

§var: String

The variable written.

§value: BehaviorExpr

The value assigned (or added).

§add: bool

false assigns value; true adds it to the current value.

§

SetLocal

Writes one of this behavior’s per-entity locals.

Fields

§local: String

The local written.

§value: BehaviorExpr

The value assigned (or added).

§add: bool

false assigns value; true adds it to the current value.

§

SetTransform

Writes an entity’s transform. An omitted field is left unchanged.

Fields

§entity: BehaviorExpr

The 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

§template: Option<AssetId>

The placement copied (e.g. a Prop).

§position: [f32; 3]

World-space position of the copy.

§rotation_deg: [f32; 3]

Euler rotation of the copy in degrees.

§scale: [f32; 3]

Scale of the copy ([1, 1, 1] keeps the template’s size).

§lifetime: f32

Seconds the copy lives before auto-despawning (0 lives forever).

§bind: Option<String>

Name the new entity is bound to for the rest of the body.

§

Despawn

Removes an entity and its children from the world.

Fields

§target: BehaviorExpr

The entity removed.

§

Reparent

Re-points an entity’s parent edge.

Fields

§child: BehaviorExpr

The 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: BehaviorExpr

The entity revealed.

§

Hide

Makes an entity (and its children) invisible without removing it. A hidden entity keeps simulating; show reverses this.

Fields

§target: BehaviorExpr

The entity hidden.

§

Sound

Plays an AudioClip flat on the main mix (no 3D position).

Fields

§clip: Option<AudioClipHandle>

The clip played.

§kind: CueKind

Playback behavior: a looping music track or a one-shot sound.

§volume: f32

Linear gain applied to the clip (1.0 leaves it unchanged).

§

Scene

Jumps the world to a named Scene.

Fields

§scene: Option<AssetId>

The scene jumped to.

§transition: String

The transition: "Cut" or "FadeBlack".

§

Screen

Shows a Screen, replacing the top of the screen stack.

Fields

§screen: Option<AssetId>

The screen shown.

§

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

Source§

fn clone(&self) -> BehaviorNode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BehaviorNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BehaviorNode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for BehaviorNode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.