Skip to main content

GameEngineHost

Struct GameEngineHost 

Source
pub struct GameEngineHost { /* private fields */ }
Expand description

Shared host coordinating a GameScene, fixed-timestep FrameClock, and InputState inside euv.

Implementations§

Source§

impl GameEngineHost

Host construction, fixed-step execution, and scene mounting for GameEngineHost.

Source

pub fn new<S>(scene: S, fixed_dt: f32) -> Self
where S: GameScene + 'static,

Creates a new GameEngineHost wrapping scene with a fixed_dt simulation cadence.

§Arguments
  • S - User game scene implementing GameScene.
  • f32 - Fixed physics timestep in seconds (e.g. 1.0 / 60.0).
§Returns
  • Self - Constructed engine host.
Source

pub fn last_gpu_composite(&self) -> Option<GpuCompositeDescriptor>

Returns the most recent GpuCompositeDescriptor submitted by GameScene::render during mount_viewport painting, if any.

§Arguments
  • &Self - Engine host reference.
§Returns
  • Option<GpuCompositeDescriptor> - Bound same-device GPU composite descriptor.
Source

pub fn take_last_gpu_composite(&self) -> Option<GpuCompositeDescriptor>

Takes and clears the most recent GpuCompositeDescriptor submitted during mount_viewport painting.

§Arguments
  • &Self - Engine host reference.
§Returns
  • Option<GpuCompositeDescriptor> - Bound same-device GPU composite descriptor.
Source

pub fn set_paused(&self, paused: bool)

Pauses or resumes simulation stepping for this game engine host (driven by Lifecycle::on_freeze/on_resume).

§Arguments
  • &Self - Engine host reference.
  • bool - true to pause simulation; false to resume.
Source

pub fn is_paused(&self) -> bool

Returns true when this game engine host is currently paused.

§Arguments
  • &Self - Engine host reference.
§Returns
  • bool - Pause state.
Source

pub fn active_viewport_bounds(&self, tree: &SceneTree) -> Vec<Rect>

Returns screen-space bounds of all mounted, currently visible viewports backed by this host.

§Arguments
  • &Self - Engine host reference.
  • &SceneTree - Active scene tree.
§Returns
  • Vec<Rect> - Visible viewport rectangles (empty when paused or not on screen).
Source

pub fn collect_active_viewport_bounds( &self, tree: &SceneTree, out: &mut Vec<Rect>, ) -> bool

Appends screen-space bounds of all currently mounted, visible game viewports into out without heap allocation.

§Arguments
  • &Self - Engine host reference.
  • &SceneTree - Active scene tree.
  • &mut Vec<Rect> - Reusable caller-owned output vector receiving visible viewport rectangles.
§Returns
  • bool - true when at least one active visible viewport rectangle was appended.
Source

pub fn ingest_event(&self, event: &WindowEvent)

Feeds a WindowEvent into the hosted game InputState.

§Arguments
  • &Self - Engine host reference.
  • &WindowEvent - Event received from the OS window.
Source

pub fn step_ns(&self, dt_ns: u64) -> u32

Advances the hosted game scene by dt_ns nanoseconds using integer-nanosecond fixed-timestep accumulation.

§Arguments
  • &Self - Engine host reference.
  • u64 - Elapsed wall nanoseconds since the previous tick.
§Returns
  • u32 - Number of fixed physics steps executed.
Source

pub fn step(&self, dt_secs: f32) -> u32

Advances the hosted game scene by dt_secs using fixed-timestep accumulation.

§Arguments
  • &Self - Engine host reference.
  • f32 - Elapsed wall seconds since the previous tick.
§Returns
  • u32 - Number of fixed physics steps executed.
Source

pub fn mark_viewports_dirty(&self)

Marks all mounted live game viewport nodes paint-dirty and prunes disposed NodeIds automatically.

§Arguments
  • &Self - Engine host reference.
Source

pub fn step_paced(&self, decision: &PacingDecision) -> u32

Executes a PacingDecision from FramePacingController, advancing simulation strictly on VSync decisions using integer nanoseconds and never on deferred non-VSync triggers.

§Arguments
  • &Self - Engine host reference.
  • &PacingDecision - Authoritative pacing decision for the current trigger.
§Returns
  • u32 - Number of fixed simulation steps executed (0 when deferred, capped, or lifecycle-first-frame).
Source

pub fn set_virtual_stick(&self, dx: f32, dy: f32)

Sets the virtual analog joystick vector (dx, dy) in [-1.0, 1.0] for mobile/tablet/gamepad play.

§Arguments
  • &Self - Engine host reference.
  • f32 - Horizontal axis.
  • f32 - Vertical axis.
Source

pub fn press_key(&self, code: KeyCode)

Presses a virtual game key (ideal for holdable mobile touch D-pad buttons).

§Arguments
  • &Self - Engine host reference.
  • KeyCode - Virtual key code to hold down.
Source

pub fn release_key(&self, code: KeyCode)

Releases a previously pressed virtual game key.

§Arguments
  • &Self - Engine host reference.
  • KeyCode - Virtual key code to release.
Source

pub fn mount_viewport(&self, style: Style) -> NodeId

Mounts a live Canvas viewport into the active ambient Context backed by this GameScene.

Supports multi-platform interaction automatically: keyboard/mouse on Desktop & Web plus direct drag-to-steer virtual analog joystick on touch/mobile/tablet screens.

§Arguments
  • &Self - Engine host reference.
  • Style - Layout and visual style of the game viewport.
§Returns
  • NodeId - Mounted game viewport scene node.
Source§

impl GameEngineHost

Source

pub fn get_clock(&self) -> &Rc<RefCell<FrameClock>>

Source

pub fn get_mut_clock(&mut self) -> &mut Rc<RefCell<FrameClock>>

Source

pub fn set_clock(&mut self, val: Rc<RefCell<FrameClock>>) -> &mut Self

Source

pub fn get_input(&self) -> &Rc<RefCell<InputState>>

Source

pub fn get_mut_input(&mut self) -> &mut Rc<RefCell<InputState>>

Source

pub fn set_input(&mut self, val: Rc<RefCell<InputState>>) -> &mut Self

Source

pub fn get_mut_scene(&mut self) -> &mut Rc<RefCell<dyn GameScene + 'static>>

Source

pub fn set_scene( &mut self, val: Rc<RefCell<dyn GameScene + 'static>>, ) -> &mut Self

Source

pub fn get_viewport_nodes(&self) -> &Rc<RefCell<Vec<(SceneHandle, NodeId)>>>

Source

pub fn get_mut_viewport_nodes( &mut self, ) -> &mut Rc<RefCell<Vec<(SceneHandle, NodeId)>>>

Source

pub fn set_viewport_nodes( &mut self, val: Rc<RefCell<Vec<(SceneHandle, NodeId)>>>, ) -> &mut Self

Source

pub fn get_paused(&self) -> &Rc<Cell<bool>>

Trait Implementations§

Source§

impl Clone for GameEngineHost

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GameEngineHost

Source§

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

Formats the struct fields as a debug struct, skipping excluded fields.

§Arguments
  • &mut ::std::fmt::Formatter<'_> - The formatter to write the representation into.
§Returns
  • ::std::fmt::Result - Success or failure of the formatting operation.

Auto Trait Implementations§

§

impl !RefUnwindSafe for GameEngineHost

§

impl !Send for GameEngineHost

§

impl !Sync for GameEngineHost

§

impl !UnwindSafe for GameEngineHost

§

impl Forget for GameEngineHost

§

impl Freeze for GameEngineHost

§

impl Move for GameEngineHost

§

impl Unpin for GameEngineHost

§

impl UnsafeUnpin for GameEngineHost

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.