Literally Murder IExamine (#7352)

This commit is contained in:
Rane
2022-04-08 17:17:25 -04:00
committed by GitHub
parent 427f7378c3
commit 7900abb888
27 changed files with 372 additions and 469 deletions

View File

@@ -1,38 +1,6 @@
using Content.Shared.Examine;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
namespace Content.Server.Power.Components
{
[RegisterComponent]
#pragma warning disable 618
public sealed class ExaminableBatteryComponent : Component, IExamine
#pragma warning restore 618
{
[Dependency] private readonly IEntityManager _entityManager = default!;
void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
{
if (!_entityManager.TryGetComponent<BatteryComponent>(Owner, out var batteryComponent))
return;
if (inDetailsRange)
{
var effectiveMax = batteryComponent.MaxCharge;
if (effectiveMax == 0)
effectiveMax = 1;
var chargeFraction = batteryComponent.CurrentCharge / effectiveMax;
var chargePercentRounded = (int) (chargeFraction * 100);
message.AddMarkup(
Loc.GetString(
"examinable-battery-component-examine-detail",
("percent", chargePercentRounded),
("markupPercentColor", "green")
)
);
}
}
}
public sealed class ExaminableBatteryComponent : Component
{}
}