diff --git a/Content.Client/RCD/AlignRCDConstruction.cs b/Content.Client/RCD/AlignRCDConstruction.cs index fcbe408a38..ef99b01855 100644 --- a/Content.Client/RCD/AlignRCDConstruction.cs +++ b/Content.Client/RCD/AlignRCDConstruction.cs @@ -75,7 +75,7 @@ public sealed class AlignRCDConstruction : PlacementMode if (!_entityManager.TryGetComponent(player, out var xform)) return false; - if (!xform.Coordinates.InRange(_entityManager, _transformSystem, position, SharedInteractionSystem.InteractionRange)) + if (!_transformSystem.InRange(xform.Coordinates, position, SharedInteractionSystem.InteractionRange)) { InvalidPlaceColor = InvalidPlaceColor.WithAlpha(0); return false; diff --git a/Content.Client/Storage/Systems/StorageSystem.cs b/Content.Client/Storage/Systems/StorageSystem.cs index 1e011f08f0..eea7b9ec79 100644 --- a/Content.Client/Storage/Systems/StorageSystem.cs +++ b/Content.Client/Storage/Systems/StorageSystem.cs @@ -142,8 +142,8 @@ public sealed class StorageSystem : SharedStorageSystem { if (!_timing.IsFirstTimePredicted) return; - - if (finalCoords.InRange(EntityManager, TransformSystem, initialCoords, 0.1f) || + + if (TransformSystem.InRange(finalCoords, initialCoords, 0.1f) || !Exists(initialCoords.EntityId) || !Exists(finalCoords.EntityId)) { return; diff --git a/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs b/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs index c2cdd4a107..0f4490cd7e 100644 --- a/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs @@ -162,7 +162,7 @@ namespace Content.Server.Atmos.EntitySystems if (component.LastPosition.HasValue) { // Check if position is out of range => don't update and disable - if (!component.LastPosition.Value.InRange(EntityManager, _transform, userPos, SharedInteractionSystem.InteractionRange)) + if (!_transform.InRange(component.LastPosition.Value, userPos, SharedInteractionSystem.InteractionRange)) { if (component.User is { } userId && component.Enabled) _popup.PopupEntity(Loc.GetString("gas-analyzer-shutoff"), userId, userId); diff --git a/Content.Server/Dragon/DragonSystem.cs b/Content.Server/Dragon/DragonSystem.cs index 62d1f61a35..96ca8d3614 100644 --- a/Content.Server/Dragon/DragonSystem.cs +++ b/Content.Server/Dragon/DragonSystem.cs @@ -146,7 +146,7 @@ public sealed partial class DragonSystem : EntitySystem // cant stack rifts near eachother foreach (var (_, riftXform) in EntityQuery(true)) { - if (riftXform.Coordinates.InRange(EntityManager, _transform, xform.Coordinates, RiftRange)) + if (_transform.InRange(riftXform.Coordinates, xform.Coordinates, RiftRange)) { _popup.PopupEntity(Loc.GetString("carp-rift-proximity", ("proximity", RiftRange)), uid, uid); return; diff --git a/Content.Server/Guardian/GuardianSystem.cs b/Content.Server/Guardian/GuardianSystem.cs index 203882ed9e..ae4d0ca2b8 100644 --- a/Content.Server/Guardian/GuardianSystem.cs +++ b/Content.Server/Guardian/GuardianSystem.cs @@ -325,7 +325,7 @@ namespace Content.Server.Guardian if (!guardianComponent.GuardianLoose) return; - if (!guardianXform.Coordinates.InRange(EntityManager, _transform, hostXform.Coordinates, guardianComponent.DistanceAllowed)) + if (!_transform.InRange(guardianXform.Coordinates, hostXform.Coordinates, guardianComponent.DistanceAllowed)) RetractGuardian(hostUid, hostComponent, guardianUid, guardianComponent); } diff --git a/Content.Server/Instruments/InstrumentSystem.cs b/Content.Server/Instruments/InstrumentSystem.cs index 582bf7fa67..6814b596dc 100644 --- a/Content.Server/Instruments/InstrumentSystem.cs +++ b/Content.Server/Instruments/InstrumentSystem.cs @@ -402,7 +402,8 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem var trans = transformQuery.GetComponent(uid); var masterTrans = transformQuery.GetComponent(master); - if (!masterTrans.Coordinates.InRange(EntityManager, _transform, trans.Coordinates, 10f)) + if (!_transform.InRange(masterTrans.Coordinates, trans.Coordinates, 10f) +) { Clean(uid, instrument); } diff --git a/Content.Server/Medical/HealthAnalyzerSystem.cs b/Content.Server/Medical/HealthAnalyzerSystem.cs index 1d6e564a32..98f4f00d89 100644 --- a/Content.Server/Medical/HealthAnalyzerSystem.cs +++ b/Content.Server/Medical/HealthAnalyzerSystem.cs @@ -65,7 +65,7 @@ public sealed class HealthAnalyzerSystem : EntitySystem //Get distance between health analyzer and the scanned entity var patientCoordinates = Transform(patient).Coordinates; - if (!patientCoordinates.InRange(EntityManager, _transformSystem, transform.Coordinates, component.MaxScanRange)) + if (!_transformSystem.InRange(patientCoordinates, transform.Coordinates, component.MaxScanRange)) { //Range too far, disable updates StopAnalyzingEntity((uid, component), patient); diff --git a/Content.Server/Movement/Systems/PullController.cs b/Content.Server/Movement/Systems/PullController.cs index 340dc5654e..4bd4b60371 100644 --- a/Content.Server/Movement/Systems/PullController.cs +++ b/Content.Server/Movement/Systems/PullController.cs @@ -58,6 +58,7 @@ public sealed class PullController : VirtualController [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!; [Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly SharedGravitySystem _gravity = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; /// /// If distance between puller and pulled entity lower that this threshold, @@ -133,8 +134,8 @@ public sealed class PullController : VirtualController var range = 2f; var fromUserCoords = coords.WithEntityId(player, EntityManager); var userCoords = new EntityCoordinates(player, Vector2.Zero); - - if (!coords.InRange(EntityManager, TransformSystem, userCoords, range)) + + if (!_transformSystem.InRange(coords, userCoords, range)) { var direction = fromUserCoords.Position - userCoords.Position; diff --git a/Content.Server/NPC/HTN/Preconditions/CoordinatesInRangePrecondition.cs b/Content.Server/NPC/HTN/Preconditions/CoordinatesInRangePrecondition.cs index 3485bd2a18..452bf327f2 100644 --- a/Content.Server/NPC/HTN/Preconditions/CoordinatesInRangePrecondition.cs +++ b/Content.Server/NPC/HTN/Preconditions/CoordinatesInRangePrecondition.cs @@ -8,12 +8,19 @@ namespace Content.Server.NPC.HTN.Preconditions; public sealed partial class CoordinatesInRangePrecondition : HTNPrecondition { [Dependency] private readonly IEntityManager _entManager = default!; + private SharedTransformSystem _transformSystem = default!; [DataField("targetKey", required: true)] public string TargetKey = default!; [DataField("rangeKey", required: true)] public string RangeKey = default!; + public override void Initialize(IEntitySystemManager sysManager) + { + base.Initialize(sysManager); + _transformSystem = sysManager.GetEntitySystem(); + } + public override bool IsMet(NPCBlackboard blackboard) { if (!blackboard.TryGetValue(NPCBlackboard.OwnerCoordinates, out var coordinates, _entManager)) @@ -22,6 +29,6 @@ public sealed partial class CoordinatesInRangePrecondition : HTNPrecondition if (!blackboard.TryGetValue(TargetKey, out var target, _entManager)) return false; - return coordinates.InRange(_entManager, _entManager.System(), target, blackboard.GetValueOrDefault(RangeKey, _entManager)); + return _transformSystem.InRange(coordinates, target, blackboard.GetValueOrDefault(RangeKey, _entManager)); } } diff --git a/Content.Server/NPC/HTN/Preconditions/CoordinatesNotInRangePrecondition.cs b/Content.Server/NPC/HTN/Preconditions/CoordinatesNotInRangePrecondition.cs index 9d000ca2eb..901831679e 100644 --- a/Content.Server/NPC/HTN/Preconditions/CoordinatesNotInRangePrecondition.cs +++ b/Content.Server/NPC/HTN/Preconditions/CoordinatesNotInRangePrecondition.cs @@ -8,12 +8,19 @@ namespace Content.Server.NPC.HTN.Preconditions; public sealed partial class CoordinatesNotInRangePrecondition : HTNPrecondition { [Dependency] private readonly IEntityManager _entManager = default!; + private SharedTransformSystem _transformSystem = default!; [DataField("targetKey", required: true)] public string TargetKey = default!; [DataField("rangeKey", required: true)] public string RangeKey = default!; + public override void Initialize(IEntitySystemManager sysManager) + { + base.Initialize(sysManager); + _transformSystem = sysManager.GetEntitySystem(); + } + public override bool IsMet(NPCBlackboard blackboard) { if (!blackboard.TryGetValue(NPCBlackboard.OwnerCoordinates, out var coordinates, _entManager)) @@ -22,7 +29,7 @@ public sealed partial class CoordinatesNotInRangePrecondition : HTNPrecondition if (!blackboard.TryGetValue(TargetKey, out var target, _entManager)) return false; - return !coordinates.InRange(_entManager, _entManager.System(), target, blackboard.GetValueOrDefault(RangeKey, _entManager)); + return !_transformSystem.InRange(coordinates, target, blackboard.GetValueOrDefault(RangeKey, _entManager)); } } diff --git a/Content.Server/NPC/HTN/Preconditions/TargetInRangePrecondition.cs b/Content.Server/NPC/HTN/Preconditions/TargetInRangePrecondition.cs index aaccb426d7..921b5ffa22 100644 --- a/Content.Server/NPC/HTN/Preconditions/TargetInRangePrecondition.cs +++ b/Content.Server/NPC/HTN/Preconditions/TargetInRangePrecondition.cs @@ -8,11 +8,17 @@ namespace Content.Server.NPC.HTN.Preconditions; public sealed partial class TargetInRangePrecondition : HTNPrecondition { [Dependency] private readonly IEntityManager _entManager = default!; + private SharedTransformSystem _transformSystem = default!; [DataField("targetKey", required: true)] public string TargetKey = default!; [DataField("rangeKey", required: true)] public string RangeKey = default!; + public override void Initialize(IEntitySystemManager sysManager) + { + base.Initialize(sysManager); + _transformSystem = sysManager.GetEntitySystem(); + } public override bool IsMet(NPCBlackboard blackboard) { @@ -23,6 +29,7 @@ public sealed partial class TargetInRangePrecondition : HTNPrecondition !_entManager.TryGetComponent(target, out var targetXform)) return false; - return coordinates.InRange(_entManager, _entManager.System(), targetXform.Coordinates, blackboard.GetValueOrDefault(RangeKey, _entManager)); + var transformSystem = _entManager.System; + return _transformSystem.InRange(coordinates, targetXform.Coordinates, blackboard.GetValueOrDefault(RangeKey, _entManager)); } } diff --git a/Content.Server/Pointing/EntitySystems/PointingSystem.cs b/Content.Server/Pointing/EntitySystems/PointingSystem.cs index ca7791fb68..4b7f50fb86 100644 --- a/Content.Server/Pointing/EntitySystems/PointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/PointingSystem.cs @@ -101,7 +101,7 @@ namespace Content.Server.Pointing.EntitySystems { if (HasComp(pointer)) { - return Transform(pointer).Coordinates.InRange(EntityManager, _transform, coordinates, 15); + return _transform.InRange(Transform(pointer).Coordinates, coordinates, 15); } else { diff --git a/Content.Shared/Actions/SharedActionsSystem.cs b/Content.Shared/Actions/SharedActionsSystem.cs index 49c137468e..013348eb4f 100644 --- a/Content.Shared/Actions/SharedActionsSystem.cs +++ b/Content.Shared/Actions/SharedActionsSystem.cs @@ -533,7 +533,7 @@ public abstract class SharedActionsSystem : EntitySystem if (action.Range <= 0) return true; - return coords.InRange(EntityManager, _transformSystem, Transform(user).Coordinates, action.Range); + return _transformSystem.InRange(coords, Transform(user).Coordinates, action.Range); } return _interactionSystem.InRangeUnobstructed(user, coords, range: action.Range); diff --git a/Content.Shared/DoAfter/SharedDoAfterSystem.Update.cs b/Content.Shared/DoAfter/SharedDoAfterSystem.Update.cs index 4f77a271b3..ad94f3b940 100644 --- a/Content.Shared/DoAfter/SharedDoAfterSystem.Update.cs +++ b/Content.Shared/DoAfter/SharedDoAfterSystem.Update.cs @@ -170,7 +170,7 @@ public abstract partial class SharedDoAfterSystem : EntitySystem if (args.BreakOnMove && !(!args.BreakOnWeightlessMove && _gravity.IsWeightless(args.User, xform: userXform))) { // Whether the user has moved too much from their original position. - if (!userXform.Coordinates.InRange(EntityManager, _transform, doAfter.UserPosition, args.MovementThreshold)) + if (!_transform.InRange(userXform.Coordinates, doAfter.UserPosition, args.MovementThreshold)) return true; // Whether the distance between the user and target(if any) has changed too much.