diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-16 17:29:42 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-16 17:29:42 -0700 |
| commit | f177cc716c5f2aa5b50b14ccbb421de89e3a7854 (patch) | |
| tree | db06f9f44251d6d90e5e9709d47e6cc4397b9443 /src/sim/cell_sim/chunk.rs | |
| parent | 40e9d818195824749293dff3afcfdd5c1432adbe (diff) | |
wip
Diffstat (limited to 'src/sim/cell_sim/chunk.rs')
| -rw-r--r-- | src/sim/cell_sim/chunk.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/sim/cell_sim/chunk.rs b/src/sim/cell_sim/chunk.rs new file mode 100644 index 0000000..116a38a --- /dev/null +++ b/src/sim/cell_sim/chunk.rs @@ -0,0 +1,29 @@ +use crate::{ + config::{CELLS_IN_CHUNK, CHUNK_SIZE}, + sim::cell::cell::Cell, +}; + +pub struct Chunk { + pub cells: Box<[Cell; CELLS_IN_CHUNK]>, + pub sleeping: bool, + pub needs_texture_update: bool, +} + +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]), + sleeping: true, + needs_texture_update: true, + } + } +} |
