pub struct ViewMut<'a, T: Component, Tracking: Tracking = <T as Component>::Tracking> { /* private fields */ }
Expand description
Exclusive view over a component storage.
Implementations
sourceimpl<'a, T: Component<Tracking = Untracked>> ViewMut<'a, T, Untracked>
impl<'a, T: Component<Tracking = Untracked>> ViewMut<'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 ViewMut
for custom SparseSet
storage.
use shipyard::{track, Component, SparseSet, StorageId, ViewMut, 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 =
ViewMut::<ScriptingComponent>::new_for_custom_storage(StorageId::Custom(0), all_storages)
.unwrap();
sourceimpl<'a, T: Component> ViewMut<'a, T>
impl<'a, T: Component> ViewMut<'a, T>
sourcepub fn apply<R, F: FnOnce(&mut T, &T) -> R>(
&mut self,
a: EntityId,
b: EntityId,
f: F
) -> R
pub fn apply<R, F: FnOnce(&mut T, &T) -> R>(
&mut self,
a: EntityId,
b: EntityId,
f: F
) -> R
Applies the given function f
to the entities a
and b
.
The two entities shouldn’t point to the same component.
Panics
- MissingComponent - if one of the entity doesn’t have any component in the storage.
- IdenticalIds - if the two entities point to the same component.
sourcepub fn apply_mut<R, F: FnOnce(&mut T, &mut T) -> R>(
&mut self,
a: EntityId,
b: EntityId,
f: F
) -> R
pub fn apply_mut<R, F: FnOnce(&mut T, &mut T) -> R>(
&mut self,
a: EntityId,
b: EntityId,
f: F
) -> R
Applies the given function f
to the entities a
and b
.
The two entities shouldn’t point to the same component.
Panics
- MissingComponent - if one of the entity doesn’t have any component in the storage.
- IdenticalIds - if the two entities point to the same component.
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<T: Component<Tracking = Insertion>> ViewMut<'_, T, Insertion>
impl<T: Component<Tracking = Insertion>> ViewMut<'_, 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.
sourcepub fn inserted_mut(&mut self) -> Inserted<&mut Self>
pub fn inserted_mut(&mut self) -> Inserted<&mut Self>
Wraps this view to be able to iterate inserted components.
sourcepub fn inserted_or_modified_mut(&mut self) -> InsertedOrModified<&mut Self>
pub fn inserted_or_modified_mut(&mut self) -> InsertedOrModified<&mut Self>
Wraps this view to be able to iterate inserted and modified components.
sourcepub fn clear_all_inserted(self)
pub fn clear_all_inserted(self)
Removes the inserted flag on all components of this storage.
sourceimpl<T: Component<Tracking = Modification>> ViewMut<'_, T, Modification>
impl<T: Component<Tracking = Modification>> ViewMut<'_, 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.
sourcepub fn modified_mut(&mut self) -> Modified<&mut Self>
pub fn modified_mut(&mut self) -> Modified<&mut Self>
Wraps this view to be able to iterate modified components.
sourcepub fn inserted_or_modified_mut(&mut self) -> InsertedOrModified<&mut Self>
pub fn inserted_or_modified_mut(&mut self) -> InsertedOrModified<&mut Self>
Wraps this view to be able to iterate inserted and modified components.
sourcepub fn clear_all_modified(self)
pub fn clear_all_modified(self)
Removes the modified flag on all components of this storage.
sourceimpl<T: Component<Tracking = Deletion>> ViewMut<'_, T, Deletion>
impl<T: Component<Tracking = Deletion>> ViewMut<'_, 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>> ViewMut<'_, T, Removal>
impl<T: Component<Tracking = Removal>> ViewMut<'_, 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>> ViewMut<'_, T, All>
impl<T: Component<Tracking = All>> ViewMut<'_, 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 inserted_mut(&mut self) -> Inserted<&mut Self>
pub fn inserted_mut(&mut self) -> Inserted<&mut Self>
Wraps this view to be able to iterate inserted components.
sourcepub fn modified_mut(&mut self) -> Modified<&mut Self>
pub fn modified_mut(&mut self) -> Modified<&mut Self>
Wraps this view to be able to iterate modified components.
sourcepub fn inserted_or_modified_mut(&mut self) -> InsertedOrModified<&mut Self>
pub fn inserted_or_modified_mut(&mut self) -> InsertedOrModified<&mut Self>
Wraps this view to be able to iterate inserted and modified components.
sourcepub fn clear_all_inserted(self)
pub fn clear_all_inserted(self)
Removes the inserted flag on all components of this storage.
sourcepub fn clear_all_modified(self)
pub fn clear_all_modified(self)
Removes the modified flag on all components of this storage.
sourcepub fn clear_all_inserted_and_modified(self)
pub fn clear_all_inserted_and_modified(self)
Removes the inserted and modified flags on all components of this storage.
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 clear_all_deleted(&mut self)
pub fn clear_all_deleted(&mut self)
Clear all deletion tracking data.
sourcepub fn clear_all_deleted_older_than_timestamp(
&mut self,
timestamp: TrackingTimestamp
)
pub fn clear_all_deleted_older_than_timestamp(
&mut self,
timestamp: TrackingTimestamp
)
Clear all deletion tracking data older than some timestamp.
sourcepub fn clear_all_removed_or_deleted(&mut self)
pub fn clear_all_removed_or_deleted(&mut self)
Clear all deletion and removal tracking data.
sourcepub fn clear_all_removed_or_deleted_older_than_timestamp(
&mut self,
timestamp: TrackingTimestamp
)
pub fn clear_all_removed_or_deleted_older_than_timestamp(
&mut self,
timestamp: TrackingTimestamp
)
Clear all deletion and removal tracking data older than some timestamp.
sourcepub fn clear_all_removed(&mut self)
pub fn clear_all_removed(&mut self)
Clear all removal tracking data.
sourcepub fn clear_all_removed_older_than_timestamp(
&mut self,
timestamp: TrackingTimestamp
)
pub fn clear_all_removed_older_than_timestamp(
&mut self,
timestamp: TrackingTimestamp
)
Clear all removal tracking data older than some timestamp.
sourcepub fn clear_all_removed_and_deleted(&mut self)
pub fn clear_all_removed_and_deleted(&mut self)
Clear all deletion and removal tracking data.
sourcepub fn clear_all_removed_or_deleted_older_than_timestamp(
&mut self,
timestamp: TrackingTimestamp
)
pub fn clear_all_removed_or_deleted_older_than_timestamp(
&mut self,
timestamp: TrackingTimestamp
)
Clear all deletion and removal tracking data older than some timestamp.
sourcepub fn clear_all_deleted(&mut self)
pub fn clear_all_deleted(&mut self)
Clear all deletion tracking data.
sourcepub fn clear_all_deleted_older_than_timestamp(
&mut self,
timestamp: TrackingTimestamp
)
pub fn clear_all_deleted_older_than_timestamp(
&mut self,
timestamp: TrackingTimestamp
)
Clear all deletion tracking data older than some timestamp.
sourcepub fn clear_all_removed(&mut self)
pub fn clear_all_removed(&mut self)
Clear all removal tracking data.
sourcepub fn clear_all_removed_older_than_timestamp(
&mut self,
timestamp: TrackingTimestamp
)
pub fn clear_all_removed_older_than_timestamp(
&mut self,
timestamp: TrackingTimestamp
)
Clear all removal tracking data older than some timestamp.
sourcepub fn clear_all_removed_and_deleted(&mut self)
pub fn clear_all_removed_and_deleted(&mut self)
Clear all deletion and removal tracking data.
sourcepub fn clear_all_removed_or_deleted_older_than_timestamp(
&mut self,
timestamp: TrackingTimestamp
)
pub fn clear_all_removed_or_deleted_older_than_timestamp(
&mut self,
timestamp: TrackingTimestamp
)
Clear all deletion and removal tracking data older than some timestamp.
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.
sourcepub fn sort_unstable(&mut self)
pub fn sort_unstable(&mut self)
Sorts the SparseSet
, but may not preserve the order of equal elements.
Trait Implementations
sourceimpl<T: Component> AddComponent for &mut ViewMut<'_, T>
impl<T: Component> AddComponent for &mut ViewMut<'_, T>
type Component = T
sourcefn add_component_unchecked(
&mut self,
entity: EntityId,
component: Self::Component
)
fn add_component_unchecked(
&mut self,
entity: EntityId,
component: Self::Component
)
Adds component
to entity
, multiple components can be added at the same time using a tuple.
This function does not check entity
is alive. It’s possible to add components to removed entities.
Use Entities::add_component
if you’re unsure. Read more
sourceimpl<T: Component> AddComponent for ViewMut<'_, T>
impl<T: Component> AddComponent for ViewMut<'_, T>
type Component = T
sourcefn add_component_unchecked(
&mut self,
entity: EntityId,
component: Self::Component
)
fn add_component_unchecked(
&mut self,
entity: EntityId,
component: Self::Component
)
Adds component
to entity
, multiple components can be added at the same time using a tuple.
This function does not check entity
is alive. It’s possible to add components to removed entities.
Use Entities::add_component
if you’re unsure. Read more
sourceimpl<T: Component + PartialEq> AddDistinctComponent for &mut ViewMut<'_, T>
impl<T: Component + PartialEq> AddDistinctComponent for &mut ViewMut<'_, T>
type Component = T
sourcefn add_distinct_component_unchecked(
&mut self,
entity: EntityId,
component: Self::Component
) -> bool
fn add_distinct_component_unchecked(
&mut self,
entity: EntityId,
component: Self::Component
) -> bool
Adds component
to entity
, multiple components can be added at the same time using a tuple.
If the entity already has this component, it won’t be replaced. Very useful if you want accurate modification tracking.
This function does not check entity
is alive. It’s possible to add components to removed entities.
Use Entities::add_component
if you’re unsure. Read more
sourceimpl<T: Component + PartialEq> AddDistinctComponent for ViewMut<'_, T>
impl<T: Component + PartialEq> AddDistinctComponent for ViewMut<'_, T>
type Component = T
sourcefn add_distinct_component_unchecked(
&mut self,
entity: EntityId,
component: Self::Component
) -> bool
fn add_distinct_component_unchecked(
&mut self,
entity: EntityId,
component: Self::Component
) -> bool
Adds component
to entity
, multiple components can be added at the same time using a tuple.
If the entity already has this component, it won’t be replaced. Very useful if you want accurate modification tracking.
This function does not check entity
is alive. It’s possible to add components to removed entities.
Use Entities::add_component
if you’re unsure. Read more
sourceimpl<'a, T: Component, U: IntoAbstract> BitOr<U> for &'a ViewMut<'a, T>
impl<'a, T: Component, U: IntoAbstract> BitOr<U> for &'a ViewMut<'a, T>
sourceimpl<'a, T: Component, U: IntoAbstract> BitOr<U> for &'a mut ViewMut<'a, T>
impl<'a, T: Component, U: IntoAbstract> BitOr<U> for &'a mut ViewMut<'a, T>
sourceimpl<'a, T: Send + Sync + Component> BorrowInfo for ViewMut<'a, T>
impl<'a, T: Send + Sync + Component> BorrowInfo for ViewMut<'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<T: Component> BulkReserve for &mut ViewMut<'_, T>
impl<T: Component> BulkReserve for &mut ViewMut<'_, T>
sourcefn bulk_reserve(&mut self, new_entities: &[EntityId])
fn bulk_reserve(&mut self, new_entities: &[EntityId])
Reserves memory for all entities in new_entities
.
sourceimpl<T: Component> BulkReserve for ViewMut<'_, T>
impl<T: Component> BulkReserve for ViewMut<'_, T>
sourcefn bulk_reserve(&mut self, new_entities: &[EntityId])
fn bulk_reserve(&mut self, new_entities: &[EntityId])
Reserves memory for all entities in new_entities
.
sourceimpl<'a, 'b, T: Component<Tracking = Modification>> Get for &'b mut ViewMut<'a, T, Modification>
impl<'a, 'b, T: Component<Tracking = Modification>> Get for &'b mut ViewMut<'a, T, Modification>
sourceimpl<'a, T: Component<Tracking = Modification>> IndexMut<EntityId> for ViewMut<'a, T, Modification>
impl<'a, T: Component<Tracking = Modification>> IndexMut<EntityId> for ViewMut<'a, T, Modification>
sourceimpl<'a: 'b, 'b, T: Component> IntoAbstract for &'b ViewMut<'a, T>
impl<'a: 'b, 'b, T: Component> IntoAbstract for &'b ViewMut<'a, T>
sourceimpl<'a: 'b, 'b, T: Component<Tracking = Insertion>> IntoAbstract for &'b mut ViewMut<'a, T, Insertion>
impl<'a: 'b, 'b, T: Component<Tracking = Insertion>> IntoAbstract for &'b mut ViewMut<'a, T, Insertion>
sourceimpl<'a: 'b, 'b, T: Component<Tracking = Modification>> IntoAbstract for &'b mut ViewMut<'a, T, Modification>
impl<'a: 'b, 'b, T: Component<Tracking = Modification>> IntoAbstract for &'b mut ViewMut<'a, T, Modification>
type AbsView = FullRawWindowMut<'b, T, Modification>
sourceimpl<'a: 'b, 'b, T: Component<Tracking = Removal>> IntoAbstract for &'b mut ViewMut<'a, T, Removal>
impl<'a: 'b, 'b, T: Component<Tracking = Removal>> IntoAbstract for &'b mut ViewMut<'a, T, Removal>
sourceimpl<'a: 'b, 'b, T: Component<Tracking = Untracked>> IntoAbstract for &'b mut ViewMut<'a, T, Untracked>
impl<'a: 'b, 'b, T: Component<Tracking = Untracked>> IntoAbstract for &'b mut ViewMut<'a, T, Untracked>
sourceimpl<T: Send + Sync + Component> IntoBorrow for ViewMut<'_, T> where
T::Tracking: Send + Sync,
impl<T: Send + Sync + Component> IntoBorrow for ViewMut<'_, T> where
T::Tracking: Send + Sync,
type Borrow = ViewMutBorrower<T>
type Borrow = ViewMutBorrower<T>
Helper type almost allowing GAT on stable.
Auto Trait Implementations
impl<'a, T, Tracking> RefUnwindSafe for ViewMut<'a, T, Tracking> where
T: RefUnwindSafe,
Tracking: RefUnwindSafe,
impl<'a, T, Tracking> Send for ViewMut<'a, T, Tracking> where
T: Send,
impl<'a, T, Tracking> Sync for ViewMut<'a, T, Tracking> where
T: Sync,
impl<'a, T, Tracking> Unpin for ViewMut<'a, T, Tracking>
impl<'a, T, Tracking = <T as Component>::Tracking> !UnwindSafe for ViewMut<'a, T, Tracking>
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