Fix hitting through directional windows (and more!) (#34793)
This commit is contained in:
@@ -170,7 +170,7 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
|||||||
var targetCoordinates = xform.Coordinates;
|
var targetCoordinates = xform.Coordinates;
|
||||||
var targetLocalAngle = xform.LocalRotation;
|
var targetLocalAngle = xform.LocalRotation;
|
||||||
|
|
||||||
return Interaction.InRangeUnobstructed(user, target, targetCoordinates, targetLocalAngle, range);
|
return Interaction.InRangeUnobstructed(user, target, targetCoordinates, targetLocalAngle, range, overlapCheck: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void DoDamageEffect(List<EntityUid> targets, EntityUid? user, TransformComponent targetXform)
|
protected override void DoDamageEffect(List<EntityUid> targets, EntityUid? user, TransformComponent targetXform)
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
|||||||
// Could also check the arc though future effort + if they're aimbotting it's not really going to make a difference.
|
// Could also check the arc though future effort + if they're aimbotting it's not really going to make a difference.
|
||||||
|
|
||||||
// (This runs lagcomp internally and is what clickattacks use)
|
// (This runs lagcomp internally and is what clickattacks use)
|
||||||
if (!Interaction.InRangeUnobstructed(ignore, targetUid, range + 0.1f))
|
if (!Interaction.InRangeUnobstructed(ignore, targetUid, range + 0.1f, overlapCheck: false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// TODO: Check arc though due to the aforementioned aimbot + damage split comments it's less important.
|
// TODO: Check arc though due to the aforementioned aimbot + damage split comments it's less important.
|
||||||
@@ -193,7 +193,7 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
|
|||||||
if (session is { } pSession)
|
if (session is { } pSession)
|
||||||
{
|
{
|
||||||
(targetCoordinates, targetLocalAngle) = _lag.GetCoordinatesAngle(target, pSession);
|
(targetCoordinates, targetLocalAngle) = _lag.GetCoordinatesAngle(target, pSession);
|
||||||
return Interaction.InRangeUnobstructed(user, target, targetCoordinates, targetLocalAngle, range);
|
return Interaction.InRangeUnobstructed(user, target, targetCoordinates, targetLocalAngle, range, overlapCheck: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Interaction.InRangeUnobstructed(user, target, range);
|
return Interaction.InRangeUnobstructed(user, target, range);
|
||||||
|
|||||||
@@ -667,7 +667,8 @@ namespace Content.Shared.Interaction
|
|||||||
float range = InteractionRange,
|
float range = InteractionRange,
|
||||||
CollisionGroup collisionMask = InRangeUnobstructedMask,
|
CollisionGroup collisionMask = InRangeUnobstructedMask,
|
||||||
Ignored? predicate = null,
|
Ignored? predicate = null,
|
||||||
bool popup = false)
|
bool popup = false,
|
||||||
|
bool overlapCheck = true)
|
||||||
{
|
{
|
||||||
if (!Resolve(other, ref other.Comp))
|
if (!Resolve(other, ref other.Comp))
|
||||||
return false;
|
return false;
|
||||||
@@ -687,7 +688,8 @@ namespace Content.Shared.Interaction
|
|||||||
range,
|
range,
|
||||||
collisionMask,
|
collisionMask,
|
||||||
predicate,
|
predicate,
|
||||||
popup);
|
popup,
|
||||||
|
overlapCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -717,6 +719,7 @@ namespace Content.Shared.Interaction
|
|||||||
/// <returns>
|
/// <returns>
|
||||||
/// True if the two points are within a given range without being obstructed.
|
/// True if the two points are within a given range without being obstructed.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
|
/// <param name="overlapCheck">If true, if the broadphase query returns an overlap (0f distance) this function will early out true with no raycast made.</param>
|
||||||
public bool InRangeUnobstructed(
|
public bool InRangeUnobstructed(
|
||||||
Entity<TransformComponent?> origin,
|
Entity<TransformComponent?> origin,
|
||||||
Entity<TransformComponent?> other,
|
Entity<TransformComponent?> other,
|
||||||
@@ -725,7 +728,8 @@ namespace Content.Shared.Interaction
|
|||||||
float range = InteractionRange,
|
float range = InteractionRange,
|
||||||
CollisionGroup collisionMask = InRangeUnobstructedMask,
|
CollisionGroup collisionMask = InRangeUnobstructedMask,
|
||||||
Ignored? predicate = null,
|
Ignored? predicate = null,
|
||||||
bool popup = false)
|
bool popup = false,
|
||||||
|
bool overlapCheck = true)
|
||||||
{
|
{
|
||||||
Ignored combinedPredicate = e => e == origin.Owner || (predicate?.Invoke(e) ?? false);
|
Ignored combinedPredicate = e => e == origin.Owner || (predicate?.Invoke(e) ?? false);
|
||||||
var inRange = true;
|
var inRange = true;
|
||||||
@@ -768,7 +772,7 @@ namespace Content.Shared.Interaction
|
|||||||
inRange = false;
|
inRange = false;
|
||||||
}
|
}
|
||||||
// Overlap, early out and no raycast.
|
// Overlap, early out and no raycast.
|
||||||
else if (distance.Equals(0f))
|
else if (overlapCheck && distance.Equals(0f))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -731,7 +731,13 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
|||||||
|
|
||||||
if (res.Count != 0)
|
if (res.Count != 0)
|
||||||
{
|
{
|
||||||
resSet.Add(res[0].HitEntity);
|
// If there's exact distance overlap, we simply have to deal with all overlapping objects to avoid selecting randomly.
|
||||||
|
var resChecked = res.Where(x => x.Distance.Equals(res[0].Distance));
|
||||||
|
foreach (var r in resChecked)
|
||||||
|
{
|
||||||
|
if (Interaction.InRangeUnobstructed(ignore, r.HitEntity, range + 0.1f, overlapCheck: false))
|
||||||
|
resSet.Add(r.HitEntity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,7 @@
|
|||||||
fix1:
|
fix1:
|
||||||
shape:
|
shape:
|
||||||
!type:PhysShapeAabb
|
!type:PhysShapeAabb
|
||||||
bounds: "-0.49,-0.49,0.49,-0.36"
|
bounds: "-0.5,-0.5,0.5,-0.28125"
|
||||||
density: 1500
|
density: 1500
|
||||||
mask:
|
mask:
|
||||||
- FullTileMask
|
- FullTileMask
|
||||||
|
|||||||
Reference in New Issue
Block a user