]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
display item charge on examine (#16116)
authorSlava0135 <40753025+Slava0135@users.noreply.github.com>
Fri, 5 May 2023 12:44:21 +0000 (15:44 +0300)
committerGitHub <noreply@github.com>
Fri, 5 May 2023 12:44:21 +0000 (22:44 +1000)
Content.Server/PowerCell/PowerCellSystem.cs
Content.Server/Radio/EntitySystems/JammerSystem.cs
Resources/Locale/en-US/radio/components/radio-jammer-component.ftl

index b28ea159ecb84ce790b90c2b31aaf6c5d337376f..6574acfb891cbc317a556ad1aeb7ba1a179d6527 100644 (file)
@@ -41,6 +41,7 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
         SubscribeLocalEvent<PowerCellComponent, RejuvenateEvent>(OnRejuvenate);
 
         SubscribeLocalEvent<PowerCellComponent, ExaminedEvent>(OnCellExamined);
+        SubscribeLocalEvent<PowerCellSlotComponent, ExaminedEvent>(OnCellSlotExamined);
 
         SubscribeLocalEvent<PowerCellDrawComponent, EntityUnpausedEvent>(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<BatteryComponent>(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}")));
     }
 }
index 67446cd70f15efad7beda9d8aa72490ab9d45ac9..b5a0c645d3de8c9204cedc5e7f9499c03e07c470 100644 (file)
@@ -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))));
         }
     }
 
index 63c0913d619bb8323682e8fdfac6dc17b0e15174..68efbf8d4eef2e2794dd04dff6de3f305e060594 100644 (file)
@@ -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.