From 350c74bc8ef61833be11bbb2bab6747245e3ae0d Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Sun, 23 Aug 2026 00:38:32 -0700 Subject: refactor out content --- src/content/materials/gas.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/content/materials/gas.rs (limited to 'src/content/materials/gas.rs') diff --git a/src/content/materials/gas.rs b/src/content/materials/gas.rs new file mode 100644 index 0000000..229d0e9 --- /dev/null +++ b/src/content/materials/gas.rs @@ -0,0 +1,24 @@ +use rand::RngExt; + +use crate::sim::cell_manager::sim::{PostUpdateAction, UpdateCtx}; + +#[inline] +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.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.swap_or_settle(&[(1 - ctx.seqno_parity as i32 * 2, 0)]) == PostUpdateAction::None + { + return PostUpdateAction::None; + } + 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 +} -- cgit v1.3.1