diff --git a/Content.Server/StationEvents/Events/RandomEntityStorageSpawnRule.cs b/Content.Server/StationEvents/Events/RandomEntityStorageSpawnRule.cs index c3cd719cc4c..f8122ad7e3f 100644 --- a/Content.Server/StationEvents/Events/RandomEntityStorageSpawnRule.cs +++ b/Content.Server/StationEvents/Events/RandomEntityStorageSpawnRule.cs @@ -10,6 +10,7 @@ namespace Content.Server.StationEvents.Events; public sealed class RandomEntityStorageSpawnRule : StationEventSystem { [Dependency] private readonly EntityStorageSystem _entityStorage = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; protected override void Started(EntityUid uid, RandomEntityStorageSpawnRuleComponent comp, GameRuleComponent gameRule, GameRuleStartedEvent args) { @@ -18,8 +19,8 @@ protected override void Started(EntityUid uid, RandomEntityStorageSpawnRuleCompo if (!TryGetRandomStation(out var station)) return; - var validLockers = new List<(EntityUid, EntityStorageComponent)>(); var spawn = Spawn(comp.Prototype, MapCoordinates.Nullspace); + var validLockers = new List<(EntityUid, EntityStorageComponent, TransformComponent)>(); var query = EntityQueryEnumerator(); while (query.MoveNext(out var ent, out var storage, out var xform)) @@ -30,7 +31,7 @@ protected override void Started(EntityUid uid, RandomEntityStorageSpawnRuleCompo if (!_entityStorage.CanInsert(spawn, ent, storage)) continue; - validLockers.Add((ent, storage)); + validLockers.Add((ent, storage, xform)); } if (validLockers.Count == 0) @@ -39,7 +40,8 @@ protected override void Started(EntityUid uid, RandomEntityStorageSpawnRuleCompo return; } - var (locker, storageComp) = RobustRandom.Pick(validLockers); + var (locker, storageComp, lockerPos) = RobustRandom.Pick(validLockers); + _transform.SetCoordinates(spawn, lockerPos.Coordinates); if (!_entityStorage.Insert(spawn, locker, storageComp)) { Del(spawn);