Files
tbd-station-14/Content.Server/Power/Components/PowerConsumerComponent.cs
Vera Aguilera Puerto ed3bf94a3b Electrocution. (#4958)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2021-10-25 16:21:56 +02:00

45 lines
1.4 KiB
C#

using Content.Server.Power.NodeGroups;
using Content.Server.Power.Pow3r;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.Power.Components
{
/// <summary>
/// Draws power directly from an MV or HV wire it is on top of.
/// </summary>
[RegisterComponent]
public class PowerConsumerComponent : BaseNetConnectorComponent<IBasePowerNet>
{
public override string Name => "PowerConsumer";
/// <summary>
/// How much power this needs to be fully powered.
/// </summary>
[DataField("drawRate")]
[ViewVariables(VVAccess.ReadWrite)]
public float DrawRate { get => NetworkLoad.DesiredPower; set => NetworkLoad.DesiredPower = value; }
/// <summary>
/// How much power this is currently receiving from <see cref="PowerSupplierComponent"/>s.
/// </summary>
[ViewVariables]
public float ReceivedPower => NetworkLoad.ReceivingPower;
public float LastReceived = float.NaN;
public PowerState.Load NetworkLoad { get; } = new();
protected override void AddSelfToNet(IBasePowerNet powerNet)
{
powerNet.AddConsumer(this);
}
protected override void RemoveSelfFromNet(IBasePowerNet powerNet)
{
powerNet.RemoveConsumer(this);
}
}
}