pub struct Sessions { /* private fields */ }
Expand description
Container for multiple game sessions.
Each session shares the same Entities
.
Implementations§
source§impl Sessions
impl Sessions
sourcepub fn create(&mut self, builder: SessionBuilder) -> &mut Session
pub fn create(&mut self, builder: SessionBuilder) -> &mut Session
Create a new session from SessionBuilder
, insert into Sessions
, and borrow it mutably so it can be modified.
If session with same name already exists, it will be replaced.
sourcepub fn create_with<N: TryInto<Ustr>>(
&mut self,
name: N,
build_function: impl FnOnce(&mut SessionBuilder),
) -> &mut Session
pub fn create_with<N: TryInto<Ustr>>( &mut self, name: N, build_function: impl FnOnce(&mut SessionBuilder), ) -> &mut Session
Create a new session from default SessionBuilder
, and modify in closure before it is added to Sessions
. Then borrow it mutably so it can be modified.
If session with same name already exists, it will be replaced.
sourcepub fn modify_and_replace_existing_session<N: TryInto<Ustr>>(
&mut self,
name: N,
build_function: impl FnOnce(&mut SessionBuilder),
) -> Option<&mut Session>
pub fn modify_and_replace_existing_session<N: TryInto<Ustr>>( &mut self, name: N, build_function: impl FnOnce(&mut SessionBuilder), ) -> Option<&mut Session>
Replaces an existing session after converting it into a SessionBuilder
with same systems, stages, etc. It then is given to build_function
to extend or modify it.
WARNING - this is intended to allow a GamePlugin
to extend a session created by another plugin during setup. It destroys and re-creates session, and if used during gameplay,
could break assumptions around determinism and cause desyncs in network play. The sessions World
is not preserved. This is a utility for constructing session, not for runtime mutation.
None
is returned if the session with name was not found.
sourcepub fn get<K: TryInto<Ustr>>(&self, name: K) -> Option<&Session>
pub fn get<K: TryInto<Ustr>>(&self, name: K) -> Option<&Session>
Borrow a session from the sessions list.
sourcepub fn get_mut<K: TryInto<Ustr>>(&mut self, name: K) -> Option<&mut Session>
pub fn get_mut<K: TryInto<Ustr>>(&mut self, name: K) -> Option<&mut Session>
Borrow a session from the sessions list.
sourcepub fn add_command(&mut self, command: Box<SessionCommand>)
pub fn add_command(&mut self, command: Box<SessionCommand>)
Add a SessionCommand
to queue.
Trait Implementations§
source§impl HasSchema for Sessions
impl HasSchema for Sessions
§fn register_schema()
fn register_schema()
§fn cast<T>(this: &Self) -> &Twhere
T: HasSchema,
fn cast<T>(this: &Self) -> &Twhere
T: HasSchema,
§fn try_cast<T>(this: &Self) -> Result<&T, SchemaMismatchError>where
T: HasSchema,
fn try_cast<T>(this: &Self) -> Result<&T, SchemaMismatchError>where
T: HasSchema,
§fn cast_mut<T>(this: &mut Self) -> &mut Twhere
T: HasSchema,
fn cast_mut<T>(this: &mut Self) -> &mut Twhere
T: HasSchema,
§fn try_cast_mut<T>(this: &mut Self) -> Result<&mut T, SchemaMismatchError>where
T: HasSchema,
fn try_cast_mut<T>(this: &mut Self) -> Result<&mut T, SchemaMismatchError>where
T: HasSchema,
§fn as_schema_ref(&self) -> SchemaRef<'_>where
Self: Sized,
fn as_schema_ref(&self) -> SchemaRef<'_>where
Self: Sized,
T
to a SchemaRef
§fn as_schema_mut(&mut self) -> SchemaRefMut<'_>where
Self: Sized,
fn as_schema_mut(&mut self) -> SchemaRefMut<'_>where
Self: Sized,
T
to a SchemaRefMut
Auto Trait Implementations§
impl Freeze for Sessions
impl !RefUnwindSafe for Sessions
impl Send for Sessions
impl Sync for Sessions
impl Unpin for Sessions
impl !UnwindSafe for Sessions
Blanket Implementations§
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
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &World) -> T
fn from_world(_world: &World) -> T
Self
using data from the given World
.