diff options
Diffstat (limited to 'src/sim/cell/materials/gas.rs')
| -rw-r--r-- | src/sim/cell/materials/gas.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/sim/cell/materials/gas.rs b/src/sim/cell/materials/gas.rs index 2ee7c00..af8f4fd 100644 --- a/src/sim/cell/materials/gas.rs +++ b/src/sim/cell/materials/gas.rs @@ -1,20 +1,24 @@ use rand::RngExt; -use crate::sim::cell_sim::sim::UpdateCtx; +use crate::sim::cell_sim::sim::{PostUpdateAction, UpdateCtx}; #[inline] -pub fn sim_update(ctx: &mut UpdateCtx) { +pub fn sim_update(ctx: &mut UpdateCtx) -> PostUpdateAction { // only allow upward movement some of the time to limit movement speed - if ctx.rng.random_range(0.0..1.0) > 0.8 && ctx.candidates_swap(&[(0, -1)]) { - return; + if ctx.rng.random_range(0.0..1.0) > 0.8 + && ctx.swap_or_settle(&[(0, -1)]) == PostUpdateAction::None + { + return PostUpdateAction::None; } // same for each horizontal direction if ctx.rng.random_range(0.0..1.0) > 0.8 - && ctx.candidates_swap(&[(1 - ctx.seqno_parity as i32 * 2, 0)]) + && ctx.swap_or_settle(&[(1 - ctx.seqno_parity as i32 * 2, 0)]) == PostUpdateAction::None { - return; + return PostUpdateAction::None; } - if ctx.rng.random_range(0.0..1.0) > 0.8 - && ctx.candidates_swap(&[(-1 + ctx.seqno_parity as i32 * 2, 0)]) - {} + if ctx.rng.random_range(0.0..1.0) > 0.8 { + return ctx.swap_or_settle(&[(-1 + ctx.seqno_parity as i32 * 2, 0)]); + } + + PostUpdateAction::Apply } |
