mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System.Linq;
|
|
using Content.Server.Station.Systems;
|
|
using Content.Shared.Construction.Components;
|
|
using Robust.Server.GameObjects;
|
|
|
|
namespace Content.Server.Construction;
|
|
|
|
public sealed partial class AnchorOnlyOnStationSystem : EntitySystem
|
|
{
|
|
[Dependency] private StationSystem _stationSystem = null!;
|
|
[Dependency] private TransformSystem _transform = null!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<GridSplitEvent>(OnGridSplit);
|
|
}
|
|
|
|
private void OnGridSplit(ref GridSplitEvent args)
|
|
{
|
|
var allGrids = args.NewGrids.ToList();
|
|
|
|
var query = AllEntityQuery<AnchorOnlyOnStationComponent, TransformComponent>();
|
|
while (query.MoveNext(out var ent, out var anchorOnlyOnStationComp, out var entXform))
|
|
{
|
|
if (entXform.GridUid == null)
|
|
continue;
|
|
|
|
if (!allGrids.Contains(entXform.GridUid.Value))
|
|
continue;
|
|
|
|
if (_stationSystem.IsOnStation(ent, anchorOnlyOnStationComp.OnlyCountLargestGrid))
|
|
continue;
|
|
|
|
_transform.Unanchor(ent, entXform);
|
|
}
|
|
}
|
|
}
|