pub trait Plugin {
// Required method
fn build(&self, engine: &mut Engine);
}Expand description
A plugin encapsulates a cohesive set of systems and resources.
Implement this trait to bundle engine configuration into a reusable unit.
§Example
use galeon_engine::{Engine, Plugin, QueryMut, Component};
#[derive(Component)]
struct Velocity { x: f32 }
fn physics_system(mut vels: QueryMut<'_, Velocity>) {
for (_, v) in vels.iter_mut() { v.x *= 0.98; }
}
pub struct PhysicsPlugin;
impl Plugin for PhysicsPlugin {
fn build(&self, engine: &mut Engine) {
engine.add_system::<(QueryMut<'_, Velocity>,)>("simulate", "physics", physics_system);
}
}Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".