using Robust.Shared.Serialization; namespace Content.Shared.APC; /// /// AppearanceData keys for APC data. /// [Serializable, NetSerializable] public enum ApcVisuals : byte { /// /// APC channel state. /// Contains an . /// ChannelState, /// /// APC lights/HUD. /// Contains an . /// ChargeState, } /// /// Sprite layers for APC visuals. /// public enum ApcVisualLayers : byte { /// /// Layer used for the status light for the channel. /// "Is power going out of the device? Is the breaker tripped?" /// Equipment, /// /// The sprite layer used for the APC screen overlay. /// "How much energy is contained in the device?" /// ChargeState, } /// /// APC power channel states. /// Is the APC delivering power currently? /// /// [Serializable, NetSerializable] public enum ApcChannelState : byte { /// /// The APC is operating normally, and is currently not delivering power. /// Off = 0, /// /// The APC is operating normally, and is delivering power to the network. /// On = 1, /// /// The APC's breaker has been opened manually, and cannot deliver power. /// BreakerOpen = 2, /// /// The APC's breaker has been tripped, and cannot deliver power. /// BreakerTripped = 3, /// /// The total number of states to show. /// NumStates = 4, } /// /// APC charge states. /// How much energy is the APC holding? /// /// [Serializable, NetSerializable] public enum ApcChargeState : byte { /// /// APC does not have enough power to charge cell (if necessary) and keep powering the area. /// Lack = 0, /// /// APC is not full but has enough power. /// Charging = 1, /// /// APC battery is full and has enough power. /// Full = 2, /// /// APC is being remotely accessed. /// Currently unimplemented, though the corresponding sprite state exists in the RSI. /// Remote = 3, /// /// The APC's breaker has been tripped. /// Tripped = 4, /// /// The number of valid states charge states the APC can be in. /// NumStates = 5, /// /// APC is emagged (and not displaying other useful power colors at a glance) /// Emag = byte.MaxValue, } /// /// The state of an APC BUI. /// Contains the details of the charge, breaker, and power delivery for a given APC. /// [Serializable, NetSerializable] public sealed class ApcBoundInterfaceState(bool mainBreaker, int power, ApcExternalPowerState apcExternalPower, float charge, float maxLoad, bool tripped) : BoundUserInterfaceState, IEquatable { /// /// If true, the breaker is active, and the APC can deliver power. /// public readonly bool MainBreaker = mainBreaker; /// /// The current amount of power being delivered, in Watts. /// public readonly int Power = power; /// /// The approximate amount of energy contained within the APC. /// public readonly ApcExternalPowerState ApcExternalPower = apcExternalPower; /// /// The energy remaining in the APC, in Joules /// public readonly float Charge = charge; /// /// The maximum allowable load of the APC, in Watts. /// public readonly float MaxLoad = maxLoad; /// /// Whether or not the breaker has been tripped. /// public readonly bool Tripped = tripped; /// public bool Equals(ApcBoundInterfaceState? other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return MainBreaker == other.MainBreaker && Power == other.Power && ApcExternalPower == other.ApcExternalPower && MathHelper.CloseTo(Charge, other.Charge) && MathHelper.CloseTo(MaxLoad, other.MaxLoad) && Tripped == other.Tripped; } /// public override bool Equals(object? obj) { return ReferenceEquals(this, obj) || obj is ApcBoundInterfaceState other && Equals(other); } /// public override int GetHashCode() { return HashCode.Combine(MainBreaker, Power, (int)ApcExternalPower, Charge, MaxLoad, Tripped); } } /// /// A request to toggle the main breaker of an APC. /// [Serializable, NetSerializable] public sealed class ApcToggleMainBreakerMessage : BoundUserInterfaceMessage; /// /// The amount of energy stored on the APC. /// Used as a traffic light state in BUI states. /// public enum ApcExternalPowerState : byte { None, Low, Good, } /// /// UI keys for the APC. /// [NetSerializable, Serializable] public enum ApcUiKey : byte { Key, }