2024-07-28 16:54:32 +00:00
|
|
|
|
using Content.Shared._White.Cult.Components;
|
2024-01-27 15:19:52 +03:00
|
|
|
|
using Robust.Client.Graphics;
|
|
|
|
|
|
using Robust.Client.Player;
|
2024-01-27 16:02:34 +03:00
|
|
|
|
using Robust.Shared.Player;
|
2024-01-29 01:02:37 +07:00
|
|
|
|
using CultistComponent = Content.Shared._White.Cult.Components.CultistComponent;
|
2024-01-27 15:19:52 +03:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Client._White.Cult;
|
|
|
|
|
|
|
|
|
|
|
|
public sealed class ShowCultHudSystem : EntitySystem
|
|
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly IPlayerManager _player = default!;
|
|
|
|
|
|
[Dependency] private readonly IOverlayManager _overlayManager = default!;
|
|
|
|
|
|
|
|
|
|
|
|
private Overlay _overlay = default!;
|
|
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
SubscribeLocalEvent<CultistComponent, ComponentInit>(OnComponentInit);
|
|
|
|
|
|
SubscribeLocalEvent<CultistComponent, ComponentRemove>(OnComponentRemoved);
|
|
|
|
|
|
SubscribeLocalEvent<CultistComponent, PlayerAttachedEvent>(OnPlayerAttached);
|
|
|
|
|
|
SubscribeLocalEvent<CultistComponent, PlayerDetachedEvent>(OnPlayerDetached);
|
|
|
|
|
|
|
2024-03-22 17:23:33 +09:00
|
|
|
|
SubscribeLocalEvent<ShowCultHudComponent, ComponentInit>(OnComponentInit);
|
|
|
|
|
|
SubscribeLocalEvent<ShowCultHudComponent, ComponentRemove>(OnComponentRemoved);
|
|
|
|
|
|
SubscribeLocalEvent<ShowCultHudComponent, PlayerAttachedEvent>(OnPlayerAttached);
|
|
|
|
|
|
SubscribeLocalEvent<ShowCultHudComponent, PlayerDetachedEvent>(OnPlayerDetached);
|
|
|
|
|
|
|
2024-01-27 15:19:52 +03:00
|
|
|
|
_overlay = new CultHudOverlay(EntityManager);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-28 16:54:32 +00:00
|
|
|
|
private void OnComponentInit<T>(EntityUid uid, T component, ComponentInit args)
|
2024-01-27 15:19:52 +03:00
|
|
|
|
{
|
2024-02-02 14:01:41 +09:00
|
|
|
|
if (_player.LocalSession?.AttachedEntity != uid)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-01-27 15:19:52 +03:00
|
|
|
|
_overlayManager.AddOverlay(_overlay);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-28 16:54:32 +00:00
|
|
|
|
private void OnComponentRemoved<T>(EntityUid uid, T component, ComponentRemove args)
|
2024-01-27 15:19:52 +03:00
|
|
|
|
{
|
2024-02-02 14:01:41 +09:00
|
|
|
|
if (_player.LocalSession?.AttachedEntity != uid)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-01-27 15:19:52 +03:00
|
|
|
|
_overlayManager.RemoveOverlay(_overlay);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-28 16:54:32 +00:00
|
|
|
|
private void OnPlayerAttached<T>(EntityUid uid, T component, PlayerAttachedEvent args)
|
2024-01-27 15:19:52 +03:00
|
|
|
|
{
|
2024-02-02 14:01:41 +09:00
|
|
|
|
if (_player.LocalSession != args.Player)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-01-27 15:19:52 +03:00
|
|
|
|
_overlayManager.AddOverlay(_overlay);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-28 16:54:32 +00:00
|
|
|
|
private void OnPlayerDetached<T>(EntityUid uid, T component, PlayerDetachedEvent args)
|
2024-01-27 15:19:52 +03:00
|
|
|
|
{
|
2024-02-02 14:01:41 +09:00
|
|
|
|
if (_player.LocalSession != args.Player)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-01-27 15:19:52 +03:00
|
|
|
|
_overlayManager.RemoveOverlay(_overlay);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|