2021-07-04 18:11:52 +02:00
|
|
|
using Content.Server.Power.NodeGroups;
|
|
|
|
|
using Content.Server.Power.Pow3r;
|
2020-06-28 09:23:26 -06:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Power.Components
|
2020-06-28 09:23:26 -06:00
|
|
|
{
|
2021-07-04 18:11:52 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Draws power directly from an MV or HV wire it is on top of.
|
|
|
|
|
/// </summary>
|
2020-06-28 09:23:26 -06:00
|
|
|
[RegisterComponent]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class PowerConsumerComponent : BaseNetConnectorComponent<IBasePowerNet>
|
2020-06-28 09:23:26 -06:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// How much power this needs to be fully powered.
|
|
|
|
|
/// </summary>
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("drawRate")]
|
2020-06-28 09:23:26 -06:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2021-07-04 18:11:52 +02:00
|
|
|
public float DrawRate { get => NetworkLoad.DesiredPower; set => NetworkLoad.DesiredPower = value; }
|
2020-06-28 09:23:26 -06:00
|
|
|
|
2023-05-31 00:34:45 +02:00
|
|
|
[DataField("showInMonitor")]
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
public bool ShowInMonitor { get; set; } = true;
|
|
|
|
|
|
2020-06-28 09:23:26 -06:00
|
|
|
/// <summary>
|
|
|
|
|
/// How much power this is currently receiving from <see cref="PowerSupplierComponent"/>s.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ViewVariables]
|
2021-07-04 18:11:52 +02:00
|
|
|
public float ReceivedPower => NetworkLoad.ReceivingPower;
|
|
|
|
|
|
|
|
|
|
public float LastReceived = float.NaN;
|
2020-06-28 09:23:26 -06:00
|
|
|
|
2021-07-04 18:11:52 +02:00
|
|
|
public PowerState.Load NetworkLoad { get; } = new();
|
2020-10-28 19:19:47 +01:00
|
|
|
|
2021-10-25 16:21:56 +02:00
|
|
|
protected override void AddSelfToNet(IBasePowerNet powerNet)
|
2020-06-28 09:23:26 -06:00
|
|
|
{
|
|
|
|
|
powerNet.AddConsumer(this);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-25 16:21:56 +02:00
|
|
|
protected override void RemoveSelfFromNet(IBasePowerNet powerNet)
|
2020-06-28 09:23:26 -06:00
|
|
|
{
|
|
|
|
|
powerNet.RemoveConsumer(this);
|
|
|
|
|
}
|
2020-10-28 19:19:47 +01:00
|
|
|
}
|
2020-06-28 09:23:26 -06:00
|
|
|
}
|