Session

Struct Session 

Source
#[non_exhaustive]
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

Contains a bones World for state, SystemStages for behavior, and a SessionRunner to determine how those are used.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§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

Source

pub fn priority(&mut self, priority: i32) -> &mut Self

Set the priority of this session relative to other sessions in the Game.

Source

pub fn runner(&mut self, runner: Box<dyn SessionRunner>) -> &mut Self

Set the SessionRunner to use for this session.

Source

pub fn activity(&mut self, active: bool) -> &mut Self

Set whether or not this session should have it’s systems run.

Source

pub fn visibility(&mut self, visible: bool) -> &mut Self

Set whether or not this session should be rendered.

Source

pub fn visible(&mut self) -> &mut Self

Set this session to be rendered.

Source

pub fn invisible(&mut self) -> &mut Self

Set this session to not be rendered.

Source

pub fn active(&mut self) -> &mut Self

Set this session to have it’s systems run.

Source

pub fn inactive(&mut self) -> &mut Self

Set this session to not have it’s systems run.

Source

pub fn install_plugin(&mut self, plugin: impl SessionPlugin) -> &mut Self

Install a SessionPlugin.

Methods from Deref<Target = SystemStages>§

pub fn add_system_to_stage<Args, S>( &mut self, label: impl StageLabel, system: S, ) -> &mut SystemStages
where S: IntoSystem<Args, (), (), Sys = StaticSystem<(), ()>>,

Add a System to the stage with the given label.

pub fn insert_stage_before<L, S>( &mut self, label: L, stage: S, ) -> &mut SystemStages
where 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 SystemStages
where L: StageLabel, S: SystemStage + 'static,

Insert a new stage, after another existing stage

pub fn run(&mut self, world: &mut World)

Execute the systems on the given world.

pub fn add_startup_system<Args, S>(&mut self, system: S) -> &mut SystemStages
where S: IntoSystem<Args, (), (), Sys = StaticSystem<(), ()>>,

👎Deprecated: use .add_system_to_stage(CoreStage::Startup, your_system) instead

Add a system to the CoreStage::Startup stage which specially runs only once, before all other core stages. Inserting CoreStageStartupSystemsRan into the world prevents systems in the startup stage from running.

pub fn add_single_success_system<Args, S>( &mut self, system: S, ) -> &mut SystemStages
where S: IntoSystem<Args, (), Option<()>, Sys = StaticSystem<(), Option<()>>>,

👎Deprecated: use `.add_system_to_stage(First, single_success_system(your_system)

Convenience method. Adds a system that will run each frame until it succeeds (returns Some). Uses Option to allow for easy usage of ?. System is added to CoreStage::First.

See also the wrapper function used inside single_success_system.

pub fn init_startup_resource<R>(&mut self) -> &mut SystemStages
where R: HasSchema + FromWorld,

Adds a system to CoreStage::Startup that inserts the default value of a resource into the World if it doesn’t already exist.

pub fn add_startup_resource<R>(&mut self, resource: R) -> &mut SystemStages
where R: HasSchema,

Adds a system to CoreStage::StartupResource that inserts the given resource into the World if it doesn’t already exist. The resource type is required to have a HasSchema clone implementation to re-insert the resource into the world after the first startup.

§Clone Requirement Details

If the type being added implements HasSchema with the derive like so:

ⓘ
#[derive(HasSchema, Default)]
#[schema(no_clone)] // This bypasses HasSchema clone requirements.
struct ResourceBeingInserted;

Then the system being added to the StartupResource system stage will panic when inserting a second time. The startup resource stage only runs once so it is therefore safe to use a type like the example above as long as you don’t plan on removing from the World the StartupSystemStage tag which in this case is CoreStageStartupResourceSystemsRan.

Trait Implementations§

Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Session

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deref for Session

Source§

type Target = SystemStages

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Session

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromWorld for T
where T: Default,

§

fn from_world(_world: &World) -> T

Creates Self using data from the given World.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> RawDefault for T
where T: Default,

§

unsafe fn raw_default(dst: *mut c_void)

Write the default value of the type to the pointer. Read more
§

fn raw_default_cb() -> Unsafe<&'static (dyn Fn(*mut c_void) + Send + Sync)>

Get a callback suitable for [SchemaData].
§

impl<T> RawDrop for T

§

unsafe fn raw_drop(ptr: *mut c_void)

Write the default value of the type to the pointer. Read more
§

fn raw_drop_cb() -> Unsafe<&'static (dyn Fn(*mut c_void) + Send + Sync)>

Get a callback suitable for [SchemaData].
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more