display item charge on examine (#16116)
This commit is contained in:
@@ -41,6 +41,7 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
|
|||||||
SubscribeLocalEvent<PowerCellComponent, RejuvenateEvent>(OnRejuvenate);
|
SubscribeLocalEvent<PowerCellComponent, RejuvenateEvent>(OnRejuvenate);
|
||||||
|
|
||||||
SubscribeLocalEvent<PowerCellComponent, ExaminedEvent>(OnCellExamined);
|
SubscribeLocalEvent<PowerCellComponent, ExaminedEvent>(OnCellExamined);
|
||||||
|
SubscribeLocalEvent<PowerCellSlotComponent, ExaminedEvent>(OnCellSlotExamined);
|
||||||
|
|
||||||
SubscribeLocalEvent<PowerCellDrawComponent, EntityUnpausedEvent>(OnUnpaused);
|
SubscribeLocalEvent<PowerCellDrawComponent, EntityUnpausedEvent>(OnUnpaused);
|
||||||
|
|
||||||
@@ -287,10 +288,19 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
|
|||||||
|
|
||||||
private void OnCellExamined(EntityUid uid, PowerCellComponent component, ExaminedEvent args)
|
private void OnCellExamined(EntityUid uid, PowerCellComponent component, ExaminedEvent args)
|
||||||
{
|
{
|
||||||
if (!TryComp(uid, out BatteryComponent? battery))
|
if (TryComp<BatteryComponent>(uid, out var battery))
|
||||||
return;
|
OnBatteryExamined(uid, battery, args);
|
||||||
|
}
|
||||||
|
|
||||||
var charge = battery.CurrentCharge / battery.MaxCharge * 100;
|
private void OnCellSlotExamined(EntityUid uid, PowerCellSlotComponent component, ExaminedEvent args)
|
||||||
|
{
|
||||||
|
if (TryGetBatteryFromSlot(uid, out var battery))
|
||||||
|
OnBatteryExamined(uid, battery, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
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}")));
|
args.PushMarkup(Loc.GetString("power-cell-component-examine-details", ("currentCharge", $"{charge:F0}")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,9 +69,6 @@ public sealed class JammerSystem : EntitySystem
|
|||||||
? Loc.GetString("radio-jammer-component-examine-on-state")
|
? Loc.GetString("radio-jammer-component-examine-on-state")
|
||||||
: Loc.GetString("radio-jammer-component-examine-off-state");
|
: Loc.GetString("radio-jammer-component-examine-off-state");
|
||||||
args.PushMarkup(msg);
|
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))));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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-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-examine-off-state = The light is currently [color=darkred]off[/color].
|
||||||
radio-jammer-component-charge = The battery is [color=yellow]{$charge}%[/color] full.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user