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;
|
|
|
|
|
using Content.Shared.StatusIcon.Components;
|
|
|
|
|
using Content.Shared.Zombies;
|
|
|
|
|
using Robust.Client.GameObjects;
|
2022-09-06 21:59:27 -04:00
|
|
|
|
|
|
|
|
namespace Content.Client.Zombies;
|
|
|
|
|
|
2024-02-01 15:08:03 +02:00
|
|
|
public sealed class ZombieSystem : EntitySystem
|
2022-09-06 21:59:27 -04:00
|
|
|
{
|
2023-07-25 17:31:35 -04:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<ZombieComponent, ComponentStartup>(OnStartup);
|
2024-02-01 15:08:03 +02:00
|
|
|
SubscribeLocalEvent<ZombieComponent, CanDisplayStatusIconsEvent>(OnCanDisplayStatusIcons);
|
2024-03-18 22:57:36 +01:00
|
|
|
SubscribeLocalEvent<InitialInfectedComponent, CanDisplayStatusIconsEvent>(OnCanDisplayStatusIcons);
|
2023-07-25 17:31:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-01 15:08:03 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Determines whether a player should be able to see the StatusIcon for zombies.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void OnCanDisplayStatusIcons(EntityUid uid, ZombieComponent component, ref CanDisplayStatusIconsEvent args)
|
2023-07-25 17:31:35 -04:00
|
|
|
{
|
2024-03-18 22:57:36 +01:00
|
|
|
if (HasComp<ZombieComponent>(args.User) || HasComp<InitialInfectedComponent>(args.User) || HasComp<ShowZombieIconsComponent>(args.User))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (component.IconVisibleToGhost && HasComp<GhostComponent>(args.User))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
args.Cancelled = true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-30 18:20:45 -07:00
|
|
|
private void OnCanDisplayStatusIcons(EntityUid uid, InitialInfectedComponent component, ref CanDisplayStatusIconsEvent args)
|
2024-03-18 22:57:36 +01:00
|
|
|
{
|
|
|
|
|
if (HasComp<InitialInfectedComponent>(args.User) && !HasComp<ZombieComponent>(args.User))
|
2024-02-01 15:08:03 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (component.IconVisibleToGhost && HasComp<GhostComponent>(args.User))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
args.Cancelled = true;
|
2023-07-25 17:31:35 -04:00
|
|
|
}
|
2022-09-06 21:59:27 -04:00
|
|
|
}
|