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 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));
}
}
}