[−][src]Trait rinecs::CreationContext
Trait implemented by World
and CreationProxy
allows to create
functions that can create new entities, components and resources
without relying on an specific object
That way a such function can be called during initialization passing a World as parameter or during run time passing a CreationProxy
Wrappers for World
should implement this trait
Required Methods
fn iter_for<'e, S: UnorderedDataLocal<'e> + 'e>(
&'e self
) -> <S as UnorderedDataLocal<'e>>::Iter
&'e self
) -> <S as UnorderedDataLocal<'e>>::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.
fn ordered_iter_for<'e, S: OrderedDataLocal<'e> + 'e>(
&'e self
) -> <S as OrderedDataLocal<'e>>::Iter
&'e self
) -> <S as OrderedDataLocal<'e>>::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
fn iter_for_entities<'e, S, E>(
&'e self,
entities: E
) -> <S as EntitiesDataLocal<'e, E>>::Iter where
S: UnorderedDataLocal<'e> + 'e,
E: IntoIterator<Item = Entity>,
&'e self,
entities: E
) -> <S as EntitiesDataLocal<'e, E>>::Iter where
S: UnorderedDataLocal<'e> + 'e,
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
fn entity_components<'e, S>(
&'e self,
entity: &Entity
) -> Option<<S as EntitiesComponentsLocal<'e>>::Components> where
S: UnorderedDataLocal<'e> + 'e,
&'e self,
entity: &Entity
) -> Option<<S as EntitiesComponentsLocal<'e>>::Components> where
S: UnorderedDataLocal<'e> + 'e,
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();
fn component_for<C: Component>(&self, entity: &Entity) -> Option<Ptr<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();
fn component_for_mut<C: Component>(&self, entity: &Entity) -> Option<PtrMut<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();
fn tree_node_for<'e, C: Component>(
&'e self,
entity: &Entity
) -> Option<NodePtr<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
&'e self,
entity: &Entity
) -> Option<NodePtr<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
Returns the node for a hierarchical component
fn tree_node_for_mut<'e, C: Component>(
&'e self,
entity: &Entity
) -> Option<NodePtrMut<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
&'e self,
entity: &Entity
) -> Option<NodePtrMut<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
Returns the node for a hierarchical component for writing
fn new_entity(&mut self) -> EntityBuilder
Returns an EntityBuilder that allows to create an entity and it's components.
let e = world.new_entity() .add(Position{x: 0., y: 0.}) .add(Velocity{x: 0., y: 0.}) .build();
fn add_component_to<C: ComponentSend>(&mut self, entity: &Entity, component: C)
Adds a Send
Component
to an already existing Entity
.
fn add_component_to_thread_local<C: ComponentThreadLocal>(
&mut self,
entity: &Entity,
component: C
)
&mut self,
entity: &Entity,
component: C
)
Adds a non Send
Component
to an already existing Entity
.
fn add_slice_component_to<C, I>(&mut self, entity: &Entity, component: I) where
C: OneToNComponentSend,
<C as Component>::Storage: OneToNStorage<'a, C>,
I: IntoIterator<Item = C>,
C: OneToNComponentSend,
<C as Component>::Storage: OneToNStorage<'a, C>,
I: IntoIterator<Item = C>,
Adds a Send
OneToNComponent
to an already existing Entity
.
This allows to add a slice of components to an entity instead of only one component. This components are stored contiguously in memory for all the entities.
fn add_slice_component_to_thread_local<C, I>(
&mut self,
entity: &Entity,
component: I
) where
C: OneToNComponentThreadLocal,
<C as Component>::Storage: OneToNStorage<'a, C>,
I: IntoIterator<Item = C>,
&mut self,
entity: &Entity,
component: I
) where
C: OneToNComponentThreadLocal,
<C as Component>::Storage: OneToNStorage<'a, C>,
I: IntoIterator<Item = C>,
Adds a non Send
OneToNComponent
to an already existing Entity
.
This allows to add a slice of components to an entity instead of only one component. This components are stored contiguously in memory for all the entities.
fn remove_component_from<C: Component>(&mut self, entity: &Entity)
Removes a compoenent of the specified type from an entity.
fn remove_entity(&mut self, entity: &Entity)
Removes an Entity
and all it's compoenents.
fn resource<T: 'static>(&self) -> Option<RwLockReadGuard<T>>
Returns a resource of the specified type if it exists for reading.
fn resource_mut<T: 'static>(&self) -> Option<RwLockWriteGuard<T>>
Returns a resource of the specified type if it exists for writing.
fn add_resource<T: 'static + Send>(&mut self, resource: T)
Adds a Send
resource to the world.
Resources are globally accesible by any system through
the Resources
object passed as parameter to them.
fn add_resource_thread_local<T: 'static>(&mut self, resource: T)
Adds a non Send
resource to the world.
Non Send
resources are globally accesible by any SystemThreadLocal
through the ResourcesThreadLocal
object passed as parameter to them.
fn remove_resource<T: 'static>(&mut self) -> Option<T>
Removes a resource of the specified type.
fn register<'e, T: ComponentSend>(&'e mut self) where
<<T as Component>::Storage as Storage<'e, T>>::Get: DebugParameter,
<<T as Component>::Storage as Storage<'e, T>>::Get: DebugParameter,
fn register_thread_local<'e, T: ComponentThreadLocal>(&'e mut self) where
<<T as Component>::Storage as Storage<'e, T>>::Get: DebugParameter,
<<T as Component>::Storage as Storage<'e, T>>::Get: DebugParameter,
Implementors
impl CreationContext for World
[src]
impl CreationContext for World
fn iter_for<'e, S: UnorderedDataLocal<'e> + 'e>(
&'e self
) -> <S as UnorderedDataLocal<'e>>::Iter
[src]
fn iter_for<'e, S: UnorderedDataLocal<'e> + 'e>(
&'e self
) -> <S as UnorderedDataLocal<'e>>::Iter
fn ordered_iter_for<'e, S: OrderedDataLocal<'e> + 'e>(
&'e self
) -> <S as OrderedDataLocal<'e>>::Iter
[src]
fn ordered_iter_for<'e, S: OrderedDataLocal<'e> + 'e>(
&'e self
) -> <S as OrderedDataLocal<'e>>::Iter
fn iter_for_entities<'e, S, E>(
&'e self,
entities: E
) -> <S as EntitiesDataLocal<'e, E>>::Iter where
S: UnorderedDataLocal<'e> + 'e,
E: IntoIterator<Item = Entity>,
[src]
fn iter_for_entities<'e, S, E>(
&'e self,
entities: E
) -> <S as EntitiesDataLocal<'e, E>>::Iter where
S: UnorderedDataLocal<'e> + 'e,
E: IntoIterator<Item = Entity>,
fn entity_components<'e, S>(
&'e self,
entity: &Entity
) -> Option<<S as EntitiesComponentsLocal<'e>>::Components> where
S: UnorderedDataLocal<'e> + 'e,
[src]
fn entity_components<'e, S>(
&'e self,
entity: &Entity
) -> Option<<S as EntitiesComponentsLocal<'e>>::Components> where
S: UnorderedDataLocal<'e> + 'e,
fn component_for<C: Component>(&self, entity: &Entity) -> Option<Ptr<C>>
[src]
fn component_for<C: Component>(&self, entity: &Entity) -> Option<Ptr<C>>
fn component_for_mut<C: Component>(&self, entity: &Entity) -> Option<PtrMut<C>>
[src]
fn component_for_mut<C: Component>(&self, entity: &Entity) -> Option<PtrMut<C>>
fn tree_node_for<'e, C: Component>(
&'e self,
entity: &Entity
) -> Option<NodePtr<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
[src]
fn tree_node_for<'e, C: Component>(
&'e self,
entity: &Entity
) -> Option<NodePtr<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
fn tree_node_for_mut<'e, C: Component>(
&'e self,
entity: &Entity
) -> Option<NodePtrMut<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
[src]
fn tree_node_for_mut<'e, C: Component>(
&'e self,
entity: &Entity
) -> Option<NodePtrMut<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
fn new_entity(&mut self) -> EntityBuilder
[src]
fn new_entity(&mut self) -> EntityBuilder
fn add_component_to<C: ComponentSend>(&mut self, entity: &Entity, component: C)
[src]
fn add_component_to<C: ComponentSend>(&mut self, entity: &Entity, component: C)
fn add_component_to_thread_local<C: ComponentThreadLocal>(
&mut self,
entity: &Entity,
component: C
)
[src]
fn add_component_to_thread_local<C: ComponentThreadLocal>(
&mut self,
entity: &Entity,
component: C
)
fn add_slice_component_to<C, I>(&mut self, entity: &Entity, component: I) where
C: OneToNComponentSend,
<C as Component>::Storage: OneToNStorage<'a, C>,
I: IntoIterator<Item = C>,
[src]
fn add_slice_component_to<C, I>(&mut self, entity: &Entity, component: I) where
C: OneToNComponentSend,
<C as Component>::Storage: OneToNStorage<'a, C>,
I: IntoIterator<Item = C>,
fn add_slice_component_to_thread_local<C, I>(
&mut self,
entity: &Entity,
component: I
) where
C: OneToNComponentThreadLocal,
<C as Component>::Storage: OneToNStorage<'a, C>,
I: IntoIterator<Item = C>,
[src]
fn add_slice_component_to_thread_local<C, I>(
&mut self,
entity: &Entity,
component: I
) where
C: OneToNComponentThreadLocal,
<C as Component>::Storage: OneToNStorage<'a, C>,
I: IntoIterator<Item = C>,
fn remove_component_from<C: Component>(&mut self, entity: &Entity)
[src]
fn remove_component_from<C: Component>(&mut self, entity: &Entity)
fn remove_entity(&mut self, entity: &Entity)
[src]
fn remove_entity(&mut self, entity: &Entity)
fn resource<T: 'static>(&self) -> Option<RwLockReadGuard<T>>
[src]
fn resource<T: 'static>(&self) -> Option<RwLockReadGuard<T>>
fn resource_mut<T: 'static>(&self) -> Option<RwLockWriteGuard<T>>
[src]
fn resource_mut<T: 'static>(&self) -> Option<RwLockWriteGuard<T>>
fn add_resource<T: 'static + Send>(&mut self, resource: T)
[src]
fn add_resource<T: 'static + Send>(&mut self, resource: T)
fn add_resource_thread_local<T: 'static>(&mut self, resource: T)
[src]
fn add_resource_thread_local<T: 'static>(&mut self, resource: T)
fn remove_resource<T: 'static>(&mut self) -> Option<T>
[src]
fn remove_resource<T: 'static>(&mut self) -> Option<T>
fn register<'e, T: ComponentSend>(&'e mut self) where
<<T as Component>::Storage as Storage<'e, T>>::Get: DebugParameter,
[src]
fn register<'e, T: ComponentSend>(&'e mut self) where
<<T as Component>::Storage as Storage<'e, T>>::Get: DebugParameter,
fn register_thread_local<'e, T: ComponentThreadLocal>(&'e mut self) where
<<T as Component>::Storage as Storage<'e, T>>::Get: DebugParameter,
[src]
fn register_thread_local<'e, T: ComponentThreadLocal>(&'e mut self) where
<<T as Component>::Storage as Storage<'e, T>>::Get: DebugParameter,
impl<'a> CreationContext for CreationProxy<'a>
[src]
impl<'a> CreationContext for CreationProxy<'a>
fn iter_for<'e, S: UnorderedDataLocal<'e> + 'e>(
&'e self
) -> <S as UnorderedDataLocal<'e>>::Iter
[src]
fn iter_for<'e, S: UnorderedDataLocal<'e> + 'e>(
&'e self
) -> <S as UnorderedDataLocal<'e>>::Iter
fn ordered_iter_for<'e, S: OrderedDataLocal<'e> + 'e>(
&'e self
) -> <S as OrderedDataLocal<'e>>::Iter
[src]
fn ordered_iter_for<'e, S: OrderedDataLocal<'e> + 'e>(
&'e self
) -> <S as OrderedDataLocal<'e>>::Iter
fn iter_for_entities<'e, S, E>(
&'e self,
entities: E
) -> <S as EntitiesDataLocal<'e, E>>::Iter where
S: UnorderedDataLocal<'e> + 'e,
E: IntoIterator<Item = Entity>,
[src]
fn iter_for_entities<'e, S, E>(
&'e self,
entities: E
) -> <S as EntitiesDataLocal<'e, E>>::Iter where
S: UnorderedDataLocal<'e> + 'e,
E: IntoIterator<Item = Entity>,
fn entity_components<'e, S>(
&'e self,
entity: &Entity
) -> Option<<S as EntitiesComponentsLocal<'e>>::Components> where
S: UnorderedDataLocal<'e> + 'e,
[src]
fn entity_components<'e, S>(
&'e self,
entity: &Entity
) -> Option<<S as EntitiesComponentsLocal<'e>>::Components> where
S: UnorderedDataLocal<'e> + 'e,
fn component_for<C: Component>(&self, entity: &Entity) -> Option<Ptr<C>>
[src]
fn component_for<C: Component>(&self, entity: &Entity) -> Option<Ptr<C>>
fn component_for_mut<C: Component>(&self, entity: &Entity) -> Option<PtrMut<C>>
[src]
fn component_for_mut<C: Component>(&self, entity: &Entity) -> Option<PtrMut<C>>
fn tree_node_for<'e, C: Component>(
&'e self,
entity: &Entity
) -> Option<NodePtr<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
[src]
fn tree_node_for<'e, C: Component>(
&'e self,
entity: &Entity
) -> Option<NodePtr<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
fn tree_node_for_mut<'e, C: Component>(
&'e self,
entity: &Entity
) -> Option<NodePtrMut<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
[src]
fn tree_node_for_mut<'e, C: Component>(
&'e self,
entity: &Entity
) -> Option<NodePtrMut<'e, C>> where
<C as Component>::Storage: HierarchicalStorage<'e, C>,
fn new_entity(&mut self) -> EntityBuilder
[src]
fn new_entity(&mut self) -> EntityBuilder
fn add_component_to<C: ComponentSend>(&mut self, entity: &Entity, component: C)
[src]
fn add_component_to<C: ComponentSend>(&mut self, entity: &Entity, component: C)
fn add_component_to_thread_local<C: ComponentThreadLocal>(
&mut self,
entity: &Entity,
component: C
)
[src]
fn add_component_to_thread_local<C: ComponentThreadLocal>(
&mut self,
entity: &Entity,
component: C
)
fn add_slice_component_to<C, I>(&mut self, entity: &Entity, component: I) where
C: OneToNComponentSend,
<C as Component>::Storage: OneToNStorage<'b, C>,
I: IntoIterator<Item = C>,
[src]
fn add_slice_component_to<C, I>(&mut self, entity: &Entity, component: I) where
C: OneToNComponentSend,
<C as Component>::Storage: OneToNStorage<'b, C>,
I: IntoIterator<Item = C>,
fn add_slice_component_to_thread_local<C, I>(
&mut self,
entity: &Entity,
component: I
) where
C: OneToNComponentThreadLocal,
<C as Component>::Storage: OneToNStorage<'b, C>,
I: IntoIterator<Item = C>,
[src]
fn add_slice_component_to_thread_local<C, I>(
&mut self,
entity: &Entity,
component: I
) where
C: OneToNComponentThreadLocal,
<C as Component>::Storage: OneToNStorage<'b, C>,
I: IntoIterator<Item = C>,
fn remove_component_from<C: Component>(&mut self, entity: &Entity)
[src]
fn remove_component_from<C: Component>(&mut self, entity: &Entity)
fn remove_entity(&mut self, entity: &Entity)
[src]
fn remove_entity(&mut self, entity: &Entity)
fn resource<T: 'static>(&self) -> Option<RwLockReadGuard<T>>
[src]
fn resource<T: 'static>(&self) -> Option<RwLockReadGuard<T>>
fn resource_mut<T: 'static>(&self) -> Option<RwLockWriteGuard<T>>
[src]
fn resource_mut<T: 'static>(&self) -> Option<RwLockWriteGuard<T>>
fn add_resource<T: 'static + Send>(&mut self, resource: T)
[src]
fn add_resource<T: 'static + Send>(&mut self, resource: T)
fn add_resource_thread_local<T: 'static>(&mut self, resource: T)
[src]
fn add_resource_thread_local<T: 'static>(&mut self, resource: T)
fn remove_resource<T: 'static>(&mut self) -> Option<T>
[src]
fn remove_resource<T: 'static>(&mut self) -> Option<T>
fn register<'e, T: ComponentSend>(&'e mut self) where
<<T as Component>::Storage as Storage<'e, T>>::Get: DebugParameter,
[src]
fn register<'e, T: ComponentSend>(&'e mut self) where
<<T as Component>::Storage as Storage<'e, T>>::Get: DebugParameter,
fn register_thread_local<'e, T: ComponentThreadLocal>(&'e mut self) where
<<T as Component>::Storage as Storage<'e, T>>::Get: DebugParameter,
[src]
fn register_thread_local<'e, T: ComponentThreadLocal>(&'e mut self) where
<<T as Component>::Storage as Storage<'e, T>>::Get: DebugParameter,