primitives/prelude/traits/
kernel.rs

1use super::{
2    AssetManager, AudioManager, EngineFactory, InputManager, Logger, Overlay, Pauseable, Preloader, SceneManager,
3    Session, Tools,
4};
5
6/// Handles main updates and provides global locators for all managers
7///
8pub trait Kernel: Pauseable + Logger {
9    /// Defined by the [EngineFactory], can be used for conditional logic relating to build modes and debug.
10    fn is_debug(&self) -> bool;
11
12    /// Identifies a non network location, can be used for conditional logic relating to build modes and debug.
13    fn is_local(&self) -> bool;
14
15    /// Toggleable by the user, intended to be used as a switch to disable intensive, but non essential, content (performance vs wow).
16    fn is_eyecandy(&self) -> bool;
17
18    /// Toggle eyecandy
19    fn set_eyecandy(&self, val: bool);
20
21    /// Toggleable by the user, enables or disables full screen mode.
22    fn is_fullscreen(&self) -> bool;
23
24    /// Toggle fullscreen
25    fn set_fullscreen(&self, val: bool);
26
27    /// The topmost visual element, used for chrome & global controls.
28    fn overlay(&self) -> Box<dyn Overlay>;
29
30    /// Assets manager.
31    fn assets(&self) -> Box<dyn AssetManager>;
32
33    /// Audio manager.
34    fn audio(&self) -> Box<dyn AudioManager>;
35
36    /// Inputs manager.
37    fn inputs(&self) -> Box<dyn InputManager>;
38
39    /// Scene manager.  State machine containing Entities.
40    fn scenes(&self) -> Box<dyn SceneManager>;
41
42    // /// Messenger manager.  Arbitrator for observer pattern across EntityCollections.
43    // fn messenger(&self) -> Box<dyn MessageManager>;
44
45    /// Helper methods.
46    fn tools(&self) -> Box<dyn Tools>;
47
48    /// Build properties and factory methods to create the application.
49    fn factory(&self) -> Box<dyn EngineFactory>;
50
51    /// Read and write globally accessible variables.
52    fn session(&self) -> Box<dyn Session>;
53
54    /// Set session variables
55    fn set_session(&self, val: Box<dyn Session>);
56
57    // /// Used for read only application settings and localisation text.
58    // /// 
59    // /// # Arguments
60    // /// 
61    // /// * `id` - The unique identifier for the config setting (e.g. XML node name).
62    // /// @return	Value of the corresponding config setting.
63    // fn get_config(&self, id: String) -> T;
64
65    /// Request the framerate of the application.
66    /// 
67    /// # Arguments
68    /// 
69    /// * `asActual` - Use actual framerate (potentially laggy), or the desired framerate (from [EngineFactory]). (optional: default: true)
70    ///
71    /// Return: Frames per second.
72    /// 
73    fn get_framerate(&self, as_actual: Option<bool>) -> f32;
74
75    /// Internal method called when preloader completes; launches the starting scene as defined by [EngineFactory::starting_scene_type].
76    /// 
77    /// # Arguments
78    /// 
79    /// * `preloader` - Corresponding [Preloader].
80    /// 
81    fn on_preloader_complete(&self, preloader: Box<dyn Preloader>);
82}