]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Replace obsolete EntityCoordiates.InRange() with TransformSystem.InRange() (#29993)
authorPlykiya <58439124+Plykiya@users.noreply.github.com>
Sat, 13 Jul 2024 21:25:51 +0000 (14:25 -0700)
committerGitHub <noreply@github.com>
Sat, 13 Jul 2024 21:25:51 +0000 (23:25 +0200)
* Replace EntityCoordiates.InRange() with TransformSystem.InRange()

* nullspace

* I figured it out

* man I have no clue how client side sutff works

* please have mercy

* remove RadiationPulseOverlay changes

* nullspace

---------

Co-authored-by: plykiya <plykiya@protonmail.com>
14 files changed:
Content.Client/RCD/AlignRCDConstruction.cs
Content.Client/Storage/Systems/StorageSystem.cs
Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs
Content.Server/Dragon/DragonSystem.cs
Content.Server/Guardian/GuardianSystem.cs
Content.Server/Instruments/InstrumentSystem.cs
Content.Server/Medical/HealthAnalyzerSystem.cs
Content.Server/Movement/Systems/PullController.cs
Content.Server/NPC/HTN/Preconditions/CoordinatesInRangePrecondition.cs
Content.Server/NPC/HTN/Preconditions/CoordinatesNotInRangePrecondition.cs
Content.Server/NPC/HTN/Preconditions/TargetInRangePrecondition.cs
Content.Server/Pointing/EntitySystems/PointingSystem.cs
Content.Shared/Actions/SharedActionsSystem.cs
Content.Shared/DoAfter/SharedDoAfterSystem.Update.cs

index fcbe408a382dc94927f7971567e94c105a5a613d..ef99b01855cba6850ee45ff999b16fd243231c28 100644 (file)
@@ -75,7 +75,7 @@ public sealed class AlignRCDConstruction : PlacementMode
         if (!_entityManager.TryGetComponent<TransformComponent>(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;
index 1e011f08f0e39f695bee9fd30a7a64288da68089..eea7b9ec797fc64de8ff39e3340d8ed4e160d3a9 100644 (file)
@@ -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;
index c2cdd4a10727ff74a2826138b9fa2b488ed1177e..0f4490cd7ebad868c370ded20ed8f821225e9477 100644 (file)
@@ -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);
index 62d1f61a35b4690d558b369c933c0fd53f0db598..96ca8d3614a22a5c807ec61e718d7301588b809b 100644 (file)
@@ -146,7 +146,7 @@ public sealed partial class DragonSystem : EntitySystem
         // cant stack rifts near eachother
         foreach (var (_, riftXform) in EntityQuery<DragonRiftComponent, TransformComponent>(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;
index 203882ed9ef0554adf076015a892e2d3c3c34490..ae4d0ca2b8cad330c3ca3c90bc1dd290f280bc04 100644 (file)
@@ -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);
         }
 
index 582bf7fa67b1c9ed7c77906016305275a5cd4d6f..6814b596dc5ef29c919ac072b94f22fa8bb08e32 100644 (file)
@@ -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);
                 }
index 1d6e564a32d90d9257d7a47b917aad870360a404..98f4f00d8999690aa4bf5a54358890c8d23648d5 100644 (file)
@@ -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);
index 340dc5654e86ed63b00852c4c738a9b144aa5d20..4bd4b603714f4f54f3bfd7676b3325e8a089b4a9 100644 (file)
@@ -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!;
 
     /// <summary>
     ///     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;
 
index 3485bd2a18c334b2dcebd1f021619d3c944f5f8e..452bf327f253eca76edbbe8fe615280d158dd7b6 100644 (file)
@@ -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<SharedTransformSystem>();
+    }
+
     public override bool IsMet(NPCBlackboard blackboard)
     {
         if (!blackboard.TryGetValue<EntityCoordinates>(NPCBlackboard.OwnerCoordinates, out var coordinates, _entManager))
@@ -22,6 +29,6 @@ public sealed partial class CoordinatesInRangePrecondition : HTNPrecondition
         if (!blackboard.TryGetValue<EntityCoordinates>(TargetKey, out var target, _entManager))
             return false;
 
-        return coordinates.InRange(_entManager, _entManager.System<SharedTransformSystem>(), target, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
+        return _transformSystem.InRange(coordinates, target, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
     }
 }
index 9d000ca2eb841b0bdae0f21628219c6a7f80f2fc..901831679e8afc7421422af0ea3418e04d0bcad6 100644 (file)
@@ -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<SharedTransformSystem>();
+    }
+
     public override bool IsMet(NPCBlackboard blackboard)
     {
         if (!blackboard.TryGetValue<EntityCoordinates>(NPCBlackboard.OwnerCoordinates, out var coordinates, _entManager))
@@ -22,7 +29,7 @@ public sealed partial class CoordinatesNotInRangePrecondition : HTNPrecondition
         if (!blackboard.TryGetValue<EntityCoordinates>(TargetKey, out var target, _entManager))
             return false;
 
-        return !coordinates.InRange(_entManager, _entManager.System<SharedTransformSystem>(), target, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
+        return !_transformSystem.InRange(coordinates, target, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
     }
 }
 
index aaccb426d714b19b6c176b4e88dd7f1372104e9c..921b5ffa226339385daade67c9eb031bdbbc3b48 100644 (file)
@@ -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<SharedTransformSystem>();
+    }
 
     public override bool IsMet(NPCBlackboard blackboard)
     {
@@ -23,6 +29,7 @@ public sealed partial class TargetInRangePrecondition : HTNPrecondition
             !_entManager.TryGetComponent<TransformComponent>(target, out var targetXform))
             return false;
 
-        return coordinates.InRange(_entManager, _entManager.System<SharedTransformSystem>(), targetXform.Coordinates, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
+        var transformSystem = _entManager.System<SharedTransformSystem>;
+        return _transformSystem.InRange(coordinates, targetXform.Coordinates, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
     }
 }
index ca7791fb68aeb98c232d2ec5eae4ddbe6973e46d..4b7f50fb86cb5abb72b7d2a71dc456faf05ba8e6 100644 (file)
@@ -101,7 +101,7 @@ namespace Content.Server.Pointing.EntitySystems
         {
             if (HasComp<GhostComponent>(pointer))
             {
-                return Transform(pointer).Coordinates.InRange(EntityManager, _transform, coordinates, 15);
+                return _transform.InRange(Transform(pointer).Coordinates, coordinates, 15);
             }
             else
             {
index 49c137468e41dfe6cee37a48f9d7e76476558b9b..013348eb4f7ca7934049016a2601398203e0711e 100644 (file)
@@ -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);
index 4f77a271b37bd4febeb783d4a8d253e7bfc7f1db..ad94f3b94086e1b218464f5d285bd366f1417d95 100644 (file)
@@ -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.