diff --git a/Content.Client/DoAfter/DoAfterSystem.cs b/Content.Client/DoAfter/DoAfterSystem.cs index 9f7f5c613a..31315ab86c 100644 --- a/Content.Client/DoAfter/DoAfterSystem.cs +++ b/Content.Client/DoAfter/DoAfterSystem.cs @@ -203,6 +203,10 @@ namespace Content.Client.DoAfter if (_attachedEntity is not {Valid: true} entity || Deleted(entity)) return; + // ReSharper disable once ConvertToLocalFunction + var predicate = (EntityUid uid, (EntityUid compOwner, EntityUid? attachedEntity) data) + => uid == data.compOwner || uid == data.attachedEntity; + var viewbox = _eyeManager.GetWorldViewport().Enlarged(2.0f); var entXform = Transform(entity); var playerPos = entXform.MapPosition; @@ -226,7 +230,7 @@ namespace Content.Client.DoAfter !ExamineSystemShared.InRangeUnOccluded( playerPos, compPos, range, - ent => ent == comp.Owner || ent == _attachedEntity)) + (comp.Owner, _attachedEntity), predicate)) { Disable(comp); continue; diff --git a/Content.Shared/Examine/ExamineSystemShared.cs b/Content.Shared/Examine/ExamineSystemShared.cs index 5ddc08a2b9..72ed6651cd 100644 --- a/Content.Shared/Examine/ExamineSystemShared.cs +++ b/Content.Shared/Examine/ExamineSystemShared.cs @@ -120,7 +120,18 @@ namespace Content.Shared.Examine return ExamineRange; } - public static bool InRangeUnOccluded(MapCoordinates origin, MapCoordinates other, float range, Ignored? predicate, bool ignoreInsideBlocker = true) + public static bool InRangeUnOccluded(MapCoordinates origin, MapCoordinates other, float range, Ignored? predicate, bool ignoreInsideBlocker = true, IEntityManager? entMan = null) + { + // No, rider. This is better. + // ReSharper disable once ConvertToLocalFunction + var wrapped = (EntityUid uid, Ignored? wrapped) + => wrapped != null && wrapped(uid); + + return InRangeUnOccluded(origin, other, range, predicate, wrapped, ignoreInsideBlocker, entMan); + } + + public static bool InRangeUnOccluded(MapCoordinates origin, MapCoordinates other, float range, + TState state, Func predicate, bool ignoreInsideBlocker = true, IEntityManager? entMan = null) { if (other.MapId != origin.MapId || other.MapId == MapId.Nullspace) return false; @@ -140,13 +151,11 @@ namespace Content.Shared.Examine } var occluderSystem = Get(); - var entMan = IoCManager.Resolve(); - - predicate ??= _ => false; + IoCManager.Resolve(ref entMan); var ray = new Ray(origin.Position, dir.Normalized); var rayResults = occluderSystem - .IntersectRayWithPredicate(origin.MapId, ray, length, predicate.Invoke, false).ToList(); + .IntersectRayWithPredicate(origin.MapId, ray, length, state, predicate, false).ToList(); if (rayResults.Count == 0) return true;