using Content.Server._White.StationEvents.Components; using Content.Server.Antag; using Content.Server.StationEvents.Components; using Content.Server.StationEvents.Events; using Content.Shared.GameTicking.Components; using Content.Shared.Station.Components; using Robust.Shared.Map; namespace Content.Server._White.StationEvents.Events; public sealed class VentSpawnRule : StationEventSystem { [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnSelectLocation); } protected override void Added(EntityUid uid, VentSpawnRuleComponent component, GameRuleComponent gameRule, GameRuleAddedEvent args) { base.Added(uid, component, gameRule, args); if (!TryGetRandomStation(out var station)) { ForceEndSelf(uid, gameRule); return; } var locations = EntityQueryEnumerator(); var validLocations = new List(); while (locations.MoveNext(out _, out _, out var transform)) { if (CompOrNull(transform.GridUid)?.Station != station) continue; validLocations.Add(_transform.GetMapCoordinates(transform)); } if (validLocations.Count == 0) { ForceEndSelf(uid, gameRule); return; } component.Coords = validLocations; } private void OnSelectLocation(Entity ent, ref AntagSelectLocationEvent args) { if (ent.Comp.Coords is {} coords) args.Coordinates.AddRange(coords); } }