Cut 1: 1536m desert relief, terrain/cover LOS detection, tier positioning, 3P shoulder cam

This commit is contained in:
Meta Vens 2026-12-04 15:14:00 +01:00
commit 3221ca1d0c
19 changed files with 1558 additions and 316 deletions

View file

@ -28,6 +28,7 @@ public partial class Hud : CanvasLayer
private readonly Func<ArenaSession?> _getSession;
private readonly Action<int, string> _onEquipCargo;
private readonly Func<float> _getCameraYaw;
private Label _chassisHeader = null!;
private Label _planeBadge = null!;
@ -35,10 +36,12 @@ public partial class Hud : CanvasLayer
private Label _coreHpLabel = null!;
private Label _statsLabel = null!;
private Label _safeLabel = null!;
private Label _detectionLabel = null!;
private Label _promptLabel = null!;
private Label _controlsHint = null!;
private RadarWidget _radar = null!;
private CrosshairOverlay _crosshair = null!;
private SchematicPanel _schematic = null!;
private VBoxContainer _cargoList = null!;
private Label _cargoHeader = null!;
@ -56,10 +59,11 @@ public partial class Hud : CanvasLayer
private int _lastCargoHash = -1;
private bool _garageExpanded;
public Hud(Func<ArenaSession?> getSession, Action<int, string> onEquipCargo)
public Hud(Func<ArenaSession?> getSession, Action<int, string> onEquipCargo, Func<float>? getCameraYaw = null)
{
_getSession = getSession;
_onEquipCargo = onEquipCargo;
_getCameraYaw = getCameraYaw ?? (() => 0f);
Layer = 10;
}
@ -75,6 +79,7 @@ public partial class Hud : CanvasLayer
public override void _Ready()
{
BuildCrosshair();
BuildTopLeft();
BuildTopRightRadar();
BuildBottomLeftSchematic();
@ -125,11 +130,26 @@ public partial class Hud : CanvasLayer
_safeLabel.Modulate = RedCol;
}
if (state.PlayerDetectedByCount > 0)
{
_detectionLabel.Text = $"DETECTED BY {state.PlayerDetectedByCount}";
_detectionLabel.Modulate = RedCol;
}
else
{
_detectionLabel.Text = "CONCEALED (TERRAIN)";
_detectionLabel.Modulate = OliveCol;
}
_promptLabel.Text = BuildInteractionPrompt(state, player);
_promptLabel.Visible = !string.IsNullOrEmpty(_promptLabel.Text);
// Radar
_radar.SetState(state);
// Crosshair + Heat Arc
_crosshair.SetState(player);
_crosshair.QueueRedraw();
// Radar (heading-up with camera yaw)
_radar.SetState(state, _getCameraYaw());
_radar.QueueRedraw();
// Schematic + Cargo
@ -164,6 +184,14 @@ public partial class Hud : CanvasLayer
}
}
private void BuildCrosshair()
{
_crosshair = new CrosshairOverlay { Name = "Crosshair" };
_crosshair.SetAnchorsPreset(Control.LayoutPreset.FullRect);
_crosshair.MouseFilter = Control.MouseFilterEnum.Ignore;
AddChild(_crosshair);
}
private void BuildTopLeft()
{
var panel = CreateStyledPanel();
@ -222,12 +250,16 @@ public partial class Hud : CanvasLayer
_safeLabel.AddThemeFontSizeOverride("font_size", 13);
vbox.AddChild(_safeLabel);
_detectionLabel = new Label { Text = "CONCEALED (TERRAIN)" };
_detectionLabel.AddThemeFontSizeOverride("font_size", 13);
vbox.AddChild(_detectionLabel);
_promptLabel = new Label { Text = "", Visible = false };
_promptLabel.AddThemeColorOverride("font_color", CyanCol);
_promptLabel.AddThemeFontSizeOverride("font_size", 14);
vbox.AddChild(_promptLabel);
_controlsHint = new Label { Text = "WASD Drive | LMB Fire | E Loot/Swap | Tab Garage | R Reset" };
_controlsHint = new Label { Text = "WASD Drive | Mouse Aim | LMB Fire | E Loot/Swap | Tab Garage | Wheel Zoom" };
_controlsHint.AddThemeColorOverride("font_color", TextMuted);
_controlsHint.AddThemeFontSizeOverride("font_size", 11);
vbox.AddChild(_controlsHint);
@ -566,15 +598,86 @@ public partial class Hud : CanvasLayer
return panel;
}
private sealed partial class CrosshairOverlay : Control
{
private ContenderState? _player;
public void SetState(ContenderState player) => _player = player;
public override void _Draw()
{
Vector2 center = Size * 0.5f;
float gap = 6f;
float tick = 10f;
Color retCol = new Color(TextLight.R, TextLight.G, TextLight.B, 0.88f);
// Clean 4-tick center crosshair + center pip
DrawCircle(center, 1.8f, retCol);
DrawLine(center + new Vector2(-gap - tick, 0f), center + new Vector2(-gap, 0f), retCol, 1.6f);
DrawLine(center + new Vector2(gap, 0f), center + new Vector2(gap + tick, 0f), retCol, 1.6f);
DrawLine(center + new Vector2(0f, -gap - tick), center + new Vector2(0f, -gap), retCol, 1.6f);
DrawLine(center + new Vector2(0f, gap), center + new Vector2(0f, gap + tick), retCol, 1.6f);
if (_player is null || !_player.Alive)
{
return;
}
// Thermal heat-arc indicator around crosshair
float heatRatio = 0f;
bool overPlateau = false;
var mounted = _player.Grid.Mounted;
for (int i = 0; i < mounted.Count; i++)
{
var m = mounted[i];
if (m.Spec.Kind == HardpointKind.Weapon)
{
float r = Math.Clamp(
(m.CurrentTemp - ChassisGrid.AmbientTemp) / MathF.Max(1f, m.Spec.MaxTemp - ChassisGrid.AmbientTemp),
0f, 1f);
if (r > heatRatio) heatRatio = r;
if (m.CurrentTemp > m.Spec.OptimalTemp + m.Spec.PlateauWidth * 0.5f)
{
overPlateau = true;
}
}
}
float arcRadius = 21f;
float startAngle = -MathF.PI * 0.75f;
float maxSweep = MathF.PI * 1.5f;
DrawArc(center, arcRadius, startAngle, startAngle + maxSweep, 24, new Color(BorderCol.R, BorderCol.G, BorderCol.B, 0.4f), 2.0f);
if (heatRatio > 0.01f)
{
Color heatCol = overPlateau
? RedCol
: (heatRatio > 0.65f ? OrangeCol : OliveCol);
DrawArc(center, arcRadius, startAngle, startAngle + maxSweep * heatRatio, 24, heatCol, 2.4f);
}
}
}
private sealed partial class RadarWidget : Control
{
private MatchState? _state;
private float _cameraYaw;
public void SetState(MatchState state) => _state = state;
public void SetState(MatchState state, float cameraYaw)
{
_state = state;
_cameraYaw = cameraYaw;
}
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;
private static Vector2 WorldToRadar(Vector2 center, float scale, float wx, float wz, float camYaw)
{
// Heading-up 3P radar: camera forward (sinY, cosY) is always UP (-screenY), camera right (-cosY, sinY) is RIGHT (+screenX).
float sinY = MathF.Sin(camYaw);
float cosY = MathF.Cos(camYaw);
float rx = -wx * cosY + wz * sinY;
float fy = wx * sinY + wz * cosY;
return center + new Vector2(rx, -fy) * scale;
}
public override void _Draw()
{
@ -584,19 +687,21 @@ public partial class Hud : CanvasLayer
DrawCircle(center, radius, BgInner);
DrawArc(center, radius, 0f, MathF.Tau, 48, BorderCol, 1.5f);
// Forward-up indicator tick at top of radar
DrawLine(center + new Vector2(0f, -radius), center + new Vector2(0f, -radius + 6f), CyanCol, 2.0f);
if (_state is null) return;
// Safe Circle
float safePx = _state.Spectators.SafeRadius * scale;
DrawArc(center, safePx, 0f, MathF.Tau, 56, OrangeCol, 1.6f);
DrawArc(center, safePx, 0f, MathF.Tau, 64, OrangeCol, 1.6f);
// Ground drops
for (int i = 0; i < _state.GroundDrops.Count; i++)
{
var d = _state.GroundDrops[i];
if (d.PickedUp) continue;
var p = WorldToRadar(center, scale, d.X, d.Z);
var p = WorldToRadar(center, scale, d.X, d.Z, _cameraYaw);
if (d.Chassis is not null)
{
DrawRect(new Rect2(p - new Vector2(2.5f, 2.5f), new Vector2(5f, 5f)), CyanCol);
@ -607,13 +712,23 @@ public partial class Hud : CanvasLayer
}
}
// Spectator Wall (scaled by RadarSignature) + red target lock lines
// Spectator Wall (LOS / Tourist horizon rule / 5s ghost memory; hidden Exemplars vanish!)
var specs = _state.Spectators.Spectators;
for (int i = 0; i < specs.Count; i++)
{
var s = specs[i];
if (!s.Alive) continue;
var p = WorldToRadar(center, scale, s.X, s.Z);
_state.SpectatorContacts.TryGetValue(s.Id, out var mem);
if (!MatchState.IsContactOnRadar(mem))
{
continue;
}
bool live = mem!.VisibleToPlayer;
float drawX = live || mem.FaintHorizonPing ? s.X : mem.LastSeenX;
float drawZ = live || mem.FaintHorizonPing ? s.Z : mem.LastSeenZ;
var p = WorldToRadar(center, scale, drawX, drawZ, _cameraYaw);
float blipR = 1.6f + s.RadarSignature * 3.1f;
Color col = s.Tier switch
@ -623,30 +738,46 @@ public partial class Hud : CanvasLayer
_ => RedCol
};
if (s.Stance != SpectatorStance.Neutral && s.TargetContenderId.HasValue)
if (live && s.Stance != SpectatorStance.Neutral && s.HasTargetLos && s.TargetContenderId.HasValue)
{
int tid = s.TargetContenderId.Value;
if (tid >= 0 && tid < _state.Contenders.Count && _state.Contenders[tid].Alive)
{
var tgt = _state.Contenders[tid];
var tp = WorldToRadar(center, scale, tgt.X, tgt.Z);
var tp = WorldToRadar(center, scale, tgt.X, tgt.Z, _cameraYaw);
DrawLine(p, tp, new Color(RedCol.R, RedCol.G, RedCol.B, 0.65f), 1.3f);
}
col = RedCol;
}
DrawCircle(p, blipR, col);
if (!live)
{
float alpha = mem.FaintHorizonPing
? 0.42f
: Math.Clamp((1f - mem.LastSeenAge / MatchState.ContactGhostDuration) * 0.48f, 0.08f, 0.48f);
Color ghostCol = mem.FaintHorizonPing ? GoldCol : col;
DrawCircle(p, blipR, new Color(ghostCol.R, ghostCol.G, ghostCol.B, alpha));
}
else
{
DrawCircle(p, blipR, col);
}
}
// Contenders
// Contenders (player always live; rivals obey LOS + 5s ghost memory)
float sinY = MathF.Sin(_cameraYaw);
float cosY = MathF.Cos(_cameraYaw);
for (int i = 0; i < _state.Contenders.Count; i++)
{
var c = _state.Contenders[i];
if (!c.Alive) continue;
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 p = WorldToRadar(center, scale, c.X, c.Z, _cameraYaw);
var dir = new Vector2(
-MathF.Sin(c.Yaw) * cosY + MathF.Cos(c.Yaw) * sinY,
-(MathF.Sin(c.Yaw) * sinY + MathF.Cos(c.Yaw) * cosY));
var perp = new Vector2(-dir.Y, dir.X);
var pts = new[]
{
@ -655,10 +786,25 @@ public partial class Hud : CanvasLayer
p - dir * 4.5f - perp * 4.2f
};
DrawColoredPolygon(pts, OliveCol);
continue;
}
_state.ContenderContacts.TryGetValue(c.Id, out var mem);
if (!MatchState.IsContactOnRadar(mem))
{
continue;
}
if (mem!.VisibleToPlayer)
{
var p = WorldToRadar(center, scale, c.X, c.Z, _cameraYaw);
DrawCircle(p, 3.3f, OrangeCol);
}
else
{
DrawCircle(p, 3.3f, OrangeCol);
var p = WorldToRadar(center, scale, mem.LastSeenX, mem.LastSeenZ, _cameraYaw);
float alpha = Math.Clamp((1f - mem.LastSeenAge / MatchState.ContactGhostDuration) * 0.48f, 0.08f, 0.48f);
DrawCircle(p, 2.8f, new Color(OrangeCol.R, OrangeCol.G, OrangeCol.B, alpha));
}
}
}