fish-station/Content.Client/Ligyb/SickSystem.cs
Lgibb18 ad39b4f298
Disease boowomp (#135)
* disease

* eula
2024-06-21 05:35:09 +03:00

51 lines
1.9 KiB
C#

// © SUNRISE, An EULA/CLA with a hosting restriction, full text: https://github.com/space-sunrise/space-station-14/blob/master/CLA.txt
using Content.Shared.CCVar;
using Content.Shared.Mind.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.NPC;
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
using Robust.Shared.Configuration;
using Robust.Client.Player;
using Robust.Shared.Prototypes;
using Content.Shared.Ligyb;
namespace Content.Client.Ligyb;
public sealed class SickSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SickComponent, GetStatusIconsEvent>(OnGetStatusIcon);
SubscribeNetworkEvent<UpdateInfectionsEvent>(OnUpdateInfect);
}
private void OnUpdateInfect(UpdateInfectionsEvent args)
{
EnsureComp<SickComponent>(GetEntity(args.Uid)).Inited = true;
}
private void OnGetStatusIcon(EntityUid uid, SickComponent component, ref GetStatusIconsEvent args)
{
if (component.Inited)
{
if (_playerManager.LocalEntity != null)
{
if (HasComp<DiseaseRoleComponent>(_playerManager.LocalEntity.Value))
{
if (!args.InContainer &&
!_mobState.IsDead(uid) &&
!HasComp<ActiveNPCComponent>(uid) &&
TryComp<MindContainerComponent>(uid, out var mindContainer) &&
mindContainer.ShowExamineInfo)
{
args.StatusIcons.Add(_prototype.Index<StatusIconPrototype>(component.Icon));
}
}
}
}
}
}