BatteryWeaponPowerCell tweaks (#33500)

* BatteryWeaponPowerCell tweaks

* add update ammo ev & shuttle guns tweaks

* MilonPL requested changes

* revert changes in OnPowerCellChanged

* Add events to get charge info & change current charge

---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
This commit is contained in:
Kirus59
2025-04-29 04:12:25 +03:00
committed by GitHub
parent a8054c37b1
commit 8c38aa3742
9 changed files with 138 additions and 43 deletions

View File

@@ -42,6 +42,9 @@ public sealed partial class PowerCellSystem : SharedPowerCellSystem
SubscribeLocalEvent<PowerCellSlotComponent, ExaminedEvent>(OnCellSlotExamined);
// funny
SubscribeLocalEvent<PowerCellSlotComponent, BeingMicrowavedEvent>(OnSlotMicrowaved);
SubscribeLocalEvent<PowerCellSlotComponent, GetChargeEvent>(OnGetCharge);
SubscribeLocalEvent<PowerCellSlotComponent, ChangeChargeEvent>(OnChangeCharge);
}
private void OnSlotMicrowaved(EntityUid uid, PowerCellSlotComponent component, BeingMicrowavedEvent args)
@@ -244,4 +247,20 @@ public sealed partial class PowerCellSystem : SharedPowerCellSystem
args.PushMarkup(Loc.GetString("power-cell-component-examine-details-no-battery"));
}
}
private void OnGetCharge(Entity<PowerCellSlotComponent> entity, ref GetChargeEvent args)
{
if (!TryGetBatteryFromSlot(entity, out var batteryUid, out _))
return;
RaiseLocalEvent(batteryUid.Value, ref args);
}
private void OnChangeCharge(Entity<PowerCellSlotComponent> entity, ref ChangeChargeEvent args)
{
if (!TryGetBatteryFromSlot(entity, out var batteryUid, out _))
return;
RaiseLocalEvent(batteryUid.Value, ref args);
}
}