Fix rockets and lasers looking like they have nothing loaded (#26933)
(cherry picked from commit 13cef85a6e7d0f5873d1f66358ef742356541582)
This commit is contained in:
parent
613b6333c4
commit
99ab8cea68
|
|
@ -40,7 +40,7 @@ public sealed partial class GunSystem
|
|||
|
||||
if (sprite == null) return;
|
||||
|
||||
if (args.AppearanceData.TryGetValue(AmmoVisuals.MagLoaded, out var magloaded) &&
|
||||
if (!args.AppearanceData.TryGetValue(AmmoVisuals.MagLoaded, out var magloaded) ||
|
||||
magloaded is true)
|
||||
{
|
||||
if (!args.AppearanceData.TryGetValue(AmmoVisuals.AmmoMax, out var capacity))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Verbs;
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
using Content.Shared.Weapons.Ranged.Events;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
|
|
@ -13,6 +12,7 @@ public abstract partial class SharedGunSystem
|
|||
|
||||
protected virtual void InitializeMagazine()
|
||||
{
|
||||
SubscribeLocalEvent<MagazineAmmoProviderComponent, MapInitEvent>(OnMagazineMapInit);
|
||||
SubscribeLocalEvent<MagazineAmmoProviderComponent, TakeAmmoEvent>(OnMagazineTakeAmmo);
|
||||
SubscribeLocalEvent<MagazineAmmoProviderComponent, GetAmmoCountEvent>(OnMagazineAmmoCount);
|
||||
SubscribeLocalEvent<MagazineAmmoProviderComponent, GetVerbsEvent<AlternativeVerb>>(OnMagazineVerb);
|
||||
|
|
@ -22,6 +22,11 @@ public abstract partial class SharedGunSystem
|
|||
SubscribeLocalEvent<MagazineAmmoProviderComponent, ExaminedEvent>(OnMagazineExamine);
|
||||
}
|
||||
|
||||
private void OnMagazineMapInit(Entity<MagazineAmmoProviderComponent> ent, ref MapInitEvent args)
|
||||
{
|
||||
MagazineSlotChanged(ent);
|
||||
}
|
||||
|
||||
private void OnMagazineExamine(EntityUid uid, MagazineAmmoProviderComponent component, ExaminedEvent args)
|
||||
{
|
||||
if (!args.IsInDetailsRange)
|
||||
|
|
@ -62,16 +67,21 @@ public abstract partial class SharedGunSystem
|
|||
if (MagazineSlot != args.Container.ID)
|
||||
return;
|
||||
|
||||
UpdateAmmoCount(uid);
|
||||
if (!TryComp<AppearanceComponent>(uid, out var appearance))
|
||||
MagazineSlotChanged((uid, component));
|
||||
}
|
||||
|
||||
private void MagazineSlotChanged(Entity<MagazineAmmoProviderComponent> ent)
|
||||
{
|
||||
UpdateAmmoCount(ent);
|
||||
if (!TryComp<AppearanceComponent>(ent, out var appearance))
|
||||
return;
|
||||
|
||||
var magEnt = GetMagazineEntity(uid);
|
||||
Appearance.SetData(uid, AmmoVisuals.MagLoaded, magEnt != null, appearance);
|
||||
var magEnt = GetMagazineEntity(ent);
|
||||
Appearance.SetData(ent, AmmoVisuals.MagLoaded, magEnt != null, appearance);
|
||||
|
||||
if (magEnt != null)
|
||||
{
|
||||
UpdateMagazineAppearance(uid, component, magEnt.Value);
|
||||
UpdateMagazineAppearance(ent, ent, magEnt.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue