diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-22 16:49:56 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-22 16:49:56 -0700 |
| commit | bdad89910dcf3a56790dba60ed1f0db679432323 (patch) | |
| tree | 19e65e2d0e9fa4a6227abc71ef28a6dd622161f0 /src/sim/entity/entities/entity_cube.rs | |
| parent | 1a515237afb7ad09353a65f5fbc6e98a7c29ce8e (diff) | |
refactor entities
Diffstat (limited to 'src/sim/entity/entities/entity_cube.rs')
| -rw-r--r-- | src/sim/entity/entities/entity_cube.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/sim/entity/entities/entity_cube.rs b/src/sim/entity/entities/entity_cube.rs new file mode 100644 index 0000000..2c79aa5 --- /dev/null +++ b/src/sim/entity/entities/entity_cube.rs @@ -0,0 +1,27 @@ +use glam::{IVec2, Vec2}; + +use crate::sim::{ + cell::{cell::Cell, materials::MaterialId}, + entity::{EntityCells, EntityDef}, +}; + +pub fn entity_cube_def(position: Vec2, material: MaterialId) -> EntityDef { + let w = 10; + let h = 10; + let mut raw_cells = vec![Cell::void(); (w * h) as usize]; + + for x in 0..w { + for y in 0..h { + let cell_idx = x + y * w; + raw_cells[cell_idx as usize] = Cell::from_material(material); + raw_cells[cell_idx as usize].set_entity(true); + } + } + + let entity_cells = EntityCells { + cells: raw_cells, + size: IVec2::new(w, h), + }; + + EntityDef::from_cells(position, entity_cells, None) +} |
