CatStation/Content.Server/Construction/AnchorOnlyOnStationSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* 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
2026-05-09 03:29:58 +00:00

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