diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-23 00:38:32 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-23 00:38:32 -0700 |
| commit | 350c74bc8ef61833be11bbb2bab6747245e3ae0d (patch) | |
| tree | b9286d694eaedaef93cf36434a5c80e6aa9e8dce /src/sim/entity/entities | |
| parent | a0ff76837ca7ed6bd90cedcfee3832c1d9ad2287 (diff) | |
refactor out content
Diffstat (limited to 'src/sim/entity/entities')
| -rw-r--r-- | src/sim/entity/entities/entity_cube.rs | 27 | ||||
| -rw-r--r-- | src/sim/entity/entities/entity_grenade.rs | 57 | ||||
| -rw-r--r-- | src/sim/entity/entities/mod.rs | 2 |
3 files changed, 0 insertions, 86 deletions
diff --git a/src/sim/entity/entities/entity_cube.rs b/src/sim/entity/entities/entity_cube.rs deleted file mode 100644 index 2c79aa5..0000000 --- a/src/sim/entity/entities/entity_cube.rs +++ /dev/null @@ -1,27 +0,0 @@ -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) -} diff --git a/src/sim/entity/entities/entity_grenade.rs b/src/sim/entity/entities/entity_grenade.rs deleted file mode 100644 index 952fb14..0000000 --- a/src/sim/entity/entities/entity_grenade.rs +++ /dev/null @@ -1,57 +0,0 @@ -use glam::{IVec2, Vec2}; - -use crate::sim::{ - cell::{cell::Cell, materials::MaterialId}, - entity::{EntityBehaviour, EntityCells, EntityDef, EntityUpdateCtx, SimCtx}, - lib::force::apply_explosion, -}; - -struct GrenadeEntityBehaviour { - pub fuse: f32, -} - -impl EntityBehaviour for GrenadeEntityBehaviour { - fn update( - &mut self, - update_ctx: &mut EntityUpdateCtx, - ctx: &mut SimCtx, - delta_time: f32, - ) -> () { - self.fuse -= delta_time; - if self.fuse <= 0.0 { - apply_explosion( - ctx, - update_ctx.entity_data.transform(ctx).unwrap().0, - 15, - Vec2::new(0.0, -0.6), - 200.0, - ); - update_ctx.deferred_destroy(update_ctx.entity_data.id); - } - } -} - -pub fn entity_grenade_def(position: Vec2, fuse: f32) -> EntityDef { - let w = 3; - let h = 3; - 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(MaterialId::Steel); - 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, - Some(Box::new(GrenadeEntityBehaviour { fuse })), - ) -} diff --git a/src/sim/entity/entities/mod.rs b/src/sim/entity/entities/mod.rs deleted file mode 100644 index e78eb89..0000000 --- a/src/sim/entity/entities/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod entity_cube; -pub mod entity_grenade; |
