pub struct Session {
pub world: World,
pub stages: SystemStages,
pub active: bool,
pub visible: bool,
pub priority: i32,
pub runner: Box<dyn SessionRunner>,
}
Expand description
A bones game. This includes all of the game worlds, and systems.
Fields§
§world: World
The ECS world for the core.
stages: SystemStages
The system stages.
active: bool
Whether or not this session should have it’s systems run.
visible: bool
Whether or not this session should be rendered.
priority: i32
The priority of this session relative to other sessions in the Game
.
runner: Box<dyn SessionRunner>
The session runner to use for this session.
Implementations§
source§impl Session
impl Session
sourcepub fn install_plugin(&mut self, plugin: impl SessionPlugin) -> &mut Self
pub fn install_plugin(&mut self, plugin: impl SessionPlugin) -> &mut Self
Install a plugin.
sourcepub fn snapshot(&self) -> World
pub fn snapshot(&self) -> World
Snapshot the world state.
This is the same as core.world.clone()
, but it is more explicit.
sourcepub fn restore(&mut self, world: &mut World)
pub fn restore(&mut self, world: &mut World)
Restore the world state.
Re-sets the world state to that of the provided world
, which may or may not have been
created with snapshot()
.
This is the same as doing an std::mem::swap
on self.world
, but it is more explicit.
sourcepub fn set_session_runner(&mut self, runner: Box<dyn SessionRunner>)
pub fn set_session_runner(&mut self, runner: Box<dyn SessionRunner>)
Set the session runner for this session.
sourcepub fn reset_internals(
&mut self,
reset_components: bool,
reset_entities: bool,
reset_systems: bool,
)
pub fn reset_internals( &mut self, reset_components: bool, reset_entities: bool, reset_systems: bool, )
Provides an interface for resetting various internal parts of the Session. Note this does not fully reset the entire Session.
Methods from Deref<Target = SystemStages>§
pub fn add_startup_system<Args, S>(&mut self, system: S) -> &mut SystemStages
pub fn add_startup_system<Args, S>(&mut self, system: S) -> &mut SystemStages
Add a system that will run only once, before all of the other non-startup systems.
pub fn add_single_success_system<Args, S>(
&mut self,
system: S,
) -> &mut SystemStages
pub fn add_single_success_system<Args, S>( &mut self, system: S, ) -> &mut SystemStages
Add a system that will run each frame until it succeeds (returns Some). Runs before all stages. Uses Option to allow for easy usage of ?
.
pub fn add_system_to_stage<Args, S>(
&mut self,
label: impl StageLabel,
system: S,
) -> &mut SystemStages
pub fn add_system_to_stage<Args, S>( &mut self, label: impl StageLabel, system: S, ) -> &mut SystemStages
Add a System
to the stage with the given label.
pub fn insert_stage_before<L, S>(
&mut self,
label: L,
stage: S,
) -> &mut SystemStageswhere
L: StageLabel,
S: SystemStage + 'static,
pub fn insert_stage_before<L, S>(
&mut self,
label: L,
stage: S,
) -> &mut SystemStageswhere
L: StageLabel,
S: SystemStage + 'static,
Insert a new stage, before another existing stage
pub fn insert_stage_after<L, S>(
&mut self,
label: L,
stage: S,
) -> &mut SystemStageswhere
L: StageLabel,
S: SystemStage + 'static,
pub fn insert_stage_after<L, S>(
&mut self,
label: L,
stage: S,
) -> &mut SystemStageswhere
L: StageLabel,
S: SystemStage + 'static,
Insert a new stage, after another existing stage
pub fn reset_remove_all_systems(&mut self)
pub fn reset_remove_all_systems(&mut self)
Remove all systems from all stages, including startup and single success systems. Resets has_started as well, allowing for startup systems to run once again.
pub fn remove_all_systems(&mut self)
pub fn remove_all_systems(&mut self)
Remove all systems from all stages, including startup and single success systems. Does not reset has_started.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Session
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl !UnwindSafe for Session
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
.