codecraft 0.2.0

A minimalist 3D game engine built on parts of Bevy (ECS, color) with wgpu and winit: OpenPBR materials, clustered lighting, a yakui-drawn UI, audio and gamepad haptics; its binary maps any folder, and the symbols of its Rust files, as a 3D wall of boxes
Documentation
use bevy_ecs::prelude::*;

use crate::ecs::{Application, Plugin};

use super::resources::{CursorPosition, MouseInput, PointerCapture, ScreenSize};
use super::state::Ui;
use crate::time::Time;

/// Registers the UI's input resources, the yakui state, and the input-edge clearing system.
pub struct UiPlugin;

impl Plugin for UiPlugin {
    fn build(&self, app: &mut Application) {
        app.insert_resource(CursorPosition::default());
        app.insert_resource(MouseInput::default());
        app.insert_resource(ScreenSize::default());
        app.init_resource::<PointerCapture>();
        app.init_resource::<super::font::Font>();
        app.init_resource::<super::outliner::Outliner>();
        app.init_resource::<super::profiler::Profiler>();
        app.insert_resource(Time::default());
        // yakui binds its tree to the thread that builds it, so this is a non-send resource.
        app.world.insert_non_send(Ui::new());
        app.add_update_systems(clear_input_edge_system);
    }
}

/// Clears the single-frame input edges; runs last, so anything reading them orders itself before this.
pub fn clear_input_edge_system(mut mouse: ResMut<MouseInput>) {
    mouse.just_pressed = false;
    mouse.just_released = false;
    mouse.scroll = 0.0;
    mouse.motion = glam::Vec2::ZERO;
}