~starkingdoms/starkingdoms

ref: 1bcde11a581ededd03b6e60e8e97048f7556ad66 starkingdoms/crates/unified/src/server/heat/cooling.rs -rw-r--r-- 449 bytes
1bcde11a — core netcode: part updates (mystery performance issue, probably related to lots of malloc()) 8 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::prelude::*;
use crate::shared::ecs::{Cooler, Temperature};

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

fn cool_part(
    time: Res<Time>,
    mut parts: Query<(&mut Temperature, &Cooler)>
) {
    for (mut temperature, cooler) in parts.iter_mut() {
        temperature.0 += cooler.heat_cooling_constant * (cooler.cool_temperature - temperature.0)
            * time.delta_secs() as f64;
    }
}