Skip to main content

Plugin

Trait Plugin 

Source
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§

Source

fn build(&self, engine: &mut Engine)

Configure engine with this plugin’s systems and resources.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§