Struct SharedState

Source
pub struct SharedState<S = ()> {
Show 15 fields pub mouse_info: MouseInfo, pub mouse_pressed: MousePressedInfo, pub mouse_events: MouseEvents, pub target_fps: Option<f64>, pub display_info: DisplayInfo, pub pressed_keys: PressedKeys, pub debounced_down_keys: HashSet<KeyCode>, pub debug_info: DebugInfo, pub debug_messages: SmallVec<[DebugMessage; 16]>, pub extensions: AnyMap, pub components_to_add: Vec<Box<dyn Component<S>>>, pub fake_events_for_next_frame: Vec<Event>, pub remove_components: HashSet<TypeId>, pub whitelisted_components: Option<HashSet<TypeId>>, pub custom: S,
}
Expand description

The shared state that is passed to all components when they are executed.

§Custom state

teng supports custom state that can be shared between components. This can be used to store game state, configuration, etc. For often used state, SharedState allows embedding that state directly into the struct via the generic parameter. For arbitrary data that may not be known statically, SharedState contains an AnyMap that can store arbitrary data.

See examples/ecs/ for an example of how to use embedded custom state.

Fields§

§mouse_info: MouseInfo§mouse_pressed: MousePressedInfo§mouse_events: MouseEvents§target_fps: Option<f64>§display_info: DisplayInfo§pressed_keys: PressedKeys§debounced_down_keys: HashSet<KeyCode>§debug_info: DebugInfo§debug_messages: SmallVec<[DebugMessage; 16]>§extensions: AnyMap§components_to_add: Vec<Box<dyn Component<S>>>§fake_events_for_next_frame: Vec<Event>§remove_components: HashSet<TypeId>§whitelisted_components: Option<HashSet<TypeId>>§custom: S

Auto Trait Implementations§

§

impl<S> Freeze for SharedState<S>
where S: Freeze,

§

impl<S = ()> !RefUnwindSafe for SharedState<S>

§

impl<S = ()> !Send for SharedState<S>

§

impl<S = ()> !Sync for SharedState<S>

§

impl<S> Unpin for SharedState<S>
where S: Unpin,

§

impl<S = ()> !UnwindSafe for SharedState<S>

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.

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.

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.
Source§

impl<T> Any for T
where T: Any,