Files
OldThink/Content.Server/Power/Components/ApcComponent.cs

51 lines
1.7 KiB
C#
Raw 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");
[DataField("lastChargeState")]
2022-01-15 11:32:46 -07:00
public ApcChargeState LastChargeState;
[DataField("lastChargeStateTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
2022-01-15 11:32:46 -07:00
public TimeSpan LastChargeStateTime;
[DataField("lastExternalState")]
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>
[DataField("lastUiUpdate", customTypeSerializer: typeof(TimeOffsetSerializer))]
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;
// TODO: remove this since it probably breaks when 2 people use it
[DataField("hasAccess")]
public bool HasAccess = false;
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);
}
}