Client HUD/Renderer: fix dead laser visibility, radar orientation, Garage grow direction, chyron churn, and NativeLibraries

This commit is contained in:
Meta Vens 2026-12-04 14:16:05 +01:00
commit 3cb60447ff
3 changed files with 82 additions and 28 deletions

View file

@ -282,6 +282,10 @@ public partial class ArenaRenderer : Node3D
if (_spectatorVisuals.TryGetValue(s.Id, out var deadVis)) if (_spectatorVisuals.TryGetValue(s.Id, out var deadVis))
{ {
deadVis.Root.Visible = false; deadVis.Root.Visible = false;
if (deadVis.LaserMesh is not null)
{
deadVis.LaserMesh.Visible = false;
}
} }
continue; continue;
} }
@ -358,7 +362,9 @@ public partial class ArenaRenderer : Node3D
{ {
vis.LaserMesh.Visible = true; vis.LaserMesh.Visible = true;
vis.LaserMesh.GlobalPosition = (start + end) * 0.5f; vis.LaserMesh.GlobalPosition = (start + end) * 0.5f;
vis.LaserMesh.LookAt(end, Vector3.Up); Vector3 dir = (end - start) / dist;
Vector3 up = MathF.Abs(dir.Dot(Vector3.Up)) > 0.99f ? Vector3.Right : Vector3.Up;
vis.LaserMesh.LookAt(end, up);
vis.LaserMesh.Scale = new Vector3(1f, 1f, dist); vis.LaserMesh.Scale = new Vector3(1f, 1f, dist);
} }
else else

View file

@ -46,6 +46,9 @@ public partial class Hud : CanvasLayer
private PanelContainer _bottomLeftPanel = null!; private PanelContainer _bottomLeftPanel = null!;
private VBoxContainer _chyronBox = null!; private VBoxContainer _chyronBox = null!;
private readonly Label[] _chyronLabels = new Label[3];
private BroadcastFeed? _lastBroadcastFeed;
private int _lastChyronCount = -1;
private PanelContainer _outcomeBanner = null!; private PanelContainer _outcomeBanner = null!;
private Label _outcomeLabel = null!; private Label _outcomeLabel = null!;
@ -140,7 +143,7 @@ public partial class Hud : CanvasLayer
} }
// Broadcast Chyron // Broadcast Chyron
SyncBroadcastChyron(state.Broadcast.Lines); SyncBroadcastChyron(state.Broadcast);
// Outcome // Outcome
if (state.Phase == MatchPhase.Victory) if (state.Phase == MatchPhase.Victory)
@ -263,6 +266,7 @@ public partial class Hud : CanvasLayer
_bottomLeftPanel.AnchorLeft = 0f; _bottomLeftPanel.AnchorLeft = 0f;
_bottomLeftPanel.AnchorTop = 1f; _bottomLeftPanel.AnchorTop = 1f;
_bottomLeftPanel.AnchorBottom = 1f; _bottomLeftPanel.AnchorBottom = 1f;
_bottomLeftPanel.GrowVertical = Control.GrowDirection.Begin;
_bottomLeftPanel.OffsetLeft = 14f; _bottomLeftPanel.OffsetLeft = 14f;
_bottomLeftPanel.OffsetTop = -248f; _bottomLeftPanel.OffsetTop = -248f;
_bottomLeftPanel.OffsetBottom = -14f; _bottomLeftPanel.OffsetBottom = -14f;
@ -332,6 +336,19 @@ public partial class Hud : CanvasLayer
_chyronBox = new VBoxContainer(); _chyronBox = new VBoxContainer();
_chyronBox.AddThemeConstantOverride("separation", 2); _chyronBox.AddThemeConstantOverride("separation", 2);
vbox.AddChild(_chyronBox); vbox.AddChild(_chyronBox);
for (int i = 0; i < _chyronLabels.Length; i++)
{
var lbl = new Label
{
Visible = false,
AutowrapMode = TextServer.AutowrapMode.Word
};
lbl.AddThemeFontSizeOverride("font_size", 11);
lbl.AddThemeColorOverride("font_color", TextMuted);
_chyronBox.AddChild(lbl);
_chyronLabels[i] = lbl;
}
} }
private void BuildOutcomeBanner() private void BuildOutcomeBanner()
@ -452,28 +469,37 @@ public partial class Hud : CanvasLayer
} }
} }
private void SyncBroadcastChyron(IReadOnlyList<BroadcastLine> lines) private void SyncBroadcastChyron(BroadcastFeed broadcast)
{ {
for (int i = _chyronBox.GetChildCount() - 1; i >= 0; i--) var lines = broadcast.Lines;
if (ReferenceEquals(_lastBroadcastFeed, broadcast) && lines.Count == _lastChyronCount)
{ {
var c = _chyronBox.GetChild(i); return;
_chyronBox.RemoveChild(c);
c.QueueFree();
} }
int start = Math.Max(0, lines.Count - 3); _lastBroadcastFeed = broadcast;
for (int i = start; i < lines.Count; i++) _lastChyronCount = lines.Count;
int start = Math.Max(0, lines.Count - _chyronLabels.Length);
int visibleCount = lines.Count - start;
for (int slot = 0; slot < _chyronLabels.Length; slot++)
{ {
var line = lines[i]; var lbl = _chyronLabels[slot];
bool isLatest = i == lines.Count - 1; if (slot < visibleCount)
var lbl = new Label
{ {
Text = $"[{line.Timestamp:00.0}s] {line.Text}", int lineIdx = start + slot;
AutowrapMode = TextServer.AutowrapMode.Word var line = lines[lineIdx];
}; bool isLatest = lineIdx == lines.Count - 1;
lbl.AddThemeFontSizeOverride("font_size", isLatest ? 12 : 11); lbl.Visible = true;
lbl.AddThemeColorOverride("font_color", isLatest ? TextLight : TextMuted); lbl.Text = $"[{line.Timestamp:00.0}s] {line.Text}";
_chyronBox.AddChild(lbl); lbl.AddThemeFontSizeOverride("font_size", isLatest ? 12 : 11);
lbl.AddThemeColorOverride("font_color", isLatest ? TextLight : TextMuted);
}
else
{
lbl.Visible = false;
lbl.Text = "";
}
} }
} }
@ -546,6 +572,10 @@ public partial class Hud : CanvasLayer
public void SetState(MatchState state) => _state = state; public void SetState(MatchState state) => _state = state;
private static Vector2 WorldToRadar(Vector2 center, float scale, float wx, float wz) =>
// Match chase camera orientation: screen-up = +Z, screen-right = -X.
center + new Vector2(-wx, -wz) * scale;
public override void _Draw() public override void _Draw()
{ {
Vector2 center = Size * 0.5f; Vector2 center = Size * 0.5f;
@ -566,7 +596,7 @@ public partial class Hud : CanvasLayer
{ {
var d = _state.GroundDrops[i]; var d = _state.GroundDrops[i];
if (d.PickedUp) continue; if (d.PickedUp) continue;
var p = center + new Vector2(d.X, d.Z) * scale; var p = WorldToRadar(center, scale, d.X, d.Z);
if (d.Chassis is not null) if (d.Chassis is not null)
{ {
DrawRect(new Rect2(p - new Vector2(2.5f, 2.5f), new Vector2(5f, 5f)), CyanCol); DrawRect(new Rect2(p - new Vector2(2.5f, 2.5f), new Vector2(5f, 5f)), CyanCol);
@ -583,7 +613,7 @@ public partial class Hud : CanvasLayer
{ {
var s = specs[i]; var s = specs[i];
if (!s.Alive) continue; if (!s.Alive) continue;
var p = center + new Vector2(s.X, s.Z) * scale; var p = WorldToRadar(center, scale, s.X, s.Z);
float blipR = 1.6f + s.RadarSignature * 3.1f; float blipR = 1.6f + s.RadarSignature * 3.1f;
Color col = s.Tier switch Color col = s.Tier switch
@ -599,7 +629,7 @@ public partial class Hud : CanvasLayer
if (tid >= 0 && tid < _state.Contenders.Count && _state.Contenders[tid].Alive) if (tid >= 0 && tid < _state.Contenders.Count && _state.Contenders[tid].Alive)
{ {
var tgt = _state.Contenders[tid]; var tgt = _state.Contenders[tid];
var tp = center + new Vector2(tgt.X, tgt.Z) * scale; var tp = WorldToRadar(center, scale, tgt.X, tgt.Z);
DrawLine(p, tp, new Color(RedCol.R, RedCol.G, RedCol.B, 0.65f), 1.3f); DrawLine(p, tp, new Color(RedCol.R, RedCol.G, RedCol.B, 0.65f), 1.3f);
} }
col = RedCol; col = RedCol;
@ -613,10 +643,10 @@ public partial class Hud : CanvasLayer
{ {
var c = _state.Contenders[i]; var c = _state.Contenders[i];
if (!c.Alive) continue; if (!c.Alive) continue;
var p = center + new Vector2(c.X, c.Z) * scale; var p = WorldToRadar(center, scale, c.X, c.Z);
if (c.IsPlayer) if (c.IsPlayer)
{ {
var dir = new Vector2(MathF.Sin(c.Yaw), MathF.Cos(c.Yaw)); var dir = new Vector2(-MathF.Sin(c.Yaw), -MathF.Cos(c.Yaw));
var perp = new Vector2(-dir.Y, dir.X); var perp = new Vector2(-dir.Y, dir.X);
var pts = new[] var pts = new[]
{ {

View file

@ -25,11 +25,29 @@ internal static class NativeLibraries
private static IntPtr Resolve(string name, Assembly assembly, DllImportSearchPath? searchPath) private static IntPtr Resolve(string name, Assembly assembly, DllImportSearchPath? searchPath)
{ {
if (name != Library) return IntPtr.Zero; if (name != Library) return IntPtr.Zero;
string dir = OS.HasFeature("template") string fileName = FileName();
? Path.Combine(Path.GetDirectoryName(OS.GetExecutablePath())!, $"data_RustToDust.Client_{Platform()}_{Arch()}")
: ProjectSettings.GlobalizePath("res://.godot/mono/temp/bin/Debug"); if (OS.HasFeature("template"))
string path = Path.Combine(dir, FileName()); {
return File.Exists(path) && NativeLibrary.TryLoad(path, out var handle) ? handle : IntPtr.Zero; string exportPath = Path.Combine(
Path.GetDirectoryName(OS.GetExecutablePath())!,
$"data_RustToDust.Client_{Platform()}_{Arch()}",
fileName);
return File.Exists(exportPath) && NativeLibrary.TryLoad(exportPath, out var exportHandle)
? exportHandle
: IntPtr.Zero;
}
string debugPath = Path.Combine(ProjectSettings.GlobalizePath("res://.godot/mono/temp/bin/Debug"), fileName);
if (File.Exists(debugPath) && NativeLibrary.TryLoad(debugPath, out var debugHandle))
{
return debugHandle;
}
string releasePath = Path.Combine(ProjectSettings.GlobalizePath("res://.godot/mono/temp/bin/Release"), fileName);
return File.Exists(releasePath) && NativeLibrary.TryLoad(releasePath, out var releaseHandle)
? releaseHandle
: IntPtr.Zero;
} }
private static string FileName() => private static string FileName() =>