From 81e4668df3b09abc5fa5b58e0a43975ff62b637a Mon Sep 17 00:00:00 2001 From: Moony Date: Sun, 6 Aug 2023 13:39:48 -0500 Subject: [PATCH] Revert "Make power grid check event force APCs off (#17935)" (#18731) This reverts commit d21e4a1d4e6ad89e2baacd3e744c83278cc3b02c. --- .../PowerGridCheckDisabledComponent.cs | 11 --------- .../Events/PowerGridCheckRule.cs | 23 ++++--------------- 2 files changed, 5 insertions(+), 29 deletions(-) delete mode 100644 Content.Server/StationEvents/Components/PowerGridCheckDisabledComponent.cs diff --git a/Content.Server/StationEvents/Components/PowerGridCheckDisabledComponent.cs b/Content.Server/StationEvents/Components/PowerGridCheckDisabledComponent.cs deleted file mode 100644 index 90c6f2c22d..0000000000 --- a/Content.Server/StationEvents/Components/PowerGridCheckDisabledComponent.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Content.Server.StationEvents.Events; - -namespace Content.Server.StationEvents.Components; - -/// -/// Added to APCs to prevent them from turning on until event end -/// -[RegisterComponent, Access(typeof(PowerGridCheckRule))] -public sealed class PowerGridCheckDisabledComponent : Component -{ -} diff --git a/Content.Server/StationEvents/Events/PowerGridCheckRule.cs b/Content.Server/StationEvents/Events/PowerGridCheckRule.cs index acddc939c1..d24f04d800 100644 --- a/Content.Server/StationEvents/Events/PowerGridCheckRule.cs +++ b/Content.Server/StationEvents/Events/PowerGridCheckRule.cs @@ -6,7 +6,9 @@ using Robust.Shared.Utility; using System.Threading; using Content.Server.Power.EntitySystems; using Timer = Robust.Shared.Timing.Timer; +using System.Linq; using Content.Server.GameTicking.Rules.Components; +using Robust.Shared.Random; using Content.Server.Station.Components; using Content.Server.StationEvents.Components; @@ -17,13 +19,6 @@ namespace Content.Server.StationEvents.Events { [Dependency] private readonly ApcSystem _apcSystem = default!; - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnApcToggleMainBreaker); - } - protected override void Started(EntityUid uid, PowerGridCheckRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) { base.Started(uid, component, gameRule, args); @@ -31,11 +26,10 @@ namespace Content.Server.StationEvents.Events if (!TryGetRandomStation(out var chosenStation)) return; - var query = AllEntityQuery(); - while (query.MoveNext(out var target, out var apc, out var transform)) + foreach (var (apc, transform) in EntityQuery(true)) { if (apc.MainBreakerEnabled && CompOrNull(transform.GridUid)?.Station == chosenStation) - component.Powered.Add(target); + component.Powered.Add(apc.Owner); } RobustRandom.Shuffle(component.Powered); @@ -54,10 +48,9 @@ namespace Content.Server.StationEvents.Events if (TryComp(entity, out ApcComponent? apcComponent)) { - if (!apcComponent.MainBreakerEnabled) + if(!apcComponent.MainBreakerEnabled) _apcSystem.ApcToggleBreaker(entity, apcComponent); } - RemComp(entity); } // Can't use the default EndAudio @@ -95,14 +88,8 @@ namespace Content.Server.StationEvents.Events if (apcComponent.MainBreakerEnabled) _apcSystem.ApcToggleBreaker(selected, apcComponent); } - EnsureComp(selected); component.Unpowered.Add(selected); } } - - private void OnApcToggleMainBreaker(EntityUid uid, PowerGridCheckDisabledComponent component, ref ApcToggleMainBreakerAttemptEvent args) - { - args.Cancelled = true; - } } }