pub struct View<'a, T: Component, Tracking: Tracking = <T as Component>::Tracking> { /* private fields */ }
Expand description
Shared view over a component storage.
Implementations§
source§impl<'a, T: Component> View<'a, T>
impl<'a, T: Component> View<'a, T>
sourcepub fn is_inserted(&self, entity: EntityId) -> bool
pub fn is_inserted(&self, entity: EntityId) -> bool
Inside a workload returns true
if entity
’s component was inserted since the last run of this system.
Outside workloads returns true
if entity
’s component was inserted since the last call to clear_all_inserted
.
Returns false
if entity
does not have a component in this storage.
sourcepub fn is_modified(&self, entity: EntityId) -> bool
pub fn is_modified(&self, entity: EntityId) -> bool
Inside a workload returns true
if entity
’s component was modified since the last run of this system.
Outside workloads returns true
if entity
’s component was modified since the last call to clear_all_modified
.
Returns false
if entity
does not have a component in this storage.
sourcepub fn is_inserted_or_modified(&self, entity: EntityId) -> bool
pub fn is_inserted_or_modified(&self, entity: EntityId) -> bool
Inside a workload returns true
if entity
’s component was inserted or modified since the last run of this system.
Outside workloads returns true
if entity
’s component was inserted or modified since the last clear call.
Returns false
if entity
does not have a component in this storage.
sourcepub fn is_deleted(&self, entity: EntityId) -> bool
pub fn is_deleted(&self, entity: EntityId) -> bool
Inside a workload returns true
if entity
’s component was deleted since the last run of this system.
Outside workloads returns true
if entity
’s component was deleted since the last call to clear_all_deleted
.
Returns false
if entity
does not have a component in this storage.
sourcepub fn is_removed(&self, entity: EntityId) -> bool
pub fn is_removed(&self, entity: EntityId) -> bool
Inside a workload returns true
if entity
’s component was removed since the last run of this system.
Outside workloads returns true
if entity
’s component was removed since the last call to clear_all_removed
.
Returns false
if entity
does not have a component in this storage.
sourcepub fn is_removed_or_deleted(&self, entity: EntityId) -> bool
pub fn is_removed_or_deleted(&self, entity: EntityId) -> bool
Inside a workload returns true
if entity
’s component was deleted or removed since the last run of this system.
Outside workloads returns true
if entity
’s component was deleted or removed since the last clear call.
Returns false
if entity
does not have a component in this storage.
source§impl<'a, T: Component<Tracking = Untracked>> View<'a, T, Untracked>
impl<'a, T: Component<Tracking = Untracked>> View<'a, T, Untracked>
sourcepub fn new_for_custom_storage(
storage_id: StorageId,
all_storages: Ref<'a, &'a AllStorages>,
) -> Result<Self, CustomStorageView>
pub fn new_for_custom_storage( storage_id: StorageId, all_storages: Ref<'a, &'a AllStorages>, ) -> Result<Self, CustomStorageView>
Creates a new View
for custom SparseSet
storage.
use shipyard::{track, Component, SparseSet, StorageId, View, World};
struct ScriptingComponent(Vec<u8>);
impl Component for ScriptingComponent {
type Tracking = track::Untracked;
}
let world = World::new();
world.add_custom_storage(
StorageId::Custom(0),
SparseSet::<ScriptingComponent>::new_custom_storage(),
).unwrap();
let all_storages = world.all_storages().unwrap();
let scripting_storage =
View::<ScriptingComponent>::new_for_custom_storage(StorageId::Custom(0), all_storages)
.unwrap();
source§impl<T: Component<Tracking = Insertion>> View<'_, T, Insertion>
impl<T: Component<Tracking = Insertion>> View<'_, T, Insertion>
sourcepub fn inserted(&self) -> Inserted<&Self>
pub fn inserted(&self) -> Inserted<&Self>
Wraps this view to be able to iterate inserted components.
sourcepub fn inserted_or_modified(&self) -> InsertedOrModified<&Self>
pub fn inserted_or_modified(&self) -> InsertedOrModified<&Self>
Wraps this view to be able to iterate inserted and modified components.
source§impl<T: Component<Tracking = Modification>> View<'_, T, Modification>
impl<T: Component<Tracking = Modification>> View<'_, T, Modification>
sourcepub fn modified(&self) -> Modified<&Self>
pub fn modified(&self) -> Modified<&Self>
Wraps this view to be able to iterate modified components.
sourcepub fn inserted_or_modified(&self) -> InsertedOrModified<&Self>
pub fn inserted_or_modified(&self) -> InsertedOrModified<&Self>
Wraps this view to be able to iterate inserted and modified components.
source§impl<T: Component<Tracking = Deletion>> View<'_, T, Deletion>
impl<T: Component<Tracking = Deletion>> View<'_, T, Deletion>
sourcepub fn deleted(&self) -> impl Iterator<Item = (EntityId, &T)> + '_
pub fn deleted(&self) -> impl Iterator<Item = (EntityId, &T)> + '_
Returns the deleted components of a storage tracking deletion.
sourcepub fn removed_or_deleted(&self) -> impl Iterator<Item = EntityId> + '_
pub fn removed_or_deleted(&self) -> impl Iterator<Item = EntityId> + '_
Returns the ids of removed or deleted components of a storage tracking removal and/or deletion.
source§impl<T: Component<Tracking = Removal>> View<'_, T, Removal>
impl<T: Component<Tracking = Removal>> View<'_, T, Removal>
sourcepub fn removed(&self) -> impl Iterator<Item = EntityId> + '_
pub fn removed(&self) -> impl Iterator<Item = EntityId> + '_
Returns the ids of removed components of a storage tracking removal.
sourcepub fn removed_or_deleted(&self) -> impl Iterator<Item = EntityId> + '_
pub fn removed_or_deleted(&self) -> impl Iterator<Item = EntityId> + '_
Returns the ids of removed or deleted components of a storage tracking removal and/or deletion.
source§impl<T: Component<Tracking = All>> View<'_, T, All>
impl<T: Component<Tracking = All>> View<'_, T, All>
sourcepub fn inserted(&self) -> Inserted<&Self>
pub fn inserted(&self) -> Inserted<&Self>
Wraps this view to be able to iterate inserted components.
sourcepub fn modified(&self) -> Modified<&Self>
pub fn modified(&self) -> Modified<&Self>
Wraps this view to be able to iterate modified components.
sourcepub fn inserted_or_modified(&self) -> InsertedOrModified<&Self>
pub fn inserted_or_modified(&self) -> InsertedOrModified<&Self>
Wraps this view to be able to iterate inserted and modified components.
sourcepub fn deleted(&self) -> impl Iterator<Item = (EntityId, &T)> + '_
pub fn deleted(&self) -> impl Iterator<Item = (EntityId, &T)> + '_
Returns the deleted components of a storage tracking deletion.
sourcepub fn removed(&self) -> impl Iterator<Item = EntityId> + '_
pub fn removed(&self) -> impl Iterator<Item = EntityId> + '_
Returns the ids of removed components of a storage tracking removal.
sourcepub fn removed_or_deleted(&self) -> impl Iterator<Item = EntityId> + '_
pub fn removed_or_deleted(&self) -> impl Iterator<Item = EntityId> + '_
Returns the ids of removed or deleted components of a storage tracking removal and/or deletion.
Methods from Deref<Target = SparseSet<T>>§
sourcepub fn contains(&self, entity: EntityId) -> bool
pub fn contains(&self, entity: EntityId) -> bool
Returns true
if entity
owns a component in this storage.
sourcepub fn index_of(&self, entity: EntityId) -> Option<usize>
pub fn index_of(&self, entity: EntityId) -> Option<usize>
Returns the index of entity
’s component in the dense
and data
vectors.
This index is only valid for this storage and until a modification happens.
sourcepub unsafe fn index_of_unchecked(&self, entity: EntityId) -> usize
pub unsafe fn index_of_unchecked(&self, entity: EntityId) -> usize
Returns the index of entity
’s component in the dense
and data
vectors.
This index is only valid for this storage and until a modification happens.
§Safety
entity
has to own a component of this type.
The index is only valid until a modification occurs in the storage.
sourcepub fn is_tracking_insertion(&self) -> bool
pub fn is_tracking_insertion(&self) -> bool
Returns true
if the storage tracks insertion.
sourcepub fn is_tracking_modification(&self) -> bool
pub fn is_tracking_modification(&self) -> bool
Returns true
if the storage tracks modification.
sourcepub fn is_tracking_deletion(&self) -> bool
pub fn is_tracking_deletion(&self) -> bool
Returns true
if the storage tracks deletion.
sourcepub fn is_tracking_removal(&self) -> bool
pub fn is_tracking_removal(&self) -> bool
Returns true
if the storage tracks removal.
sourcepub fn is_tracking_any(&self) -> bool
pub fn is_tracking_any(&self) -> bool
Returns true
if the storage tracks insertion, modification, deletion or removal.
Trait Implementations§
source§impl<'a, T: Component> IntoAbstract for &'a View<'a, T>
impl<'a, T: Component> IntoAbstract for &'a View<'a, T>
source§impl<T: Send + Sync + Component> IntoBorrow for View<'_, T>
impl<T: Send + Sync + Component> IntoBorrow for View<'_, T>
§type Borrow = ViewBorrower<T>
type Borrow = ViewBorrower<T>
Auto Trait Implementations§
impl<'a, T, Tracking> Freeze for View<'a, T, Tracking>
impl<'a, T, Tracking> RefUnwindSafe for View<'a, T, Tracking>where
Tracking: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, Tracking> Send for View<'a, T, Tracking>where
T: Sync,
impl<'a, T, Tracking> Sync for View<'a, T, Tracking>where
T: Sync,
impl<'a, T, Tracking> Unpin for View<'a, T, Tracking>
impl<'a, T, Tracking> UnwindSafe for View<'a, T, Tracking>where
Tracking: RefUnwindSafe,
T: RefUnwindSafe,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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