From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Thu, 1 Feb 2024 13:39:43 +0000 (+1100) Subject: Remove obsolete transform call (#24217) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=52808694e0a479c162930a0aae20e91b68bc67a4;p=space-station-14.git Remove obsolete transform call (#24217) * Remove obsolete transform call Shrimple PR also fixed bad flatpack call that would break on non-standard tilesizes. * Update calls * weh --- diff --git a/Content.Server/Anomaly/Effects/EntityAnomalySystem.cs b/Content.Server/Anomaly/Effects/EntityAnomalySystem.cs index 9bfc48f4ba..7c397d6888 100644 --- a/Content.Server/Anomaly/Effects/EntityAnomalySystem.cs +++ b/Content.Server/Anomaly/Effects/EntityAnomalySystem.cs @@ -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 _physicsQuery; /// public override void Initialize() { + _physicsQuery = GetEntityQuery(); + SubscribeLocalEvent(OnPulse); SubscribeLocalEvent(OnSupercritical); SubscribeLocalEvent(OnStabilityChanged); @@ -82,7 +88,7 @@ public sealed class EntityAnomalySystem : SharedEntityAnomalySystem private void SpawnEntities(Entity anomaly, EntitySpawnSettingsEntry entry, float stability, float severity) { var xform = Transform(anomaly); - if (!TryComp(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)); } } } diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs index 89a42b576b..53035e1ed3 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs @@ -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); diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Hotspot.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Hotspot.cs index 8966f232e0..713d1c4682 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Hotspot.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Hotspot.cs @@ -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. diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs index 116ab17211..dd2a967559 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs @@ -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!; diff --git a/Content.Shared/Anomaly/SharedAnomalySystem.cs b/Content.Shared/Anomaly/SharedAnomalySystem.cs index 5c9739da72..711f9d1493 100644 --- a/Content.Shared/Anomaly/SharedAnomalySystem.cs +++ b/Content.Shared/Anomaly/SharedAnomalySystem.cs @@ -377,9 +377,9 @@ public abstract class SharedAnomalySystem : EntitySystem var physQuery = GetEntityQuery(); var resultList = new List(); - 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; diff --git a/Content.Shared/Construction/SharedFlatpackSystem.cs b/Content.Shared/Construction/SharedFlatpackSystem.cs index 6432f87e8e..c6f3e89744 100644 --- a/Content.Shared/Construction/SharedFlatpackSystem.cs +++ b/Content.Shared/Construction/SharedFlatpackSystem.cs @@ -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.