pub enum BehaviorExpr {
Show 30 variants
Bool(bool),
Int(i32),
Float(f32),
Vec3([f32; 3]),
Var(String),
Local(String),
Bind(String),
Named(Option<AssetId>),
SelfEntity,
Dt,
Elapsed,
Position(Box<BehaviorExpr>),
Distance(Box<BehaviorExpr>, Box<BehaviorExpr>),
First(String),
Count(String),
Alive(Box<BehaviorExpr>),
Add(Box<BehaviorExpr>, Box<BehaviorExpr>),
Sub(Box<BehaviorExpr>, Box<BehaviorExpr>),
Mul(Box<BehaviorExpr>, Box<BehaviorExpr>),
Div(Box<BehaviorExpr>, Box<BehaviorExpr>),
Normalize(Box<BehaviorExpr>),
Eq(Box<BehaviorExpr>, Box<BehaviorExpr>),
Ne(Box<BehaviorExpr>, Box<BehaviorExpr>),
Lt(Box<BehaviorExpr>, Box<BehaviorExpr>),
Le(Box<BehaviorExpr>, Box<BehaviorExpr>),
Gt(Box<BehaviorExpr>, Box<BehaviorExpr>),
Ge(Box<BehaviorExpr>, Box<BehaviorExpr>),
All(Vec<BehaviorExpr>),
Any(Vec<BehaviorExpr>),
Not(Box<BehaviorExpr>),
}Expand description
A value expression in a Behavior.
Expressions are pure: they read state, entities, and the clock, and never change the world. Arithmetic works on both scalars and vectors, and mixing the two is a build error.
Variants§
Bool(bool)
A boolean literal.
Int(i32)
An integer literal.
Float(f32)
A float literal.
Vec3([f32; 3])
A vector literal.
Var(String)
Reads a world variable.
Local(String)
Reads one of this behavior’s per-entity locals.
Bind(String)
Reads a name bound earlier by a let or for_each node.
Named(Option<AssetId>)
An entity declared in the world, addressed by asset name.
SelfEntity
The entity this behavior instance runs for. Only valid with a scope.
Dt
Seconds elapsed since the previous tick.
Elapsed
Seconds elapsed since the world started.
Position(Box<BehaviorExpr>)
World-space position of an entity.
Distance(Box<BehaviorExpr>, Box<BehaviorExpr>)
Distance between two entities.
First(String)
The first entity of a declared query, or none when it is empty.
Count(String)
How many entities a declared query matched.
Alive(Box<BehaviorExpr>)
Whether an entity is still alive.
Add(Box<BehaviorExpr>, Box<BehaviorExpr>)
Sum of two values.
Sub(Box<BehaviorExpr>, Box<BehaviorExpr>)
Difference of two values.
Mul(Box<BehaviorExpr>, Box<BehaviorExpr>)
Product of two values; a vector may be scaled by a scalar.
Div(Box<BehaviorExpr>, Box<BehaviorExpr>)
Quotient of two values; dividing by zero yields zero.
Normalize(Box<BehaviorExpr>)
A vector rescaled to unit length; a zero vector stays zero.
Eq(Box<BehaviorExpr>, Box<BehaviorExpr>)
Equality test.
Ne(Box<BehaviorExpr>, Box<BehaviorExpr>)
Inequality test.
Lt(Box<BehaviorExpr>, Box<BehaviorExpr>)
Less-than test.
Le(Box<BehaviorExpr>, Box<BehaviorExpr>)
Less-than-or-equal test.
Gt(Box<BehaviorExpr>, Box<BehaviorExpr>)
Greater-than test.
Ge(Box<BehaviorExpr>, Box<BehaviorExpr>)
Greater-than-or-equal test.
All(Vec<BehaviorExpr>)
True when every operand is true.
Any(Vec<BehaviorExpr>)
True when any operand is true.
Not(Box<BehaviorExpr>)
Logical negation.
Trait Implementations§
Source§impl Clone for BehaviorExpr
impl Clone for BehaviorExpr
Source§fn clone(&self) -> BehaviorExpr
fn clone(&self) -> BehaviorExpr
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BehaviorExpr
impl Debug for BehaviorExpr
Source§impl Default for BehaviorExpr
impl Default for BehaviorExpr
Source§fn default() -> BehaviorExpr
fn default() -> BehaviorExpr
Source§impl<'de> Deserialize<'de> for BehaviorExpr
impl<'de> Deserialize<'de> for BehaviorExpr
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<BehaviorExpr, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<BehaviorExpr, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for BehaviorExpr
impl PartialEq for BehaviorExpr
Source§impl Serialize for BehaviorExpr
impl Serialize for BehaviorExpr
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for BehaviorExpr
Auto Trait Implementations§
impl Freeze for BehaviorExpr
impl RefUnwindSafe for BehaviorExpr
impl Send for BehaviorExpr
impl Sync for BehaviorExpr
impl Unpin for BehaviorExpr
impl UnsafeUnpin for BehaviorExpr
impl UnwindSafe for BehaviorExpr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().