Clean up APCs (#19841)

While here, fix an issue where APCs don't update the UI state after a load change.
This commit is contained in:
deltanedas
2023-09-05 22:19:43 +01:00
committed by GitHub
parent 8437038fd4
commit f2669b5771
2 changed files with 194 additions and 181 deletions

View File

@@ -1,6 +1,7 @@
using Content.Server.Power.NodeGroups;
using Content.Shared.APC;
using Robust.Shared.Audio;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Server.Power.Components;
@@ -10,16 +11,26 @@ public sealed partial class ApcComponent : BaseApcNetComponent
[DataField("onReceiveMessageSound")]
public SoundSpecifier OnReceiveMessageSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
[ViewVariables]
[DataField("lastChargeState")]
public ApcChargeState LastChargeState;
[DataField("lastChargeStateTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan LastChargeStateTime;
[ViewVariables]
[DataField("lastExternalState")]
public ApcExternalPowerState LastExternalState;
/// <summary>
/// Time the ui was last updated automatically.
/// Done after every <see cref="VisualsChangeDelay"/> to show the latest load.
/// If charge state changes it will be instantly updated.
/// </summary>
[DataField("lastUiUpdate", customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan LastUiUpdate;
[ViewVariables]
[DataField("enabled")]
public bool MainBreakerEnabled = true;
// TODO: remove this since it probably breaks when 2 people use it
[DataField("hasAccess")]
public bool HasAccess = false;
public const float HighPowerThreshold = 0.9f;