Files
crystall-punk-14/Content.Server/Power/Components/ApcComponent.cs

49 lines
1.4 KiB
C#
Raw Permalink Normal View History

using Content.Server.Power.NodeGroups;
2021-06-09 22:19:39 +02:00
using Content.Shared.APC;
2022-07-29 14:13:12 +12:00
using Robust.Shared.Audio;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
2022-01-15 11:32:46 -07:00
namespace Content.Server.Power.Components;
2022-01-15 11:32:46 -07:00
[RegisterComponent]
public sealed partial class ApcComponent : BaseApcNetComponent
2022-01-15 11:32:46 -07:00
{
[DataField("onReceiveMessageSound")]
public SoundSpecifier OnReceiveMessageSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
2022-01-15 11:32:46 -07:00
public ApcChargeState LastChargeState;
public TimeSpan? LastChargeStateTime;
2022-01-15 11:32:46 -07:00
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>
2022-01-15 11:32:46 -07:00
public TimeSpan LastUiUpdate;
[DataField("enabled")]
2022-01-15 11:32:46 -07:00
public bool MainBreakerEnabled = true;
/// <summary>
/// APC state needs to always be updated after first processing tick.
/// </summary>
public bool NeedStateUpdate;
2022-01-15 11:32:46 -07:00
public const float HighPowerThreshold = 0.9f;
public static TimeSpan VisualsChangeDelay = TimeSpan.FromSeconds(1);
2022-01-15 11:32:46 -07:00
// TODO ECS power a little better!
// End the suffering
2022-01-15 11:32:46 -07:00
protected override void AddSelfToNet(IApcNet apcNet)
{
apcNet.AddApc(Owner, this);
2022-01-15 11:32:46 -07:00
}
2022-01-15 11:32:46 -07:00
protected override void RemoveSelfFromNet(IApcNet apcNet)
{
apcNet.RemoveApc(Owner, this);
}
}