2021-07-04 18:11:52 +02:00
|
|
|
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;
|
2023-09-05 22:19:43 +01:00
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
2020-06-28 09:23:26 -06:00
|
|
|
|
2022-01-15 11:32:46 -07:00
|
|
|
namespace Content.Server.Power.Components;
|
2020-06-28 09:23:26 -06:00
|
|
|
|
2022-01-15 11:32:46 -07:00
|
|
|
[RegisterComponent]
|
2023-08-22 18:14:33 -07:00
|
|
|
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");
|
2020-06-28 09:23:26 -06:00
|
|
|
|
2023-09-05 22:19:43 +01:00
|
|
|
[DataField("lastChargeState")]
|
2022-01-15 11:32:46 -07:00
|
|
|
public ApcChargeState LastChargeState;
|
2023-09-05 22:19:43 +01:00
|
|
|
[DataField("lastChargeStateTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
|
2022-01-15 11:32:46 -07:00
|
|
|
public TimeSpan LastChargeStateTime;
|
2021-02-01 10:19:43 -06:00
|
|
|
|
2023-09-05 22:19:43 +01:00
|
|
|
[DataField("lastExternalState")]
|
2022-01-15 11:32:46 -07:00
|
|
|
public ApcExternalPowerState LastExternalState;
|
2023-09-05 22:19:43 +01:00
|
|
|
|
|
|
|
|
/// <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;
|
2021-07-04 18:11:52 +02:00
|
|
|
|
2023-09-05 22:19:43 +01:00
|
|
|
[DataField("enabled")]
|
2022-01-15 11:32:46 -07:00
|
|
|
public bool MainBreakerEnabled = true;
|
2023-09-05 22:19:43 +01:00
|
|
|
// TODO: remove this since it probably breaks when 2 people use it
|
|
|
|
|
[DataField("hasAccess")]
|
2023-03-07 09:55:35 +08:00
|
|
|
public bool HasAccess = false;
|
2021-07-04 18:11:52 +02:00
|
|
|
|
2022-01-15 11:32:46 -07:00
|
|
|
public const float HighPowerThreshold = 0.9f;
|
|
|
|
|
public static TimeSpan VisualsChangeDelay = TimeSpan.FromSeconds(1);
|
2020-06-28 09:23:26 -06:00
|
|
|
|
2022-01-15 11:32:46 -07:00
|
|
|
// TODO ECS power a little better!
|
2023-09-20 00:44:49 +12:00
|
|
|
// End the suffering
|
2022-01-15 11:32:46 -07:00
|
|
|
protected override void AddSelfToNet(IApcNet apcNet)
|
|
|
|
|
{
|
2023-09-20 00:44:49 +12:00
|
|
|
apcNet.AddApc(Owner, this);
|
2022-01-15 11:32:46 -07:00
|
|
|
}
|
2020-08-22 22:29:20 +02:00
|
|
|
|
2022-01-15 11:32:46 -07:00
|
|
|
protected override void RemoveSelfFromNet(IApcNet apcNet)
|
|
|
|
|
{
|
2023-09-20 00:44:49 +12:00
|
|
|
apcNet.RemoveApc(Owner, this);
|
2020-06-28 09:23:26 -06:00
|
|
|
}
|
|
|
|
|
}
|