Struct bones_framework::lib::ecs::World
source · pub struct World {
pub resources: Resources,
pub components: ComponentStores,
}
Expand description
The World
is simply a collection of Resources
, and ComponentStores
.
Also stored in the world is the Entities
, but it is stored as a resource.
World
is designed to be trivially Clone
ed to allow for snapshotting the world state. The
is especially useful in the context of rollback networking, which requires the ability to
snapshot and restore state.
Fields§
§resources: Resources
Stores the world resources.
components: ComponentStores
Stores the world components.
Implementations§
source§impl World
impl World
sourcepub fn with_entities(entities: AtomicResource<Entities>) -> World
pub fn with_entities(entities: AtomicResource<Entities>) -> World
Create a new world that uses the provided entities resource.
This allows multiple worlds to avoid allocating the same entity IDs.
sourcepub fn maintain(&self)
pub fn maintain(&self)
Remove the component info for dead entities.
This should be called every game frame to cleanup entities that have been killed.
This will remove the component storage for all killed entities, and allow their slots to be re-used for any new entities.
sourcepub fn run_system<'system, R, In, Out, S>(&self, system: S, input: In) -> Outwhere
In: 'system,
Out: 'system,
S: IntoSystem<R, In, Out>,
<S as IntoSystem<R, In, Out>>::Sys: 'system,
pub fn run_system<'system, R, In, Out, S>(&self, system: S, input: In) -> Outwhere
In: 'system,
Out: 'system,
S: IntoSystem<R, In, Out>,
<S as IntoSystem<R, In, Out>>::Sys: 'system,
Run a system once.
This is good for initializing the world with setup systems.
sourcepub fn entity_components<Q>(
&self,
entity: Entity,
query: Q,
) -> <<Q as QueryItem>::Iter as Iterator>::Itemwhere
Q: QueryItem,
pub fn entity_components<Q>(
&self,
entity: Entity,
query: Q,
) -> <<Q as QueryItem>::Iter as Iterator>::Itemwhere
Q: QueryItem,
Get an entity’s components.
§Panics
Panics if the entity does not have the required components from the query.
sourcepub fn get_entity_components<Q>(
&self,
entity: Entity,
query: Q,
) -> Option<<<Q as QueryItem>::Iter as Iterator>::Item>where
Q: QueryItem,
pub fn get_entity_components<Q>(
&self,
entity: Entity,
query: Q,
) -> Option<<<Q as QueryItem>::Iter as Iterator>::Item>where
Q: QueryItem,
Get an entity’s components.
sourcepub fn init_resource<R>(&mut self) -> RefMut<'_, R>
pub fn init_resource<R>(&mut self) -> RefMut<'_, R>
Initialize a resource of type T
by inserting it’s default value.
sourcepub fn insert_resource<R>(&mut self, resource: R) -> Option<R>where
R: HasSchema,
pub fn insert_resource<R>(&mut self, resource: R) -> Option<R>where
R: HasSchema,
Insert a resource.
sourcepub fn resource_mut<T>(&self) -> RefMut<'_, T>where
T: HasSchema,
pub fn resource_mut<T>(&self) -> RefMut<'_, T>where
T: HasSchema,
sourcepub fn get_resource<T>(&self) -> Option<Ref<'_, T>>where
T: HasSchema,
pub fn get_resource<T>(&self) -> Option<Ref<'_, T>>where
T: HasSchema,
Borrow a resource from the world, if it exists.
sourcepub fn get_resource_mut<T>(&mut self) -> Option<RefMut<'_, T>>where
T: HasSchema,
pub fn get_resource_mut<T>(&mut self) -> Option<RefMut<'_, T>>where
T: HasSchema,
Borrow a resource from the world, if it exists.
sourcepub fn component<T>(&self) -> Ref<'_, ComponentStore<T>>where
T: HasSchema,
pub fn component<T>(&self) -> Ref<'_, ComponentStore<T>>where
T: HasSchema,
Borrow a component store from the world.
§Panics
Panics if the component store does not exist in the world.
sourcepub fn component_mut<T>(&self) -> RefMut<'_, ComponentStore<T>>where
T: HasSchema,
pub fn component_mut<T>(&self) -> RefMut<'_, ComponentStore<T>>where
T: HasSchema,
Mutably borrow a component store from the world.
§Panics
Panics if the component store does not exist in the world.
sourcepub fn reset_internals(&mut self, reset_components: bool, reset_entities: bool)
pub fn reset_internals(&mut self, reset_components: bool, reset_entities: bool)
Provides an interface for resetting entities, and components.
Trait Implementations§
source§impl SystemParam for &World
impl SystemParam for &World
§type Param<'s> = &'s World
type Param<'s> = &'s World
source§fn get_state(_world: &World) -> <&World as SystemParam>::State
fn get_state(_world: &World) -> <&World as SystemParam>::State
source§fn borrow<'s>(
world: &'s World,
_state: &'s mut <&World as SystemParam>::State,
) -> <&World as SystemParam>::Param<'s>
fn borrow<'s>( world: &'s World, _state: &'s mut <&World as SystemParam>::State, ) -> <&World as SystemParam>::Param<'s>
Auto Trait Implementations§
impl Freeze for World
impl !RefUnwindSafe for World
impl Send for World
impl Sync for World
impl Unpin for World
impl !UnwindSafe for World
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
source§fn from_world(_world: &World) -> T
fn from_world(_world: &World) -> T
Self
using data from the given World
.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> RawDefault for Twhere
T: Default,
impl<T> RawDefault for Twhere
T: Default,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.