Pow3r: stage 1 (#4208)

Co-authored-by: 20kdc <asdd2808@gmail.com>
This commit is contained in:
Pieter-Jan Briers
2021-07-04 18:11:52 +02:00
committed by GitHub
parent ea60a81fdf
commit 103bc19508
212 changed files with 8584 additions and 4426 deletions

View File

@@ -1,5 +1,6 @@
#nullable enable
using Content.Server.NodeContainer.NodeGroups;
using Content.Server.Power.NodeGroups;
using Content.Server.Power.Pow3r;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -12,9 +13,45 @@ namespace Content.Server.Power.Components
public override string Name => "PowerSupplier";
[ViewVariables(VVAccess.ReadWrite)]
public int SupplyRate { get => _supplyRate; set => SetSupplyRate(value); }
[DataField("supplyRate")]
private int _supplyRate;
public float MaxSupply { get => NetworkSupply.MaxSupply; set => NetworkSupply.MaxSupply = value; }
[ViewVariables(VVAccess.ReadWrite)]
[DataField("supplyRampTolerance")]
public float SupplyRampTolerance
{
get => NetworkSupply.SupplyRampTolerance;
set => NetworkSupply.SupplyRampTolerance = value;
}
[ViewVariables(VVAccess.ReadWrite)]
[DataField("supplyRampRate")]
public float SupplyRampRate
{
get => NetworkSupply.SupplyRampRate;
set => NetworkSupply.SupplyRampRate = value;
}
[ViewVariables(VVAccess.ReadWrite)]
[DataField("supplyRampPosition")]
public float SupplyRampPosition
{
get => NetworkSupply.SupplyRampPosition;
set => NetworkSupply.SupplyRampPosition = value;
}
[ViewVariables(VVAccess.ReadWrite)]
[DataField("enabled")]
public bool Enabled
{
get => NetworkSupply.Enabled;
set => NetworkSupply.Enabled = value;
}
[ViewVariables] public float CurrentSupply => NetworkSupply.CurrentSupply;
[ViewVariables]
public PowerState.Supply NetworkSupply { get; } = new();
protected override void AddSelfToNet(IPowerNet powerNet)
{
@@ -25,11 +62,5 @@ namespace Content.Server.Power.Components
{
powerNet.RemoveSupplier(this);
}
private void SetSupplyRate(int newSupplyRate)
{
Net.UpdateSupplierSupply(this, SupplyRate, newSupplyRate);
_supplyRate = newSupplyRate;
}
}
}