summaryrefslogtreecommitdiff
path: root/src/content/materials
diff options
context:
space:
mode:
authorKai Stevenson <kai@kaistevenson.com>2026-08-23 12:37:54 -0700
committerKai Stevenson <kai@kaistevenson.com>2026-08-23 12:37:54 -0700
commit35f1bc48629456ee66cfb4643ca69b0811f02167 (patch)
tree80e271c7ad5fd074f27b33dcdcdafafc391d2d13 /src/content/materials
parente6742f59102f2beb305b813d7f0ee1d544bbc3e0 (diff)
Revert "separate data from cells"
This reverts commit e6742f59102f2beb305b813d7f0ee1d544bbc3e0.
Diffstat (limited to 'src/content/materials')
-rw-r--r--src/content/materials/fire.rs26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/content/materials/fire.rs b/src/content/materials/fire.rs
index 5e5b29a..2e5ef2f 100644
--- a/src/content/materials/fire.rs
+++ b/src/content/materials/fire.rs
@@ -8,25 +8,19 @@ use crate::{
},
};
-pub trait FireCtxView {
- fn get_ticks_lived(&self, x: i32, y: i32) -> u16;
- fn set_ticks_lived(&mut self, x: i32, y: i32, ticks: u16) -> ();
-}
-
-impl FireCtxView for UpdateCtx<'_, '_, '_> {
- fn get_ticks_lived(&self, x: i32, y: i32) -> u16 {
- self.get_cell_data(x, y).unwrap_or(0)
- }
- fn set_ticks_lived(&mut self, x: i32, y: i32, ticks: u16) {
- self.set_cell_data(x, y, ticks);
- }
-}
-
pub trait FireCellView {
+ fn get_ticks_lived(self) -> u16;
+ fn set_ticks_lived(&mut self, ticks: u16) -> ();
fn is_flammable(self) -> bool;
}
impl FireCellView for Cell {
+ fn get_ticks_lived(self) -> u16 {
+ self.data
+ }
+ fn set_ticks_lived(&mut self, ticks: u16) {
+ self.data = ticks;
+ }
// this could be a property of the material def, I think it's better here for now
fn is_flammable(self) -> bool {
[MaterialId::Wood].contains(&self.material)
@@ -37,7 +31,7 @@ impl FireCellView for Cell {
// TODO wtf is fire
#[inline]
pub fn sim_update(ctx: &mut UpdateCtx) -> PostUpdateAction {
- let ticks_lived = ctx.get_ticks_lived(0, 0);
+ 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
@@ -80,7 +74,7 @@ pub fn sim_update(ctx: &mut UpdateCtx) -> PostUpdateAction {
}
}
- ctx.set_ticks_lived(0, 0, ticks_lived + 1);
+ ctx.cell.set_ticks_lived(ticks_lived + 1);
// apply our new lifespan
PostUpdateAction::Apply
}