Indicator fixes (#357)

* - fix: Fix hud showing stealth entities.

* - fix: Fix aghost SSD indicator.

* - tweak: Make ninja more stealthy.
This commit is contained in:
Aviu00
2024-06-15 13:11:59 +00:00
committed by GitHub
parent 7072dd31d2
commit 73954e87b1
8 changed files with 78 additions and 3 deletions

View File

@@ -1,7 +1,10 @@
using Content.Shared.CCVar;
using Content.Shared.Ghost;
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Configuration;
namespace Content.Client.StatusIcon;
@@ -13,6 +16,10 @@ public sealed class StatusIconSystem : SharedStatusIconSystem
{
[Dependency] private readonly IConfigurationManager _configuration = default!;
[Dependency] private readonly IOverlayManager _overlay = default!;
[Dependency] private readonly IPlayerManager _playerMan = default!;
private EntityQuery<GhostComponent> _ghostQuery;
private EntityQuery<SpriteComponent> _spriteQuery;
private bool _globalEnabled;
private bool _localEnabled;
@@ -20,6 +27,9 @@ public sealed class StatusIconSystem : SharedStatusIconSystem
/// <inheritdoc/>
public override void Initialize()
{
_ghostQuery = GetEntityQuery<GhostComponent>();
_spriteQuery = GetEntityQuery<SpriteComponent>();
Subs.CVar(_configuration, CCVars.LocalStatusIconsEnabled, OnLocalStatusIconChanged, true);
Subs.CVar(_configuration, CCVars.GlobalStatusIconsEnabled, OnGlobalStatusIconChanged, true);
}
@@ -59,5 +69,29 @@ public sealed class StatusIconSystem : SharedStatusIconSystem
RaiseLocalEvent(uid, ref ev);
return ev.StatusIcons;
}
/// <summary>
/// For overlay to check if an entity can be seen.
/// </summary>
public bool IsVisible(EntityUid uid)
{
// ghosties can always see them
var viewer = _playerMan.LocalSession?.AttachedEntity;
if (_ghostQuery.HasComponent(viewer))
return true;
if (_spriteQuery.TryGetComponent(uid, out var sprite) && !sprite.Visible)
return false;
var ev = new StatusIconVisibleEvent(true);
RaiseLocalEvent(uid, ref ev);
return ev.Visible;
}
}
/// <summary>
/// Raised on an entity to check if it should draw hud icons.
/// Used to check invisibility etc inside the screen bounds.
/// </summary>
[ByRefEvent]
public record struct StatusIconVisibleEvent(bool Visible);