pub enum ContentValue {
Bool(bool),
Integer(i64),
Float(f64),
Text(String),
TextList(Vec<String>),
NumberList(Vec<f64>),
Color([f32; 4]),
}Expand description
Author-defined attribute value attached to content definitions.
This type is deliberately broad but small. Use it for gameplay metadata that the framework should store and expose without interpreting globally.
Variants§
Bool(bool)
Boolean flag, e.g. flammable = true.
Integer(i64)
Signed integer, e.g. fuel_value = 20.
Float(f64)
Floating-point number, e.g. hardness = 1.25.
Text(String)
Text value, e.g. required_tool = "pickaxe".
TextList(Vec<String>)
Ordered list of text values, e.g. drops, groups, or recipe ids.
NumberList(Vec<f64>)
Ordered list of numeric values.
Color([f32; 4])
RGBA color represented as four linear floats.
Implementations§
Source§impl ContentValue
impl ContentValue
Sourcepub fn strings(values: impl IntoIterator<Item = impl Into<String>>) -> Self
pub fn strings(values: impl IntoIterator<Item = impl Into<String>>) -> Self
Convenience constructor for string lists.
Sourcepub fn as_number(&self) -> Option<f64>
pub fn as_number(&self) -> Option<f64>
Returns this value as a number when it stores an integer or float.
Sourcepub fn as_text_list(&self) -> Option<&[String]>
pub fn as_text_list(&self) -> Option<&[String]>
Returns this value as a text list when it stores one.
Sourcepub fn as_number_list(&self) -> Option<&[f64]>
pub fn as_number_list(&self) -> Option<&[f64]>
Returns this value as a number list when it stores one.
Trait Implementations§
Source§impl Clone for ContentValue
impl Clone for ContentValue
Source§impl Debug for ContentValue
impl Debug for ContentValue
Source§impl<'de> Deserialize<'de> for ContentValue
impl<'de> Deserialize<'de> for ContentValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 From<&str> for ContentValue
impl From<&str> for ContentValue
Source§impl From<String> for ContentValue
impl From<String> for ContentValue
Source§impl From<bool> for ContentValue
impl From<bool> for ContentValue
Source§impl From<f32> for ContentValue
impl From<f32> for ContentValue
Source§impl From<f64> for ContentValue
impl From<f64> for ContentValue
Source§impl From<i32> for ContentValue
impl From<i32> for ContentValue
Source§impl From<i64> for ContentValue
impl From<i64> for ContentValue
Source§impl From<u32> for ContentValue
impl From<u32> for ContentValue
Source§impl PartialEq for ContentValue
impl PartialEq for ContentValue
Source§impl Serialize for ContentValue
impl Serialize for ContentValue
impl StructuralPartialEq for ContentValue
Auto Trait Implementations§
impl Freeze for ContentValue
impl RefUnwindSafe for ContentValue
impl Send for ContentValue
impl Sync for ContentValue
impl Unpin for ContentValue
impl UnsafeUnpin for ContentValue
impl UnwindSafe for ContentValue
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
Return the
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
Mutably borrows from an owned value. Read more
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> ConditionalSend for Twhere
T: Send,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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>
Converts
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>
Converts
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)
Converts
&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)
Converts
&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> ⓘ
Converts
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> ⓘ
Converts
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<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
impl<T> Settings for T
Source§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
Creates a type-erased clone of this value.