From f177cc716c5f2aa5b50b14ccbb421de89e3a7854 Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Sun, 16 Aug 2026 17:29:42 -0700 Subject: wip --- src/sim/rb_sim/rb_entity.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/sim/rb_sim/rb_entity.rs (limited to 'src/sim/rb_sim/rb_entity.rs') diff --git a/src/sim/rb_sim/rb_entity.rs b/src/sim/rb_sim/rb_entity.rs new file mode 100644 index 0000000..50243bc --- /dev/null +++ b/src/sim/rb_sim/rb_entity.rs @@ -0,0 +1,24 @@ +use rapier2d::prelude; + +use crate::{ + config::{CELLS_IN_CHUNK, CHUNK_SIZE}, + sim::cell::cell::Cell, +}; + +pub struct RbEntity { + pub id: u32, + // TODO resizable + pub cells: Box<[Cell; CELLS_IN_CHUNK]>, + pub rb_parent: prelude::RigidBodyHandle, +} + +impl RbEntity { + #[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; + } +} -- cgit v1.3.1