Struct keeshond::gameloop::GameControl
source · [−]pub struct GameControl { /* private fields */ }
Expand description
Main context, for controlling the game while it is running. You don’t normally need to create this yourself as Gameloop::new() does this for you, but it can be useful to create this directly if you need to run automated tests.
Implementations
sourceimpl GameControl
impl GameControl
sourcepub fn new_headless(gameinfo: &GameInfo) -> Result<GameControl, InitError>
pub fn new_headless(gameinfo: &GameInfo) -> Result<GameControl, InitError>
Creates a GameControl in a headless configuration, allowing you to run automated tests, validation, or other processes without needing a gameloop, window, renderer, or audio.
sourcepub fn input(&self) -> &Input
pub fn input(&self) -> &Input
Retrieves the Input object for reading player input such as keyboard, mouse, and gamepad.
sourcepub fn input_mut(&mut self) -> &mut Input
pub fn input_mut(&mut self) -> &mut Input
Retrieves the Input object mutably for changing input bindings and deadzones
sourcepub fn renderer(&self) -> &Renderer
pub fn renderer(&self) -> &Renderer
Retrieves the Renderer object to read various parameters for the renderer window
sourcepub fn renderer_mut(&mut self) -> &mut Renderer
pub fn renderer_mut(&mut self) -> &mut Renderer
Retrieves the Renderer object mutably to change various parameters for the renderer window
sourcepub fn audio(&self) -> &Box<dyn Audio>
pub fn audio(&self) -> &Box<dyn Audio>
Retrieves the Audio object for reading information about audio playback
sourcepub fn audio_mut(&mut self) -> &mut Box<dyn Audio>
pub fn audio_mut(&mut self) -> &mut Box<dyn Audio>
Retrieves the Audio object mutably to control audio playback
sourcepub fn source_manager(&self) -> Rc<RefCell<SourceManager>>
pub fn source_manager(&self) -> Rc<RefCell<SourceManager>>
Retrieves the SourceManager for registering and querying data Sources
sourcepub fn res(&self) -> &DataMultistore
pub fn res(&self) -> &DataMultistore
Retrieves the DataMultistore for accessing data resources
sourcepub fn singleton_mut<T: 'static + GameSingleton + Default>(&mut self) -> &mut T
pub fn singleton_mut<T: 'static + GameSingleton + Default>(&mut self) -> &mut T
Retrieves the GameSingleton of the current type mutably. If it has not been created yet, it will be Default-constructed.
sourcepub fn target_framerate(&self) -> f64
pub fn target_framerate(&self) -> f64
Returns the framerate that game logic is synchronized to, in frames per second
sourcepub fn set_target_framerate(&mut self, new_framerate: f64)
pub fn set_target_framerate(&mut self, new_framerate: f64)
Sets the framerate that game logic is synchronized to, in frames per second
sourcepub fn frame_interpolation(&self) -> FrameInterpolationMode
pub fn frame_interpolation(&self) -> FrameInterpolationMode
Returns the mode to use for interpolating frames in the renderer.
sourcepub fn set_frame_interpolation(&mut self, mode: FrameInterpolationMode)
pub fn set_frame_interpolation(&mut self, mode: FrameInterpolationMode)
Sets the mode to use for interpolating frames in the renderer.
sourcepub fn frame_interpolation_cap(&self) -> FrameInterpolationCap
pub fn frame_interpolation_cap(&self) -> FrameInterpolationCap
Returns the framerate cap mode for when frame interpolation is enabled.
sourcepub fn set_frame_interpolation_cap(&mut self, cap: FrameInterpolationCap)
pub fn set_frame_interpolation_cap(&mut self, cap: FrameInterpolationCap)
Sets the framerate cap mode for when frame interpolation is enabled.
sourcepub fn frame_interpolation_pacing(&self) -> FrameInterpolationPacing
pub fn frame_interpolation_pacing(&self) -> FrameInterpolationPacing
Returns the framerate pacing mode for when frame interpolation is enabled.
sourcepub fn set_frame_interpolation_pacing(
&mut self,
pacing: FrameInterpolationPacing
)
pub fn set_frame_interpolation_pacing(
&mut self,
pacing: FrameInterpolationPacing
)
Sets the framerate pacing mode for when frame interpolation is enabled.
sourcepub fn frame_interpolation_active(&self) -> bool
pub fn frame_interpolation_active(&self) -> bool
Returns true if frame interpolation is currently active. For the automatic mode, returns true if the refresh rate of the window’s current monitor does not match with the target logic framerate.
sourcepub fn console_history(&self) -> MutexGuard<'_, ConsoleHistory>
pub fn console_history(&self) -> MutexGuard<'_, ConsoleHistory>
Retrieves the ConsoleHistory object, which is useful for implementing an in-game console window
sourcepub fn stats(&self) -> &GameStats
pub fn stats(&self) -> &GameStats
Retrieves the GameStats object, which contains timing statistics
sourcepub fn goto_new_scene<T: SceneType + 'static>(&mut self)
pub fn goto_new_scene<T: SceneType + 'static>(&mut self)
Switches the game to a new scene of the given SceneType after the current frame is done. Doing this will perform automatic unloading of unused data resources (ones without an active crate::datapack::DataHandle or crate::datapack::PackageUseToken) if it is configured to do so via the GameInfo passed in during creation of the Gameloop or GameControl.
Auto Trait Implementations
impl !RefUnwindSafe for GameControl
impl !Send for GameControl
impl !Sync for GameControl
impl Unpin for GameControl
impl !UnwindSafe for GameControl
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
sourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more