CatStation/Content.Client/Zombies/ZombieSystem.cs
Whatstone f42f8df6d1
Cleanup: ProtoMan Part 2 - remove Client and Server EntitySystem IPrototypeManager instances (#44416)
* Remove all IPrototypeManager instances

* Remove redundant IComponentFactory instances too

* Found some stragglers

* DestructibleSystem.PrototypeManager: no dependency

* not based
2026-06-29 21:33:56 +00:00

50 lines
1.5 KiB
C#

using System.Linq;
using Content.Shared.Body;
using Content.Shared.StatusIcon.Components;
using Content.Shared.Zombies;
using Robust.Client.GameObjects;
namespace Content.Client.Zombies;
public sealed partial class ZombieSystem : SharedZombieSystem
{
[Dependency] private 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 = ProtoMan.Index(ent.Comp.StatusIcon);
args.StatusIcons.Add(iconPrototype);
}
private void GetInitialInfectedIcon(Entity<InitialInfectedComponent> ent, ref GetStatusIconsEvent args)
{
if (HasComp<ZombieComponent>(ent))
return;
var iconPrototype = ProtoMan.Index(ent.Comp.StatusIcon);
args.StatusIcons.Add(iconPrototype);
}
private void OnStartup(EntityUid uid, ZombieComponent component, ComponentStartup args)
{
if (HasComp<VisualBodyComponent>(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);
}
}
}