diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-22 13:54:00 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-22 13:54:00 -0700 |
| commit | 6350e4ffca8ce1e46465284ef3d7559e0f40229b (patch) | |
| tree | 597bd17cc5c86d7271fea5abba4495fb58b4d7c2 /src/sim/cell/materials/gas.rs | |
| parent | 21f6ee0be48f83db3a0052269cfc47ac73dc64f9 (diff) | |
fixes and refactors
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 } |
