Struct rin::ecs::World[][src]

pub struct World { /* fields omitted */ }

Main rinecs object that contains all entities, resources and systems.

A world is the first object one creates when using rinecs.

Through it one can create every other element, like entities and their components.

Also resources, globbally accessible data, is stored in the world and passed later to the systems.

The systems order of exectuion is defined by adding systems to the world and using barriers to define groups of parallel execution.

Once the world is setup one can call run_once or the more specific run_multi_threaded and run_single_threaded to run the systems in the order they were added.

Implementations

impl World[src]

pub fn new() -> World[src]

pub fn register_with_capacity<'r, C>(&mut self, capacity: usize) where
    C: ComponentSend,
    <C as Component>::Storage: for<'s> Storage<'s, C>,
    <<C as Component>::Storage as Storage<'r, C>>::Get: DebugParameter
[src]

Registers a type that implements Send as Component reserving an initial amount of memory.

Send components can be used from System which run from different threads.

Calling this method is not needed but will make initial insertion faster if we can estimate the total amount of components beforehand

pub fn register_thread_local_with_capacity<'r, C>(&mut self, capacity: usize) where
    C: ComponentSend,
    <C as Component>::Storage: for<'s> Storage<'s, C>,
    <<C as Component>::Storage as Storage<'r, C>>::Get: DebugParameter
[src]

Registers a type that can only be used from the main thread asComponent reserving an initial amount of memory.

Send components can be used from System which run from different threads.

Calling this method is not needed but will make initial insertion faster if we can estimate the total amount of components beforehand

pub fn new_entity(&mut self) -> EntityBuilder<'_>[src]

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();

pub fn component_mask<C>(&self) -> U256 where
    C: 'static, 
[src]

pub fn entities(&mut self) -> Entities<'_>[src]

Returns an Entities object that allows to iterate over all the Send components of entities in this world.

pub fn entities_thread_local(&mut self) -> EntitiesThreadLocal<'_>[src]

Returns an EntitiesThreadLocal object that allows to iterate over all the Send and non Send components of entities in this world.

pub fn entities_creation(&mut self) -> EntitiesCreation<'_>[src]

Returns an EntitiesCreation object that allows to iterate over all the Send and non Send components of entities in this world and create new entities and resources.

pub fn debug_entities(&mut self) -> EntitiesDebug<'_>[src]

Returns an EntitiesDebug object that allows to iterate over all the Send and non Send components of entities in this world and debug / serialize them

pub fn add_component_to<'r, C>(&mut self, entity: &Entity, component: C) where
    C: ComponentSend,
    <C as Component>::Storage: for<'s> Storage<'s, C>,
    <<C as Component>::Storage as Storage<'r, C>>::Get: DebugParameter
[src]

Adds a Send Component to an already existing Entity.

pub fn add_component_to_thread_local<'r, C>(
    &mut self,
    entity: &Entity,
    component: C
) where
    C: ComponentThreadLocal,
    <C as Component>::Storage: for<'s> Storage<'s, C>,
    <<C as Component>::Storage as Storage<'r, C>>::Get: DebugParameter
[src]

Adds a non Send Component to an already existing Entity.

pub fn add_tag_to<C>(&mut self, entity: &Entity) where
    C: 'static, 
[src]

pub fn add_child_component_to<'r, C>(
    &mut self,
    parent: &Entity,
    entity: &Entity,
    component: C
) where
    C: ComponentSend,
    <C as Component>::Storage: for<'b> HierarchicalStorage<'b, C>,
    <<C as Component>::Storage as Storage<'r, C>>::Get: DebugParameter
[src]

Adds a Send Component to an already existing Entity.

pub fn add_child_component_to_thread_local<'r, C>(
    &mut self,
    parent: &Entity,
    entity: &Entity,
    component: C
) where
    C: ComponentThreadLocal,
    <C as Component>::Storage: for<'b> HierarchicalStorage<'b, C>,
    <<C as Component>::Storage as Storage<'r, C>>::Get: DebugParameter
[src]

Adds a non Send Component to an already existing Entity.

pub fn add_slice_component_to<'r, C, I>(
    &mut self,
    entity: &Entity,
    component: I
) where
    C: OneToNComponentSend,
    I: IntoIterator<Item = C>,
    <C as Component>::Storage: for<'s> OneToNStorage<'s, C>,
    <<C as Component>::Storage as Storage<'r, C>>::Get: DebugParameter
[src]

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.

pub fn add_slice_component_to_thread_local<'r, C, I>(
    &mut self,
    entity: &Entity,
    component: I
) where
    C: OneToNComponentThreadLocal,
    I: IntoIterator<Item = C>,
    <C as Component>::Storage: for<'s> OneToNStorage<'s, C>,
    <<C as Component>::Storage as Storage<'r, C>>::Get: DebugParameter
[src]

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.

pub fn remove_component_from<'r, C>(&mut self, entity: &Entity) where
    C: Component,
    <C as Component>::Storage: for<'s> Storage<'s, C>,
    <<C as Component>::Storage as Storage<'r, C>>::Get: DebugParameter
[src]

Removes a compoenent of the specified type from an entity.

pub fn remove_entity(&mut self, entity: &Entity)[src]

Removes an Entity and all it’s compoenents.

pub fn add_resource<T>(&mut self, resource: T) where
    T: 'static + Send
[src]

Adds a Send resource to the world.

Resources are globally accesible by any system through the Resources object passed as parameter to them.

pub fn add_resource_as_trait<T, U, F, FMut>(&mut self, resource: (T, F, FMut)) where
    T: 'static + Send,
    F: Fn(&T) -> &U + 'static,
    U: 'static + Send + ?Sized,
    FMut: Fn(&mut T) -> &mut U + 'static, 
[src]

Adds a Send resource to the world accessible as a &dyn Trait.

Resources are globally accesible by any system through the Resources object passed as parameter to them.

pub fn resources(&self) -> Resources<'_>[src]

Returns a Resources object that allows to access all the Send resources in the world.

pub fn entities_and_resources(&mut self) -> (Entities<'_>, Resources<'_>)[src]

pub fn remove_resource<T>(&mut self) -> Option<T> where
    T: 'static, 
[src]

Removes a resource of the specified type.

pub fn add_resource_thread_local<T>(&mut self, resource: T) where
    T: 'static, 
[src]

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.

pub fn add_resource_as_trait_thread_local<T, U, F, FMut>(
    &mut self,
    resource: (T, F, FMut)
) where
    T: 'static,
    F: Fn(&T) -> &U + 'static,
    U: 'static + ?Sized,
    FMut: Fn(&mut T) -> &mut U + 'static, 
[src]

Adds a non Send resource to the world accessible as a &dyn Trait.

Non Send resources are are globally accesible by any system through the Resources object passed as parameter to them.

pub fn resource<T>(&self) -> Option<ReadGuardRef<'_, T>> where
    T: 'static, 
[src]

Returns a resource of the specified type if it exists for reading.

pub fn resource_as<T>(&self) -> Option<ReadGuardRef<'_, T>> where
    T: 'static + ?Sized
[src]

Returns a resource of the specified type if it exists for reading.

pub fn resource_mut<T>(&self) -> Option<WriteGuardRef<'_, T, ()>> where
    T: 'static, 
[src]

Returns a resource of the specified type if it exists for writing.

pub fn resources_thread_local(&self) -> ResourcesThreadLocal<'_>[src]

Returns a ResourcesThreadLocal object that allows to access all the resources in the world.

pub fn entities_and_resources_thread_local(
    &mut self
) -> (EntitiesThreadLocal<'_>, ResourcesThreadLocal<'_>)
[src]

pub fn resources_creation(&mut self) -> ResourcesCreation<'_>[src]

Returns a Resources object that allows to access all the Send and non Send resources in the world and also allows to create new resources and delete them.

pub fn entities_and_resources_creation(
    &mut self
) -> (EntitiesCreation<'_>, ResourcesCreation<'_>)
[src]

pub fn add_system<S>(&mut self, system: S) -> &mut World where
    S: System + 'static, 
[src]

Adds a Send System that will be run in the order it was added.

Send systems will run in parallel with other Send systems and with thread local systems added in between barriers.

pub fn add_system_once<S>(&mut self, system: S) -> &mut World where
    S: SystemOnce + 'static, 
[src]

Adds a Send System that will be run in the order it was added.

Send systems will run in parallel with other Send systems and with thread local systems added in between barriers.

pub fn add_system_with_data<S, D>(&mut self, system: S, data: D) -> &mut World where
    D: Send + 'static,
    S: FnMut(&mut D, Entities<'_>, Resources<'_>) + Send + 'static, 
[src]

Adds a Send System that will be run in the order it was added and data that will be passed to the system as first parameter.

Send systems will run in parallel with other Send systems and with thread local systems added in between barriers.

pub fn add_system_thread_local<S>(&mut self, system: S) -> &mut World where
    S: SystemThreadLocal + 'static, 
[src]

Adds a non Send System that will be run in the order it was added.

SystemThreadLocal will always run in the main thread but can run in parallel with Send systems.

pub fn add_system_once_thread_local<S>(&mut self, system: S) -> &mut World where
    S: SystemOnceThreadLocal + 'static, 
[src]

Adds a non Send System that will be run only once

SystemOnceThreadLocal will run in the main thread but can run in parallel with Send systems.

pub fn add_system_thread_local_with_data<S, D>(
    &mut self,
    system: S,
    data: D
) -> &mut World where
    D: 'static,
    S: FnMut(&mut D, EntitiesThreadLocal<'_>, ResourcesThreadLocal<'_>) + 'static, 
[src]

Adds a non Send System that will be run in the order it was added and data that will be passed to the system as first parameter.

SystemThreadLocal will always run in the main thread but can run in parallel with Send systems.

pub fn add_creation_system<S>(&mut self, system: S) -> &mut World where
    S: CreationSystem + 'static, 
[src]

Adds a CreationSystem that will be run in the order it was added.

CreationSystems run alone with no other system running in parallel.

pub fn add_creation_system_once<S>(&mut self, system: S) -> &mut World where
    S: CreationSystemOnce + 'static, 
[src]

Adds a CreationSystemOnce

CreationSystemsOnce run once and alone with no other system running in parallel.

pub fn add_creation_system_with_data<S, D>(
    &mut self,
    system: S,
    data: D
) -> &mut World where
    D: 'static,
    S: FnMut(&mut D, EntitiesCreation<'_>, ResourcesCreation<'_>) + 'static, 
[src]

Adds a CreationSystem that will be run in the order it was added and data that will be passed to the system as first parameter.

CreationSystems run alone with no other system running in parallel.

pub fn add_system_with<S>(&mut self, system: S) -> Builder<'_, '_, S> where
    S: System + 'static, 
[src]

Adds a Send System that will be run in the order it was added using a Builder that allows to set some system settings like the name it’ll show up with in stats or the conditions under it will run.

The settings set using the builder will override those that system sets itself through attributes or implementation.

Send systems will run in parallel with other Send systems and with thread local systems added in between barriers.

pub fn add_system_once_with<S>(&mut self, system: S) -> BuilderOnce<'_, '_, S> where
    S: SystemOnce + 'static, 
[src]

Adds a Send SystemOnce that will be run only once using a Builder that allows to set some system settings like the name it’ll show up with in stats or the conditions under it will run.

The settings set using the builder will override those that system sets itself through attributes or implementation.

Send systems will run in parallel with other Send systems and with thread local systems added in between barriers.

pub fn add_system_thread_local_with<S>(
    &mut self,
    system: S
) -> BuilderThreadLocal<'_, '_, S> where
    S: SystemThreadLocal + 'static, 
[src]

Adds a thread local System using a Builder that allows to set some system settings like the name it’ll show up with in stats or the conditions under it will run.

The settings set using the builder will override those that system sets itself through attributes or implementation.

SystemThreadLocal will always run in the main thread but can run in parallel with Send systems.

pub fn add_system_once_thread_local_with<S>(
    &mut self,
    system: S
) -> BuilderOnceThreadLocal<'_, '_, S> where
    S: SystemOnceThreadLocal + 'static, 
[src]

Adds a thread local System that will be run only once using a Builder that allows to set some system settings like the name it’ll show up with in stats or the conditions under it will run.

The settings set using the builder will override those that system sets itself through attributes or implementation.

SystemThreadLocal will always run in the main thread but can run in parallel with Send systems.

pub fn add_creation_system_with<S>(
    &mut self,
    system: S
) -> BuilderCreation<'_, '_, S> where
    S: CreationSystem + 'static, 
[src]

Adds a creation System using a Builder that allows to set some system settings like the name it’ll show up with in stats or the conditions under it will run.

The settings set using the builder will override those that system sets itself through attributes or implementation.

CreationSystems run alone with no other system running in parallel.

pub fn add_creation_system_once_with<S>(
    &mut self,
    system: S
) -> BuilderCreationOnce<'_, '_, S> where
    S: CreationSystemOnce + 'static, 
[src]

Adds a creation System that will be run only once using a Builder that allows to set some system settings like the name it’ll show up with in stats or the conditions under it will run.

The settings set using the builder will override those that system sets itself through attributes or implementation.

CreationSystems run alone with no other system running in parallel.

pub fn add_debug_system<S>(&mut self, system: S) -> &mut World where
    S: SystemDebug + 'static, 
[src]

Adds a SystemDebug

SystemDebug run alone with no other system running in parallel.

pub fn add_barrier<B>(&mut self) -> &mut World where
    B: 'static + Barrier
[src]

Delimits all the systems that will run in parallel.

Only systems between barriers (or creation and debug systems) will run in parallel with each other.

Barriers allow to create groups of systems that run in parallel including thread local systems that run one by one in the main thread but in parallel with Send systems.

pub fn render_systems_dependency_graph<P>(&mut self, file: P) where
    P: AsRef<Path>, 
[src]

pub fn run_once(&mut self)[src]

Runs all the systems in the world once.

If the parallel_systems features are enabled the systems will al be run in the main thread sequentially but without monitoring for parallelism conflicts.

If parallel_systems is enabled it’ll run Send and thread local systems in parallel, running thread local systems always from the main thread. Creation and Debug systems act as a barrier and run alone.

pub fn run_multi_threaded(&mut self)[src]

Only available when the default parallel_systems feature is enabled it’ll run Send and thread local systems in parallel, running thread local systems always from the main thread. Creation and Debug systems act as a barrier and run alone.

pub fn run_single_threaded(&mut self)[src]

It runs all he systems in the world in the main thread sequentially

pub fn is_registered<C>(&self) -> bool where
    C: Component
[src]

pub fn creation_storage<C>(&mut self) -> CreationSto<'_, C> where
    C: Component
[src]

pub fn component_for<C>(&self, entity: &Entity) -> Option<Ptr<'_, C>> where
    C: Component,
    <C as Component>::Storage: for<'s> Storage<'s, C>, 
[src]

pub fn component_for_mut<C>(&self, entity: &Entity) -> Option<PtrMut<'_, C>> where
    C: Component,
    <C as Component>::Storage: for<'s> Storage<'s, C>, 
[src]

pub fn storage_for<'r, S>(&'r self) -> Sto<'r, S> where
    S: UnorderedData<'r> + ReadOnlyOp<'r>, 
[src]

pub fn storage_for_mut<'r, S>(&'r mut self) -> Sto<'r, S> where
    S: UnorderedData<'r>, 
[src]

Trait Implementations

impl<'a> CreationContextExt<'a> for World[src]

impl Default for World[src]

impl<'a> EntitiesCreationExt<'a> for World[src]

impl<'a> EntitiesExt<'a> for World[src]

impl EntitiesStorage for World[src]

impl ResourcesCreationExt for World[src]

impl ResourcesExt for World[src]

impl ResourcesThreadLocalExt for World[src]

Auto Trait Implementations

impl !RefUnwindSafe for World

impl !Send for World

impl !Sync for World

impl Unpin for World

impl !UnwindSafe for World

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<'a, C> CreationContext<'a> for C where
    C: CreationContextExt<'a> + EntitiesExt<'a> + ResourcesExt + ResourcesThreadLocalExt
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<V> IntoPnt<V> for V[src]

impl<V> IntoVec<V> for V[src]

impl<'a, C> PathFollowerBuilderExt<C> for C where
    C: CreationContext<'a>, 
[src]

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]