From: Slava0135 <40753025+Slava0135@users.noreply.github.com> Date: Fri, 5 May 2023 12:44:21 +0000 (+0300) Subject: display item charge on examine (#16116) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=811b35a1cf65577385f9ca604ea43adb3ec8e4ba;p=space-station-14.git display item charge on examine (#16116) --- diff --git a/Content.Server/PowerCell/PowerCellSystem.cs b/Content.Server/PowerCell/PowerCellSystem.cs index b28ea159ec..6574acfb89 100644 --- a/Content.Server/PowerCell/PowerCellSystem.cs +++ b/Content.Server/PowerCell/PowerCellSystem.cs @@ -41,6 +41,7 @@ public sealed class PowerCellSystem : SharedPowerCellSystem SubscribeLocalEvent(OnRejuvenate); SubscribeLocalEvent(OnCellExamined); + SubscribeLocalEvent(OnCellSlotExamined); SubscribeLocalEvent(OnUnpaused); @@ -287,10 +288,19 @@ public sealed class PowerCellSystem : SharedPowerCellSystem private void OnCellExamined(EntityUid uid, PowerCellComponent component, ExaminedEvent args) { - if (!TryComp(uid, out BatteryComponent? battery)) - return; + if (TryComp(uid, out var battery)) + OnBatteryExamined(uid, battery, args); + } + + private void OnCellSlotExamined(EntityUid uid, PowerCellSlotComponent component, ExaminedEvent args) + { + if (TryGetBatteryFromSlot(uid, out var battery)) + OnBatteryExamined(uid, battery, args); + } - var charge = battery.CurrentCharge / battery.MaxCharge * 100; + private void OnBatteryExamined(EntityUid uid, BatteryComponent component, ExaminedEvent args) + { + var charge = component.CurrentCharge / component.MaxCharge * 100; args.PushMarkup(Loc.GetString("power-cell-component-examine-details", ("currentCharge", $"{charge:F0}"))); } } diff --git a/Content.Server/Radio/EntitySystems/JammerSystem.cs b/Content.Server/Radio/EntitySystems/JammerSystem.cs index 67446cd70f..b5a0c645d3 100644 --- a/Content.Server/Radio/EntitySystems/JammerSystem.cs +++ b/Content.Server/Radio/EntitySystems/JammerSystem.cs @@ -69,9 +69,6 @@ public sealed class JammerSystem : EntitySystem ? Loc.GetString("radio-jammer-component-examine-on-state") : Loc.GetString("radio-jammer-component-examine-off-state"); args.PushMarkup(msg); - if (_powerCell.TryGetBatteryFromSlot(uid, out var battery)) - args.PushMarkup(Loc.GetString("radio-jammer-component-charge", - ("charge", (int) ((battery.CurrentCharge / battery.MaxCharge) * 100)))); } } diff --git a/Resources/Locale/en-US/radio/components/radio-jammer-component.ftl b/Resources/Locale/en-US/radio/components/radio-jammer-component.ftl index 63c0913d61..68efbf8d4e 100644 --- a/Resources/Locale/en-US/radio/components/radio-jammer-component.ftl +++ b/Resources/Locale/en-US/radio/components/radio-jammer-component.ftl @@ -4,4 +4,3 @@ radio-jammer-component-off-state = off radio-jammer-component-examine-on-state = The light is currently [color=darkgreen]on[/color]. radio-jammer-component-examine-off-state = The light is currently [color=darkred]off[/color]. -radio-jammer-component-charge = The battery is [color=yellow]{$charge}%[/color] full.