Re-organize all projects (#4166)
This commit is contained in:
35
Content.Server/Power/Components/PowerSupplierComponent.cs
Normal file
35
Content.Server/Power/Components/PowerSupplierComponent.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
#nullable enable
|
||||
using Content.Server.NodeContainer.NodeGroups;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Power.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class PowerSupplierComponent : BasePowerNetComponent
|
||||
{
|
||||
public override string Name => "PowerSupplier";
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public int SupplyRate { get => _supplyRate; set => SetSupplyRate(value); }
|
||||
[DataField("supplyRate")]
|
||||
private int _supplyRate;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user