~starkingdoms/starkingdoms

ref: 5ed17b2ec1a3f95349833a08850fc8d7ef5d8d4f starkingdoms/crates/unified/src/server/drill.rs -rw-r--r-- 579 bytes
5ed17b2eghostly_zsh feat: toggle drill button 3 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::{ecs::{Drill, ToggleDrillEvent}, prelude::*};

pub fn drill_plugin(app: &mut App) {
    app.add_systems(Update, toggle_drill);
}

fn toggle_drill(
    mut toggle_drill_reader: MessageReader<FromClient<ToggleDrillEvent>>,
    mut drills: Query<&mut Drill>,
) {
    for toggle_drill_event in toggle_drill_reader.read() {
        // this getting of the drill also serves to check whether or not
        // the entity is a drill
        let Ok(mut drill) = drills.get_mut(toggle_drill_event.drill_entity) else { return };
        drill.drilling = !drill.drilling;
    }
}