diff --git a/client/ArenaRenderer.cs b/client/ArenaRenderer.cs index a4895ac..8d2289c 100644 --- a/client/ArenaRenderer.cs +++ b/client/ArenaRenderer.cs @@ -282,6 +282,10 @@ public partial class ArenaRenderer : Node3D if (_spectatorVisuals.TryGetValue(s.Id, out var deadVis)) { deadVis.Root.Visible = false; + if (deadVis.LaserMesh is not null) + { + deadVis.LaserMesh.Visible = false; + } } continue; } @@ -358,7 +362,9 @@ public partial class ArenaRenderer : Node3D { vis.LaserMesh.Visible = true; 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); } else diff --git a/client/Hud.cs b/client/Hud.cs index 5e0ce22..6f409c6 100644 --- a/client/Hud.cs +++ b/client/Hud.cs @@ -46,6 +46,9 @@ public partial class Hud : CanvasLayer private PanelContainer _bottomLeftPanel = null!; private VBoxContainer _chyronBox = null!; + private readonly Label[] _chyronLabels = new Label[3]; + private BroadcastFeed? _lastBroadcastFeed; + private int _lastChyronCount = -1; private PanelContainer _outcomeBanner = null!; private Label _outcomeLabel = null!; @@ -140,7 +143,7 @@ public partial class Hud : CanvasLayer } // Broadcast Chyron - SyncBroadcastChyron(state.Broadcast.Lines); + SyncBroadcastChyron(state.Broadcast); // Outcome if (state.Phase == MatchPhase.Victory) @@ -263,6 +266,7 @@ public partial class Hud : CanvasLayer _bottomLeftPanel.AnchorLeft = 0f; _bottomLeftPanel.AnchorTop = 1f; _bottomLeftPanel.AnchorBottom = 1f; + _bottomLeftPanel.GrowVertical = Control.GrowDirection.Begin; _bottomLeftPanel.OffsetLeft = 14f; _bottomLeftPanel.OffsetTop = -248f; _bottomLeftPanel.OffsetBottom = -14f; @@ -332,6 +336,19 @@ public partial class Hud : CanvasLayer _chyronBox = new VBoxContainer(); _chyronBox.AddThemeConstantOverride("separation", 2); 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() @@ -452,28 +469,37 @@ public partial class Hud : CanvasLayer } } - private void SyncBroadcastChyron(IReadOnlyList 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); - _chyronBox.RemoveChild(c); - c.QueueFree(); + return; } - int start = Math.Max(0, lines.Count - 3); - for (int i = start; i < lines.Count; i++) + _lastBroadcastFeed = broadcast; + _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]; - bool isLatest = i == lines.Count - 1; - var lbl = new Label + var lbl = _chyronLabels[slot]; + if (slot < visibleCount) { - Text = $"[{line.Timestamp:00.0}s] {line.Text}", - AutowrapMode = TextServer.AutowrapMode.Word - }; - lbl.AddThemeFontSizeOverride("font_size", isLatest ? 12 : 11); - lbl.AddThemeColorOverride("font_color", isLatest ? TextLight : TextMuted); - _chyronBox.AddChild(lbl); + int lineIdx = start + slot; + var line = lines[lineIdx]; + bool isLatest = lineIdx == lines.Count - 1; + lbl.Visible = true; + lbl.Text = $"[{line.Timestamp:00.0}s] {line.Text}"; + 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; + 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() { Vector2 center = Size * 0.5f; @@ -566,7 +596,7 @@ public partial class Hud : CanvasLayer { var d = _state.GroundDrops[i]; 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) { 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]; 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; 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) { 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); } col = RedCol; @@ -613,10 +643,10 @@ public partial class Hud : CanvasLayer { var c = _state.Contenders[i]; 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) { - 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 pts = new[] { diff --git a/client/NativeLibraries.cs b/client/NativeLibraries.cs index d789a5a..e5bafde 100644 --- a/client/NativeLibraries.cs +++ b/client/NativeLibraries.cs @@ -25,11 +25,29 @@ internal static class NativeLibraries private static IntPtr Resolve(string name, Assembly assembly, DllImportSearchPath? searchPath) { if (name != Library) return IntPtr.Zero; - string dir = OS.HasFeature("template") - ? Path.Combine(Path.GetDirectoryName(OS.GetExecutablePath())!, $"data_RustToDust.Client_{Platform()}_{Arch()}") - : ProjectSettings.GlobalizePath("res://.godot/mono/temp/bin/Debug"); - string path = Path.Combine(dir, FileName()); - return File.Exists(path) && NativeLibrary.TryLoad(path, out var handle) ? handle : IntPtr.Zero; + string fileName = FileName(); + + if (OS.HasFeature("template")) + { + 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() =>