pub trait Module<G>: 'staticwhere
G: GameData,{
// Required method
fn name(&self) -> &'static str;
// Provided methods
fn install(&mut self, _install: &mut Install<'_, G>) { ... }
fn before_update(&mut self, _ctx: &mut Ctx<G>, _dt: f32) { ... }
fn draw_over(&self, _ctx: &Ctx<G>, _buf: &mut GlyphBuffer) { ... }
fn reloaded(&mut self, _ctx: &mut Ctx<G>, _changed: &[String]) { ... }
}Expand description
A piece that joins a running game: the game installs it with
Game::with_module, and calls only the
hooks its install declares, in install order.
Required Methods§
Provided Methods§
Sourcefn install(&mut self, _install: &mut Install<'_, G>)
fn install(&mut self, _install: &mut Install<'_, G>)
Declares what it does: its hooks and its state on the context. By default nothing.
Sourcefn before_update(&mut self, _ctx: &mut Ctx<G>, _dt: f32)
fn before_update(&mut self, _ctx: &mut Ctx<G>, _dt: f32)
Runs each frame dt seconds long, after the input and before the
top screen’s update (Hook::BeforeUpdate).
Sourcefn draw_over(&self, _ctx: &Ctx<G>, _buf: &mut GlyphBuffer)
fn draw_over(&self, _ctx: &Ctx<G>, _buf: &mut GlyphBuffer)
Draws over the screens, after them (Hook::DrawOver).
Sourcefn reloaded(&mut self, _ctx: &mut Ctx<G>, _changed: &[String])
fn reloaded(&mut self, _ctx: &mut Ctx<G>, _changed: &[String])
Runs when files changed on disk, before the frame’s update, with
their paths in the bundle (Hook::Reloaded): in a build with debug
tools, where the platform watches them. The module refreshes the
Hot values it keeps as its own state, and says
how each went (Ctx::note_reload).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".