summaryrefslogtreecommitdiff
path: root/src/sim/cell/materials/fire.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sim/cell/materials/fire.rs')
-rw-r--r--src/sim/cell/materials/fire.rs17
1 files changed, 7 insertions, 10 deletions
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
}