PowerStorageComponent now prints battery statistics to the examine window.
This commit is contained in:
@@ -5,6 +5,9 @@ using Robust.Shared.IoC;
|
|||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
using YamlDotNet.RepresentationModel;
|
using YamlDotNet.RepresentationModel;
|
||||||
|
|
||||||
@@ -13,7 +16,7 @@ namespace Content.Server.GameObjects.Components.Power
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stores electrical energy. Used by power cells and SMESes.
|
/// Stores electrical energy. Used by power cells and SMESes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class PowerStorageComponent : Component
|
public abstract class PowerStorageComponent : Component, IExamine
|
||||||
{
|
{
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public ChargeState LastChargeState { get; private set; } = ChargeState.Still;
|
public ChargeState LastChargeState { get; private set; } = ChargeState.Still;
|
||||||
@@ -164,5 +167,13 @@ namespace Content.Server.GameObjects.Components.Power
|
|||||||
}
|
}
|
||||||
AddCharge(RequestCharge(frameTime));
|
AddCharge(RequestCharge(frameTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void Examine(FormattedMessage message)
|
||||||
|
{
|
||||||
|
message.PushColor(Color.Yellow);
|
||||||
|
var chargePercent = Math.Round(100*(Capacity != 0f ? (Charge/Capacity) : 1f), 2).ToString(NumberFormatInfo.InvariantInfo);
|
||||||
|
message.AddText($"Charge: {Math.Round(Charge, 2)}J / {Capacity}J ({chargePercent}%)\nRate: {ChargeRate}W IN, {DistributionRate}W OUT");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user