From 9acf37e99daa628fbde435a71710c7f3645f55db Mon Sep 17 00:00:00 2001 From: Acruid Date: Fri, 30 Aug 2019 23:36:07 -0700 Subject: [PATCH] PowerStorageComponent now prints battery statistics to the examine window. --- .../Components/Power/PowerStorageComponent.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/Power/PowerStorageComponent.cs b/Content.Server/GameObjects/Components/Power/PowerStorageComponent.cs index e403f638fd..064e184a72 100644 --- a/Content.Server/GameObjects/Components/Power/PowerStorageComponent.cs +++ b/Content.Server/GameObjects/Components/Power/PowerStorageComponent.cs @@ -5,6 +5,9 @@ using Robust.Shared.IoC; using Robust.Shared.Serialization; using Robust.Shared.Utility; using System; +using System.Globalization; +using Content.Server.GameObjects.EntitySystems; +using Robust.Shared.Maths; using Robust.Shared.ViewVariables; using YamlDotNet.RepresentationModel; @@ -13,7 +16,7 @@ namespace Content.Server.GameObjects.Components.Power /// /// Stores electrical energy. Used by power cells and SMESes. /// - public abstract class PowerStorageComponent : Component + public abstract class PowerStorageComponent : Component, IExamine { [ViewVariables] public ChargeState LastChargeState { get; private set; } = ChargeState.Still; @@ -164,5 +167,13 @@ namespace Content.Server.GameObjects.Components.Power } AddCharge(RequestCharge(frameTime)); } + + /// + 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"); + } } }