[−][src]Struct rinecs::EntityBuilder
Adds an entity and it's components to the world.
It's methods can be chain called to add several components and finally build the entity.
let e = world.new_entity() .add(Position{x: 0., y: 0.}) .add(Velocity{x: 0., y: 0.}) .build();
Methods
impl<'a> EntityBuilder<'a>
[src]
impl<'a> EntityBuilder<'a>
pub fn build(self) -> Entity
[src]
pub fn build(self) -> Entity
Builds the entity after adding all the components
pub fn add<C: ComponentSend + 'a>(self, component: C) -> Self
[src]
pub fn add<C: ComponentSend + 'a>(self, component: C) -> Self
Adds a Send
Component
to the entity.
There can only be one component of each type per entity
pub fn add_thread_local<C: ComponentThreadLocal>(self, component: C) -> Self
[src]
pub fn add_thread_local<C: ComponentThreadLocal>(self, component: C) -> Self
Adds a non Send
Component
to the entity.
There can only be one component of each type per entity.
Non Send
components, or thread local, can only be accessed
from systems that run from the main thread, namely SystemThreadLocal
CreationSystem and DebugSystem.
pub fn add_child<C: ComponentSend>(self, parent: &Entity, component: C) -> Self where
<C as Component>::Storage: HierarchicalStorage<'a, C>,
[src]
pub fn add_child<C: ComponentSend>(self, parent: &Entity, component: C) -> Self where
<C as Component>::Storage: HierarchicalStorage<'a, C>,
Adds a Send
component as a child of another entity.
This can only be used with types that derive HierarchicalComponent.
It allows to create a hierarchy of entities compoenents that can then
be iterated as a tree allowing to update this compoenents taking into
account that hierarchy. See also the ReadHierarchical
, WriteHierarchical
ReadAndParent
and WriteAndParent
operators.
#[derive(HierarchicalComponent, Debug)] struct Position{ x: f32, y: f32, } let parent = world.new_entity() .add(Position{x: 0., y: 0.}) .build(); let child = world.new_entity() .add_child(&parent, Position{x: 10., y: 10.}) .build();
pub fn add_child_thread_local<C: ComponentThreadLocal>(
self,
parent: &Entity,
component: C
) -> Self where
<C as Component>::Storage: HierarchicalStorage<'a, C>,
[src]
pub fn add_child_thread_local<C: ComponentThreadLocal>(
self,
parent: &Entity,
component: C
) -> Self where
<C as Component>::Storage: HierarchicalStorage<'a, C>,
Adds a non Send
component as a child of another entity.
This can only be used with types that derive HierarchicalComponent.
It allows to create a hierarchy of entities compoenents that can then
be iterated as a tree allowing to update this compoenents taking into
account that hierarchy. See also the ReadHierarchical
, WriteHierarchical
ReadAndParent
and WriteAndParent
operators.
#[derive(HierarchicalComponent, Debug)] struct Position{ x: f32, y: f32, } let parent = world.new_entity() .add_thread_local(Position{x: 0., y: 0.}) .build(); let child = world.new_entity() .add_child_thread_local(&parent, Position{x: 10., y: 10.}) .build();
pub fn add_slice<C, I>(self, component: I) -> Self where
C: OneToNComponentSend,
<C as Component>::Storage: OneToNStorage<'b, C>,
I: IntoIterator<Item = C>,
[src]
pub fn add_slice<C, I>(self, component: I) -> Self where
C: OneToNComponentSend,
<C as Component>::Storage: OneToNStorage<'b, C>,
I: IntoIterator<Item = C>,
Adds a slice of components to an entity
This can only be used with types that derive OneToNComponent
It allows to store more than one element per entity instead of only one. All the elements for all the entities are stored contiguously.
Slice components can be accessed lateer with the normal operators that will return a slice instead of a reference to one compoenent
pub fn add_slice_thread_local<C, I>(self, component: I) -> Self where
C: OneToNComponentThreadLocal,
<C as Component>::Storage: OneToNStorage<'b, C>,
I: IntoIterator<Item = C>,
[src]
pub fn add_slice_thread_local<C, I>(self, component: I) -> Self where
C: OneToNComponentThreadLocal,
<C as Component>::Storage: OneToNStorage<'b, C>,
I: IntoIterator<Item = C>,
Adds a slice of non Send
components to an entity
This can only be used with types that derive OneToNComponent
It allows to store more than one element per entity instead of only one. All the elements for all the entities are stored contiguously.
Slice components can be accessed lateer with the normal operators that will return a slice instead of a reference to one compoenent
pub fn add_hierarchy<C: HierarchicalOneToNComponentSend>(
&mut self
) -> HierarchyBuilder<C>
[src]
pub fn add_hierarchy<C: HierarchicalOneToNComponentSend>(
&mut self
) -> HierarchyBuilder<C>
Adds a one to n hierarchy
pub fn add_hierarchy_thread_local<C: HierarchicalOneToNComponentThreadLocal>(
&mut self
) -> HierarchyBuilder<C>
[src]
pub fn add_hierarchy_thread_local<C: HierarchicalOneToNComponentThreadLocal>(
&mut self
) -> HierarchyBuilder<C>
Adds a non Send
one to n hierarchy
pub fn add_option<C: ComponentSend + 'a>(self, component: Option<C>) -> Self
[src]
pub fn add_option<C: ComponentSend + 'a>(self, component: Option<C>) -> Self
Optionally add a Send
component
Since the entity builder takes ownership of itself when adding new components, in cases where we are adding components to entities that might or might not have them, this allows to avoid an if else structure and instead pass an option.
The component will only be added if the passed parameter is Some
eg: Instead of doing:
let builder = world.new_entity() .add(Position{x: 0., y: 0.}); let builder = if has_velocity { builder.add(Velocity{x: 0., y: 0.}) }else{ builder }; let e = builder.build();
you can do:
let velocity = if has_velocity { Some(Velocity{x: 0., y: 0.}) }else{ None }; let e = world.new_entity() .add(Position{x: 0., y: 0.}) .add_option(velocity) .build();
pub fn add_thread_local_option<C: ComponentThreadLocal>(
self,
component: Option<C>
) -> Self
[src]
pub fn add_thread_local_option<C: ComponentThreadLocal>(
self,
component: Option<C>
) -> Self
Optionally add a non Send
component
See add_option for more information
pub fn add_child_option<C: ComponentSend>(
self,
parent: &Entity,
component: Option<C>
) -> Self where
<C as Component>::Storage: HierarchicalStorage<'a, C>,
[src]
pub fn add_child_option<C: ComponentSend>(
self,
parent: &Entity,
component: Option<C>
) -> Self where
<C as Component>::Storage: HierarchicalStorage<'a, C>,
Optionally add a child component
See add_option for more information
pub fn add_child_thread_local_option<C: ComponentThreadLocal>(
self,
parent: &Entity,
component: Option<C>
) -> Self where
<C as Component>::Storage: HierarchicalStorage<'a, C>,
[src]
pub fn add_child_thread_local_option<C: ComponentThreadLocal>(
self,
parent: &Entity,
component: Option<C>
) -> Self where
<C as Component>::Storage: HierarchicalStorage<'a, C>,
Optionally add a child non Send
component
See add_option for more information
pub fn add_slice_option<C, I>(self, component: Option<I>) -> Self where
C: OneToNComponentSend,
<C as Component>::Storage: OneToNStorage<'b, C>,
I: IntoIterator<Item = C>,
[src]
pub fn add_slice_option<C, I>(self, component: Option<I>) -> Self where
C: OneToNComponentSend,
<C as Component>::Storage: OneToNStorage<'b, C>,
I: IntoIterator<Item = C>,
Optionally add a slice component
See add_option for more information
pub fn add_slice_thread_local_option<C, I>(self, component: Option<I>) -> Self where
C: OneToNComponentThreadLocal,
<C as Component>::Storage: OneToNStorage<'b, C>,
I: IntoIterator<Item = C>,
[src]
pub fn add_slice_thread_local_option<C, I>(self, component: Option<I>) -> Self where
C: OneToNComponentThreadLocal,
<C as Component>::Storage: OneToNStorage<'b, C>,
I: IntoIterator<Item = C>,
Optionally add a slice non Send
component
See add_option for more information
Auto Trait Implementations
impl<'a> !Send for EntityBuilder<'a>
impl<'a> !Send for EntityBuilder<'a>
impl<'a> !Sync for EntityBuilder<'a>
impl<'a> !Sync for EntityBuilder<'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> 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