pub struct StatDefinition { /* private fields */ }Expand description
Author-defined stat metadata and bounds.
Implementations§
Source§impl StatDefinition
impl StatDefinition
Sourcepub fn new(id: impl Into<StatId>, default_value: f32) -> Self
pub fn new(id: impl Into<StatId>, default_value: f32) -> Self
Creates a stat definition with default bounds 0.0..=default_value.
Sourcepub fn display_name(&self) -> &str
pub fn display_name(&self) -> &str
Returns the display name intended for UI/docs.
Sourcepub fn default_value(&self) -> f32
pub fn default_value(&self) -> f32
Returns the default runtime value.
Sourcepub fn span(&self) -> f32
pub fn span(&self) -> f32
Returns the absolute span between the minimum and maximum runtime values.
A stat with equal bounds has a span of 0.0.
Sourcepub fn bounds(self, min_value: f32, max_value: f32) -> Self
pub fn bounds(self, min_value: f32, max_value: f32) -> Self
Sets runtime bounds. Reversed bounds are normalized.
Sourcepub fn initial_value(self, value: f32) -> Self
pub fn initial_value(self, value: f32) -> Self
Sets a new default runtime value, clamped into the current bounds.
Sourcepub fn attribute(
self,
key: impl Into<String>,
value: impl Into<ContentValue>,
) -> Self
pub fn attribute( self, key: impl Into<String>, value: impl Into<ContentValue>, ) -> Self
Adds or replaces an author-defined gameplay attribute.
Sourcepub fn get_attribute(&self, key: &str) -> Option<&ContentValue>
pub fn get_attribute(&self, key: &str) -> Option<&ContentValue>
Returns a gameplay attribute by key.
Sourcepub fn number_attribute(&self, key: &str) -> Option<f64>
pub fn number_attribute(&self, key: &str) -> Option<f64>
Returns a numeric gameplay attribute by key.
Sourcepub fn bool_attribute(&self, key: &str) -> Option<bool>
pub fn bool_attribute(&self, key: &str) -> Option<bool>
Returns a boolean gameplay attribute by key.
Sourcepub fn text_attribute(&self, key: &str) -> Option<&str>
pub fn text_attribute(&self, key: &str) -> Option<&str>
Returns a text gameplay attribute by key.
Sourcepub fn attributes(&self) -> &HashMap<String, ContentValue>
pub fn attributes(&self) -> &HashMap<String, ContentValue>
Returns all gameplay attributes.
Returns all author-defined tags.
Sourcepub fn snapshot(&self) -> StatDefinitionSnapshot
pub fn snapshot(&self) -> StatDefinitionSnapshot
Creates a serializable, deterministic snapshot of this stat definition.
Trait Implementations§
Source§impl Clone for StatDefinition
impl Clone for StatDefinition
Source§fn clone(&self) -> StatDefinition
fn clone(&self) -> StatDefinition
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 StatDefinition
impl Debug for StatDefinition
Source§impl PartialEq for StatDefinition
impl PartialEq for StatDefinition
impl StructuralPartialEq for StatDefinition
Auto Trait Implementations§
impl Freeze for StatDefinition
impl RefUnwindSafe for StatDefinition
impl Send for StatDefinition
impl Sync for StatDefinition
impl Unpin for StatDefinition
impl UnsafeUnpin for StatDefinition
impl UnwindSafe for StatDefinition
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
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, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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 more