Skip to main content

Module

Trait Module 

Source
pub trait Module<G>: 'static
where 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§

Source

fn name(&self) -> &'static str

Its name: snake_case ASCII, unique in a game.

Provided Methods§

Source

fn install(&mut self, _install: &mut Install<'_, G>)

Declares what it does: its hooks and its state on the context. By default nothing.

Source

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).

Source

fn draw_over(&self, _ctx: &Ctx<G>, _buf: &mut GlyphBuffer)

Draws over the screens, after them (Hook::DrawOver).

Source

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".

Implementors§