Files
tbd-station-14/Content.Server/GameObjects/Components/Power/PowerNetComponents/PowerSupplierComponent.cs
collinlunn b51b8cb182 Some Power nullable & ComponentDependency (#3050)
* Power nullability

* AME nullability

* re-adds EnsureComponents

* conflict fix

* Update Content.Server/GameObjects/Components/Power/PowerNetComponents/RadiationCollectorComponent.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>

* Update Content.Server/GameObjects/Components/Power/PowerNetComponents/BatteryStorageComponent.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>

* Update Content.Server/GameObjects/Components/Power/PowerNetComponents/BatteryStorageComponent.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>

* Update Content.Server/GameObjects/Components/Power/PowerNetComponents/BatteryDischargerComponent.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>

* Update Content.Server/GameObjects/Components/Power/PowerNetComponents/BatteryDischargerComponent.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>

* removes duplicate component assignment

Co-authored-by: py01 <pyronetics01@gmail.com>
Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
2021-02-01 17:19:43 +01:00

41 lines
1.2 KiB
C#

#nullable enable
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Power.PowerNetComponents
{
[RegisterComponent]
public class PowerSupplierComponent : BasePowerNetComponent
{
public override string Name => "PowerSupplier";
[ViewVariables(VVAccess.ReadWrite)]
public int SupplyRate { get => _supplyRate; set => SetSupplyRate(value); }
private int _supplyRate;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _supplyRate, "supplyRate", 0);
}
protected override void AddSelfToNet(IPowerNet powerNet)
{
powerNet.AddSupplier(this);
}
protected override void RemoveSelfFromNet(IPowerNet powerNet)
{
powerNet.RemoveSupplier(this);
}
private void SetSupplyRate(int newSupplyRate)
{
Net.UpdateSupplierSupply(this, SupplyRate, newSupplyRate);
_supplyRate = newSupplyRate;
}
}
}