Files
tbd-station-14/Content.Server/Power/Components/ApcComponent.cs
eoineoineoin 70b7747fdd Make APC UI work correctly with multiple users (#32465)
* Make APC UI work correctly with multiple users

* Check access only on client, when constructing UI

* Do TODO (Thanks, Robust 236.1)

---------

Co-authored-by: Eoin Mcloughlin <helloworld@eoinrul.es>
2024-10-12 19:21:43 +11:00

49 lines
1.4 KiB
C#

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;
[RegisterComponent]
public sealed partial class ApcComponent : BaseApcNetComponent
{
[DataField("onReceiveMessageSound")]
public SoundSpecifier OnReceiveMessageSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
public ApcChargeState LastChargeState;
public TimeSpan? LastChargeStateTime;
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>
public TimeSpan LastUiUpdate;
[DataField("enabled")]
public bool MainBreakerEnabled = true;
/// <summary>
/// APC state needs to always be updated after first processing tick.
/// </summary>
public bool NeedStateUpdate;
public const float HighPowerThreshold = 0.9f;
public static TimeSpan VisualsChangeDelay = TimeSpan.FromSeconds(1);
// TODO ECS power a little better!
// End the suffering
protected override void AddSelfToNet(IApcNet apcNet)
{
apcNet.AddApc(Owner, this);
}
protected override void RemoveSelfFromNet(IApcNet apcNet)
{
apcNet.RemoveApc(Owner, this);
}
}