Struct amethyst::ecs::prelude::Storage [−]
pub struct Storage<'e, T, D> { /* fields omitted */ }A wrapper around the masked storage and the generations vector.
Can be used for safe lookup of components, insertions and removes.
This is what World::read/write fetches for the user.
Methods
impl<'st, T, D> Storage<'st, T, D> where
D: Deref<Target = MaskedStorage<T>>,
T: Component,
impl<'st, T, D> Storage<'st, T, D> where
D: Deref<Target = MaskedStorage<T>>,
T: Component, pub fn restrict(
&'rf self
) -> RestrictedStorage<'rf, 'st, T, &'rf <T as Component>::Storage, &'rf BitSet, ImmutableParallelRestriction>
pub fn restrict(
&'rf self
) -> RestrictedStorage<'rf, 'st, T, &'rf <T as Component>::Storage, &'rf BitSet, ImmutableParallelRestriction>Builds an immutable RestrictedStorage out of a Storage. Allows deferred
unchecked access to the entity's component.
This is returned as a ParallelRestriction version since you can only get
immutable components with this which is safe for parallel by default.
impl<'st, T, D> Storage<'st, T, D> where
D: DerefMut<Target = MaskedStorage<T>>,
T: Component,
impl<'st, T, D> Storage<'st, T, D> where
D: DerefMut<Target = MaskedStorage<T>>,
T: Component, pub fn restrict_mut(
&'rf mut self
) -> RestrictedStorage<'rf, 'st, T, &'rf mut <T as Component>::Storage, &'rf BitSet, SequentialRestriction>
pub fn restrict_mut(
&'rf mut self
) -> RestrictedStorage<'rf, 'st, T, &'rf mut <T as Component>::Storage, &'rf BitSet, SequentialRestriction>Builds a mutable RestrictedStorage out of a Storage. Allows restricted
access to the inner components without allowing invalidating the
bitset for iteration in Join.
pub fn par_restrict_mut(
&'rf mut self
) -> RestrictedStorage<'rf, 'st, T, &'rf mut <T as Component>::Storage, &'rf BitSet, MutableParallelRestriction>
pub fn par_restrict_mut(
&'rf mut self
) -> RestrictedStorage<'rf, 'st, T, &'rf mut <T as Component>::Storage, &'rf BitSet, MutableParallelRestriction>Builds a mutable, parallel RestrictedStorage,
does not allow mutably getting other components
aside from the current iteration.
impl<'e, T, D> Storage<'e, T, D> where
D: Deref<Target = MaskedStorage<T>>,
T: Component,
<T as Component>::Storage: Tracked,
impl<'e, T, D> Storage<'e, T, D> where
D: Deref<Target = MaskedStorage<T>>,
T: Component,
<T as Component>::Storage: Tracked, pub fn channels(&self) -> &TrackChannels
pub fn channels(&self) -> &TrackChannelsReturns the event channel tracking modified components.
pub fn modified(&self) -> &EventChannel<ModifiedFlag>
pub fn modified(&self) -> &EventChannel<ModifiedFlag>Returns the event channel tracking modified components.
pub fn inserted(&self) -> &EventChannel<InsertedFlag>
pub fn inserted(&self) -> &EventChannel<InsertedFlag>Returns the event channel tracking inserted components.
pub fn removed(&self) -> &EventChannel<RemovedFlag>
pub fn removed(&self) -> &EventChannel<RemovedFlag>Returns the event channel tracking removed components.
pub fn populate_modified<E>(
&self,
reader_id: &mut ReaderId<ModifiedFlag>,
value: &mut E
) where
E: Extend<u32>,
pub fn populate_modified<E>(
&self,
reader_id: &mut ReaderId<ModifiedFlag>,
value: &mut E
) where
E: Extend<u32>, Reads events from the modified EventChannel and populates a structure using the events.
pub fn populate_inserted<E>(
&self,
reader_id: &mut ReaderId<InsertedFlag>,
value: &mut E
) where
E: Extend<u32>,
pub fn populate_inserted<E>(
&self,
reader_id: &mut ReaderId<InsertedFlag>,
value: &mut E
) where
E: Extend<u32>, Reads events from the inserted EventChannel and populates a structure using the events.
pub fn populate_removed<E>(
&self,
reader_id: &mut ReaderId<RemovedFlag>,
value: &mut E
) where
E: Extend<u32>,
pub fn populate_removed<E>(
&self,
reader_id: &mut ReaderId<RemovedFlag>,
value: &mut E
) where
E: Extend<u32>, Reads events from the removed EventChannel and populates a structure using the events.
impl<'e, T, D> Storage<'e, T, D> where
D: DerefMut<Target = MaskedStorage<T>>,
T: Component,
<T as Component>::Storage: Tracked,
impl<'e, T, D> Storage<'e, T, D> where
D: DerefMut<Target = MaskedStorage<T>>,
T: Component,
<T as Component>::Storage: Tracked, pub fn channels_mut(&mut self) -> &mut TrackChannels
pub fn channels_mut(&mut self) -> &mut TrackChannelsReturns all of the event channels for this component.
pub fn modified_mut(&mut self) -> &mut EventChannel<ModifiedFlag>
pub fn modified_mut(&mut self) -> &mut EventChannel<ModifiedFlag>Returns the event channel tracking modified components mutably.
pub fn inserted_mut(&mut self) -> &mut EventChannel<InsertedFlag>
pub fn inserted_mut(&mut self) -> &mut EventChannel<InsertedFlag>Returns the event channel tracking inserted components mutably.
pub fn removed_mut(&mut self) -> &mut EventChannel<RemovedFlag>
pub fn removed_mut(&mut self) -> &mut EventChannel<RemovedFlag>Returns the event channel tracking removed components mutably.
pub fn track_modified(&mut self) -> ReaderId<ModifiedFlag>
pub fn track_modified(&mut self) -> ReaderId<ModifiedFlag>Starts tracking modified events.
pub fn track_inserted(&mut self) -> ReaderId<InsertedFlag>
pub fn track_inserted(&mut self) -> ReaderId<InsertedFlag>Starts tracking inserted events.
pub fn track_removed(&mut self) -> ReaderId<RemovedFlag>
pub fn track_removed(&mut self) -> ReaderId<RemovedFlag>Starts tracking removed events.
pub fn flag_modified(&mut self, id: u32)
pub fn flag_modified(&mut self, id: u32)Flags an index as modified.
pub fn flag_inserted(&mut self, id: u32)
pub fn flag_inserted(&mut self, id: u32)Flags an index as inserted.
pub fn flag_removed(&mut self, id: u32)
pub fn flag_removed(&mut self, id: u32)Flags an index as removed.
impl<'e, T, D> Storage<'e, T, D>
impl<'e, T, D> Storage<'e, T, D>pub fn new(entities: Fetch<'e, EntitiesRes>, data: D) -> Storage<'e, T, D>
pub fn new(entities: Fetch<'e, EntitiesRes>, data: D) -> Storage<'e, T, D>Create a new Storage
impl<'e, T, D> Storage<'e, T, D> where
D: Deref<Target = MaskedStorage<T>>,
T: Component,
impl<'e, T, D> Storage<'e, T, D> where
D: Deref<Target = MaskedStorage<T>>,
T: Component, pub fn unprotected_storage(&self) -> &<T as Component>::Storage
pub fn unprotected_storage(&self) -> &<T as Component>::StorageGets the wrapped storage.
pub fn get(&self, e: Entity) -> Option<&T>
pub fn get(&self, e: Entity) -> Option<&T>Tries to read the data associated with an Entity.
pub fn contains(&self, e: Entity) -> bool
pub fn contains(&self, e: Entity) -> boolReturns true if the storage has a component for this entity, and that entity is alive.
pub fn mask(&self) -> &BitSet
pub fn mask(&self) -> &BitSetReturns a reference to the bitset of this storage which allows filtering by the component type without actually getting the component.
impl<'e, T, D> Storage<'e, T, D> where
D: DerefMut<Target = MaskedStorage<T>>,
T: Component,
impl<'e, T, D> Storage<'e, T, D> where
D: DerefMut<Target = MaskedStorage<T>>,
T: Component, pub unsafe fn unprotected_storage_mut(
&mut self
) -> &mut <T as Component>::Storage
pub unsafe fn unprotected_storage_mut(
&mut self
) -> &mut <T as Component>::StorageGets mutable access to the wrapped storage.
This is unsafe because modifying the wrapped storage without also updating the mask bitset accordingly can result in illegal memory access.
pub fn get_mut(&mut self, e: Entity) -> Option<&mut T>
pub fn get_mut(&mut self, e: Entity) -> Option<&mut T>Tries to mutate the data associated with an Entity.
pub fn entry<'a>(
&'a mut self,
e: Entity
) -> Result<StorageEntry<'a, 'e, T, D>, WrongGeneration> where
'e: 'a,
pub fn entry<'a>(
&'a mut self,
e: Entity
) -> Result<StorageEntry<'a, 'e, T, D>, WrongGeneration> where
'e: 'a, Returns an entry to the component associated to the entity.
Behaves somewhat similarly to std::collections::HashMap's entry api.
Example
if let Ok(entry) = storage.entry(entity) { entry.or_insert(Comp { field: 55 }); }
pub fn insert(&mut self, e: Entity, v: T) -> Result<Option<T>, Error>
pub fn insert(&mut self, e: Entity, v: T) -> Result<Option<T>, Error>Inserts new data for a given Entity.
Returns the result of the operation as a InsertResult<T>
pub fn remove(&mut self, e: Entity) -> Option<T>
pub fn remove(&mut self, e: Entity) -> Option<T>Removes the data associated with an Entity.
pub fn clear(&mut self)
pub fn clear(&mut self)Clears the contents of the storage.
pub fn drain(&mut self) -> Drain<T>
pub fn drain(&mut self) -> Drain<T>Creates a draining storage wrapper which can be .joined
to get a draining iterator.
Trait Implementations
impl<'a, 'e, T, D> ParJoin for &'a mut Storage<'e, T, D> where
D: DerefMut<Target = MaskedStorage<T>>,
T: Component,
<T as Component>::Storage: Sync,
<T as Component>::Storage: DistinctStorage,
impl<'a, 'e, T, D> ParJoin for &'a mut Storage<'e, T, D> where
D: DerefMut<Target = MaskedStorage<T>>,
T: Component,
<T as Component>::Storage: Sync,
<T as Component>::Storage: DistinctStorage, fn par_join(self) -> JoinParIter<Self>
fn par_join(self) -> JoinParIter<Self>Create a joined parallel iterator over the contents.
impl<'a, 'e, T, D> ParJoin for &'a Storage<'e, T, D> where
D: Deref<Target = MaskedStorage<T>>,
T: Component,
<T as Component>::Storage: Sync,
impl<'a, 'e, T, D> ParJoin for &'a Storage<'e, T, D> where
D: Deref<Target = MaskedStorage<T>>,
T: Component,
<T as Component>::Storage: Sync, fn par_join(self) -> JoinParIter<Self>
fn par_join(self) -> JoinParIter<Self>Create a joined parallel iterator over the contents.
impl<'a, 'e, T, D> Not for &'a Storage<'e, T, D> where
D: Deref<Target = MaskedStorage<T>>,
T: Component,
impl<'a, 'e, T, D> Not for &'a Storage<'e, T, D> where
D: Deref<Target = MaskedStorage<T>>,
T: Component, type Output = AntiStorage<'a>
The resulting type after applying the ! operator.
fn not(self) -> <&'a Storage<'e, T, D> as Not>::Output
fn not(self) -> <&'a Storage<'e, T, D> as Not>::OutputPerforms the unary ! operation.
impl<'a, 'e, T, D> Join for &'a Storage<'e, T, D> where
D: Deref<Target = MaskedStorage<T>>,
T: Component,
impl<'a, 'e, T, D> Join for &'a Storage<'e, T, D> where
D: Deref<Target = MaskedStorage<T>>,
T: Component, type Type = &'a T
Type of joined components.
type Value = &'a <T as Component>::Storage
Type of joined storages.
type Mask = &'a BitSet
Type of joined bit mask.
unsafe fn open(
self
) -> (<&'a Storage<'e, T, D> as Join>::Mask, <&'a Storage<'e, T, D> as Join>::Value)
unsafe fn open(
self
) -> (<&'a Storage<'e, T, D> as Join>::Mask, <&'a Storage<'e, T, D> as Join>::Value)Open this join by returning the mask and the storages. Read more
ⓘImportant traits for &'a mut Runsafe fn get(v: &mut <&'a Storage<'e, T, D> as Join>::Value, i: u32) -> &'a T
unsafe fn get(v: &mut <&'a Storage<'e, T, D> as Join>::Value, i: u32) -> &'a TGet a joined component value by a given index.
ⓘImportant traits for JoinIter<J>fn join(self) -> JoinIter<Self>
fn join(self) -> JoinIter<Self>Create a joined iterator over the contents.
impl<'a, 'e, T, D> Join for &'a mut Storage<'e, T, D> where
D: DerefMut<Target = MaskedStorage<T>>,
T: Component,
impl<'a, 'e, T, D> Join for &'a mut Storage<'e, T, D> where
D: DerefMut<Target = MaskedStorage<T>>,
T: Component, type Type = &'a mut T
Type of joined components.
type Value = &'a mut <T as Component>::Storage
Type of joined storages.
type Mask = &'a BitSet
Type of joined bit mask.
unsafe fn open(
self
) -> (<&'a mut Storage<'e, T, D> as Join>::Mask, <&'a mut Storage<'e, T, D> as Join>::Value)
unsafe fn open(
self
) -> (<&'a mut Storage<'e, T, D> as Join>::Mask, <&'a mut Storage<'e, T, D> as Join>::Value)Open this join by returning the mask and the storages. Read more
ⓘImportant traits for &'a mut Runsafe fn get(
v: &mut <&'a mut Storage<'e, T, D> as Join>::Value,
i: u32
) -> &'a mut T
unsafe fn get(
v: &mut <&'a mut Storage<'e, T, D> as Join>::Value,
i: u32
) -> &'a mut TGet a joined component value by a given index.
ⓘImportant traits for JoinIter<J>fn join(self) -> JoinIter<Self>
fn join(self) -> JoinIter<Self>Create a joined iterator over the contents.
impl<'a, T, D> DistinctStorage for Storage<'a, T, D> where
T: Component,
<T as Component>::Storage: DistinctStorage,
impl<'a, T, D> DistinctStorage for Storage<'a, T, D> where
T: Component,
<T as Component>::Storage: DistinctStorage, impl<'a, T> GenericReadStorage for Storage<'a, T, Fetch<'a, MaskedStorage<T>>> where
T: Component,
impl<'a, T> GenericReadStorage for Storage<'a, T, Fetch<'a, MaskedStorage<T>>> where
T: Component, type Component = T
The component type of the storage
fn get(
&self,
entity: Entity
) -> Option<&<Storage<'a, T, Fetch<'a, MaskedStorage<T>>> as GenericReadStorage>::Component>
fn get(
&self,
entity: Entity
) -> Option<&<Storage<'a, T, Fetch<'a, MaskedStorage<T>>> as GenericReadStorage>::Component>Get immutable access to an Entitys component
fn _private() -> Seal
fn _private() -> SealPrivate function to seal the trait
impl<'a, T> GenericReadStorage for Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> where
T: Component,
impl<'a, T> GenericReadStorage for Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> where
T: Component, type Component = T
The component type of the storage
fn get(
&self,
entity: Entity
) -> Option<&<Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericReadStorage>::Component>
fn get(
&self,
entity: Entity
) -> Option<&<Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericReadStorage>::Component>Get immutable access to an Entitys component
fn _private() -> Seal
fn _private() -> SealPrivate function to seal the trait
impl<'a, 'b, T> GenericReadStorage for &'b Storage<'a, T, Fetch<'a, MaskedStorage<T>>> where
'a: 'b,
T: Component,
impl<'a, 'b, T> GenericReadStorage for &'b Storage<'a, T, Fetch<'a, MaskedStorage<T>>> where
'a: 'b,
T: Component, type Component = T
The component type of the storage
fn get(
&self,
entity: Entity
) -> Option<&<&'b Storage<'a, T, Fetch<'a, MaskedStorage<T>>> as GenericReadStorage>::Component>
fn get(
&self,
entity: Entity
) -> Option<&<&'b Storage<'a, T, Fetch<'a, MaskedStorage<T>>> as GenericReadStorage>::Component>Get immutable access to an Entitys component
fn _private() -> Seal
fn _private() -> SealPrivate function to seal the trait
impl<'a, 'b, T> GenericReadStorage for &'b Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> where
'a: 'b,
T: Component,
impl<'a, 'b, T> GenericReadStorage for &'b Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> where
'a: 'b,
T: Component, type Component = T
The component type of the storage
fn get(
&self,
entity: Entity
) -> Option<&<&'b Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericReadStorage>::Component>
fn get(
&self,
entity: Entity
) -> Option<&<&'b Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericReadStorage>::Component>Get immutable access to an Entitys component
fn _private() -> Seal
fn _private() -> SealPrivate function to seal the trait
impl<'a, T> SystemData<'a> for Storage<'a, T, Fetch<'a, MaskedStorage<T>>> where
T: Component,
impl<'a, T> SystemData<'a> for Storage<'a, T, Fetch<'a, MaskedStorage<T>>> where
T: Component, fn setup(res: &mut Resources)
fn setup(res: &mut Resources)Sets up the system data for fetching it from the Resources.
fn fetch(res: &'a Resources) -> Storage<'a, T, Fetch<'a, MaskedStorage<T>>>
fn fetch(res: &'a Resources) -> Storage<'a, T, Fetch<'a, MaskedStorage<T>>>Fetches the system data from Resources. Note that this is only specified for one concrete lifetime 'a, you need to implement the SystemData trait for every possible lifetime. Read more
fn reads() -> Vec<ResourceId>
fn reads() -> Vec<ResourceId>Returns all read dependencies as fetched from Self::fetch. Read more
fn writes() -> Vec<ResourceId>
fn writes() -> Vec<ResourceId>Returns all write dependencies as fetched from Self::fetch. Read more
impl<'a, T> SystemData<'a> for Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> where
T: Component,
impl<'a, T> SystemData<'a> for Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> where
T: Component, fn setup(res: &mut Resources)
fn setup(res: &mut Resources)Sets up the system data for fetching it from the Resources.
fn fetch(res: &'a Resources) -> Storage<'a, T, FetchMut<'a, MaskedStorage<T>>>
fn fetch(res: &'a Resources) -> Storage<'a, T, FetchMut<'a, MaskedStorage<T>>>Fetches the system data from Resources. Note that this is only specified for one concrete lifetime 'a, you need to implement the SystemData trait for every possible lifetime. Read more
fn reads() -> Vec<ResourceId>
fn reads() -> Vec<ResourceId>Returns all read dependencies as fetched from Self::fetch. Read more
fn writes() -> Vec<ResourceId>
fn writes() -> Vec<ResourceId>Returns all write dependencies as fetched from Self::fetch. Read more
impl<'a, T> GenericWriteStorage for Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> where
T: Component,
impl<'a, T> GenericWriteStorage for Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> where
T: Component, type Component = T
The component type of the storage
fn get_mut(
&mut self,
entity: Entity
) -> Option<&mut <Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericWriteStorage>::Component>
fn get_mut(
&mut self,
entity: Entity
) -> Option<&mut <Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericWriteStorage>::Component>Get mutable access to an Entitys component
fn insert(
&mut self,
entity: Entity,
comp: <Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericWriteStorage>::Component
) -> Result<Option<<Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericWriteStorage>::Component>, Error>
fn insert(
&mut self,
entity: Entity,
comp: <Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericWriteStorage>::Component
) -> Result<Option<<Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericWriteStorage>::Component>, Error>Insert a component for an Entity
fn remove(&mut self, entity: Entity)
fn remove(&mut self, entity: Entity)Remove the component for an Entity
fn _private() -> Seal
fn _private() -> SealPrivate function to seal the trait
impl<'a, 'b, T> GenericWriteStorage for &'b mut Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> where
'a: 'b,
T: Component,
impl<'a, 'b, T> GenericWriteStorage for &'b mut Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> where
'a: 'b,
T: Component, type Component = T
The component type of the storage
fn get_mut(
&mut self,
entity: Entity
) -> Option<&mut <&'b mut Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericWriteStorage>::Component>
fn get_mut(
&mut self,
entity: Entity
) -> Option<&mut <&'b mut Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericWriteStorage>::Component>Get mutable access to an Entitys component
fn insert(
&mut self,
entity: Entity,
comp: <&'b mut Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericWriteStorage>::Component
) -> Result<Option<<&'b mut Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericWriteStorage>::Component>, Error>
fn insert(
&mut self,
entity: Entity,
comp: <&'b mut Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericWriteStorage>::Component
) -> Result<Option<<&'b mut Storage<'a, T, FetchMut<'a, MaskedStorage<T>>> as GenericWriteStorage>::Component>, Error>Insert a component for an Entity
fn remove(&mut self, entity: Entity)
fn remove(&mut self, entity: Entity)Remove the component for an Entity
fn _private() -> Seal
fn _private() -> SealPrivate function to seal the trait