mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 14:07:53 +03:00
Fix Tipped Ammo not being Spent (cherry picked from commit e40318b83130a532e3654bdacd08993220b7be93)
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using Content.Client.Weapons.Ranged.Components;
|
|
using Content.Shared.Weapons.Ranged.Systems;
|
|
using Robust.Client.GameObjects;
|
|
|
|
namespace Content.Client.Weapons.Ranged.Systems;
|
|
|
|
public sealed partial class GunSystem
|
|
{
|
|
private void InitializeSpentAmmo()
|
|
{
|
|
SubscribeLocalEvent<SpentAmmoVisualsComponent, AppearanceChangeEvent>(OnSpentAmmoAppearance);
|
|
}
|
|
|
|
private void OnSpentAmmoAppearance(EntityUid uid, SpentAmmoVisualsComponent component, ref AppearanceChangeEvent args)
|
|
{
|
|
var sprite = args.Sprite;
|
|
if (sprite == null) return;
|
|
|
|
if (!args.AppearanceData.TryGetValue(AmmoVisuals.Spent, out var varSpent))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var spent = (bool) varSpent;
|
|
string state;
|
|
|
|
if (spent)
|
|
state = component.Suffix ? $"{component.State}-spent" : "spent";
|
|
else
|
|
state = component.State;
|
|
|
|
sprite.LayerSetState(AmmoVisualLayers.Base, state);
|
|
if (sprite.LayerExists(AmmoVisualLayers.Tip)){
|
|
sprite.RemoveLayer(AmmoVisualLayers.Tip);
|
|
}
|
|
}
|
|
}
|