summaryrefslogtreecommitdiff
path: root/src/sim/chunk.rs
diff options
context:
space:
mode:
authorKai Stevenson <kai@kaistevenson.com>2026-08-13 01:56:09 -0700
committerKai Stevenson <kai@kaistevenson.com>2026-08-13 01:56:09 -0700
commitfeefeecec6c6050635b2c016452dfa1529575987 (patch)
tree024cc36c2c75e10b6bfd68f29c1494830bec37df /src/sim/chunk.rs
parent7ce9781f86c56f932dabc3bc84b8d21d7be8fecc (diff)
big refactor for board
Diffstat (limited to 'src/sim/chunk.rs')
-rw-r--r--src/sim/chunk.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/sim/chunk.rs b/src/sim/chunk.rs
new file mode 100644
index 0000000..154cf82
--- /dev/null
+++ b/src/sim/chunk.rs
@@ -0,0 +1,25 @@
+use crate::{
+ config::{CELLS_IN_CHUNK, CHUNK_SIZE},
+ sim::cell::Cell,
+};
+
+pub struct Chunk {
+ pub cells: Box<[Cell; CELLS_IN_CHUNK as usize]>,
+}
+
+impl Chunk {
+ #[inline]
+ pub fn get_cell_at_local_position(&self, x: u8, y: u8) -> Cell {
+ self.cells[x as usize + y as usize * CHUNK_SIZE as usize]
+ }
+ #[inline]
+ pub fn set_cell_at_local_position(&mut self, x: u8, y: u8, cell: Cell) {
+ self.cells[x as usize + y as usize * CHUNK_SIZE as usize] = cell;
+ }
+
+ pub fn void() -> Self {
+ Chunk {
+ cells: Box::new([Cell::void(); CELLS_IN_CHUNK]),
+ }
+ }
+}