Revert "Make power grid check event force APCs off (#17935)" (#18731)

This reverts commit d21e4a1d4e.
This commit is contained in:
Moony
2023-08-06 13:39:48 -05:00
committed by GitHub
parent 146cda19c5
commit 81e4668df3
2 changed files with 5 additions and 29 deletions

View File

@@ -1,11 +0,0 @@
using Content.Server.StationEvents.Events;
namespace Content.Server.StationEvents.Components;
/// <summary>
/// Added to APCs to prevent them from turning on until event end
/// </summary>
[RegisterComponent, Access(typeof(PowerGridCheckRule))]
public sealed class PowerGridCheckDisabledComponent : Component
{
}

View File

@@ -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<PowerGridCheckDisabledComponent, ApcToggleMainBreakerAttemptEvent>(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<ApcComponent, TransformComponent>();
while (query.MoveNext(out var target, out var apc, out var transform))
foreach (var (apc, transform) in EntityQuery<ApcComponent, TransformComponent>(true))
{
if (apc.MainBreakerEnabled && CompOrNull<StationMemberComponent>(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<PowerGridCheckDisabledComponent>(entity);
}
// Can't use the default EndAudio
@@ -95,14 +88,8 @@ namespace Content.Server.StationEvents.Events
if (apcComponent.MainBreakerEnabled)
_apcSystem.ApcToggleBreaker(selected, apcComponent);
}
EnsureComp<PowerGridCheckDisabledComponent>(selected);
component.Unpowered.Add(selected);
}
}
private void OnApcToggleMainBreaker(EntityUid uid, PowerGridCheckDisabledComponent component, ref ApcToggleMainBreakerAttemptEvent args)
{
args.Cancelled = true;
}
}
}