2023-10-04 21:47:33 -04:00
|
|
|
using System.Linq;
|
2024-02-01 15:08:03 +02:00
|
|
|
using Content.Shared.Ghost;
|
2023-07-25 17:31:35 -04:00
|
|
|
using Content.Shared.Humanoid;
|
2024-06-03 12:12:21 -04:00
|
|
|
using Content.Shared.StatusIcon;
|
2023-07-25 17:31:35 -04:00
|
|
|
using Content.Shared.StatusIcon.Components;
|
|
|
|
|
using Content.Shared.Zombies;
|
|
|
|
|
using Robust.Client.GameObjects;
|
2024-06-03 12:12:21 -04:00
|
|
|
using Robust.Shared.Prototypes;
|
2022-09-06 21:59:27 -04:00
|
|
|
|
|
|
|
|
namespace Content.Client.Zombies;
|
|
|
|
|
|
2024-06-03 12:12:21 -04:00
|
|
|
public sealed class ZombieSystem : SharedZombieSystem
|
2022-09-06 21:59:27 -04:00
|
|
|
{
|
2024-06-03 12:12:21 -04:00
|
|
|
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
2025-05-19 19:52:03 -04:00
|
|
|
[Dependency] private readonly SpriteSystem _sprite = default!;
|
2024-06-03 12:12:21 -04:00
|
|
|
|
2023-07-25 17:31:35 -04:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<ZombieComponent, ComponentStartup>(OnStartup);
|
2024-06-03 12:12:21 -04:00
|
|
|
SubscribeLocalEvent<ZombieComponent, GetStatusIconsEvent>(GetZombieIcon);
|
|
|
|
|
SubscribeLocalEvent<InitialInfectedComponent, GetStatusIconsEvent>(GetInitialInfectedIcon);
|
2023-07-25 17:31:35 -04:00
|
|
|
}
|
|
|
|
|
|
2024-06-03 12:12:21 -04:00
|
|
|
private void GetZombieIcon(Entity<ZombieComponent> ent, ref GetStatusIconsEvent args)
|
2023-07-25 17:31:35 -04:00
|
|
|
{
|
2024-06-03 12:12:21 -04:00
|
|
|
var iconPrototype = _prototype.Index(ent.Comp.StatusIcon);
|
|
|
|
|
args.StatusIcons.Add(iconPrototype);
|
2023-07-25 17:31:35 -04:00
|
|
|
}
|
|
|
|
|
|
2024-06-03 12:12:21 -04:00
|
|
|
private void GetInitialInfectedIcon(Entity<InitialInfectedComponent> ent, ref GetStatusIconsEvent args)
|
2023-07-25 17:31:35 -04:00
|
|
|
{
|
2024-06-03 12:12:21 -04:00
|
|
|
if (HasComp<ZombieComponent>(ent))
|
2024-03-18 22:57:36 +01:00
|
|
|
return;
|
|
|
|
|
|
2024-06-03 12:12:21 -04:00
|
|
|
var iconPrototype = _prototype.Index(ent.Comp.StatusIcon);
|
|
|
|
|
args.StatusIcons.Add(iconPrototype);
|
2024-03-18 22:57:36 +01:00
|
|
|
}
|
|
|
|
|
|
2024-06-03 12:12:21 -04:00
|
|
|
private void OnStartup(EntityUid uid, ZombieComponent component, ComponentStartup args)
|
2024-03-18 22:57:36 +01:00
|
|
|
{
|
2024-06-03 12:12:21 -04:00
|
|
|
if (HasComp<HumanoidAppearanceComponent>(uid))
|
2024-02-01 15:08:03 +02:00
|
|
|
return;
|
|
|
|
|
|
2024-06-03 12:12:21 -04:00
|
|
|
if (!TryComp<SpriteComponent>(uid, out var sprite))
|
2024-02-01 15:08:03 +02:00
|
|
|
return;
|
|
|
|
|
|
2024-06-03 12:12:21 -04:00
|
|
|
for (var i = 0; i < sprite.AllLayers.Count(); i++)
|
|
|
|
|
{
|
2025-05-19 19:52:03 -04:00
|
|
|
_sprite.LayerSetColor((uid, sprite), i, component.SkinColor);
|
2024-06-03 12:12:21 -04:00
|
|
|
}
|
2023-07-25 17:31:35 -04:00
|
|
|
}
|
2022-09-06 21:59:27 -04:00
|
|
|
}
|