VV support.

This commit is contained in:
PJB3005
2018-09-09 15:34:43 +02:00
parent 06ea07eca5
commit 1dabe49234
24 changed files with 91 additions and 9 deletions

View File

@@ -9,6 +9,7 @@ using SS14.Shared.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using SS14.Shared.ViewVariables;
using YamlDotNet.RepresentationModel;
namespace Content.Server.GameObjects.Components.Power
@@ -23,6 +24,7 @@ namespace Content.Server.GameObjects.Components.Power
/// <summary>
/// The method of draw we will try to use to place our load set via component parameter, defaults to using power providers
/// </summary>
[ViewVariables]
public virtual DrawTypes DrawType
{
get => _drawType;
@@ -33,14 +35,17 @@ namespace Content.Server.GameObjects.Components.Power
/// <summary>
/// The power draw method we are currently connected to and using
/// </summary>
[ViewVariables]
public DrawTypes Connected { get; protected set; } = DrawTypes.None;
[ViewVariables]
public bool Powered { get; private set; } = false;
/// <summary>
/// Is an external power source currently available?
/// </summary>
[ViewVariables]
public bool ExternalPowered
{
get => _externalPowered;
@@ -55,6 +60,7 @@ namespace Content.Server.GameObjects.Components.Power
/// <summary>
/// Is an internal power source currently available?
/// </summary>
[ViewVariables]
public bool InternalPowered
{
get => _internalPowered;
@@ -69,6 +75,7 @@ namespace Content.Server.GameObjects.Components.Power
/// <summary>
/// Priority for powernet draw, lower will draw first, defined in powernet.cs
/// </summary>
[ViewVariables]
public virtual Powernet.Priority Priority
{
get => _priority;
@@ -81,6 +88,7 @@ namespace Content.Server.GameObjects.Components.Power
/// Power load from this entity.
/// In Watts.
/// </summary>
[ViewVariables]
public float Load
{
get => _load;
@@ -98,6 +106,7 @@ namespace Content.Server.GameObjects.Components.Power
/// <summary>
/// A power provider that will handle our load, if we are linked to any
/// </summary>
[ViewVariables]
public PowerProviderComponent Provider
{
get => _provider;

View File

@@ -5,6 +5,7 @@ using SS14.Shared.Log;
using SS14.Shared.Serialization;
using SS14.Shared.Utility;
using System;
using SS14.Shared.ViewVariables;
using YamlDotNet.RepresentationModel;
namespace Content.Server.GameObjects.Components.Power
@@ -20,6 +21,7 @@ namespace Content.Server.GameObjects.Components.Power
/// Power supply from this entity
/// </summary>
private float _supply = 1000; //arbitrary initial magic number to start
[ViewVariables]
public float Supply
{
get => _supply;

View File

@@ -5,6 +5,7 @@ using SS14.Shared.Interfaces.GameObjects.Components;
using SS14.Shared.IoC;
using System;
using System.Linq;
using SS14.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Power
{
@@ -18,7 +19,8 @@ namespace Content.Server.GameObjects.Components.Power
/// <summary>
/// The powernet this node is connected to
/// </summary>
public Powernet Parent;
[ViewVariables]
public Powernet Parent { get; set; }
/// <summary>
/// An event handling when this node connects to a powernet

View File

@@ -9,6 +9,7 @@ using SS14.Shared.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using SS14.Shared.ViewVariables;
using YamlDotNet.RepresentationModel;
namespace Content.Server.GameObjects.Components.Power
@@ -26,6 +27,7 @@ namespace Content.Server.GameObjects.Components.Power
/// <summary>
/// Variable that determines the range that the power provider will try to supply power to
/// </summary>
[ViewVariables]
public int PowerRange
{
get => _range;
@@ -51,6 +53,7 @@ namespace Content.Server.GameObjects.Components.Power
private bool _mainBreaker = true;
[ViewVariables(VVAccess.ReadWrite)]
public bool MainBreaker
{
get => _mainBreaker;
@@ -76,6 +79,7 @@ namespace Content.Server.GameObjects.Components.Power
private float _theoreticalLoad = 0f;
[ViewVariables]
public float TheoreticalLoad
{
get => _theoreticalLoad;

View File

@@ -5,6 +5,7 @@ using SS14.Shared.IoC;
using SS14.Shared.Serialization;
using SS14.Shared.Utility;
using System;
using SS14.Shared.ViewVariables;
using YamlDotNet.RepresentationModel;
namespace Content.Server.GameObjects.Components.Power
@@ -23,6 +24,7 @@ namespace Content.Server.GameObjects.Components.Power
/// Maximum amount of energy the internal battery can store.
/// In Joules.
/// </summary>
[ViewVariables]
public float Capacity => _capacity;
private float _capacity = 10000; // Arbitrary value, replace.
@@ -30,6 +32,7 @@ namespace Content.Server.GameObjects.Components.Power
/// Energy the battery is currently storing.
/// In Joules.
/// </summary>
[ViewVariables]
public float Charge => _charge;
private float _charge = 0;
@@ -37,6 +40,7 @@ namespace Content.Server.GameObjects.Components.Power
/// Rate at which energy will be taken to charge internal battery.
/// In Watts.
/// </summary>
[ViewVariables]
public float ChargeRate => _chargeRate;
private float _chargeRate = 1000;
@@ -44,9 +48,11 @@ namespace Content.Server.GameObjects.Components.Power
/// Rate at which energy will be distributed to the powernet if needed.
/// In Watts.
/// </summary>
[ViewVariables]
public float DistributionRate => _distributionRate;
private float _distributionRate = 1000;
[ViewVariables]
public bool Full => Charge >= Capacity;
private bool _chargepowernet = false;
@@ -54,6 +60,7 @@ namespace Content.Server.GameObjects.Components.Power
/// <summary>
/// Do we distribute power into the powernet from our stores if the powernet requires it?
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public bool ChargePowernet
{
get => _chargepowernet;

View File

@@ -7,6 +7,7 @@ using System.Linq;
using SS14.Shared.Interfaces.GameObjects;
using Content.Server.GameObjects.Components.Interactable.Tools;
using SS14.Shared.Interfaces.GameObjects.Components;
using SS14.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Power
{
@@ -20,8 +21,10 @@ namespace Content.Server.GameObjects.Components.Power
/// <summary>
/// The powernet this component is connected to
/// </summary>
public Powernet Parent;
[ViewVariables]
public Powernet Parent { get; set; }
[ViewVariables]
public bool Regenerating { get; set; } = false;
public override void Initialize()

View File

@@ -4,6 +4,7 @@ using SS14.Shared.IoC;
using SS14.Shared.Log;
using System;
using System.Collections.Generic;
using SS14.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Power
{
@@ -23,6 +24,7 @@ namespace Content.Server.GameObjects.Components.Power
/// <summary>
/// Unique identifier per powernet, used for debugging mostly.
/// </summary>
[ViewVariables]
public int Uid { get; }
/// <summary>
@@ -41,6 +43,7 @@ namespace Content.Server.GameObjects.Components.Power
private readonly Dictionary<PowerGeneratorComponent, float> GeneratorList =
new Dictionary<PowerGeneratorComponent, float>();
[ViewVariables]
public int GeneratorCount => GeneratorList.Count;
/// <summary>
@@ -49,6 +52,7 @@ namespace Content.Server.GameObjects.Components.Power
private readonly SortedSet<PowerDeviceComponent> DeviceLoadList =
new SortedSet<PowerDeviceComponent>(new DevicePriorityCompare());
[ViewVariables]
public int DeviceCount => DeviceLoadList.Count;
/// <summary>
@@ -61,6 +65,7 @@ namespace Content.Server.GameObjects.Components.Power
/// </summary>
private readonly List<PowerStorageComponent> PowerStorageSupplierList = new List<PowerStorageComponent>();
[ViewVariables]
public int PowerStorageSupplierCount => PowerStorageSupplierList.Count;
/// <summary>
@@ -68,23 +73,27 @@ namespace Content.Server.GameObjects.Components.Power
/// </summary>
private readonly List<PowerStorageComponent> PowerStorageConsumerList = new List<PowerStorageComponent>();
[ViewVariables]
public int PowerStorageConsumerCount => PowerStorageConsumerList.Count;
/// <summary>
/// Static counter of all continuous load placed from devices on this power network.
/// In Watts.
/// </summary>
[ViewVariables]
public float Load { get; private set; } = 0;
/// <summary>
/// Static counter of all continuous supply from generators on this power network.
/// In Watts.
/// </summary>
[ViewVariables]
public float Supply { get; private set; } = 0;
/// <summary>
/// Variable that causes powernet to be regenerated from its wires during the next update cycle.
/// </summary>
[ViewVariables]
public bool Dirty { get; set; } = false;
// These are stats for power monitoring equipment such as APCs.
@@ -93,6 +102,7 @@ namespace Content.Server.GameObjects.Components.Power
/// The total supply that was available to us last tick.
/// This does not mean it was used.
/// </summary>
[ViewVariables]
public float LastTotalAvailable { get; private set; }
/// <summary>
@@ -102,6 +112,7 @@ namespace Content.Server.GameObjects.Components.Power
/// If avail &lt; demand, this will be just &lt;= than the actual avail
/// (e.g. if all machines need 100 W but there's 20 W excess, the 20 W will be avail but not drawn.)
/// </summary>
[ViewVariables]
public float LastTotalDraw { get; private set; }
/// <summary>
@@ -111,6 +122,7 @@ namespace Content.Server.GameObjects.Components.Power
/// As such, this will quite abruptly shoot up if available rises to cover supplier charge demand too.
/// </summary>
/// <seealso cref="LastTotalDemandWithSuppliers"/>
[ViewVariables]
public float LastTotalDemand { get; private set; }
/// <summary>
@@ -118,11 +130,13 @@ namespace Content.Server.GameObjects.Components.Power
/// This does not mean it was full filled in practice.
/// See <see cref="LastTotalDemand"/> for the difference.
/// </summary>
[ViewVariables]
public float LastTotalDemandWithSuppliers { get; private set; }
/// <summary>
/// The amount of power that we are lacking to properly power everything (excluding storage supplier charging).
/// </summary>
[ViewVariables]
public float Lack => Math.Max(0, LastTotalDemand - LastTotalAvailable);
/// <summary>
@@ -131,6 +145,7 @@ namespace Content.Server.GameObjects.Components.Power
/// It is ALSO not implied that if this is &gt; 0, that we have sufficient power for everything.
/// See the doc comment on <see cref="LastTotalDraw"/>.
/// </summary>
[ViewVariables]
public float Excess => Math.Max(0, LastTotalAvailable - LastTotalDraw);
public void Update(float frameTime)