Gun refactor (#8301)
Co-authored-by: Kara <lunarautomaton6@gmail.com> Co-authored-by: T-Stalker <le0nel_1van@hotmail.com> Co-authored-by: T-Stalker <43253663+DogZeroX@users.noreply.github.com> Co-authored-by: ElectroJr <leonsfriedrich@gmail.com> Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
34
Content.Client/Weapons/Ranged/Systems/GunSystem.SpentAmmo.cs
Normal file
34
Content.Client/Weapons/Ranged/Systems/GunSystem.SpentAmmo.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user