Struct Engine

Source
pub struct Engine<'a> {
    pub resource_db: ResourceDatabase,
    pub resource_loader: ResourceLoader,
    pub frame_arena: LinearAllocator<'a>,
    pub thread_pool: ThreadPool,
    pub audio_mixer: Mixer,
    pub event_queue: EventQueue,
}
Expand description

The top-level structure of the game engine which owns all the runtime state of the game engine and has methods for running the engine.

Fields§

§resource_db: ResourceDatabase

Database of the non-code parts of the game, e.g. sprites.

§resource_loader: ResourceLoader

Queue of loading tasks which insert loaded chunks into the resource_db occasionally.

§frame_arena: LinearAllocator<'a>

Linear allocator for any frame-internal dynamic allocation needs. Reset at the start of each frame.

§thread_pool: ThreadPool

Thread pool for splitting compute-heavy workloads to multiple threads.

§audio_mixer: Mixer

Mixer for playing back audio.

§event_queue: EventQueue

Queued up events from the platform layer. Discarded after being used by the game to trigger an action via InputDeviceState, or after a timeout if not.

Implementations§

Source§

impl Engine<'_>

Source

pub fn new( platform: &dyn Platform, arena: &'static LinearAllocator<'_>, limits: EngineLimits, ) -> Self

Creates a new instance of the engine.

  • platform: the platform implementation to be used for this instance of the engine.
  • arena: an arena for all the persistent memory the engine requires, e.g. the resource database.
  • limits: defines the limits for the various subsystems of the engine, for dialing in the appropriate tradeoffs between memory usage and game requirements.

Trait Implementations§

Source§

impl EngineCallbacks for Engine<'_>

Source§

fn run_frame( &mut self, platform: &dyn Platform, run_game_frame: &mut dyn FnMut(Instant, &dyn Platform, &mut Self), )

Run one frame of the game loop.
Source§

fn event(&mut self, event: Event, timestamp: Instant)

Handle an event.

Auto Trait Implementations§

§

impl<'a> !Freeze for Engine<'a>

§

impl<'a> !RefUnwindSafe for Engine<'a>

§

impl<'a> !Send for Engine<'a>

§

impl<'a> Sync for Engine<'a>

§

impl<'a> Unpin for Engine<'a>

§

impl<'a> !UnwindSafe for Engine<'a>

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.