diff --git a/Content.Shared/Utility/SharedUnobstructedExtensions.cs b/Content.Shared/Utility/SharedUnobstructedExtensions.cs index fa564940de..4cbce7d6e5 100644 --- a/Content.Shared/Utility/SharedUnobstructedExtensions.cs +++ b/Content.Shared/Utility/SharedUnobstructedExtensions.cs @@ -1,4 +1,5 @@ -using Content.Shared.GameObjects.EntitySystems; +#nullable enable +using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interfaces.GameObjects.Components; using Content.Shared.Physics; using Robust.Shared.GameObjects.Systems; @@ -20,7 +21,7 @@ namespace Content.Shared.Utility IEntity other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -33,7 +34,7 @@ namespace Content.Shared.Utility IComponent other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -46,7 +47,7 @@ namespace Content.Shared.Utility IContainer other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -61,7 +62,7 @@ namespace Content.Shared.Utility EntityCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -74,7 +75,7 @@ namespace Content.Shared.Utility MapCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -89,7 +90,7 @@ namespace Content.Shared.Utility IEntity other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -104,7 +105,7 @@ namespace Content.Shared.Utility IComponent other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -119,7 +120,7 @@ namespace Content.Shared.Utility IContainer other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -135,7 +136,7 @@ namespace Content.Shared.Utility EntityCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -150,7 +151,7 @@ namespace Content.Shared.Utility MapCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -167,7 +168,7 @@ namespace Content.Shared.Utility IEntity other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var originEntity = origin.Owner; @@ -181,7 +182,7 @@ namespace Content.Shared.Utility IComponent other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -196,7 +197,7 @@ namespace Content.Shared.Utility IContainer other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -212,7 +213,7 @@ namespace Content.Shared.Utility EntityCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -227,7 +228,7 @@ namespace Content.Shared.Utility MapCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -244,11 +245,10 @@ namespace Content.Shared.Utility IEntity other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { - var entityManager = IoCManager.Resolve(); - var originPosition = origin.ToMap(entityManager); + var originPosition = origin.ToMap(other.EntityManager); var otherPosition = other.Transform.MapPosition; return SharedInteractionSystem.InRangeUnobstructed(originPosition, otherPosition, range, collisionMask, @@ -260,11 +260,10 @@ namespace Content.Shared.Utility IComponent other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { - var entityManager = IoCManager.Resolve(); - var originPosition = origin.ToMap(entityManager); + var originPosition = origin.ToMap(other.Owner.EntityManager); var otherPosition = other.Owner.Transform.MapPosition; return SharedInteractionSystem.InRangeUnobstructed(originPosition, otherPosition, range, collisionMask, @@ -276,11 +275,10 @@ namespace Content.Shared.Utility IContainer other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { - var entityManager = IoCManager.Resolve(); - var originPosition = origin.ToMap(entityManager); + var originPosition = origin.ToMap(other.Owner.EntityManager); var otherPosition = other.Owner.Transform.MapPosition; return SharedInteractionSystem.InRangeUnobstructed(originPosition, otherPosition, range, collisionMask, @@ -292,10 +290,12 @@ namespace Content.Shared.Utility EntityCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, - bool ignoreInsideBlocker = false) + Ignored? predicate = null, + bool ignoreInsideBlocker = false, + IEntityManager? entityManager = null) { - var entityManager = IoCManager.Resolve(); + entityManager ??= IoCManager.Resolve(); + var originPosition = origin.ToMap(entityManager); var otherPosition = other.ToMap(entityManager); @@ -308,10 +308,12 @@ namespace Content.Shared.Utility MapCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, - bool ignoreInsideBlocker = false) + Ignored? predicate = null, + bool ignoreInsideBlocker = false, + IEntityManager? entityManager = null) { - var entityManager = IoCManager.Resolve(); + entityManager ??= IoCManager.Resolve(); + var originPosition = origin.ToMap(entityManager); return SharedInteractionSystem.InRangeUnobstructed(originPosition, other, range, collisionMask, predicate, @@ -325,7 +327,7 @@ namespace Content.Shared.Utility IEntity other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var otherPosition = other.Transform.MapPosition; @@ -339,7 +341,7 @@ namespace Content.Shared.Utility IComponent other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var otherPosition = other.Owner.Transform.MapPosition; @@ -353,7 +355,7 @@ namespace Content.Shared.Utility IContainer other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var otherPosition = other.Owner.Transform.MapPosition; @@ -367,10 +369,12 @@ namespace Content.Shared.Utility EntityCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, - bool ignoreInsideBlocker = false) + Ignored? predicate = null, + bool ignoreInsideBlocker = false, + IEntityManager? entityManager = null) { - var entityManager = IoCManager.Resolve(); + entityManager ??= IoCManager.Resolve(); + var otherPosition = other.ToMap(entityManager); return SharedInteractionSystem.InRangeUnobstructed(origin, otherPosition, range, collisionMask, predicate, @@ -382,7 +386,7 @@ namespace Content.Shared.Utility MapCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { return SharedInteractionSystem.InRangeUnobstructed(origin, other, range, collisionMask, predicate, @@ -395,7 +399,7 @@ namespace Content.Shared.Utility this ITargetedInteractEventArgs args, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -407,7 +411,7 @@ namespace Content.Shared.Utility this DragDropEventArgs args, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { @@ -419,7 +423,7 @@ namespace Content.Shared.Utility this AfterInteractEventArgs args, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { diff --git a/Content.Shared/Utility/SharedUnoccludedExtensions.cs b/Content.Shared/Utility/SharedUnoccludedExtensions.cs index cd092cbb79..0f14238509 100644 --- a/Content.Shared/Utility/SharedUnoccludedExtensions.cs +++ b/Content.Shared/Utility/SharedUnoccludedExtensions.cs @@ -1,4 +1,5 @@ -using Content.Shared.GameObjects.EntitySystems; +#nullable enable +using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interfaces.GameObjects.Components; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects.Components; @@ -16,7 +17,7 @@ namespace Content.Shared.Utility this IEntity origin, IEntity other, float range = ExamineRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { return ExamineSystemShared.InRangeUnOccluded(origin, other, range, predicate, ignoreInsideBlocker); @@ -26,7 +27,7 @@ namespace Content.Shared.Utility this IEntity origin, IComponent other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { return ExamineSystemShared.InRangeUnOccluded(origin, other, range, predicate, ignoreInsideBlocker); @@ -36,7 +37,7 @@ namespace Content.Shared.Utility this IEntity origin, IContainer other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var otherEntity = other.Owner; @@ -48,7 +49,7 @@ namespace Content.Shared.Utility this IEntity origin, EntityCoordinates other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { return ExamineSystemShared.InRangeUnOccluded(origin, other, range, predicate, ignoreInsideBlocker); @@ -58,7 +59,7 @@ namespace Content.Shared.Utility this IEntity origin, MapCoordinates other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { return ExamineSystemShared.InRangeUnOccluded(origin, other, range, predicate, ignoreInsideBlocker); @@ -70,7 +71,7 @@ namespace Content.Shared.Utility this IComponent origin, IEntity other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var originEntity = origin.Owner; @@ -82,7 +83,7 @@ namespace Content.Shared.Utility this IComponent origin, IComponent other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var originEntity = origin.Owner; @@ -94,7 +95,7 @@ namespace Content.Shared.Utility this IComponent origin, IContainer other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var originEntity = origin.Owner; @@ -108,7 +109,7 @@ namespace Content.Shared.Utility this IComponent origin, EntityCoordinates other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var originEntity = origin.Owner; @@ -120,7 +121,7 @@ namespace Content.Shared.Utility this IComponent origin, MapCoordinates other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var originEntity = origin.Owner; @@ -135,7 +136,7 @@ namespace Content.Shared.Utility this IContainer origin, IEntity other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var originEntity = origin.Owner; @@ -148,7 +149,7 @@ namespace Content.Shared.Utility this IContainer origin, IComponent other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var originEntity = origin.Owner; @@ -160,7 +161,7 @@ namespace Content.Shared.Utility this IContainer origin, IContainer other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var originEntity = origin.Owner; @@ -174,7 +175,7 @@ namespace Content.Shared.Utility this IContainer origin, EntityCoordinates other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var originEntity = origin.Owner; @@ -186,7 +187,7 @@ namespace Content.Shared.Utility this IContainer origin, MapCoordinates other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var originEntity = origin.Owner; @@ -200,11 +201,10 @@ namespace Content.Shared.Utility this EntityCoordinates origin, IEntity other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { - var entityManager = IoCManager.Resolve(); - var originPosition = origin.ToMap(entityManager); + var originPosition = origin.ToMap(other.EntityManager); var otherPosition = other.Transform.MapPosition; return ExamineSystemShared.InRangeUnOccluded(originPosition, otherPosition, range, @@ -215,11 +215,10 @@ namespace Content.Shared.Utility this EntityCoordinates origin, IComponent other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { - var entityManager = IoCManager.Resolve(); - var originPosition = origin.ToMap(entityManager); + var originPosition = origin.ToMap(other.Owner.EntityManager); var otherPosition = other.Owner.Transform.MapPosition; return ExamineSystemShared.InRangeUnOccluded(originPosition, otherPosition, range, @@ -230,11 +229,10 @@ namespace Content.Shared.Utility this EntityCoordinates origin, IContainer other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { - var entityManager = IoCManager.Resolve(); - var originPosition = origin.ToMap(entityManager); + var originPosition = origin.ToMap(other.Owner.EntityManager); var otherPosition = other.Owner.Transform.MapPosition; return ExamineSystemShared.InRangeUnOccluded(originPosition, otherPosition, range, @@ -245,10 +243,12 @@ namespace Content.Shared.Utility this EntityCoordinates origin, EntityCoordinates other, float range = InteractionRange, - Ignored predicate = null, - bool ignoreInsideBlocker = false) + Ignored? predicate = null, + bool ignoreInsideBlocker = false, + IEntityManager? entityManager = null) { - var entityManager = IoCManager.Resolve(); + entityManager ??= IoCManager.Resolve(); + var originPosition = origin.ToMap(entityManager); var otherPosition = other.ToMap(entityManager); @@ -260,10 +260,12 @@ namespace Content.Shared.Utility this EntityCoordinates origin, MapCoordinates other, float range = InteractionRange, - Ignored predicate = null, - bool ignoreInsideBlocker = false) + Ignored? predicate = null, + bool ignoreInsideBlocker = false, + IEntityManager? entityManager = null) { - var entityManager = IoCManager.Resolve(); + entityManager ??= IoCManager.Resolve(); + var originPosition = origin.ToMap(entityManager); return ExamineSystemShared.InRangeUnOccluded(originPosition, other, range, predicate, @@ -276,7 +278,7 @@ namespace Content.Shared.Utility this MapCoordinates origin, IEntity other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var otherPosition = other.Transform.MapPosition; @@ -289,7 +291,7 @@ namespace Content.Shared.Utility this MapCoordinates origin, IComponent other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var otherPosition = other.Owner.Transform.MapPosition; @@ -302,7 +304,7 @@ namespace Content.Shared.Utility this MapCoordinates origin, IContainer other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { var otherPosition = other.Owner.Transform.MapPosition; @@ -315,10 +317,12 @@ namespace Content.Shared.Utility this MapCoordinates origin, EntityCoordinates other, float range = InteractionRange, - Ignored predicate = null, - bool ignoreInsideBlocker = false) + Ignored? predicate = null, + bool ignoreInsideBlocker = false, + IEntityManager? entityManager = null) { - var entityManager = IoCManager.Resolve(); + entityManager ??= IoCManager.Resolve(); + var otherPosition = other.ToMap(entityManager); return ExamineSystemShared.InRangeUnOccluded(origin, otherPosition, range, predicate, @@ -329,7 +333,7 @@ namespace Content.Shared.Utility this MapCoordinates origin, MapCoordinates other, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { return ExamineSystemShared.InRangeUnOccluded(origin, other, range, predicate, @@ -341,7 +345,7 @@ namespace Content.Shared.Utility public static bool InRangeUnOccluded( this ITargetedInteractEventArgs args, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { return ExamineSystemShared.InRangeUnOccluded(args, range, predicate, @@ -351,7 +355,7 @@ namespace Content.Shared.Utility public static bool InRangeUnOccluded( this DragDropEventArgs args, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { return ExamineSystemShared.InRangeUnOccluded(args, range, predicate, @@ -361,7 +365,7 @@ namespace Content.Shared.Utility public static bool InRangeUnOccluded( this AfterInteractEventArgs args, float range = InteractionRange, - Ignored predicate = null, + Ignored? predicate = null, bool ignoreInsideBlocker = false) { return ExamineSystemShared.InRangeUnOccluded(args, range, predicate,