From 6350e4ffca8ce1e46465284ef3d7559e0f40229b Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Sat, 22 Aug 2026 13:54:00 -0700 Subject: fixes and refactors --- src/sim/cell/materials/fire.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/sim/cell/materials/fire.rs') diff --git a/src/sim/cell/materials/fire.rs b/src/sim/cell/materials/fire.rs index 2a1225e..8667cea 100644 --- a/src/sim/cell/materials/fire.rs +++ b/src/sim/cell/materials/fire.rs @@ -2,7 +2,7 @@ use rand::RngExt; use crate::sim::{ cell::{cell::Cell, materials::MaterialId}, - cell_sim::sim::UpdateCtx, + cell_sim::sim::{PostUpdateAction, UpdateCtx}, }; pub trait FireCellView { @@ -27,21 +27,16 @@ impl FireCellView for Cell { // TODO optimize number of rng calls? // TODO wtf is fire #[inline] -pub fn sim_update(ctx: &mut UpdateCtx) { +pub fn sim_update(ctx: &mut UpdateCtx) -> PostUpdateAction { let ticks_lived = ctx.cell.get_ticks_lived(); // 2 seconds if ticks_lived > 240 { // we have a chance to live longer--roughly ?% chance of living an extra second if ctx.rng.random_range(0.0..1.0) > 0.9 { // kill ourselves, with a chance to turn into ash - if ctx.rng.random_range(0.0..1.0) > 0.8 { - // TODO ash material - // ctx.set_cell(0, 0, Cell::from_material(MaterialId::Sand)); - } else { - ctx.do_rewrite = false; - ctx.set_cell(0, 0, Cell::void()); - } - return; + ctx.set_cell(0, 0, Cell::void()); + // the updater should take no action since we already killed ourselves + return PostUpdateAction::None; } } @@ -77,4 +72,6 @@ pub fn sim_update(ctx: &mut UpdateCtx) { } ctx.cell.set_ticks_lived(ticks_lived + 1); + // apply our new lifespan + PostUpdateAction::Apply } -- cgit v1.3.1