Struct shipyard::View

source ·
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>

source

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.

source

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.

source

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.

source

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.

source

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.

source

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>

source

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>

source

pub fn inserted(&self) -> Inserted<&Self>

Wraps this view to be able to iterate inserted components.

source

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>

source

pub fn modified(&self) -> Modified<&Self>

Wraps this view to be able to iterate modified components.

source

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>

source

pub fn deleted(&self) -> impl Iterator<Item = (EntityId, &T)> + '_

Returns the deleted components of a storage tracking deletion.

source

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>

source

pub fn removed(&self) -> impl Iterator<Item = EntityId> + '_

Returns the ids of removed components of a storage tracking removal.

source

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>

source

pub fn inserted(&self) -> Inserted<&Self>

Wraps this view to be able to iterate inserted components.

source

pub fn modified(&self) -> Modified<&Self>

Wraps this view to be able to iterate modified components.

source

pub fn inserted_or_modified(&self) -> InsertedOrModified<&Self>

Wraps this view to be able to iterate inserted and modified components.

source

pub fn deleted(&self) -> impl Iterator<Item = (EntityId, &T)> + '_

Returns the deleted components of a storage tracking deletion.

source

pub fn removed(&self) -> impl Iterator<Item = EntityId> + '_

Returns the ids of removed components of a storage tracking removal.

source

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>>§

source

pub fn as_slice(&self) -> &[T]

Returns a slice of all the components in this storage.

source

pub fn contains(&self, entity: EntityId) -> bool

Returns true if entity owns a component in this storage.

source

pub fn len(&self) -> usize

Returns the length of the storage.

source

pub fn is_empty(&self) -> bool

Returns true if the storage’s length is 0.

source

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.

source

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.

source

pub fn id_at(&self, index: usize) -> Option<EntityId>

Returns the EntityId at a given index.

source

pub fn is_tracking_insertion(&self) -> bool

Returns true if the storage tracks insertion.

source

pub fn is_tracking_modification(&self) -> bool

Returns true if the storage tracks modification.

source

pub fn is_tracking_deletion(&self) -> bool

Returns true if the storage tracks deletion.

source

pub fn is_tracking_removal(&self) -> bool

Returns true if the storage tracks removal.

source

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> AsRef<SparseSet<T>> for View<'a, T>

source§

fn as_ref(&self) -> &SparseSet<T>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<'a, T: Component, U: IntoAbstract> BitOr<U> for &'a View<'a, T>

§

type Output = Or<(&'a View<'a, T>, U)>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: U) -> Self::Output

Performs the | operation. Read more
source§

impl<'a, T: Send + Sync + Component> BorrowInfo for View<'a, T>

source§

fn borrow_info(info: &mut Vec<TypeInfo>)

This information is used during workload creation to determine which systems can run in parallel. Read more
source§

impl<'a, T: Component> Clone for View<'a, T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a: 'b, 'b, T: Component> Contains for &'b View<'a, T>

source§

fn contains(&self, entity: EntityId) -> bool

Returns true if all storages contains entity.
source§

impl<T: Debug + Component> Debug for View<'_, T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, T: Component> Deref for View<'a, T>

§

type Target = SparseSet<T>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'a, 'b, T: Component> Get for &'b View<'a, T>

§

type Out = &'b T

source§

fn get(self, entity: EntityId) -> Result<Self::Out, MissingComponent>

Retrieve components of entity. Read more
source§

impl<T: Component> Index<EntityId> for View<'_, T>

§

type Output = T

The returned type after indexing.
source§

fn index(&self, entity: EntityId) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<'a, T: Component> IntoAbstract for &'a View<'a, T>

§

type AbsView = FullRawWindow<'a, T, <T as Component>::Tracking>

source§

impl<T: Send + Sync + Component> IntoBorrow for View<'_, T>
where T::Tracking: Send + Sync,

§

type Borrow = ViewBorrower<T>

Helper type almost allowing GAT on stable.
source§

impl<T: Component> Not for &View<'_, T>

§

type Output = Not<&View<'_, T>>

The resulting type after applying the ! operator.
source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more