CatStation/Content.Client/Weapons/Ranged/Systems/GunSystem.SpentAmmo.cs
Whatstone d9ffbf1d03
Cleanup: AppearanceSystem.TryGetData to AppearanceChangeEvent.TryGetData (#45373)
* First impl. of appearance TryGetData cleanup

* Handful of fixes

* DamageVisuals: fix HandleDamage call, inheritdoc

* bunch of unused AppearanceSystem instances

* Handful more unused appearance systems, inheritdoc

* JetpackSystem: Ent<T>

* cleanup roundup, more Ent<T>

* a few lingering AppearanceSystem.TryGetData calls

* more lingering AppearanceData access

* Remove unnecessary inheritdoc

* once again, with feeling
2026-10-05 00:45:37 +00:00

32 lines
976 B
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(Entity<SpentAmmoVisualsComponent> ent, ref AppearanceChangeEvent args)
{
var sprite = args.Sprite;
if (sprite == null) return;
if (!args.TryGetData<bool>(AmmoVisuals.Spent, out var spent))
return;
string state;
if (spent)
state = ent.Comp.Suffix ? $"{ent.Comp.State}-spent" : "spent";
else
state = ent.Comp.State;
_sprite.LayerSetRsiState((ent, sprite), AmmoVisualLayers.Base, state);
_sprite.RemoveLayer((ent, sprite), AmmoVisualLayers.Tip, false);
}
}