pub struct Variables {
pub asset_id: AssetId,
pub vars: Vec<VariableDecl>,
}Expand description
The world’s shared variables: the state Behaviors read with
var and write with set, and the state a save node persists.
Declaring this asset makes the table authoritative: every variable a
behavior names must appear here, and its declared value fixes both the
variable’s type and its starting value. A world without a Variables asset
keeps every variable implicit and integer-typed, so declaring one is how a
world opts into typed variables and into catching misspelled names at build
time.
Variables are world-scoped and shared. Per-entity state belongs in a
behavior’s locals, which are typed the same way but private to one entity
and never persisted.
Fields§
§asset_id: AssetIdAsset identity; injected via inject_name. Not part of args.
vars: Vec<VariableDecl>Every variable the world declares.
Trait Implementations§
Source§impl Component for Variables
impl Component for Variables
Source§const NAME: &'static str = "Variables"
const NAME: &'static str = "Variables"
The registry name a world authors this component under.
Source§fn from_baked(bytes: &[u8]) -> Result<Self, CnResult>
fn from_baked(bytes: &[u8]) -> Result<Self, CnResult>
Reconstruct this component from a blob record, whose bytes are the
serialized runtime component (cook already ran the asset -> component
translation). The default rejects: runtime-only components are never
stored in a blob, so only loadable types provide an implementation.
Source§fn inject_locator(&mut self, _locator: PayloadLocator)
fn inject_locator(&mut self, _locator: PayloadLocator)
Called after construction to inject the payload locator from the blob def.
Only meaningful for components with a compiled payload.
The default implementation does nothing (correct for most components).
Source§fn inject_name(&mut self, _id: AssetId)
fn inject_name(&mut self, _id: AssetId)
Called after construction to inject the asset’s identity from the blob
def. Only meaningful for components that look themselves up by id at
runtime. The default implementation does nothing.
Source§impl ComponentSlot for Variables
impl ComponentSlot for Variables
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
The component type’s stable id, used as its
ComponentId.Source§fn slot(s: &ComponentStorage) -> &Column<Self>
fn slot(s: &ComponentStorage) -> &Column<Self>
Borrow this type’s column out of the storage.
Source§fn slot_mut(s: &mut ComponentStorage) -> &mut Column<Self>
fn slot_mut(s: &mut ComponentStorage) -> &mut Column<Self>
Mutably borrow this type’s column out of the storage.
Source§impl<'de> Deserialize<'de> for Variables
impl<'de> Deserialize<'de> for Variables
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Variables, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Variables, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<Variables> for ComponentAsset
impl From<Variables> for ComponentAsset
impl RuntimeComponent for Variables
Source§impl Serialize for Variables
impl Serialize for Variables
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,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for Variables
impl RefUnwindSafe for Variables
impl Send for Variables
impl Sync for Variables
impl Unpin for Variables
impl UnsafeUnpin for Variables
impl UnwindSafe for Variables
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
Mutably borrows from an owned value. Read more