Hud refactor (#7202)
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: Jezithyr <jmaster9999@gmail.com> Co-authored-by: Jezithyr <Jezithyr@gmail.com> Co-authored-by: Visne <39844191+Visne@users.noreply.github.com> Co-authored-by: wrexbe <wrexbe@protonmail.com> Co-authored-by: wrexbe <81056464+wrexbe@users.noreply.github.com>
This commit is contained in:
@@ -1,65 +1,5 @@
|
||||
using Content.Client.Chat.Managers;
|
||||
using Content.Client.Chat.UI;
|
||||
using Content.Client.Examine;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Examine;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Client.Chat;
|
||||
|
||||
public sealed class ChatSystem : SharedChatSystem
|
||||
{
|
||||
[Dependency] private readonly IChatManager _manager = default!;
|
||||
[Dependency] private readonly IPlayerManager _player = default!;
|
||||
[Dependency] private readonly ExamineSystem _examineSystem = default!;
|
||||
|
||||
public override void FrameUpdate(float frameTime)
|
||||
{
|
||||
base.FrameUpdate(frameTime);
|
||||
|
||||
var player = _player.LocalPlayer?.ControlledEntity;
|
||||
var predicate = static (EntityUid uid, (EntityUid compOwner, EntityUid? attachedEntity) data)
|
||||
=> uid == data.compOwner || uid == data.attachedEntity;
|
||||
var bubbles = _manager.GetSpeechBubbles();
|
||||
var playerPos = player != null ? Transform(player.Value).MapPosition : MapCoordinates.Nullspace;
|
||||
|
||||
var occluded = player != null && _examineSystem.IsOccluded(player.Value);
|
||||
|
||||
foreach (var (ent, bubs) in bubbles)
|
||||
{
|
||||
if (Deleted(ent))
|
||||
{
|
||||
SetBubbles(bubs, false);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ent == player)
|
||||
{
|
||||
SetBubbles(bubs, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
var otherPos = Transform(ent).MapPosition;
|
||||
|
||||
if (occluded && !ExamineSystemShared.InRangeUnOccluded(
|
||||
playerPos,
|
||||
otherPos, 0f,
|
||||
(ent, player), predicate))
|
||||
{
|
||||
SetBubbles(bubs, false);
|
||||
continue;
|
||||
}
|
||||
|
||||
SetBubbles(bubs, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetBubbles(List<SpeechBubble> bubbles, bool value)
|
||||
{
|
||||
foreach (var bubble in bubbles)
|
||||
{
|
||||
bubble.Visible = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
public sealed class ChatSystem : SharedChatSystem {}
|
||||
|
||||
Reference in New Issue
Block a user