Fix ignoreInsideBlocker not working correctly for inRangeUnobstructed and inRangeUnoccluded (#2417)
* Fix ignoreInsideBlocker not working correctly for range checks * Other way around
This commit is contained in:
@@ -4,6 +4,8 @@ using Content.Shared.Interfaces.GameObjects.Components;
|
|||||||
using Content.Shared.Utility;
|
using Content.Shared.Utility;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.GameObjects.Components;
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
@@ -88,9 +90,24 @@ namespace Content.Shared.GameObjects.EntitySystems
|
|||||||
|
|
||||||
if (!ignoreInsideBlocker) return false;
|
if (!ignoreInsideBlocker) return false;
|
||||||
|
|
||||||
if (rayResults.Count <= 0) return false;
|
foreach (var result in rayResults)
|
||||||
|
{
|
||||||
|
if (!result.HitEntity.TryGetComponent(out OccluderComponent o))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
return (rayResults[0].HitPos - other.Position).Length < 1f;
|
var bBox = o.BoundingBox.Translated(o.Owner.Transform.WorldPosition);
|
||||||
|
|
||||||
|
if (bBox.Contains(origin.Position) || bBox.Contains(other.Position))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool InRangeUnOccluded(IEntity origin, IEntity other, float range, Ignored predicate, bool ignoreInsideBlocker = true)
|
public static bool InRangeUnOccluded(IEntity origin, IEntity other, float range, Ignored predicate, bool ignoreInsideBlocker = true)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Content.Shared.Interfaces;
|
|||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Robust.Shared.GameObjects.Components;
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Interfaces.Physics;
|
using Robust.Shared.Interfaces.Physics;
|
||||||
@@ -132,9 +133,24 @@ namespace Content.Shared.GameObjects.EntitySystems
|
|||||||
|
|
||||||
if (!ignoreInsideBlocker) return false;
|
if (!ignoreInsideBlocker) return false;
|
||||||
|
|
||||||
if (rayResults.Count <= 0) return false;
|
foreach (var result in rayResults)
|
||||||
|
{
|
||||||
|
if (!result.HitEntity.TryGetComponent(out IPhysicsComponent p))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
return (rayResults[0].HitPos - other.Position).Length < 1f;
|
var bBox = p.WorldAABB;
|
||||||
|
|
||||||
|
if (bBox.Contains(origin.Position) || bBox.Contains(other.Position))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user