using Content.Server.DeviceLinking.Systems;
using Content.Shared.DeviceLinking;
using Content.Shared.Power.Generator;
using Content.Shared.Tools;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Server.DeviceLinking.Components;
///
/// A power sensor checks the power network it's anchored to.
/// Has 2 ports for when it is charging or discharging. They should never both be high.
/// Requires to function.
///
[RegisterComponent, Access(typeof(PowerSensorSystem))]
public sealed partial class PowerSensorComponent : Component
{
///
/// Whether to check the power network's input or output battery stats.
/// Useful when working with SMESes where input and output can both be important.
/// Or with APCs where there is no output and only input.
///
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool Output;
///
/// Tool quality to use for switching between input and output.
/// Cannot be pulsing since linking uses that.
///
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId SwitchQuality = "Screwing";
///
/// Sound played when switching between input and output.
///
[DataField]
public SoundSpecifier SwitchSound = new SoundPathSpecifier("/Audio/Machines/lightswitch.ogg");
///
/// Name of the port set when the network is charging power.
///
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId ChargingPort = "PowerCharging";
///
/// Name of the port set when the network is discharging power.
///
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId DischargingPort = "PowerDischarging";
///
/// How long to wait before checking the power network.
///
[DataField, ViewVariables(VVAccess.ReadWrite)]
public TimeSpan CheckDelay = TimeSpan.FromSeconds(1);
///
/// Time at which power will be checked.
///
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan NextCheck = TimeSpan.Zero;
///
/// Charge the network was at, at the last check.
/// Charging/discharging is derived from this.
///
[DataField]
public float LastCharge;
// Initial state
[DataField]
public bool ChargingState;
[DataField]
public bool DischargingState;
}