hud: drop [T] CONDUITS layer, always-active thermal glow, and directional hit-arcs
This commit is contained in:
parent
1319d85e08
commit
3e499c31ee
4 changed files with 192 additions and 153 deletions
190
client/Hud.cs
190
client/Hud.cs
|
|
@ -43,7 +43,6 @@ public partial class Hud : CanvasLayer
|
|||
private RadarWidget _radar = null!;
|
||||
private CrosshairOverlay _crosshair = null!;
|
||||
private InventoryGridControl _schematic = null!;
|
||||
private Button _thermalButton = null!;
|
||||
private Label _hoverLabel = null!;
|
||||
private VBoxContainer _cargoList = null!;
|
||||
private Label _cargoHeader = null!;
|
||||
|
|
@ -73,8 +72,10 @@ public partial class Hud : CanvasLayer
|
|||
}
|
||||
|
||||
public bool GarageExpanded => _garageExpanded;
|
||||
public bool ThermalMode => _schematic.ThermalEnabled;
|
||||
public InventoryGridControl Schematic => _schematic;
|
||||
internal int ActiveHitArcCount => _crosshair.ActiveHitArcCount;
|
||||
internal void PushTestHitArc(float sourceX, float sourceZ, WeaponVisualClass weaponClass) =>
|
||||
_crosshair.PushTestHitArc(sourceX, sourceZ, weaponClass);
|
||||
internal Rect2 BottomLeftPanelRect => _bottomLeftPanel.GetGlobalRect();
|
||||
internal Rect2 ChyronPanelRect => _chyronPanel.GetGlobalRect();
|
||||
|
||||
|
|
@ -95,21 +96,9 @@ public partial class Hud : CanvasLayer
|
|||
_schematic.QueueRedraw();
|
||||
}
|
||||
|
||||
public void ToggleThermal() => SetThermalMode(!_schematic.ThermalEnabled);
|
||||
|
||||
public void SetThermalMode(bool enabled, bool instant = false)
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (instant)
|
||||
{
|
||||
_schematic.SetThermalInstant(enabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
_schematic.ThermalEnabled = enabled;
|
||||
}
|
||||
_thermalButton.ButtonPressed = enabled;
|
||||
_thermalButton.Modulate = enabled ? CyanCol : TextMuted;
|
||||
_thermalButton.Text = enabled ? "[T] CONDUITS: ON" : "[T] CONDUITS";
|
||||
_crosshair?.Advance((float)delta);
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
|
|
@ -185,7 +174,7 @@ public partial class Hud : CanvasLayer
|
|||
else
|
||||
{
|
||||
_statsLabel.Text = $"SPD {player.Speed:F1} m/s | ALIVE {aliveCount} / {state.Contenders.Count} | KILLS {player.Kills}";
|
||||
_controlsHint.Text = "WASD Drive | Mouse Aim | LMB Fire | E Bolt/Swap | Tab Garage | T Conduits | Wheel Zoom";
|
||||
_controlsHint.Text = "WASD Drive | Mouse Aim | LMB Fire | E Bolt/Swap | Tab Garage | Wheel Zoom";
|
||||
}
|
||||
|
||||
float distCenter = MathF.Sqrt(player.X * player.X + player.Z * player.Z);
|
||||
|
|
@ -218,8 +207,8 @@ public partial class Hud : CanvasLayer
|
|||
_promptLabel.Text = BuildInteractionPrompt(state, player);
|
||||
_promptLabel.Visible = !string.IsNullOrEmpty(_promptLabel.Text);
|
||||
|
||||
// Crosshair + Heat Arc
|
||||
_crosshair.SetState(player);
|
||||
// Crosshair + Heat Arc + Directional Incoming Hit Arcs
|
||||
_crosshair.SetState(state, player, _getCameraYaw());
|
||||
_crosshair.QueueRedraw();
|
||||
|
||||
// Radar (heading-up with camera yaw)
|
||||
|
|
@ -335,7 +324,7 @@ public partial class Hud : CanvasLayer
|
|||
_promptLabel.AddThemeFontSizeOverride("font_size", 14);
|
||||
vbox.AddChild(_promptLabel);
|
||||
|
||||
_controlsHint = new Label { Text = "WASD Drive | Mouse Aim | LMB Fire | E Loot/Swap | Tab Garage | T Conduits | Wheel Zoom" };
|
||||
_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);
|
||||
|
|
@ -402,17 +391,6 @@ public partial class Hud : CanvasLayer
|
|||
title.AddThemeFontSizeOverride("font_size", 12);
|
||||
headRow.AddChild(title);
|
||||
|
||||
_thermalButton = new Button
|
||||
{
|
||||
Text = "[T] CONDUITS",
|
||||
ToggleMode = true,
|
||||
FocusMode = Control.FocusModeEnum.None,
|
||||
Modulate = TextMuted
|
||||
};
|
||||
_thermalButton.AddThemeFontSizeOverride("font_size", 10);
|
||||
_thermalButton.Pressed += () => SetThermalMode(_thermalButton.ButtonPressed);
|
||||
headRow.AddChild(_thermalButton);
|
||||
|
||||
_schematic = new InventoryGridControl
|
||||
{
|
||||
CustomMinimumSize = new Vector2(180f, 188f)
|
||||
|
|
@ -776,9 +754,92 @@ public partial class Hud : CanvasLayer
|
|||
|
||||
private sealed partial class CrosshairOverlay : Control
|
||||
{
|
||||
private ContenderState? _player;
|
||||
private const float HitArcDuration = 0.65f;
|
||||
|
||||
public void SetState(ContenderState player) => _player = player;
|
||||
private sealed class IncomingHitArc
|
||||
{
|
||||
public float SourceX;
|
||||
public float SourceZ;
|
||||
public WeaponVisualClass WeaponClass;
|
||||
public float Age;
|
||||
}
|
||||
|
||||
private ContenderState? _player;
|
||||
private float _cameraYaw;
|
||||
private MatchState? _lastState;
|
||||
private long _lastProcessedHitId;
|
||||
private readonly List<IncomingHitArc> _incomingArcs = new();
|
||||
|
||||
public void SetState(MatchState state, ContenderState player, float cameraYaw)
|
||||
{
|
||||
if (!ReferenceEquals(_lastState, state))
|
||||
{
|
||||
_lastState = state;
|
||||
_lastProcessedHitId = 0;
|
||||
_incomingArcs.Clear();
|
||||
}
|
||||
|
||||
_player = player;
|
||||
_cameraYaw = cameraYaw;
|
||||
|
||||
var hits = state.HitEvents;
|
||||
for (int i = 0; i < hits.Count; i++)
|
||||
{
|
||||
var ev = hits[i];
|
||||
if (ev.EventId <= _lastProcessedHitId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
_lastProcessedHitId = ev.EventId;
|
||||
|
||||
if (ev.TargetKind == HitTargetKind.Contender && ev.TargetId == player.Id)
|
||||
{
|
||||
if (_incomingArcs.Count >= 8)
|
||||
{
|
||||
_incomingArcs.RemoveAt(0);
|
||||
}
|
||||
_incomingArcs.Add(new IncomingHitArc
|
||||
{
|
||||
SourceX = ev.SourceX,
|
||||
SourceZ = ev.SourceZ,
|
||||
WeaponClass = ev.WeaponClass,
|
||||
Age = 0f
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Advance(float dt)
|
||||
{
|
||||
if (_incomingArcs.Count == 0 || dt <= 0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int i = _incomingArcs.Count - 1; i >= 0; i--)
|
||||
{
|
||||
_incomingArcs[i].Age += dt;
|
||||
if (_incomingArcs[i].Age >= HitArcDuration)
|
||||
{
|
||||
_incomingArcs.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
QueueRedraw();
|
||||
}
|
||||
|
||||
public void PushTestHitArc(float sourceX, float sourceZ, WeaponVisualClass weaponClass)
|
||||
{
|
||||
if (_incomingArcs.Count >= 8) _incomingArcs.RemoveAt(0);
|
||||
_incomingArcs.Add(new IncomingHitArc
|
||||
{
|
||||
SourceX = sourceX,
|
||||
SourceZ = sourceZ,
|
||||
WeaponClass = weaponClass,
|
||||
Age = 0f
|
||||
});
|
||||
QueueRedraw();
|
||||
}
|
||||
|
||||
public int ActiveHitArcCount => _incomingArcs.Count;
|
||||
|
||||
public override void _Draw()
|
||||
{
|
||||
|
|
@ -859,6 +920,69 @@ public partial class Hud : CanvasLayer
|
|||
: (heatRatio > 0.65f ? OrangeCol : OliveCol);
|
||||
DrawArc(center, arcRadius, startAngle, startAngle + maxSweep * heatRatio, 24, heatCol, 2.4f);
|
||||
}
|
||||
|
||||
// Directional incoming-hit indicator arcs (fade over 0.65s)
|
||||
if (_incomingArcs.Count > 0)
|
||||
{
|
||||
float sinY = MathF.Sin(_cameraYaw);
|
||||
float cosY = MathF.Cos(_cameraYaw);
|
||||
for (int i = 0; i < _incomingArcs.Count; i++)
|
||||
{
|
||||
var arc = _incomingArcs[i];
|
||||
float alpha = Math.Clamp(1f - arc.Age / HitArcDuration, 0f, 1f);
|
||||
if (alpha <= 0.01f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
float dx = arc.SourceX - _player.X;
|
||||
float dz = arc.SourceZ - _player.Z;
|
||||
float rx = -dx * cosY + dz * sinY;
|
||||
float fy = dx * sinY + dz * cosY;
|
||||
float angle = (rx * rx + fy * fy) > 1e-4f ? MathF.Atan2(-fy, rx) : 0f;
|
||||
|
||||
Color arcCol = arc.WeaponClass switch
|
||||
{
|
||||
WeaponVisualClass.Explosive => new Color(1.0f, 0.36f, 0.12f, alpha * 0.96f),
|
||||
WeaponVisualClass.ThermalBeam => new Color(0.30f, 0.90f, 1.0f, alpha * 0.96f),
|
||||
_ => new Color(0.96f, 0.72f, 0.22f, alpha * 0.94f)
|
||||
};
|
||||
|
||||
const float hitR = 39f;
|
||||
const float halfSpan = 0.34f;
|
||||
DrawArc(center, hitR, angle - halfSpan, angle + halfSpan, 14, arcCol, 4.2f);
|
||||
if (arc.WeaponClass == WeaponVisualClass.ThermalBeam)
|
||||
{
|
||||
DrawArc(center, hitR - 3.5f, angle - halfSpan * 0.75f, angle + halfSpan * 0.75f, 10,
|
||||
new Color(GoldCol.R, GoldCol.G, GoldCol.B, alpha * 0.90f), 2.0f);
|
||||
}
|
||||
|
||||
Vector2 dirVec = new(MathF.Cos(angle), MathF.Sin(angle));
|
||||
Vector2 perp = new(-dirVec.Y, dirVec.X);
|
||||
Vector2 tip = center + dirVec * (hitR + 9f);
|
||||
Vector2 baseL = center + dirVec * (hitR + 1.5f) - perp * 4.5f;
|
||||
Vector2 baseR = center + dirVec * (hitR + 1.5f) + perp * 4.5f;
|
||||
DrawColoredPolygon(new[] { tip, baseL, baseR }, arcCol);
|
||||
}
|
||||
|
||||
var latest = _incomingArcs[^1];
|
||||
float tagAlpha = Math.Clamp(1f - latest.Age / HitArcDuration, 0f, 1f);
|
||||
(string tagText, Color tagCol) = latest.WeaponClass switch
|
||||
{
|
||||
WeaponVisualClass.Autocannon => ("20MM IMPACT", new Color(0.98f, 0.70f, 0.20f, tagAlpha)),
|
||||
WeaponVisualClass.Explosive => ("BLAST IMPACT", new Color(1.0f, 0.38f, 0.14f, tagAlpha)),
|
||||
WeaponVisualClass.ThermalBeam => ("THERMAL HIT", new Color(0.36f, 0.92f, 1.0f, tagAlpha)),
|
||||
_ => ("KINETIC HIT", new Color(0.96f, 0.78f, 0.28f, tagAlpha))
|
||||
};
|
||||
DrawString(
|
||||
ThemeDB.FallbackFont,
|
||||
center + new Vector2(-36f, 54f),
|
||||
tagText,
|
||||
HorizontalAlignment.Left,
|
||||
-1,
|
||||
10,
|
||||
tagCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue