]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Remove obsolete transform call (#24217)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Thu, 1 Feb 2024 13:39:43 +0000 (00:39 +1100)
committerGitHub <noreply@github.com>
Thu, 1 Feb 2024 13:39:43 +0000 (00:39 +1100)
* Remove obsolete transform call

Shrimple PR also fixed bad flatpack call that would break on non-standard tilesizes.

* Update calls

* weh

Content.Server/Anomaly/Effects/EntityAnomalySystem.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.Hotspot.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs
Content.Shared/Anomaly/SharedAnomalySystem.cs
Content.Shared/Construction/SharedFlatpackSystem.cs

index 9bfc48f4baa316bc5e2aa951316f9e81cc4e135f..7c397d68887297f50fce1c6ed12f76f08b613840 100644 (file)
@@ -4,6 +4,7 @@ using Content.Shared.Anomaly.Effects;
 using Content.Shared.Anomaly.Effects.Components;
 using Robust.Shared.Map;
 using Robust.Shared.Map.Components;
+using Robust.Shared.Physics.Components;
 using Robust.Shared.Random;
 
 namespace Content.Server.Anomaly.Effects;
@@ -13,10 +14,15 @@ public sealed class EntityAnomalySystem : SharedEntityAnomalySystem
     [Dependency] private readonly SharedAnomalySystem _anomaly = default!;
     [Dependency] private readonly IMapManager _map = default!;
     [Dependency] private readonly IRobustRandom _random = default!;
+    [Dependency] private readonly SharedMapSystem _mapSystem = default!;
+
+    private EntityQuery<PhysicsComponent> _physicsQuery;
 
     /// <inheritdoc/>
     public override void Initialize()
     {
+        _physicsQuery = GetEntityQuery<PhysicsComponent>();
+
         SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalyPulseEvent>(OnPulse);
         SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalySupercriticalEvent>(OnSupercritical);
         SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalyStabilityChangedEvent>(OnStabilityChanged);
@@ -82,7 +88,7 @@ public sealed class EntityAnomalySystem : SharedEntityAnomalySystem
     private void SpawnEntities(Entity<EntitySpawnAnomalyComponent> anomaly, EntitySpawnSettingsEntry entry, float stability, float severity)
     {
         var xform = Transform(anomaly);
-        if (!TryComp<MapGridComponent>(xform.GridUid, out var grid))
+        if (!TryComp(xform.GridUid, out MapGridComponent? grid))
             return;
 
         var tiles = _anomaly.GetSpawningPoints(anomaly, stability, severity, entry.Settings);
@@ -91,7 +97,7 @@ public sealed class EntityAnomalySystem : SharedEntityAnomalySystem
 
         foreach (var tileref in tiles)
         {
-            Spawn(_random.Pick(entry.Spawns), tileref.GridIndices.ToEntityCoordinates(xform.GridUid.Value, _map));
+            Spawn(_random.Pick(entry.Spawns), _mapSystem.ToCenterCoordinates(tileref, grid));
         }
     }
 }
index 89a42b576bc8663409516c12aa3eb9d4ecd90a51..53035e1ed3c5555df7225031cad7c0f7cb82794c 100644 (file)
@@ -100,7 +100,7 @@ namespace Content.Server.Atmos.EntitySystems
             {
                 if(_spaceWindSoundCooldown == 0 && !string.IsNullOrEmpty(SpaceWindSound))
                 {
-                    var coordinates = tile.GridIndices.ToEntityCoordinates(tile.GridIndex, _mapManager);
+                    var coordinates = _mapSystem.ToCenterCoordinates(tile.GridIndex, tile.GridIndices);
                     _audio.PlayPvs(SpaceWindSound, coordinates, AudioParams.Default.WithVariation(0.125f).WithVolume(MathHelper.Clamp(tile.PressureDifference / 10, 10, 100)));
                 }
             }
@@ -163,7 +163,7 @@ namespace Content.Server.Atmos.EntitySystems
                         gridAtmosphere.Comp.UpdateCounter,
                         tile.PressureDifference,
                         tile.PressureDirection, 0,
-                        tile.PressureSpecificTarget?.GridIndices.ToEntityCoordinates(tile.GridIndex, _mapManager) ?? EntityCoordinates.Invalid,
+                        tile.PressureSpecificTarget != null ? _mapSystem.ToCenterCoordinates(tile.GridIndex, tile.PressureSpecificTarget.GridIndices) : EntityCoordinates.Invalid,
                         gridWorldRotation,
                         xforms.GetComponent(entity),
                         body);
index 8966f232e06b4426b5e6270b0071f7daf442c3fe..713d1c4682c538a0504abf292c102575fde3f96c 100644 (file)
@@ -11,8 +11,6 @@ namespace Content.Server.Atmos.EntitySystems
 {
     public sealed partial class AtmosphereSystem
     {
-        [Dependency] private readonly EntityLookupSystem _lookup = default!;
-
         private const int HotspotSoundCooldownCycles = 200;
 
         private int _hotspotSoundCooldown = 0;
@@ -81,7 +79,8 @@ namespace Content.Server.Atmos.EntitySystems
 
             if (_hotspotSoundCooldown++ == 0 && !string.IsNullOrEmpty(HotspotSound))
             {
-                var coordinates = tile.GridIndices.ToEntityCoordinates(tile.GridIndex, _mapManager);
+                var coordinates = _mapSystem.ToCenterCoordinates(tile.GridIndex, tile.GridIndices);
+
                 // A few details on the audio parameters for fire.
                 // The greater the fire state, the lesser the pitch variation.
                 // The greater the fire state, the greater the volume.
index 116ab1721130776e030ada9ed51b1866e0c51f77..dd2a967559184ad9809e2392fabe29303254270d 100644 (file)
@@ -25,12 +25,14 @@ public sealed partial class AtmosphereSystem : SharedAtmosphereSystem
     [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
     [Dependency] private readonly IRobustRandom _robustRandom = default!;
     [Dependency] private readonly IAdminLogManager _adminLog = default!;
+    [Dependency] private readonly EntityLookupSystem _lookup = default!;
     [Dependency] private readonly InternalsSystem _internals = default!;
     [Dependency] private readonly SharedContainerSystem _containers = default!;
     [Dependency] private readonly SharedPhysicsSystem _physics = default!;
     [Dependency] private readonly GasTileOverlaySystem _gasTileOverlaySystem = default!;
     [Dependency] private readonly SharedAudioSystem _audio = default!;
-    [Dependency] private readonly TransformSystem _transformSystem = default!;
+    [Dependency] private readonly SharedMapSystem _mapSystem = default!;
+    [Dependency] private readonly SharedTransformSystem _transformSystem = default!;
     [Dependency] private readonly TileSystem _tile = default!;
     [Dependency] private readonly MapSystem _map = default!;
     [Dependency] public readonly PuddleSystem Puddle = default!;
index 5c9739da72d2462551f60909ffc278bfb6b468ab..711f9d1493cff7135c4ec820dd41143801943e35 100644 (file)
@@ -377,9 +377,9 @@ public abstract class SharedAnomalySystem : EntitySystem
 
         var physQuery = GetEntityQuery<PhysicsComponent>();
         var resultList = new List<TileRef>();
-        while (resultList.Count() < amount)
+        while (resultList.Count < amount)
         {
-            if (tilerefs.Count() == 0)
+            if (tilerefs.Count == 0)
                 break;
 
             var tileref = _random.Pick(tilerefs);
@@ -414,6 +414,7 @@ public abstract class SharedAnomalySystem : EntitySystem
                     continue;
                 }
             }
+
             resultList.Add(tileref);
         }
         return resultList;
index 6432f87e8ed9ce04565da1f19f1ee43c6b7566d1..c6f3e89744d2a208790bff2177676451a9850096 100644 (file)
@@ -67,8 +67,9 @@ public abstract class SharedFlatpackSystem : EntitySystem
         }
 
         var buildPos = _map.TileIndicesFor(grid, gridComp, xform.Coordinates);
-        var intersecting = _entityLookup.GetEntitiesIntersecting(buildPos.ToEntityCoordinates(grid, _mapManager).Offset(new Vector2(0.5f, 0.5f))
-            , LookupFlags.Dynamic | LookupFlags.Static);
+        var coords = _map.ToCenterCoordinates(grid, buildPos);
+
+        var intersecting = _entityLookup.GetEntitiesIntersecting(coords, LookupFlags.Dynamic | LookupFlags.Static);
 
         // todo make this logic smarter.
         // This should eventually allow for shit like building microwaves on tables and such.