using System.Threading;
using Content.Server.StationEvents.Events;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
namespace Content.Server.StationEvents.Components;
[RegisterComponent, Access(typeof(PowerGridCheckRule))]
public sealed partial class PowerGridCheckRuleComponent : Component
{
///
/// Default sound for power restoration announcement.
///
private static readonly ProtoId DefaultPowerOn = new("PowerOn");
///
/// Sound to play when power is restored.
///
[DataField]
public SoundSpecifier PowerOnSound = new SoundCollectionSpecifier(DefaultPowerOn, AudioParams.Default.WithVolume(-4f));
///
/// Token source for cancelling the power restoration announcement.
///
public CancellationTokenSource? AnnounceCancelToken;
///
/// Station affected by the power grid event.
///
[DataField]
public EntityUid AffectedStation;
///
/// List of APC entities that will be sequentially turned off during the event.
///
[DataField]
public List Powered = new();
///
/// List of APC entities that have been turned off.
///
[DataField]
public List Unpowered = new();
///
/// Time delay in seconds before starting to turn off APCs.
///
[DataField]
public float SecondsUntilOff = 30.0f;
///
/// Number of APC toggles to process per second during the shutdown phase.
/// Dynamically calculated based on total APC count and .
///
public int NumberPerSecond = 0;
///
/// Computed time interval between APC toggles.
///
public float UpdateRate => 1.0f / NumberPerSecond;
///
/// Accumulated frame time to track when to process the next APC toggle.
///
[DataField]
public float FrameTimeAccumulator = 0.0f;
}