Data Rework Content Edition (#82)

* WiP Data Rework.

* Convert stationstation to new map format.

* stationstation.yml v2

* Update submodule
This commit is contained in:
Pieter-Jan Briers
2018-07-26 23:38:16 +02:00
committed by GitHub
parent 8c874c76dc
commit b34591ab59
19 changed files with 1280 additions and 2906 deletions

View File

@@ -3,6 +3,7 @@ using SS14.Server.GameObjects;
using SS14.Shared.GameObjects;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.IoC;
using SS14.Shared.Serialization;
using SS14.Shared.Utility;
using System;
using System.Collections.Generic;
@@ -21,7 +22,12 @@ 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>
public virtual DrawTypes DrawType { get; protected set; } = DrawTypes.Provider;
public virtual DrawTypes DrawType
{
get => _drawType;
protected set => _drawType = value;
}
private DrawTypes _drawType = DrawTypes.Provider;
/// <summary>
/// The power draw method we are currently connected to and using
@@ -62,8 +68,12 @@ namespace Content.Server.GameObjects.Components.Power
/// <summary>
/// Priority for powernet draw, lower will draw first, defined in powernet.cs
/// </summary>
public virtual Powernet.Priority Priority { get; protected set; } = Powernet.Priority.Medium;
public virtual Powernet.Priority Priority
{
get => _priority;
protected set => _priority = value;
}
private Powernet.Priority _priority = Powernet.Priority.Medium;
private float _load = 100; //arbitrary magic number to start
/// <summary>
@@ -152,20 +162,13 @@ namespace Content.Server.GameObjects.Components.Power
base.Shutdown();
}
public override void LoadParameters(YamlMappingNode mapping)
public override void ExposeData(ObjectSerializer serializer)
{
if (mapping.TryGetNode("drawtype", out YamlNode node))
{
DrawType = node.AsEnum<DrawTypes>();
}
if (mapping.TryGetNode("load", out node))
{
Load = node.AsFloat();
}
if (mapping.TryGetNode("priority", out node))
{
Priority = node.AsEnum<Powernet.Priority>();
}
base.ExposeData(serializer);
serializer.DataField(ref _drawType, "drawtype", DrawTypes.Provider);
serializer.DataField(ref _load, "load", 100);
serializer.DataField(ref _priority, "priority", Powernet.Priority.Medium);
}
string IExamine.Examine()

View File

@@ -2,6 +2,7 @@
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.IoC;
using SS14.Shared.Log;
using SS14.Shared.Serialization;
using SS14.Shared.Utility;
using System;
using YamlDotNet.RepresentationModel;
@@ -25,12 +26,11 @@ namespace Content.Server.GameObjects.Components.Power
set { UpdateSupply(value); }
}
public override void LoadParameters(YamlMappingNode mapping)
public override void ExposeData(ObjectSerializer serializer)
{
if (mapping.TryGetNode("supply", out YamlNode node))
{
Supply = node.AsFloat();
}
base.ExposeData(serializer);
serializer.DataField(ref _supply, "supply", 1000);
}
public override void OnAdd()

View File

@@ -3,6 +3,7 @@ using SS14.Server.Interfaces.GameObjects;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.IoC;
using SS14.Shared.Log;
using SS14.Shared.Serialization;
using SS14.Shared.Utility;
using System;
using System.Collections.Generic;
@@ -24,7 +25,12 @@ namespace Content.Server.GameObjects.Components.Power
/// <summary>
/// Variable that determines the range that the power provider will try to supply power to
/// </summary>
public int PowerRange { get; private set; } = 0;
public int PowerRange
{
get => _range;
private set => _range = value;
}
private int _range = 0;
/// <summary>
/// List storing all the power devices that we are currently providing power to
@@ -56,16 +62,11 @@ namespace Content.Server.GameObjects.Components.Power
AdvertisedDevices.Clear();
}
public override void LoadParameters(YamlMappingNode mapping)
public override void ExposeData(ObjectSerializer serializer)
{
if (mapping.TryGetNode("range", out YamlNode node))
{
PowerRange = node.AsInt();
}
if (mapping.TryGetNode("priority", out node))
{
Priority = node.AsEnum<Powernet.Priority>();
}
base.ExposeData(serializer);
serializer.DataField(ref _range, "range", 0);
}
internal override void ProcessInternalPower(float frametime)

View File

@@ -2,6 +2,7 @@
using SS14.Shared.GameObjects;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.IoC;
using SS14.Shared.Serialization;
using SS14.Shared.Utility;
using System;
using YamlDotNet.RepresentationModel;
@@ -22,25 +23,29 @@ namespace Content.Server.GameObjects.Components.Power
/// Maximum amount of energy the internal battery can store.
/// In Joules.
/// </summary>
public float Capacity { get; private set; } = 10000; //arbitrary value replace
public float Capacity => _capacity;
private float _capacity = 10000; // Arbitrary value, replace.
/// <summary>
/// Energy the battery is currently storing.
/// In Joules.
/// </summary>
public float Charge { get; private set; } = 0;
public float Charge => _charge;
private float _charge = 0;
/// <summary>
/// Rate at which energy will be taken to charge internal battery.
/// In Watts.
/// </summary>
public float ChargeRate { get; private set; } = 1000;
public float ChargeRate => _chargeRate;
private float _chargeRate = 1000;
/// <summary>
/// Rate at which energy will be distributed to the powernet if needed.
/// In Watts.
/// </summary>
public float DistributionRate { get; private set; } = 1000;
public float DistributionRate => _distributionRate;
private float _distributionRate = 1000;
public bool Full => Charge >= Capacity;
@@ -63,29 +68,15 @@ namespace Content.Server.GameObjects.Components.Power
}
}
public override void LoadParameters(YamlMappingNode mapping)
public override void ExposeData(ObjectSerializer serializer)
{
if (mapping.TryGetNode("capacity", out YamlNode node))
{
Capacity = node.AsFloat();
}
if (mapping.TryGetNode("charge", out node))
{
Charge = node.AsFloat();
}
if (mapping.TryGetNode("chargerate", out node))
{
ChargeRate = node.AsFloat();
}
if (mapping.TryGetNode("distributionrate", out node))
{
DistributionRate = node.AsFloat();
}
if (mapping.TryGetNode("chargepowernet", out node))
{
_chargepowernet = node.AsBool();
}
base.ExposeData(serializer);
serializer.DataField(ref _capacity, "capacity", 10000);
serializer.DataField(ref _charge, "charge", 0);
serializer.DataField(ref _chargeRate, "chargerate", 1000);
serializer.DataField(ref _distributionRate, "distributionrate", 1000);
serializer.DataField(ref _chargepowernet, "chargepowernet", false);
}
public override void OnAdd()
@@ -134,14 +125,14 @@ namespace Content.Server.GameObjects.Components.Power
/// </summary>
public void DeductCharge(float todeduct)
{
Charge = Math.Max(0, Charge - todeduct);
_charge = Math.Max(0, Charge - todeduct);
LastChargeState = ChargeState.Discharging;
LastChargeStateChange = DateTime.Now;
}
public void AddCharge(float charge)
{
Charge = Math.Min(Capacity, Charge + charge);
_charge = Math.Min(Capacity, Charge + charge);
LastChargeState = ChargeState.Charging;
LastChargeStateChange = DateTime.Now;
}