basic rule editing

This commit is contained in:
Crispy 2024-05-01 00:05:20 +02:00
parent aa4cec6dbf
commit 365035a64d
2 changed files with 20 additions and 4 deletions

View file

@ -3,7 +3,7 @@ use rand::prelude::*;
pub const CHUNK_SIZE: usize = 32;
#[derive(Default, Debug, PartialEq, Clone, Copy)]
pub struct Cell(u16);
pub struct Cell(pub u16);
#[derive(Debug)]
pub struct Dish {
@ -172,6 +172,14 @@ impl RulePattern {
}
}
pub fn get_mut(&mut self, x: usize, y: usize) -> Option<&mut Cell> {
if x >= self.width || y >= self.height {
None
} else {
self.contents[x + self.width * y].as_mut()
}
}
pub fn height(&self) -> usize {
self.height
}