mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'sam/remove-combat-last-pos' into 'master'
Shockwaves and beams no longer use last position in calculating if they hit. See merge request veloren/veloren!1934
This commit is contained in:
commit
64c8f75a4f
@ -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<Pos>>,
|
||||
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
|
||||
|
@ -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<Pos>>,
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user