Files
tbd-station-14/Content.Client/Zombies/ZombieSystem.cs
Tayrtahn c5ac160ea8 Cleanup more SpriteComponent warnings (part 6) (#37607)
* 1 warning in MechAssemblyVisualizerSystem

* 2 warnings in RecyclerVisualizerSystem

* 1 warning in ClusterGrenadeVisualizerSystem

* 2 warnings in BarSignSystem

* 4 warnings in AlertControl

* 1 warning in ToolSystem

* 2 warnings in PinpointerSystem

* 2 warnings in ClientSpriteMovementSystem

* 2 warnings in OptionsVisualizerSystem

* 1 warning in FlatpackSystem

* 1 warning in ZombieSystem

* 1 warning in StackSystem

* 1 warning in MiningOverlay

* 1 warning in FlippableClothingVisualizerSystem

* Guard clause for MechAssemblyVisualizerSystem

* Get SpriteSystem in AlertControl constructor
2025-05-20 01:52:03 +02:00

55 lines
1.7 KiB
C#

using System.Linq;
using Content.Shared.Ghost;
using Content.Shared.Humanoid;
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
using Content.Shared.Zombies;
using Robust.Client.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.Client.Zombies;
public sealed class ZombieSystem : SharedZombieSystem
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly SpriteSystem _sprite = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ZombieComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<ZombieComponent, GetStatusIconsEvent>(GetZombieIcon);
SubscribeLocalEvent<InitialInfectedComponent, GetStatusIconsEvent>(GetInitialInfectedIcon);
}
private void GetZombieIcon(Entity<ZombieComponent> ent, ref GetStatusIconsEvent args)
{
var iconPrototype = _prototype.Index(ent.Comp.StatusIcon);
args.StatusIcons.Add(iconPrototype);
}
private void GetInitialInfectedIcon(Entity<InitialInfectedComponent> ent, ref GetStatusIconsEvent args)
{
if (HasComp<ZombieComponent>(ent))
return;
var iconPrototype = _prototype.Index(ent.Comp.StatusIcon);
args.StatusIcons.Add(iconPrototype);
}
private void OnStartup(EntityUid uid, ZombieComponent component, ComponentStartup args)
{
if (HasComp<HumanoidAppearanceComponent>(uid))
return;
if (!TryComp<SpriteComponent>(uid, out var sprite))
return;
for (var i = 0; i < sprite.AllLayers.Count(); i++)
{
_sprite.LayerSetColor((uid, sprite), i, component.SkinColor);
}
}
}