2024-02-01 15:08:03 +02:00
|
|
|
using Content.Shared.Antag;
|
2023-10-04 21:47:33 -04:00
|
|
|
using Content.Shared.Revolutionary.Components;
|
2024-02-01 15:08:03 +02:00
|
|
|
using Content.Shared.Ghost;
|
2023-10-04 21:47:33 -04:00
|
|
|
using Content.Shared.StatusIcon.Components;
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.Revolutionary;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Used for the client to get status icons from other revs.
|
|
|
|
|
/// </summary>
|
2024-02-01 15:08:03 +02:00
|
|
|
public sealed class RevolutionarySystem : EntitySystem
|
2023-10-04 21:47:33 -04:00
|
|
|
{
|
2024-02-01 15:08:03 +02:00
|
|
|
|
2023-10-04 21:47:33 -04:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
2024-02-01 15:08:03 +02:00
|
|
|
SubscribeLocalEvent<RevolutionaryComponent, CanDisplayStatusIconsEvent>(OnCanShowRevIcon);
|
|
|
|
|
SubscribeLocalEvent<HeadRevolutionaryComponent, CanDisplayStatusIconsEvent>(OnCanShowRevIcon);
|
2023-10-04 21:47:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-02-01 15:08:03 +02:00
|
|
|
/// Determine whether a client should display the rev icon.
|
2023-10-04 21:47:33 -04:00
|
|
|
/// </summary>
|
2024-02-01 15:08:03 +02:00
|
|
|
private void OnCanShowRevIcon<T>(EntityUid uid, T comp, ref CanDisplayStatusIconsEvent args) where T : IAntagStatusIconComponent
|
2023-10-04 21:47:33 -04:00
|
|
|
{
|
2024-02-01 15:08:03 +02:00
|
|
|
args.Cancelled = !CanDisplayIcon(args.User, comp.IconVisibleToGhost);
|
2023-10-04 21:47:33 -04:00
|
|
|
}
|
|
|
|
|
|
2024-02-01 15:08:03 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// The criteria that determine whether a client should see Rev/Head rev icons.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private bool CanDisplayIcon(EntityUid? uid, bool visibleToGhost)
|
2023-10-04 21:47:33 -04:00
|
|
|
{
|
2024-02-01 15:08:03 +02:00
|
|
|
if (HasComp<HeadRevolutionaryComponent>(uid) || HasComp<RevolutionaryComponent>(uid))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (visibleToGhost && HasComp<GhostComponent>(uid))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return HasComp<ShowRevIconsComponent>(uid);
|
2023-10-04 21:47:33 -04:00
|
|
|
}
|
2024-02-01 15:08:03 +02:00
|
|
|
|
2023-10-04 21:47:33 -04:00
|
|
|
}
|