| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- 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!;
- 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(i, component.SkinColor);
- }
- }
- }
|