fish-station/Content.Client/Weapons/Ranged/Systems/GunSystem.SpentAmmo.cs
Vigers Ray b52f640b5a
Порт стрельбы со старлайна (#2640)
Co-authored-by: KaiserMaus <kaiser.ratte@gmail.com>
2025-08-08 22:25:02 +03:00

41 lines
1.2 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 = null;
if (spent && component.State != null)
state = component.Suffix ? $"{component.State}-spent" : "spent";
else
state = component.State;
if (spent && component.revealSpent) /// Starlight
{
_sprite.LayerSetVisible((uid, sprite), AmmoVisualLayers.Spent, true);
return;
}
_sprite.LayerSetRsiState((uid, sprite), AmmoVisualLayers.Base, state);
_sprite.RemoveLayer((uid, sprite), AmmoVisualLayers.Tip, false);
}
}