Struct bones_framework::lib::SessionBuilder
source · pub struct SessionBuilder {
pub name: Ustr,
pub stages: SystemStagesBuilder,
pub active: bool,
pub visible: bool,
pub priority: i32,
pub runner: Box<dyn SessionRunner>,
/* private fields */
}
Expand description
Builder type used to create Session
. If using this directly (as opposed to Sessions::create_with
),
it is important to rember to finish session and add to Sessions
with SessionBuilder::finish_and_add
.
Fields§
§name: Ustr
Name of session
stages: SystemStagesBuilder
System stage builder
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 SessionBuilder
impl SessionBuilder
sourcepub fn new<N>(name: N) -> SessionBuilder
pub fn new<N>(name: N) -> SessionBuilder
Create a new SessionBuilder
. Be sure to add it to Sessions
when finished, with SessionBuilder::finish_and_add
, or Sessions::create
.
§Panics
Panics if the name.try_into()
cannot convert into Ustr
.
sourcepub fn from_existing_session<N>(name: N, session: Session) -> SessionBuilder
pub fn from_existing_session<N>(name: N, session: Session) -> SessionBuilder
Create a SessionBuilder
to match existing Session
, consuming it. This is useful if a GamePlugin
wishes to modify a session created by another plugin.
The builder is initialized with settings from session, can be further modified, and then added to session to replace existing.
sourcepub fn stages(&mut self) -> &mut SystemStagesBuilder
pub fn stages(&mut self) -> &mut SystemStagesBuilder
Get the SystemStagesBuilder
(though the stage build functions are also on SessionBuilder
for convenience).
sourcepub fn set_active(&mut self, active: bool) -> &mut SessionBuilder
pub fn set_active(&mut self, active: bool) -> &mut SessionBuilder
Whether or not session should run systems.
sourcepub fn set_visible(&mut self, visible: bool) -> &mut SessionBuilder
pub fn set_visible(&mut self, visible: bool) -> &mut SessionBuilder
Whether or not session should be rendered.
sourcepub fn set_priority(&mut self, priority: i32) -> &mut SessionBuilder
pub fn set_priority(&mut self, priority: i32) -> &mut SessionBuilder
The priority of this session relative to other sessions in the Game
.
sourcepub fn insert_resource<T>(&mut self, resource: T) -> &mut SessionBuilderwhere
T: HasSchema,
pub fn insert_resource<T>(&mut self, resource: T) -> &mut SessionBuilderwhere
T: HasSchema,
Insert a resource.
Note: The resource is not actually initialized in World until first step of SystemStages
.
To mutate or inspect a resource inserted by another SessionPlugin
during session build, use SessionBuilder::resource_mut
.
sourcepub fn init_resource<T>(&mut self) -> RefMut<'_, T>
pub fn init_resource<T>(&mut self) -> RefMut<'_, T>
Insert a resource using default value (if not found). Returns a mutable ref for modification.
Note: The resource is not actually initialized in World until first step of SystemStages
.
To mutate or inspect a resource inserted by another SessionPlugin
during session build, use SessionBuilder::resource_mut
.
sourcepub fn resource_mut<T>(&self) -> Option<RefMut<'_, T>>where
T: HasSchema,
pub fn resource_mut<T>(&self) -> Option<RefMut<'_, T>>where
T: HasSchema,
Get mutable reference to a resource if it exists.
sourcepub fn add_startup_system<Args, S>(&mut self, system: S) -> &mut SessionBuilder
pub fn add_startup_system<Args, S>(&mut self, system: S) -> &mut SessionBuilder
Add a system that will run only once, before all of the other non-startup systems.
If wish to reset startup systems during gameplay and run again, can modify SessionStarted
resource in world.
sourcepub fn add_single_success_system<Args, S>(
&mut self,
system: S,
) -> &mut SessionBuilder
pub fn add_single_success_system<Args, S>( &mut self, system: S, ) -> &mut SessionBuilder
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 ?
.
sourcepub fn add_system_to_stage<Args, S>(
&mut self,
label: impl StageLabel,
system: S,
) -> &mut SessionBuilder
pub fn add_system_to_stage<Args, S>( &mut self, label: impl StageLabel, system: S, ) -> &mut SessionBuilder
Add a System
to the stage with the given label.
sourcepub fn insert_stage_before<L, S>(
&mut self,
label: L,
stage: S,
) -> &mut SessionBuilderwhere
L: StageLabel,
S: SystemStage + 'static,
pub fn insert_stage_before<L, S>(
&mut self,
label: L,
stage: S,
) -> &mut SessionBuilderwhere
L: StageLabel,
S: SystemStage + 'static,
Insert a new stage, before another existing stage
sourcepub fn insert_stage_after<L, S>(
&mut self,
label: L,
stage: S,
) -> &mut SessionBuilderwhere
L: StageLabel,
S: SystemStage + 'static,
pub fn insert_stage_after<L, S>(
&mut self,
label: L,
stage: S,
) -> &mut SessionBuilderwhere
L: StageLabel,
S: SystemStage + 'static,
Insert a new stage, after another existing stage
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 install_plugin(
&mut self,
plugin: impl SessionPlugin,
) -> &mut SessionBuilder
pub fn install_plugin( &mut self, plugin: impl SessionPlugin, ) -> &mut SessionBuilder
Install a plugin.
sourcepub fn finish_and_add(self, sessions: &mut Sessions) -> &mut Session
pub fn finish_and_add(self, sessions: &mut Sessions) -> &mut Session
Finalize and add to Sessions
.
Alternatively, you may directly pass a SessionBuilder
to Sessions::create
to add and finalize.
Auto Trait Implementations§
impl Freeze for SessionBuilder
impl !RefUnwindSafe for SessionBuilder
impl Send for SessionBuilder
impl Sync for SessionBuilder
impl Unpin for SessionBuilder
impl !UnwindSafe for SessionBuilder
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
§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
§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<T> IntoArcAny for T
impl<T> IntoArcAny for T
§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.§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.