pub struct View<'a, T: Component, Tracking: Tracking = <T as Component>::Tracking> { /* private fields */ }
Expand description
Shared view over a component storage.
Implementations
sourceimpl<'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.
sourceimpl<'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();
sourceimpl<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.
sourceimpl<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.
sourceimpl<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.
sourceimpl<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.
sourceimpl<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 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
sourceimpl<'a, T: Component, U: IntoAbstract> BitOr<U> for &'a View<'a, T>
impl<'a, T: Component, U: IntoAbstract> BitOr<U> for &'a View<'a, T>
sourceimpl<'a, T: Send + Sync + Component> BorrowInfo for View<'a, T>
impl<'a, T: Send + Sync + Component> BorrowInfo for View<'a, T>
sourcefn borrow_info(info: &mut Vec<TypeInfo>)
fn borrow_info(info: &mut Vec<TypeInfo>)
This information is used during workload creation to determine which systems can run in parallel. Read more
sourceimpl<'a, T: Component> IntoAbstract for &'a View<'a, T>
impl<'a, T: Component> IntoAbstract for &'a View<'a, T>
Auto Trait Implementations
impl<'a, T, Tracking> RefUnwindSafe for View<'a, T, Tracking> where
T: RefUnwindSafe,
Tracking: 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
T: RefUnwindSafe,
Tracking: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more