summaryrefslogtreecommitdiff
path: root/src/sim/entity
diff options
context:
space:
mode:
Diffstat (limited to 'src/sim/entity')
-rw-r--r--src/sim/entity/entities/entity_grenade.rs2
-rw-r--r--src/sim/entity/mod.rs24
2 files changed, 17 insertions, 9 deletions
diff --git a/src/sim/entity/entities/entity_grenade.rs b/src/sim/entity/entities/entity_grenade.rs
index abc57d9..952fb14 100644
--- a/src/sim/entity/entities/entity_grenade.rs
+++ b/src/sim/entity/entities/entity_grenade.rs
@@ -39,7 +39,7 @@ pub fn entity_grenade_def(position: Vec2, fuse: f32) -> EntityDef {
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::Wood);
+ raw_cells[cell_idx as usize] = Cell::from_material(MaterialId::Steel);
raw_cells[cell_idx as usize].set_entity(true);
}
}
diff --git a/src/sim/entity/mod.rs b/src/sim/entity/mod.rs
index 555d2c6..0f4ae3c 100644
--- a/src/sim/entity/mod.rs
+++ b/src/sim/entity/mod.rs
@@ -5,7 +5,7 @@ use rapier2d::{
};
use crate::{
- config::CELLS_TO_METRES,
+ config::{CELLS_TO_METRES, MASS_SCALING},
sim::{
cell::{cell::Cell, materials::MaterialId},
lib::marching_squares::Marchable,
@@ -48,16 +48,16 @@ impl Marchable for EntityCells {
pub trait EntityBehaviour {
fn update(
&mut self,
- update_ctx: &mut EntityUpdateCtx,
- ctx: &mut SimCtx,
- delta_time: f32,
+ _update_ctx: &mut EntityUpdateCtx,
+ _ctx: &mut SimCtx,
+ _delta_time: f32,
) -> () {
}
fn physics_update(
&mut self,
- update_ctx: &mut EntityUpdateCtx,
- ctx: &mut SimCtx,
- delta_time: f32,
+ _update_ctx: &mut EntityUpdateCtx,
+ _ctx: &mut SimCtx,
+ _delta_time: f32,
) -> () {
}
}
@@ -79,7 +79,15 @@ impl EntityDef {
.translation(position / CELLS_TO_METRES)
.build();
- let collider = RbManager::convex_hull_collider_from_marchable(&cells, None).build();
+ let mass = cells
+ .cells
+ .iter()
+ .fold(0, |acc, cur| acc + cur.material.def().density) as f32
+ * MASS_SCALING;
+
+ let collider = RbManager::convex_hull_collider_from_marchable(&cells, None)
+ .mass(mass)
+ .build();
EntityDef {
rb: Some(rb),