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
This commit is contained in:
metalgearsloth
2024-02-02 00:39:43 +11:00
committed by GitHub
parent d4185144dd
commit 52808694e0
6 changed files with 21 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ using Content.Shared.Anomaly.Effects;
using Content.Shared.Anomaly.Effects.Components; using Content.Shared.Anomaly.Effects.Components;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Map.Components; using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Components;
using Robust.Shared.Random; using Robust.Shared.Random;
namespace Content.Server.Anomaly.Effects; namespace Content.Server.Anomaly.Effects;
@@ -13,10 +14,15 @@ public sealed class EntityAnomalySystem : SharedEntityAnomalySystem
[Dependency] private readonly SharedAnomalySystem _anomaly = default!; [Dependency] private readonly SharedAnomalySystem _anomaly = default!;
[Dependency] private readonly IMapManager _map = default!; [Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
private EntityQuery<PhysicsComponent> _physicsQuery;
/// <inheritdoc/> /// <inheritdoc/>
public override void Initialize() public override void Initialize()
{ {
_physicsQuery = GetEntityQuery<PhysicsComponent>();
SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalyPulseEvent>(OnPulse); SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalyPulseEvent>(OnPulse);
SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalySupercriticalEvent>(OnSupercritical); SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalySupercriticalEvent>(OnSupercritical);
SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalyStabilityChangedEvent>(OnStabilityChanged); 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) private void SpawnEntities(Entity<EntitySpawnAnomalyComponent> anomaly, EntitySpawnSettingsEntry entry, float stability, float severity)
{ {
var xform = Transform(anomaly); var xform = Transform(anomaly);
if (!TryComp<MapGridComponent>(xform.GridUid, out var grid)) if (!TryComp(xform.GridUid, out MapGridComponent? grid))
return; return;
var tiles = _anomaly.GetSpawningPoints(anomaly, stability, severity, entry.Settings); var tiles = _anomaly.GetSpawningPoints(anomaly, stability, severity, entry.Settings);
@@ -91,7 +97,7 @@ public sealed class EntityAnomalySystem : SharedEntityAnomalySystem
foreach (var tileref in tiles) 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));
} }
} }
} }

View File

@@ -100,7 +100,7 @@ namespace Content.Server.Atmos.EntitySystems
{ {
if(_spaceWindSoundCooldown == 0 && !string.IsNullOrEmpty(SpaceWindSound)) 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))); _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, gridAtmosphere.Comp.UpdateCounter,
tile.PressureDifference, tile.PressureDifference,
tile.PressureDirection, 0, 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, gridWorldRotation,
xforms.GetComponent(entity), xforms.GetComponent(entity),
body); body);

View File

@@ -11,8 +11,6 @@ namespace Content.Server.Atmos.EntitySystems
{ {
public sealed partial class AtmosphereSystem public sealed partial class AtmosphereSystem
{ {
[Dependency] private readonly EntityLookupSystem _lookup = default!;
private const int HotspotSoundCooldownCycles = 200; private const int HotspotSoundCooldownCycles = 200;
private int _hotspotSoundCooldown = 0; private int _hotspotSoundCooldown = 0;
@@ -81,7 +79,8 @@ namespace Content.Server.Atmos.EntitySystems
if (_hotspotSoundCooldown++ == 0 && !string.IsNullOrEmpty(HotspotSound)) 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. // 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 lesser the pitch variation.
// The greater the fire state, the greater the volume. // The greater the fire state, the greater the volume.

View File

@@ -25,12 +25,14 @@ public sealed partial class AtmosphereSystem : SharedAtmosphereSystem
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly IAdminLogManager _adminLog = default!; [Dependency] private readonly IAdminLogManager _adminLog = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly InternalsSystem _internals = default!; [Dependency] private readonly InternalsSystem _internals = default!;
[Dependency] private readonly SharedContainerSystem _containers = default!; [Dependency] private readonly SharedContainerSystem _containers = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly GasTileOverlaySystem _gasTileOverlaySystem = default!; [Dependency] private readonly GasTileOverlaySystem _gasTileOverlaySystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = 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 TileSystem _tile = default!;
[Dependency] private readonly MapSystem _map = default!; [Dependency] private readonly MapSystem _map = default!;
[Dependency] public readonly PuddleSystem Puddle = default!; [Dependency] public readonly PuddleSystem Puddle = default!;

View File

@@ -377,9 +377,9 @@ public abstract class SharedAnomalySystem : EntitySystem
var physQuery = GetEntityQuery<PhysicsComponent>(); var physQuery = GetEntityQuery<PhysicsComponent>();
var resultList = new List<TileRef>(); var resultList = new List<TileRef>();
while (resultList.Count() < amount) while (resultList.Count < amount)
{ {
if (tilerefs.Count() == 0) if (tilerefs.Count == 0)
break; break;
var tileref = _random.Pick(tilerefs); var tileref = _random.Pick(tilerefs);
@@ -414,6 +414,7 @@ public abstract class SharedAnomalySystem : EntitySystem
continue; continue;
} }
} }
resultList.Add(tileref); resultList.Add(tileref);
} }
return resultList; return resultList;

View File

@@ -67,8 +67,9 @@ public abstract class SharedFlatpackSystem : EntitySystem
} }
var buildPos = _map.TileIndicesFor(grid, gridComp, xform.Coordinates); var buildPos = _map.TileIndicesFor(grid, gridComp, xform.Coordinates);
var intersecting = _entityLookup.GetEntitiesIntersecting(buildPos.ToEntityCoordinates(grid, _mapManager).Offset(new Vector2(0.5f, 0.5f)) var coords = _map.ToCenterCoordinates(grid, buildPos);
, LookupFlags.Dynamic | LookupFlags.Static);
var intersecting = _entityLookup.GetEntitiesIntersecting(coords, LookupFlags.Dynamic | LookupFlags.Static);
// todo make this logic smarter. // todo make this logic smarter.
// This should eventually allow for shit like building microwaves on tables and such. // This should eventually allow for shit like building microwaves on tables and such.