From 2bceb2d3a64c81d1cffb6b266f50dbae95566ed6 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 17 Mar 2021 17:24:39 -0400 Subject: [PATCH] Shockwaves and beams no longer use last position in calculating if they hit. --- common/sys/src/beam.rs | 9 +++------ common/sys/src/shockwave.rs | 10 +++------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/common/sys/src/beam.rs b/common/sys/src/beam.rs index 82766f28ad..98350e7696 100644 --- a/common/sys/src/beam.rs +++ b/common/sys/src/beam.rs @@ -1,8 +1,8 @@ use common::{ combat::{AttackerInfo, TargetInfo}, comp::{ - Beam, BeamSegment, Body, Combo, Energy, Group, Health, HealthSource, Inventory, Last, Ori, - Pos, Scale, Stats, + Beam, BeamSegment, Body, Combo, Energy, Group, Health, HealthSource, Inventory, Ori, Pos, + Scale, Stats, }, event::{EventBus, ServerEvent}, resources::{DeltaTime, Time}, @@ -26,7 +26,6 @@ pub struct ReadData<'a> { uid_allocator: Read<'a, UidAllocator>, uids: ReadStorage<'a, Uid>, positions: ReadStorage<'a, Pos>, - last_positions: ReadStorage<'a, Last>, orientations: ReadStorage<'a, Ori>, scales: ReadStorage<'a, Scale>, bodies: ReadStorage<'a, Body>, @@ -128,7 +127,6 @@ impl<'a> System<'a> for Sys { // Scales let scale_b = read_data.scales.get(target).map_or(1.0, |s| s.0); - let last_pos_b_maybe = read_data.last_positions.get(target); let rad_b = body_b.radius() * scale_b; let height_b = body_b.height() * scale_b; @@ -136,8 +134,7 @@ impl<'a> System<'a> for Sys { let hit = entity != target && !health_b.is_dead // Collision shapes - && (sphere_wedge_cylinder_collision(pos.0, frame_start_dist, frame_end_dist, *ori.look_dir(), beam_segment.angle, pos_b.0, rad_b, height_b) - || last_pos_b_maybe.map_or(false, |pos_maybe| {sphere_wedge_cylinder_collision(pos.0, frame_start_dist, frame_end_dist, *ori.look_dir(), beam_segment.angle, (pos_maybe.0).0, rad_b, height_b)})); + && sphere_wedge_cylinder_collision(pos.0, frame_start_dist, frame_end_dist, *ori.look_dir(), beam_segment.angle, pos_b.0, rad_b, height_b); if hit { // See if entities are in the same group diff --git a/common/sys/src/shockwave.rs b/common/sys/src/shockwave.rs index e89eee5efe..8d421c269e 100644 --- a/common/sys/src/shockwave.rs +++ b/common/sys/src/shockwave.rs @@ -1,8 +1,8 @@ use common::{ combat::{AttackerInfo, TargetInfo}, comp::{ - Body, Combo, Energy, Group, Health, HealthSource, Inventory, Last, Ori, PhysicsState, Pos, - Scale, Shockwave, ShockwaveHitEntities, Stats, + Body, Combo, Energy, Group, Health, HealthSource, Inventory, Ori, PhysicsState, Pos, Scale, + Shockwave, ShockwaveHitEntities, Stats, }, event::{EventBus, ServerEvent}, resources::{DeltaTime, Time}, @@ -26,7 +26,6 @@ pub struct ReadData<'a> { uid_allocator: Read<'a, UidAllocator>, uids: ReadStorage<'a, Uid>, positions: ReadStorage<'a, Pos>, - last_positions: ReadStorage<'a, Last>, orientations: ReadStorage<'a, Ori>, scales: ReadStorage<'a, Scale>, bodies: ReadStorage<'a, Body>, @@ -140,7 +139,6 @@ impl<'a> System<'a> for Sys { // 2D versions let pos_b2 = pos_b.0.xy(); - let last_pos_b2_maybe = read_data.last_positions.get(target).map(|p| (p.0).0.xy()); // Scales let scale_b = read_data.scales.get(target).map_or(1.0, |s| s.0); @@ -168,9 +166,7 @@ impl<'a> System<'a> for Sys { && { // TODO: write code to collide rect with the arc strip so that we can do // more complete collision detection for rapidly moving entities - arc_strip.collides_with_circle(Disk::new(pos_b2, rad_b)) || last_pos_b2_maybe.map_or(false, |pos| { - arc_strip.collides_with_circle(Disk::new(pos, rad_b)) - }) + arc_strip.collides_with_circle(Disk::new(pos_b2, rad_b)) } && (pos_b_ground - pos.0).angle_between(pos_b.0 - pos.0) < max_angle && (!shockwave.requires_ground || physics_state_b.on_ground);