[−][src]Struct rinecs::Entities
Allows to access and modify the Send
components of the entities in the world.
Methods
impl<'a> Entities<'a>
[src]
impl<'a> Entities<'a>
pub fn iter_for<S: UnorderedData<'a> + 'a>(
self
) -> <S as UnorderedData<'a>>::Iter
[src]
pub fn iter_for<S: UnorderedData<'a> + 'a>(
self
) -> <S as UnorderedData<'a>>::Iter
Iterator over all the components that match the operator
for (pos, vel) in entities.iter_for::<(Write<Position>, Read<Velocity>)>(){ pos.x += vel.x; pos.y += vel.y; }
Will iterate over all the entities that have both position and velocity and update the position by adding the velocity to it. In this example position can be modified cause we use the Write operator but velocity can only be read.
pub fn par_iter_for<S: ParUnorderedData<'a> + 'a>(
self
) -> <S as ParUnorderedData<'a>>::ParIter
[src]
pub fn par_iter_for<S: ParUnorderedData<'a> + 'a>(
self
) -> <S as ParUnorderedData<'a>>::ParIter
Parallel iterator over all the components that match the operator
Similar to iter_for but iterates through all the compoenents in parallel potentically running many iterations of the loop simultaneously.
extern crate rayon; use rayon::prelude::*; entities.par_iter_for::<(Write<Position>, Read<Velocity>)>().for_each( |(pos,vel)| { pos.x += vel.x; pos.y += vel.y; });
Will do the same as the example in iter_for but the update will be done in parallel for many components at the same time
To use parallel iterators one must import the rayon crate in the application
pub fn ordered_iter_for<S: OrderedData<'a> + 'a>(
self
) -> <S as OrderedData<'a>>::Iter
[src]
pub fn ordered_iter_for<S: OrderedData<'a> + 'a>(
self
) -> <S as OrderedData<'a>>::Iter
Iterator over ordered data
Similar to iter_for but to be used with operators that specify an order like ReadAndParent in which parents will be processed first and then their children
pub fn iter_for_entities<S, E>(
self,
entities: E
) -> <S as EntitiesData<'a, E>>::Iter where
S: UnorderedData<'a> + 'a,
E: IntoIterator<Item = Entity>,
[src]
pub fn iter_for_entities<S, E>(
self,
entities: E
) -> <S as EntitiesData<'a, E>>::Iter where
S: UnorderedData<'a> + 'a,
E: IntoIterator<Item = Entity>,
Iterator for the specified operators over a set of entities instead of every entity in the world
It's usage is similar to iter_for but instead of iterating over all the entities it only returns components that match the operators for the entities passed as parameter
let e1 = world.new_entity() .add(Position{x: 0., y: 0.}) .build(); let e2 = world.new_entity() .add(Position{x: 0., y: 0.}) .build(); let e3 = world.new_entity() .add(Position{x: 0., y: 0.}) .build(); let entities = world.entities(); for pos in entities.iter_for_entities::<Read<Position>, _>(vec![e1, e2]){ //... }
The operators parameter in this method needs a second type for the entities iterator type which can jsut be elided with a _ since it'll be guessed from the passed parameter
pub fn entity_components<S>(
self,
entity: &Entity
) -> Option<<S as EntitiesComponents<'a>>::Components> where
S: UnorderedData<'a> + 'a,
[src]
pub fn entity_components<S>(
self,
entity: &Entity
) -> Option<<S as EntitiesComponents<'a>>::Components> where
S: UnorderedData<'a> + 'a,
Similar to iter_for_entities but for one entity instead of several
let e1 = world.new_entity() .add(Position{x: 0., y: 0.}) .add(Velocity{x: 0., y: 0.}) .build(); let entities = world.entities(); let (pos, vel) = entities .entity_components::<(Read<Position>, Read<Velocity>)>(&e1) .unwrap();
pub fn component_for<C: ComponentSend>(
self,
entity: &Entity
) -> Option<Ptr<'a, C>>
[src]
pub fn component_for<C: ComponentSend>(
self,
entity: &Entity
) -> Option<Ptr<'a, C>>
Returns a component for reading for the passed entity
let e1 = world.new_entity() .add(Position{x: 0., y: 0.}) .build(); let entities = world.entities(); let pos = entities.component_for::<Position>(&e1).unwrap();
pub fn component_for_mut<C: ComponentSend>(
self,
entity: &Entity
) -> Option<PtrMut<'a, C>>
[src]
pub fn component_for_mut<C: ComponentSend>(
self,
entity: &Entity
) -> Option<PtrMut<'a, C>>
Returns a component for writing for the passed entity
let e1 = world.new_entity() .add(Position{x: 0., y: 0.}) .build(); let entities = world.entities(); let mut pos = entities.component_for_mut::<Position>(&e1).unwrap();
pub fn tree_node_for<C: Component>(
self,
entity: &Entity
) -> Option<NodePtr<'a, C>> where
<C as Component>::Storage: HierarchicalStorage<'a, C>,
[src]
pub fn tree_node_for<C: Component>(
self,
entity: &Entity
) -> Option<NodePtr<'a, C>> where
<C as Component>::Storage: HierarchicalStorage<'a, C>,
Returns the node for a hierarchical component
pub fn tree_node_for_mut<C: Component>(
self,
entity: &Entity
) -> Option<NodePtrMut<'a, C>> where
<C as Component>::Storage: HierarchicalStorage<'a, C>,
[src]
pub fn tree_node_for_mut<C: Component>(
self,
entity: &Entity
) -> Option<NodePtrMut<'a, C>> where
<C as Component>::Storage: HierarchicalStorage<'a, C>,
Returns the node for a hierarchical component for writing
Trait Implementations
impl<'a> EntitiesT<'a> for Entities<'a>
[src]
impl<'a> EntitiesT<'a> for Entities<'a>
fn iter_for<'e, S: UnorderedData<'e> + 'a>(
&'e self
) -> <S as UnorderedData<'e>>::Iter
[src]
fn iter_for<'e, S: UnorderedData<'e> + 'a>(
&'e self
) -> <S as UnorderedData<'e>>::Iter
fn ordered_iter_for<'e, S: OrderedData<'e> + 'a>(
&'e self
) -> <S as OrderedData<'e>>::Iter
[src]
fn ordered_iter_for<'e, S: OrderedData<'e> + 'a>(
&'e self
) -> <S as OrderedData<'e>>::Iter
fn iter_for_entities<'e, S, E>(
&'e self,
entities: E
) -> <S as EntitiesData<'e, E>>::Iter where
S: UnorderedData<'e> + 'e,
E: IntoIterator<Item = Entity>,
[src]
fn iter_for_entities<'e, S, E>(
&'e self,
entities: E
) -> <S as EntitiesData<'e, E>>::Iter where
S: UnorderedData<'e> + 'e,
E: IntoIterator<Item = Entity>,
fn entity_components<'e, S>(
&'e self,
entity: &Entity
) -> Option<<S as EntitiesComponents<'e>>::Components> where
S: UnorderedData<'e> + 'e,
[src]
fn entity_components<'e, S>(
&'e self,
entity: &Entity
) -> Option<<S as EntitiesComponents<'e>>::Components> where
S: UnorderedData<'e> + 'e,
fn component_for<C: ComponentSend>(&self, entity: &Entity) -> Option<Ptr<C>>
[src]
fn component_for<C: ComponentSend>(&self, entity: &Entity) -> Option<Ptr<C>>
fn component_for_mut<C: ComponentSend>(
&self,
entity: &Entity
) -> Option<PtrMut<C>>
[src]
fn component_for_mut<C: ComponentSend>(
&self,
entity: &Entity
) -> Option<PtrMut<C>>
fn tree_node_for<'e, C: ComponentSend>(
&'e self,
entity: &Entity
) -> Option<NodePtr<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
[src]
fn tree_node_for<'e, C: ComponentSend>(
&'e self,
entity: &Entity
) -> Option<NodePtr<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
fn tree_node_for_mut<'e, C: ComponentSend>(
&'e self,
entity: &Entity
) -> Option<NodePtrMut<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
[src]
fn tree_node_for_mut<'e, C: ComponentSend>(
&'e self,
entity: &Entity
) -> Option<NodePtrMut<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
impl<'a> Sync for Entities<'a>
[src]
impl<'a> Sync for Entities<'a>
impl<'a> Send for Entities<'a>
[src]
impl<'a> Send for Entities<'a>
impl<'a> Clone for Entities<'a>
[src]
impl<'a> Clone for Entities<'a>
fn clone(&self) -> Entities<'a>
[src]
fn clone(&self) -> Entities<'a>
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<'a> Copy for Entities<'a>
[src]
impl<'a> Copy for Entities<'a>
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
impl<T> Any for T where
T: Any,
[src]
impl<T> Any for T where
T: Any,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
impl<T> SetParameter for T
[src]
impl<T> SetParameter for T