Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Jabak
2024-06-15 19:29:46 +03:00
51 changed files with 640 additions and 77 deletions

View File

@@ -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);

View File

@@ -1,4 +1,5 @@
using System.Linq;
using Content.Client.UserInterface.Systems.Chat;
using Content.Shared.Examine;
using Content.Shared.Chat;
using Content.Shared.GameTicking;
@@ -10,7 +11,6 @@ using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Shared.Configuration;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Replays;
@@ -31,7 +31,6 @@ namespace Content.Client.Popups
[Dependency] private readonly IReplayRecordingManager _replayRecording = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly IClientNetManager _clientNet = default!;
public IReadOnlyList<WorldPopupLabel> WorldLabels => _aliveWorldLabels;
public IReadOnlyList<CursorPopupLabel> CursorLabels => _aliveCursorLabels;
@@ -94,6 +93,13 @@ namespace Content.Client.Popups
_aliveWorldLabels.Add(label);
// START WhiteDream
if (!_isLogging)
return;
if (!_examine.InRangeUnOccluded(_playerManager.LocalEntity!.Value, coordinates, 10))
return;
var fontSizeDict = new Dictionary<PopupType, string>
{
{ PopupType.Medium, "12" },
@@ -103,14 +109,16 @@ namespace Content.Client.Popups
};
var fontsize = fontSizeDict.GetValueOrDefault(type, "10");
var fontcolor = type is PopupType.LargeCaution or PopupType.MediumCaution or PopupType.SmallCaution ? "c62828" : "aeabc4";
var fontcolor = type is PopupType.LargeCaution or PopupType.MediumCaution or PopupType.SmallCaution
? "c62828"
: "aeabc4";
if (_isLogging)
{
var wrappedMEssage = $"[font size={fontsize}][color=#{fontcolor}]{message}[/color][/font]";
var chatMsg = new ChatMessage(ChatChannel.Emotes, message, wrappedMEssage, GetNetEntity(EntityUid.Invalid), null);
_clientNet.DispatchLocalNetMessage(new MsgChatMessage { Message = chatMsg });
}
var wrappedMEssage = $"[font size={fontsize}][color=#{fontcolor}]{message}[/color][/font]";
var chatMsg = new ChatMessage(ChatChannel.Emotes, message, wrappedMEssage,
GetNetEntity(EntityUid.Invalid), null);
_uiManager.GetUIController<ChatUIController>().ProcessChatMessage(chatMsg);
// END WhiteDream
}
#region Abstract Method Implementations

View File

@@ -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;
}
}

View File

@@ -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);

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);

View File

@@ -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;
}
}

View File

@@ -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;
}
}