Addressed review feedback

This commit is contained in:
Joshua Barretto 2023-04-11 10:34:06 +01:00
parent 9d2ea10090
commit 81b52298f0
2 changed files with 17 additions and 22 deletions

View File

@ -2093,6 +2093,7 @@ fn handle_kill_npcs(
let players = ecs.read_storage::<comp::Player>(); let players = ecs.read_storage::<comp::Player>();
let alignments = ecs.read_storage::<Alignment>(); let alignments = ecs.read_storage::<Alignment>();
let rtsim_entities = ecs.read_storage::<common::rtsim::RtSimEntity>(); let rtsim_entities = ecs.read_storage::<common::rtsim::RtSimEntity>();
let mut rtsim = ecs.write_resource::<crate::rtsim::RtSim>();
( (
&entities, &entities,
@ -2113,8 +2114,7 @@ fn handle_kill_npcs(
if should_kill { if should_kill {
if let Some(rtsim_entity) = rtsim_entities.get(entity).copied() { if let Some(rtsim_entity) = rtsim_entities.get(entity).copied() {
ecs.write_resource::<crate::rtsim::RtSim>() rtsim.hook_rtsim_actor_death(
.hook_rtsim_actor_death(
&ecs.read_resource::<Arc<world::World>>(), &ecs.read_resource::<Arc<world::World>>(),
ecs.read_resource::<world::IndexOwned>().as_index_ref(), ecs.read_resource::<world::IndexOwned>().as_index_ref(),
Actor::Npc(rtsim_entity.0), Actor::Npc(rtsim_entity.0),
@ -4108,18 +4108,15 @@ fn handle_scale(
) -> CmdResult<()> { ) -> CmdResult<()> {
if let (Some(scale), reset_mass) = parse_cmd_args!(args, f32, bool) { if let (Some(scale), reset_mass) = parse_cmd_args!(args, f32, bool) {
let scale = scale.clamped(0.025, 1000.0); let scale = scale.clamped(0.025, 1000.0);
let _ = server insert_or_replace_component(server, target, comp::Scale(scale), "target")?;
.state
.ecs_mut()
.write_storage::<comp::Scale>()
.insert(target, comp::Scale(scale));
if reset_mass.unwrap_or(true) { if reset_mass.unwrap_or(true) {
if let Some(body) = server.state.ecs().read_storage::<comp::Body>().get(target) { let mass = server.state.ecs()
let _ = server .read_storage::<comp::Body>()
.state .get(target)
.ecs() // Mass is derived from volume, which changes with the third power of scale
.write_storage() .map(|body| body.mass().0 * scale.powi(3));
.insert(target, comp::Mass(body.mass().0 * scale.powi(3))); if let Some(mass) = mass {
insert_or_replace_component(server, target, comp::Mass(mass), "target")?;
} }
} }
server.notify_client( server.notify_client(

View File

@ -538,9 +538,7 @@ impl Scene {
.get(scene_data.viewpoint_entity) .get(scene_data.viewpoint_entity)
.map_or(1.0, |scale| scale.0); .map_or(1.0, |scale| scale.0);
let (is_humanoid, viewpoint_height, viewpoint_eye_height) = scene_data let (is_humanoid, viewpoint_height, viewpoint_eye_height) = ecs
.state
.ecs()
.read_storage::<comp::Body>() .read_storage::<comp::Body>()
.get(scene_data.viewpoint_entity) .get(scene_data.viewpoint_entity)
.map_or((false, 1.0, 0.0), |b| { .map_or((false, 1.0, 0.0), |b| {