Indicator fixes (#357)
* - fix: Fix hud showing stealth entities. * - fix: Fix aghost SSD indicator. * - tweak: Make ninja more stealthy.
This commit is contained in:
@@ -7,6 +7,7 @@ using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.Enums;
|
||||
using System.Numerics;
|
||||
using Content.Client.StatusIcon;
|
||||
using Content.Shared.StatusIcon.Components;
|
||||
using Content.Client.UserInterface.Systems;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -24,6 +25,7 @@ public sealed class EntityHealthBarOverlay : Overlay
|
||||
private readonly MobStateSystem _mobStateSystem;
|
||||
private readonly MobThresholdSystem _mobThresholdSystem;
|
||||
private readonly ProgressColorSystem _progressColor;
|
||||
private readonly StatusIconSystem _statusIcon;
|
||||
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;
|
||||
public HashSet<string> DamageContainers = new();
|
||||
|
||||
@@ -34,6 +36,7 @@ public sealed class EntityHealthBarOverlay : Overlay
|
||||
_mobStateSystem = _entManager.System<MobStateSystem>();
|
||||
_mobThresholdSystem = _entManager.System<MobThresholdSystem>();
|
||||
_progressColor = _entManager.System<ProgressColorSystem>();
|
||||
_statusIcon = entManager.System<StatusIconSystem>();
|
||||
}
|
||||
|
||||
protected override void Draw(in OverlayDrawArgs args)
|
||||
@@ -70,6 +73,9 @@ public sealed class EntityHealthBarOverlay : Overlay
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!_statusIcon.IsVisible(uid))
|
||||
continue;
|
||||
|
||||
// we use the status icon component bounds if specified otherwise use sprite
|
||||
var bounds = _entManager.GetComponentOrNull<StatusIconComponent>(uid)?.Bounds ?? spriteComponent.Bounds;
|
||||
var worldPos = _transform.GetWorldPosition(xform, xformQuery);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Ghost;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.Mind.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.NPC;
|
||||
@@ -34,9 +36,18 @@ public sealed class SSDIndicatorSystem : EntitySystem
|
||||
!_mobState.IsDead(uid) &&
|
||||
!HasComp<ActiveNPCComponent>(uid) &&
|
||||
TryComp<MindContainerComponent>(uid, out var mindContainer) &&
|
||||
mindContainer.ShowExamineInfo)
|
||||
mindContainer.ShowExamineInfo &&
|
||||
!IsAghosted(mindContainer)) // WD EDIT
|
||||
{
|
||||
args.StatusIcons.Add(_prototype.Index<StatusIconPrototype>(component.Icon));
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsAghosted(MindContainerComponent mindContainer) // WD
|
||||
{
|
||||
if (!TryComp(mindContainer.Mind, out MindComponent? mindComp))
|
||||
return false;
|
||||
|
||||
return TryComp(mindComp.VisitingEntity, out GhostComponent? ghost) && ghost.CanGhostInteract;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,9 @@ public sealed class StatusIconOverlay : Overlay
|
||||
if (icons.Count == 0)
|
||||
continue;
|
||||
|
||||
if (!_statusIcon.IsVisible(uid))
|
||||
continue;
|
||||
|
||||
var worldMatrix = Matrix3.CreateTranslation(worldPos);
|
||||
Matrix3.Multiply(scaleMatrix, worldMatrix, out var scaledWorld);
|
||||
Matrix3.Multiply(rotationMatrix, scaledWorld, out var matty);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Client.Interactable.Components;
|
||||
using Content.Client.StatusIcon;
|
||||
using Content.Shared.Stealth;
|
||||
using Content.Shared.Stealth.Components;
|
||||
using Robust.Client.GameObjects;
|
||||
@@ -18,9 +19,12 @@ public sealed class StealthSystem : SharedStealthSystem
|
||||
base.Initialize();
|
||||
|
||||
_shader = _protoMan.Index<ShaderPrototype>("Stealth").InstanceUnique();
|
||||
|
||||
SubscribeLocalEvent<StealthComponent, ComponentShutdown>(OnShutdown);
|
||||
SubscribeLocalEvent<StealthComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<StealthComponent, BeforePostShaderRenderEvent>(OnShaderRender);
|
||||
|
||||
SubscribeLocalEvent<StealthComponent, StatusIconVisibleEvent>(OnStatusIconVisible);
|
||||
}
|
||||
|
||||
public override void SetEnabled(EntityUid uid, bool value, StealthComponent? component = null)
|
||||
@@ -92,5 +96,12 @@ public sealed class StealthSystem : SharedStealthSystem
|
||||
visibility = MathF.Max(0, visibility);
|
||||
args.Sprite.Color = new Color(visibility, visibility, 1, 1);
|
||||
}
|
||||
|
||||
private void OnStatusIconVisible(EntityUid uid, StealthComponent comp, ref StatusIconVisibleEvent args)
|
||||
{
|
||||
// no sechud seing invisible ninjas
|
||||
if (comp.Enabled)
|
||||
args.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Client.StatusIcon;
|
||||
using Content.Client.Storage.Components;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.Foldable;
|
||||
@@ -29,6 +30,8 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
|
||||
|
||||
SubscribeLocalEvent<EntityStorageComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<EntityStorageComponent, ComponentHandleState>(OnHandleState);
|
||||
|
||||
SubscribeLocalEvent<InsideEntityStorageComponent, StatusIconVisibleEvent>(OnStatusIconVisible);
|
||||
}
|
||||
|
||||
public override bool ResolveStorage(EntityUid uid, [NotNullWhen(true)] ref SharedEntityStorageComponent? component)
|
||||
@@ -40,4 +43,9 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
|
||||
component = storage;
|
||||
return component != null;
|
||||
}
|
||||
|
||||
private void OnStatusIconVisible(EntityUid uid, InsideEntityStorageComponent comp, ref StatusIconVisibleEvent args)
|
||||
{
|
||||
args.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,8 @@ public sealed class AGhost : LocalizedCommands
|
||||
return;
|
||||
}
|
||||
|
||||
_entities.Dirty(mindId, mind); // WD
|
||||
|
||||
if (mind.VisitingEntity != default && _entities.TryGetComponent<GhostComponent>(mind.VisitingEntity, out var oldGhostComponent))
|
||||
{
|
||||
mindSystem.UnVisit(mindId, mind);
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
- type: Clothing
|
||||
sprite: Clothing/OuterClothing/Suits/spaceninja.rsi
|
||||
- type: StealthClothing
|
||||
visibility: 1.1
|
||||
visibility: 0.5
|
||||
toggleAction: ActionTogglePhaseCloak
|
||||
- type: PressureProtection
|
||||
highPressureMultiplier: 0.6
|
||||
|
||||
Reference in New Issue
Block a user