HUD target boxes/arrows, remove 3D target laser, and universal Monaspace Krypton UI font
This commit is contained in:
parent
24eb3c96b8
commit
cffef82845
12 changed files with 576 additions and 134 deletions
|
|
@ -24,9 +24,7 @@ public partial class ArenaRenderer : Node3D
|
|||
public required VehicleVisualInstance Visual;
|
||||
public MeshInstance3D? HaloMesh;
|
||||
public StandardMaterial3D? HaloMat;
|
||||
public MeshInstance3D? LaserMesh;
|
||||
public SpectatorStance? LastHaloStance;
|
||||
public bool LastLaserVisible;
|
||||
public float RigDtAccum;
|
||||
public int RigSkipFrames;
|
||||
}
|
||||
|
|
@ -728,10 +726,6 @@ public partial class ArenaRenderer : Node3D
|
|||
hiddenVis.Visual.SyncDamageAndHeat(s.Grid, _debris, Vector3.Zero);
|
||||
}
|
||||
hiddenVis.Visual.Root.Visible = false;
|
||||
if (hiddenVis.LaserMesh is not null)
|
||||
{
|
||||
hiddenVis.LaserMesh.Visible = false;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -853,42 +847,6 @@ public partial class ArenaRenderer : Node3D
|
|||
vis.HaloMat.EmissionEnergyMultiplier = pulse;
|
||||
}
|
||||
}
|
||||
|
||||
// Lock-on laser beam when Cleared or Provoked
|
||||
if (vis.LaserMesh is not null)
|
||||
{
|
||||
if (s.Stance != SpectatorStance.Neutral && s.HasTargetLos && target is { Alive: true } &&
|
||||
(target.Id == session.LocalContenderId || session.IsContenderVisible(target.Id)))
|
||||
{
|
||||
Vector3 start = specPos + new Vector3(0f, s.Grid.Spec.HalfHeight * 0.7f, 0f);
|
||||
var (targetPos, _, _) = session.GetInterpolatedContenderPose(target.Id, alpha);
|
||||
Vector3 end = new Vector3(targetPos.X, targetPos.Y + target.Grid.Spec.HalfHeight * 0.3f, targetPos.Z);
|
||||
float dist = start.DistanceTo(end);
|
||||
if (dist > 0.5f)
|
||||
{
|
||||
if (!vis.LastLaserVisible)
|
||||
{
|
||||
vis.LastLaserVisible = true;
|
||||
vis.LaserMesh.Visible = true;
|
||||
}
|
||||
vis.LaserMesh.GlobalPosition = (start + end) * 0.5f;
|
||||
Vector3 dir = (end - start).Normalized();
|
||||
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 if (vis.LastLaserVisible)
|
||||
{
|
||||
vis.LastLaserVisible = false;
|
||||
vis.LaserMesh.Visible = false;
|
||||
}
|
||||
}
|
||||
else if (vis.LastLaserVisible)
|
||||
{
|
||||
vis.LastLaserVisible = false;
|
||||
vis.LaserMesh.Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -910,30 +868,11 @@ public partial class ArenaRenderer : Node3D
|
|||
};
|
||||
instance.Root.AddChild(halo);
|
||||
|
||||
var laserMat = new StandardMaterial3D
|
||||
{
|
||||
AlbedoColor = new Color(2.2f, 0.24f, 0.20f, 0.85f),
|
||||
EmissionEnabled = true,
|
||||
Emission = new Color(1f, 0.12f, 0.1f),
|
||||
EmissionEnergyMultiplier = 2.2f,
|
||||
ShadingMode = BaseMaterial3D.ShadingModeEnum.Unshaded,
|
||||
Transparency = BaseMaterial3D.TransparencyEnum.Alpha
|
||||
};
|
||||
var laser = new MeshInstance3D
|
||||
{
|
||||
Mesh = new BoxMesh { Size = new Vector3(0.08f, 0.08f, 1.0f) },
|
||||
MaterialOverride = laserMat,
|
||||
Visible = false,
|
||||
CastShadow = GeometryInstance3D.ShadowCastingSetting.Off
|
||||
};
|
||||
_actorsGroup.AddChild(laser);
|
||||
|
||||
return new ActorVisual
|
||||
{
|
||||
Visual = instance,
|
||||
HaloMesh = halo,
|
||||
HaloMat = haloMat,
|
||||
LaserMesh = laser
|
||||
HaloMat = haloMat
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
411
client/Hud.cs
411
client/Hud.cs
|
|
@ -57,7 +57,7 @@ public partial class Hud : CanvasLayer
|
|||
private Label _mapAttribLabel = null!;
|
||||
private ColorRect _vignetteRect = null!;
|
||||
private ShaderMaterial _vignetteMat = null!;
|
||||
private SquadChevronOverlay _squadOverlay = null!;
|
||||
private WorldMarkerOverlay _worldMarkers = null!;
|
||||
private CrosshairOverlay _crosshair = null!;
|
||||
private float _damagePulse;
|
||||
private float _lowCoreRatio;
|
||||
|
|
@ -505,9 +505,9 @@ public partial class Hud : CanvasLayer
|
|||
_promptLabel.Visible = !string.IsNullOrEmpty(_promptLabel.Text);
|
||||
}
|
||||
|
||||
// Squad 3D projected chevrons
|
||||
_squadOverlay.SetState(session, _projectWorld);
|
||||
_squadOverlay.QueueRedraw();
|
||||
// 3D projected world markers (ally chevrons, visible enemy target boxes, offscreen arrows)
|
||||
_worldMarkers.SetState(session, _projectWorld);
|
||||
_worldMarkers.QueueRedraw();
|
||||
|
||||
// Crosshair + Heat Arc / Orbital Altimeter + Directional Incoming Hit Arcs
|
||||
_crosshair.SetState(state, player, _getCameraYaw(), localPod);
|
||||
|
|
@ -585,10 +585,10 @@ public partial class Hud : CanvasLayer
|
|||
_vignetteRect.SetAnchorsPreset(Control.LayoutPreset.FullRect);
|
||||
AddChild(_vignetteRect);
|
||||
|
||||
_squadOverlay = new SquadChevronOverlay { Name = "SquadChevrons" };
|
||||
_squadOverlay.SetAnchorsPreset(Control.LayoutPreset.FullRect);
|
||||
_squadOverlay.MouseFilter = Control.MouseFilterEnum.Ignore;
|
||||
AddChild(_squadOverlay);
|
||||
_worldMarkers = new WorldMarkerOverlay { Name = "WorldMarkers" };
|
||||
_worldMarkers.SetAnchorsPreset(Control.LayoutPreset.FullRect);
|
||||
_worldMarkers.MouseFilter = Control.MouseFilterEnum.Ignore;
|
||||
AddChild(_worldMarkers);
|
||||
|
||||
_crosshair = new CrosshairOverlay { Name = "Crosshair" };
|
||||
_crosshair.SetAnchorsPreset(Control.LayoutPreset.FullRect);
|
||||
|
|
@ -1521,7 +1521,7 @@ public partial class Hud : CanvasLayer
|
|||
if (allDisabled)
|
||||
{
|
||||
DrawString(
|
||||
ThemeDB.FallbackFont,
|
||||
UiFonts.Regular,
|
||||
center + new Vector2(-52f, 36f),
|
||||
"WEAPONS STRIPPED",
|
||||
HorizontalAlignment.Left,
|
||||
|
|
@ -1532,7 +1532,7 @@ public partial class Hud : CanvasLayer
|
|||
else if (outOfArc)
|
||||
{
|
||||
DrawString(
|
||||
ThemeDB.FallbackFont,
|
||||
UiFonts.Regular,
|
||||
center + new Vector2(-34f, 36f),
|
||||
"OUT OF ARC",
|
||||
HorizontalAlignment.Left,
|
||||
|
|
@ -1570,7 +1570,7 @@ public partial class Hud : CanvasLayer
|
|||
DrawLine(topR + new Vector2(0f, barH - fillH), topR + new Vector2(0f, barH), bracketCol, 3.0f);
|
||||
|
||||
DrawString(
|
||||
ThemeDB.FallbackFont,
|
||||
UiFonts.Regular,
|
||||
center + new Vector2(-88f, 54f),
|
||||
$"ALT {agl:F0}m | HORIZ {horizSpeed:F0} m/s | VERT {vel:F0} m/s",
|
||||
HorizontalAlignment.Left,
|
||||
|
|
@ -1580,7 +1580,7 @@ public partial class Hud : CanvasLayer
|
|||
if (burning)
|
||||
{
|
||||
DrawString(
|
||||
ThemeDB.FallbackFont,
|
||||
UiFonts.Regular,
|
||||
center + new Vector2(-46f, -52f),
|
||||
"RETRO BURN ACTIVE",
|
||||
HorizontalAlignment.Left,
|
||||
|
|
@ -1686,7 +1686,7 @@ public partial class Hud : CanvasLayer
|
|||
_ => ("KINETIC HIT", new Color(0.96f, 0.78f, 0.28f, tagAlpha))
|
||||
};
|
||||
DrawString(
|
||||
ThemeDB.FallbackFont,
|
||||
UiFonts.Regular,
|
||||
center + new Vector2(-36f, 54f),
|
||||
tagText,
|
||||
HorizontalAlignment.Left,
|
||||
|
|
@ -1956,10 +1956,36 @@ public partial class Hud : CanvasLayer
|
|||
private static readonly Color PatronColor = Color.FromHtml("#4ba8a5");
|
||||
}
|
||||
|
||||
private sealed partial class SquadChevronOverlay : Control
|
||||
private sealed partial class WorldMarkerOverlay : Control
|
||||
{
|
||||
private const float BorderPad = 36f;
|
||||
private const float OffscreenHostileMaxDistance = 220f;
|
||||
private const int MaxOffscreenHostileArrows = 6;
|
||||
|
||||
private readonly struct OffscreenMarker
|
||||
{
|
||||
public readonly Vector2 ScreenPos;
|
||||
public readonly bool Behind;
|
||||
public readonly float Distance;
|
||||
public readonly Color Color;
|
||||
public readonly bool IsLockedOnLocal;
|
||||
|
||||
public OffscreenMarker(Vector2 screenPos, bool behind, float distance, Color color, bool isLockedOnLocal)
|
||||
{
|
||||
ScreenPos = screenPos;
|
||||
Behind = behind;
|
||||
Distance = distance;
|
||||
Color = color;
|
||||
IsLockedOnLocal = isLockedOnLocal;
|
||||
}
|
||||
}
|
||||
|
||||
private IClientArenaSession? _session;
|
||||
private Func<System.Numerics.Vector3, (bool Visible, bool Behind, Vector2 ScreenPos)>? _projectWorld;
|
||||
private readonly List<OffscreenMarker> _offscreenHostiles = new(16);
|
||||
private readonly Vector2[] _cornerBuf = new Vector2[3];
|
||||
private readonly Vector2[] _triBuf = new Vector2[3];
|
||||
private readonly Vector2[] _shadowTriBuf = new Vector2[3];
|
||||
|
||||
public void SetState(
|
||||
IClientArenaSession session,
|
||||
|
|
@ -1973,84 +1999,321 @@ public partial class Hud : CanvasLayer
|
|||
{
|
||||
if (_session is null || _projectWorld is null) return;
|
||||
var state = _session.ViewState;
|
||||
if (state.SquadSize <= 1) return;
|
||||
|
||||
int localId = _session.LocalContenderId;
|
||||
if (localId < 0 || localId >= state.Contenders.Count) return;
|
||||
|
||||
Vector2 viewSize = Size;
|
||||
if (viewSize.X < 64f || viewSize.Y < 64f) return;
|
||||
|
||||
var (localPos, _, _) = _session.GetInterpolatedContenderPose(localId, 1f);
|
||||
const float borderPad = 36f;
|
||||
Vector2 center = viewSize * 0.5f;
|
||||
float halfW = MathF.Max(16f, center.X - borderPad);
|
||||
float halfH = MathF.Max(16f, center.Y - borderPad);
|
||||
float halfW = MathF.Max(16f, center.X - BorderPad);
|
||||
float halfH = MathF.Max(16f, center.Y - BorderPad);
|
||||
Font font = UiFonts.Regular;
|
||||
|
||||
// 1. Allied squad chevrons (only when SquadSize > 1)
|
||||
if (state.SquadSize > 1)
|
||||
{
|
||||
for (int i = 0; i < state.Contenders.Count; i++)
|
||||
{
|
||||
var c = state.Contenders[i];
|
||||
if (c.Id == localId || !c.Alive || !state.AreAllies(localId, c.Id)) continue;
|
||||
|
||||
var (allyPos, _, _) = _session.GetInterpolatedContenderPose(c.Id, 1f);
|
||||
float dist = (allyPos - localPos).Length();
|
||||
float headOffset = c.IsInDropPod ? 3.4f : (c.Grid.Spec.HalfHeight + 1.9f);
|
||||
var worldHead = new System.Numerics.Vector3(allyPos.X, allyPos.Y + headOffset, allyPos.Z);
|
||||
var (visible, behind, sp) = _projectWorld(worldHead);
|
||||
if (!visible) continue;
|
||||
|
||||
bool inFrame = !behind &&
|
||||
sp.X >= BorderPad && sp.X <= viewSize.X - BorderPad &&
|
||||
sp.Y >= BorderPad && sp.Y <= viewSize.Y - BorderPad;
|
||||
|
||||
string label = $"{c.Name} {dist:F0}m";
|
||||
if (inFrame)
|
||||
{
|
||||
_triBuf[0] = sp + new Vector2(0f, 5f);
|
||||
_triBuf[1] = sp + new Vector2(-6f, -5f);
|
||||
_triBuf[2] = sp + new Vector2(6f, -5f);
|
||||
DrawColoredPolygon(_triBuf, AlliedCol);
|
||||
DrawString(
|
||||
font,
|
||||
sp + new Vector2(-28f, -11f),
|
||||
label,
|
||||
HorizontalAlignment.Left,
|
||||
-1,
|
||||
10,
|
||||
AlliedCol);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 dir = behind ? (center - sp) : (sp - center);
|
||||
if (dir.LengthSquared() < 1e-4f) dir = Vector2.Up;
|
||||
else dir = dir.Normalized();
|
||||
|
||||
float tx = MathF.Abs(dir.X) > 1e-4f ? halfW / MathF.Abs(dir.X) : float.PositiveInfinity;
|
||||
float ty = MathF.Abs(dir.Y) > 1e-4f ? halfH / MathF.Abs(dir.Y) : float.PositiveInfinity;
|
||||
Vector2 edge = center + dir * MathF.Min(tx, ty);
|
||||
Vector2 perp = new(-dir.Y, dir.X);
|
||||
|
||||
_triBuf[0] = edge + dir * 7f;
|
||||
_triBuf[1] = edge - dir * 5f + perp * 5f;
|
||||
_triBuf[2] = edge - dir * 5f - perp * 5f;
|
||||
DrawColoredPolygon(_triBuf, new Color(AlliedCol.R, AlliedCol.G, AlliedCol.B, 0.88f));
|
||||
Vector2 textPos = new(
|
||||
Math.Clamp(edge.X - 32f, 10f, viewSize.X - 110f),
|
||||
Math.Clamp(edge.Y + (dir.Y > 0f ? -12f : 18f), 16f, viewSize.Y - 12f));
|
||||
DrawString(
|
||||
font,
|
||||
textPos,
|
||||
label,
|
||||
HorizontalAlignment.Left,
|
||||
-1,
|
||||
10,
|
||||
new Color(AlliedCol.R, AlliedCol.G, AlliedCol.B, 0.90f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Visible enemy contenders (strictly obeying fog-of-war / LOS)
|
||||
var contenderContacts = _session.LocalContenderContacts;
|
||||
var spectatorContacts = _session.LocalSpectatorContacts;
|
||||
_offscreenHostiles.Clear();
|
||||
|
||||
for (int i = 0; i < state.Contenders.Count; i++)
|
||||
{
|
||||
var c = state.Contenders[i];
|
||||
if (c.Id == localId || !c.Alive || !state.AreAllies(localId, c.Id)) continue;
|
||||
if (c.Id == localId || !c.Alive || state.AreAllies(localId, c.Id)) continue;
|
||||
if (!_session.IsContenderVisible(c.Id)) continue;
|
||||
if (!contenderContacts.TryGetValue(c.Id, out var mem) || !mem.VisibleToPlayer) continue;
|
||||
|
||||
var (allyPos, _, _) = _session.GetInterpolatedContenderPose(c.Id, 1f);
|
||||
float dist = (allyPos - localPos).Length();
|
||||
float headOffset = c.IsInDropPod ? 3.4f : (c.Grid.Spec.HalfHeight + 1.9f);
|
||||
var worldHead = new System.Numerics.Vector3(allyPos.X, allyPos.Y + headOffset, allyPos.Z);
|
||||
var (visible, behind, sp) = _projectWorld(worldHead);
|
||||
if (!visible) continue;
|
||||
var (pos, rot, _) = _session.GetInterpolatedContenderPose(c.Id, 1f);
|
||||
float dist = (pos - localPos).Length();
|
||||
bool targetingLocal = c.AiTargetContenderId == localId;
|
||||
Color col = targetingLocal ? RedCol : OrangeCol;
|
||||
float hpRatio = c.Grid.MaxCoreHp > 0f ? c.Grid.CoreHp / c.Grid.MaxCoreHp : 1f;
|
||||
|
||||
bool inFrame = !behind &&
|
||||
sp.X >= borderPad && sp.X <= viewSize.X - borderPad &&
|
||||
sp.Y >= borderPad && sp.Y <= viewSize.Y - borderPad;
|
||||
float halfBoundW = c.IsInDropPod ? 1.4f : c.Grid.Spec.HalfWidth;
|
||||
float halfBoundH = c.IsInDropPod ? 1.8f : c.Grid.Spec.HalfHeight;
|
||||
float halfBoundL = c.IsInDropPod ? 1.4f : c.Grid.Spec.HalfLength;
|
||||
|
||||
string label = $"{c.Name} {dist:F0}m";
|
||||
if (inFrame)
|
||||
ProcessHostileTarget(
|
||||
pos, rot, halfBoundW, halfBoundH, halfBoundL,
|
||||
dist, hpRatio, col, targetingLocal,
|
||||
viewSize, font);
|
||||
}
|
||||
|
||||
// 3. Visible hostile/provoked spectators (neutral tourists do NOT get hostile target boxes)
|
||||
var specs = state.Spectators.Spectators;
|
||||
for (int i = 0; i < specs.Count; i++)
|
||||
{
|
||||
var s = specs[i];
|
||||
if (!s.Alive || s.Stance == SpectatorStance.Neutral) continue;
|
||||
if (!_session.IsSpectatorVisible(s.Id)) continue;
|
||||
if (!spectatorContacts.TryGetValue(s.Id, out var mem) || !mem.VisibleToPlayer) continue;
|
||||
|
||||
var (pos, rot, _) = _session.GetInterpolatedSpectatorPose(s.Id, 1f);
|
||||
float dist = (pos - localPos).Length();
|
||||
bool lockedOnLocal = s.TargetContenderId == localId && s.HasTargetLos;
|
||||
float hpRatio = s.Grid.MaxCoreHp > 0f ? s.Grid.CoreHp / s.Grid.MaxCoreHp : 1f;
|
||||
|
||||
ProcessHostileTarget(
|
||||
pos, rot, s.Grid.Spec.HalfWidth, s.Grid.Spec.HalfHeight, s.Grid.Spec.HalfLength,
|
||||
dist, hpRatio, RedCol, lockedOnLocal,
|
||||
viewSize, font);
|
||||
}
|
||||
|
||||
// 4. Off-screen hostile arrows (locked-on threats first, then nearest visible hostiles)
|
||||
if (_offscreenHostiles.Count > 0)
|
||||
{
|
||||
_offscreenHostiles.Sort(static (a, b) =>
|
||||
{
|
||||
var pts = new[]
|
||||
{
|
||||
sp + new Vector2(0f, 5f),
|
||||
sp + new Vector2(-6f, -5f),
|
||||
sp + new Vector2(6f, -5f)
|
||||
};
|
||||
DrawColoredPolygon(pts, AlliedCol);
|
||||
DrawString(
|
||||
ThemeDB.FallbackFont,
|
||||
sp + new Vector2(-28f, -11f),
|
||||
label,
|
||||
HorizontalAlignment.Left,
|
||||
-1,
|
||||
10,
|
||||
AlliedCol);
|
||||
}
|
||||
else
|
||||
int lockCmp = b.IsLockedOnLocal.CompareTo(a.IsLockedOnLocal);
|
||||
return lockCmp != 0 ? lockCmp : a.Distance.CompareTo(b.Distance);
|
||||
});
|
||||
|
||||
int count = Math.Min(_offscreenHostiles.Count, MaxOffscreenHostileArrows);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
Vector2 dir = behind ? (center - sp) : (sp - center);
|
||||
if (dir.LengthSquared() < 1e-4f) dir = Vector2.Up;
|
||||
else dir = dir.Normalized();
|
||||
|
||||
float tx = MathF.Abs(dir.X) > 1e-4f ? halfW / MathF.Abs(dir.X) : float.PositiveInfinity;
|
||||
float ty = MathF.Abs(dir.Y) > 1e-4f ? halfH / MathF.Abs(dir.Y) : float.PositiveInfinity;
|
||||
Vector2 edge = center + dir * MathF.Min(tx, ty);
|
||||
Vector2 perp = new(-dir.Y, dir.X);
|
||||
|
||||
var pts = new[]
|
||||
{
|
||||
edge + dir * 7f,
|
||||
edge - dir * 5f + perp * 5f,
|
||||
edge - dir * 5f - perp * 5f
|
||||
};
|
||||
DrawColoredPolygon(pts, new Color(AlliedCol.R, AlliedCol.G, AlliedCol.B, 0.88f));
|
||||
Vector2 textPos = new(
|
||||
Math.Clamp(edge.X - 32f, 10f, viewSize.X - 110f),
|
||||
Math.Clamp(edge.Y + (dir.Y > 0f ? -12f : 18f), 16f, viewSize.Y - 12f));
|
||||
DrawString(
|
||||
ThemeDB.FallbackFont,
|
||||
textPos,
|
||||
label,
|
||||
HorizontalAlignment.Left,
|
||||
-1,
|
||||
10,
|
||||
new Color(AlliedCol.R, AlliedCol.G, AlliedCol.B, 0.90f));
|
||||
DrawOffscreenArrow(_offscreenHostiles[i], viewSize, center, halfW, halfH, font);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessHostileTarget(
|
||||
System.Numerics.Vector3 worldCenter,
|
||||
System.Numerics.Quaternion rot,
|
||||
float halfBoundW,
|
||||
float halfBoundH,
|
||||
float halfBoundL,
|
||||
float dist,
|
||||
float hpRatio,
|
||||
Color col,
|
||||
bool isLockedOnLocal,
|
||||
Vector2 viewSize,
|
||||
Font font)
|
||||
{
|
||||
var (cVis, cBehind, cSp) = _projectWorld!(worldCenter);
|
||||
if (!cVis) return;
|
||||
|
||||
bool inFrame = !cBehind &&
|
||||
cSp.X >= BorderPad && cSp.X <= viewSize.X - BorderPad &&
|
||||
cSp.Y >= BorderPad && cSp.Y <= viewSize.Y - BorderPad;
|
||||
|
||||
if (!inFrame)
|
||||
{
|
||||
if (isLockedOnLocal || dist <= OffscreenHostileMaxDistance)
|
||||
{
|
||||
_offscreenHostiles.Add(new OffscreenMarker(cSp, cBehind, dist, col, isLockedOnLocal));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
float minX = float.PositiveInfinity, minY = float.PositiveInfinity;
|
||||
float maxX = float.NegativeInfinity, maxY = float.NegativeInfinity;
|
||||
bool allCornersInFront = true;
|
||||
|
||||
for (int sx = -1; sx <= 1; sx += 2)
|
||||
{
|
||||
for (int sy = -1; sy <= 1; sy += 2)
|
||||
{
|
||||
for (int sz = -1; sz <= 1; sz += 2)
|
||||
{
|
||||
var localCorner = new System.Numerics.Vector3(sx * halfBoundW, sy * halfBoundH, sz * halfBoundL);
|
||||
var worldCorner = worldCenter + System.Numerics.Vector3.Transform(localCorner, rot);
|
||||
var (vis, beh, sp) = _projectWorld(worldCorner);
|
||||
if (!vis || beh)
|
||||
{
|
||||
allCornersInFront = false;
|
||||
break;
|
||||
}
|
||||
if (sp.X < minX) minX = sp.X;
|
||||
if (sp.X > maxX) maxX = sp.X;
|
||||
if (sp.Y < minY) minY = sp.Y;
|
||||
if (sp.Y > maxY) maxY = sp.Y;
|
||||
}
|
||||
if (!allCornersInFront) break;
|
||||
}
|
||||
if (!allCornersInFront) break;
|
||||
}
|
||||
|
||||
if (!allCornersInFront)
|
||||
{
|
||||
var (topVis, topBeh, topSp) = _projectWorld(worldCenter + new System.Numerics.Vector3(0f, halfBoundH, 0f));
|
||||
var (botVis, botBeh, botSp) = _projectWorld(worldCenter - new System.Numerics.Vector3(0f, halfBoundH, 0f));
|
||||
float rawH = (topVis && !topBeh && botVis && !botBeh)
|
||||
? MathF.Abs(botSp.Y - topSp.Y) + 8f
|
||||
: 44f;
|
||||
float horizRadius = MathF.Max(halfBoundW, halfBoundL);
|
||||
float rawW = rawH * (horizRadius / MathF.Max(0.4f, halfBoundH));
|
||||
minX = cSp.X - rawW * 0.5f;
|
||||
maxX = cSp.X + rawW * 0.5f;
|
||||
minY = cSp.Y - rawH * 0.5f;
|
||||
maxY = cSp.Y + rawH * 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
minX -= 3f;
|
||||
maxX += 3f;
|
||||
minY -= 3f;
|
||||
maxY += 3f;
|
||||
}
|
||||
|
||||
float boxW = Math.Clamp(maxX - minX, 22f, 220f);
|
||||
float boxH = Math.Clamp(maxY - minY, 22f, 220f);
|
||||
Vector2 boxCenter = new((minX + maxX) * 0.5f, (minY + maxY) * 0.5f);
|
||||
var rect = new Rect2(boxCenter.X - boxW * 0.5f, boxCenter.Y - boxH * 0.5f, boxW, boxH);
|
||||
|
||||
DrawTargetBox(rect, col, dist, hpRatio, isLockedOnLocal, font);
|
||||
}
|
||||
|
||||
private void DrawTargetBox(Rect2 rect, Color col, float dist, float hpRatio, bool isLockedOnLocal, Font font)
|
||||
{
|
||||
float x0 = rect.Position.X;
|
||||
float y0 = rect.Position.Y;
|
||||
float x1 = x0 + rect.Size.X;
|
||||
float y1 = y0 + rect.Size.Y;
|
||||
float legX = Math.Clamp(rect.Size.X * 0.22f, 5f, 26f);
|
||||
float legY = Math.Clamp(rect.Size.Y * 0.22f, 5f, 26f);
|
||||
|
||||
Color shadowCol = new(0.04f, 0.05f, 0.04f, 0.78f);
|
||||
Color strokeCol = new(col.R, col.G, col.B, 0.95f);
|
||||
|
||||
// Top-left
|
||||
_cornerBuf[0] = new Vector2(x0, y0 + legY);
|
||||
_cornerBuf[1] = new Vector2(x0, y0);
|
||||
_cornerBuf[2] = new Vector2(x0 + legX, y0);
|
||||
DrawPolyline(_cornerBuf, shadowCol, 3.6f);
|
||||
DrawPolyline(_cornerBuf, strokeCol, 2.0f);
|
||||
|
||||
// Top-right
|
||||
_cornerBuf[0] = new Vector2(x1 - legX, y0);
|
||||
_cornerBuf[1] = new Vector2(x1, y0);
|
||||
_cornerBuf[2] = new Vector2(x1, y0 + legY);
|
||||
DrawPolyline(_cornerBuf, shadowCol, 3.6f);
|
||||
DrawPolyline(_cornerBuf, strokeCol, 2.0f);
|
||||
|
||||
// Bottom-right
|
||||
_cornerBuf[0] = new Vector2(x1, y1 - legY);
|
||||
_cornerBuf[1] = new Vector2(x1, y1);
|
||||
_cornerBuf[2] = new Vector2(x1 - legX, y1);
|
||||
DrawPolyline(_cornerBuf, shadowCol, 3.6f);
|
||||
DrawPolyline(_cornerBuf, strokeCol, 2.0f);
|
||||
|
||||
// Bottom-left
|
||||
_cornerBuf[0] = new Vector2(x0 + legX, y1);
|
||||
_cornerBuf[1] = new Vector2(x0, y1);
|
||||
_cornerBuf[2] = new Vector2(x0, y1 - legY);
|
||||
DrawPolyline(_cornerBuf, shadowCol, 3.6f);
|
||||
DrawPolyline(_cornerBuf, strokeCol, 2.0f);
|
||||
|
||||
// Thin HP bar right above top bracket
|
||||
float barW = Math.Clamp(rect.Size.X, 22f, 64f);
|
||||
float barX = (x0 + x1) * 0.5f - barW * 0.5f;
|
||||
float barY = y0 - 7f;
|
||||
DrawRect(new Rect2(barX - 1f, barY - 1f, barW + 2f, 4f), new Color(0.04f, 0.05f, 0.04f, 0.78f));
|
||||
DrawRect(new Rect2(barX, barY, barW * Math.Clamp(hpRatio, 0f, 1f), 2f), strokeCol);
|
||||
|
||||
// Distance + LOCK tag above HP bar
|
||||
string label = isLockedOnLocal ? $"{dist:F0}m LOCK" : $"{dist:F0}m";
|
||||
Vector2 textSize = font.GetStringSize(label, HorizontalAlignment.Left, -1, 10);
|
||||
Vector2 textPos = new((x0 + x1) * 0.5f - textSize.X * 0.5f, barY - 3f);
|
||||
DrawString(font, textPos + new Vector2(1f, 1f), label, HorizontalAlignment.Left, -1, 10, new Color(0.04f, 0.05f, 0.04f, 0.90f));
|
||||
DrawString(font, textPos, label, HorizontalAlignment.Left, -1, 10, strokeCol);
|
||||
}
|
||||
|
||||
private void DrawOffscreenArrow(OffscreenMarker m, Vector2 viewSize, Vector2 center, float halfW, float halfH, Font font)
|
||||
{
|
||||
Vector2 dir = m.Behind ? (center - m.ScreenPos) : (m.ScreenPos - center);
|
||||
if (dir.LengthSquared() < 1e-4f) dir = Vector2.Up;
|
||||
else dir = dir.Normalized();
|
||||
|
||||
float tx = MathF.Abs(dir.X) > 1e-4f ? halfW / MathF.Abs(dir.X) : float.PositiveInfinity;
|
||||
float ty = MathF.Abs(dir.Y) > 1e-4f ? halfH / MathF.Abs(dir.Y) : float.PositiveInfinity;
|
||||
Vector2 edge = center + dir * MathF.Min(tx, ty);
|
||||
Vector2 perp = new(-dir.Y, dir.X);
|
||||
|
||||
_shadowTriBuf[0] = edge + dir * 10f;
|
||||
_shadowTriBuf[1] = edge - dir * 6.5f + perp * 7f;
|
||||
_shadowTriBuf[2] = edge - dir * 6.5f - perp * 7f;
|
||||
DrawColoredPolygon(_shadowTriBuf, new Color(0.04f, 0.05f, 0.04f, 0.74f));
|
||||
|
||||
_triBuf[0] = edge + dir * 8f;
|
||||
_triBuf[1] = edge - dir * 5f + perp * 5.2f;
|
||||
_triBuf[2] = edge - dir * 5f - perp * 5.2f;
|
||||
Color arrowCol = new(m.Color.R, m.Color.G, m.Color.B, 0.94f);
|
||||
DrawColoredPolygon(_triBuf, arrowCol);
|
||||
|
||||
string label = m.IsLockedOnLocal ? $"{m.Distance:F0}m !" : $"{m.Distance:F0}m";
|
||||
Vector2 sz = font.GetStringSize(label, HorizontalAlignment.Left, -1, 10);
|
||||
Vector2 inward = edge - dir * 17f;
|
||||
Vector2 textPos = new(
|
||||
Math.Clamp(inward.X - sz.X * 0.5f, 10f, viewSize.X - sz.X - 10f),
|
||||
Math.Clamp(inward.Y + sz.Y * 0.35f, 16f, viewSize.Y - 10f));
|
||||
DrawString(font, textPos + new Vector2(1f, 1f), label, HorizontalAlignment.Left, -1, 10, new Color(0.04f, 0.05f, 0.04f, 0.90f));
|
||||
DrawString(font, textPos, label, HorizontalAlignment.Left, -1, 10, arrowCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -724,7 +724,7 @@ public partial class InventoryGridControl : Control
|
|||
|
||||
// Dark shadow for crisp legibility over bright thermal glow
|
||||
DrawString(
|
||||
ThemeDB.FallbackFont,
|
||||
UiFonts.Regular,
|
||||
pos + new Vector2(7f, fontSize + 6f),
|
||||
tag,
|
||||
HorizontalAlignment.Left,
|
||||
|
|
@ -733,7 +733,7 @@ public partial class InventoryGridControl : Control
|
|||
new Color(0.04f, 0.05f, 0.04f, alpha * 0.9f));
|
||||
|
||||
DrawString(
|
||||
ThemeDB.FallbackFont,
|
||||
UiFonts.Regular,
|
||||
pos + new Vector2(6f, fontSize + 5f),
|
||||
tag,
|
||||
HorizontalAlignment.Left,
|
||||
|
|
|
|||
35
client/UiFonts.cs
Normal file
35
client/UiFonts.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using Godot;
|
||||
|
||||
namespace RustToDust.Client;
|
||||
|
||||
/// <summary>
|
||||
/// Central font accessor for custom <c>Control._Draw()</c> canvas calls.
|
||||
/// Standard controls inherit <c>gui/theme/custom_font</c> from <c>project.godot</c>.
|
||||
/// </summary>
|
||||
internal static class UiFonts
|
||||
{
|
||||
private const string RegularPath = "res://fonts/MonaspaceKrypton-Regular.otf";
|
||||
private const string SemiBoldPath = "res://fonts/MonaspaceKrypton-SemiBold.otf";
|
||||
private const string BoldPath = "res://fonts/MonaspaceKrypton-Bold.otf";
|
||||
|
||||
private static Font? _regular;
|
||||
private static Font? _semiBold;
|
||||
private static Font? _bold;
|
||||
|
||||
public static Font Regular => _regular ??= LoadOrFallback(RegularPath, ThemeDB.FallbackFont);
|
||||
public static Font SemiBold => _semiBold ??= LoadOrFallback(SemiBoldPath, Regular);
|
||||
public static Font Bold => _bold ??= LoadOrFallback(BoldPath, SemiBold);
|
||||
|
||||
private static Font LoadOrFallback(string path, Font fallback)
|
||||
{
|
||||
if (ResourceLoader.Exists(path))
|
||||
{
|
||||
var loaded = GD.Load<Font>(path);
|
||||
if (loaded is not null)
|
||||
{
|
||||
return loaded;
|
||||
}
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
93
client/fonts/MONASPACE_LICENSE.txt
Normal file
93
client/fonts/MONASPACE_LICENSE.txt
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
Copyright (c) 2023, GitHub https://github.com/githubnext/monaspace
|
||||
with Reserved Font Name "Monaspace", including subfamilies: "Argon", "Neon", "Xenon", "Radon", and "Krypton"
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting — in part or in whole — any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
BIN
client/fonts/MonaspaceKrypton-Bold.otf
Normal file
BIN
client/fonts/MonaspaceKrypton-Bold.otf
Normal file
Binary file not shown.
36
client/fonts/MonaspaceKrypton-Bold.otf.import
Normal file
36
client/fonts/MonaspaceKrypton-Bold.otf.import
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
[remap]
|
||||
|
||||
importer="font_data_dynamic"
|
||||
type="FontFile"
|
||||
uid="uid://dlsxsr034f5sv"
|
||||
path="res://.godot/imported/MonaspaceKrypton-Bold.otf-a6e22263037c0e08923dee8788f7d7d1.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://fonts/MonaspaceKrypton-Bold.otf"
|
||||
dest_files=["res://.godot/imported/MonaspaceKrypton-Bold.otf-a6e22263037c0e08923dee8788f7d7d1.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
Rendering=null
|
||||
antialiasing=1
|
||||
generate_mipmaps=false
|
||||
disable_embedded_bitmaps=true
|
||||
multichannel_signed_distance_field=false
|
||||
msdf_pixel_range=8
|
||||
msdf_size=48
|
||||
allow_system_fallback=true
|
||||
force_autohinter=false
|
||||
modulate_color_glyphs=false
|
||||
hinting=3
|
||||
subpixel_positioning=4
|
||||
keep_rounding_remainders=true
|
||||
oversampling=0.0
|
||||
Fallbacks=null
|
||||
fallbacks=[]
|
||||
Compress=null
|
||||
compress=true
|
||||
preload=[]
|
||||
language_support={}
|
||||
script_support={}
|
||||
opentype_features={}
|
||||
BIN
client/fonts/MonaspaceKrypton-Regular.otf
Normal file
BIN
client/fonts/MonaspaceKrypton-Regular.otf
Normal file
Binary file not shown.
36
client/fonts/MonaspaceKrypton-Regular.otf.import
Normal file
36
client/fonts/MonaspaceKrypton-Regular.otf.import
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
[remap]
|
||||
|
||||
importer="font_data_dynamic"
|
||||
type="FontFile"
|
||||
uid="uid://1udxuivwq46s"
|
||||
path="res://.godot/imported/MonaspaceKrypton-Regular.otf-879dc21ea909cad808c934de94044b6e.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://fonts/MonaspaceKrypton-Regular.otf"
|
||||
dest_files=["res://.godot/imported/MonaspaceKrypton-Regular.otf-879dc21ea909cad808c934de94044b6e.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
Rendering=null
|
||||
antialiasing=1
|
||||
generate_mipmaps=false
|
||||
disable_embedded_bitmaps=true
|
||||
multichannel_signed_distance_field=false
|
||||
msdf_pixel_range=8
|
||||
msdf_size=48
|
||||
allow_system_fallback=true
|
||||
force_autohinter=false
|
||||
modulate_color_glyphs=false
|
||||
hinting=3
|
||||
subpixel_positioning=4
|
||||
keep_rounding_remainders=true
|
||||
oversampling=0.0
|
||||
Fallbacks=null
|
||||
fallbacks=[]
|
||||
Compress=null
|
||||
compress=true
|
||||
preload=[]
|
||||
language_support={}
|
||||
script_support={}
|
||||
opentype_features={}
|
||||
BIN
client/fonts/MonaspaceKrypton-SemiBold.otf
Normal file
BIN
client/fonts/MonaspaceKrypton-SemiBold.otf
Normal file
Binary file not shown.
36
client/fonts/MonaspaceKrypton-SemiBold.otf.import
Normal file
36
client/fonts/MonaspaceKrypton-SemiBold.otf.import
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
[remap]
|
||||
|
||||
importer="font_data_dynamic"
|
||||
type="FontFile"
|
||||
uid="uid://270t27q6bpet"
|
||||
path="res://.godot/imported/MonaspaceKrypton-SemiBold.otf-c294810382571aa26a9353cf57198e74.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://fonts/MonaspaceKrypton-SemiBold.otf"
|
||||
dest_files=["res://.godot/imported/MonaspaceKrypton-SemiBold.otf-c294810382571aa26a9353cf57198e74.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
Rendering=null
|
||||
antialiasing=1
|
||||
generate_mipmaps=false
|
||||
disable_embedded_bitmaps=true
|
||||
multichannel_signed_distance_field=false
|
||||
msdf_pixel_range=8
|
||||
msdf_size=48
|
||||
allow_system_fallback=true
|
||||
force_autohinter=false
|
||||
modulate_color_glyphs=false
|
||||
hinting=3
|
||||
subpixel_positioning=4
|
||||
keep_rounding_remainders=true
|
||||
oversampling=0.0
|
||||
Fallbacks=null
|
||||
fallbacks=[]
|
||||
Compress=null
|
||||
compress=true
|
||||
preload=[]
|
||||
language_support={}
|
||||
script_support={}
|
||||
opentype_features={}
|
||||
|
|
@ -20,6 +20,10 @@ window/stretch/mode="canvas_items"
|
|||
|
||||
project/assembly_name="RustToDust.Client"
|
||||
|
||||
[gui]
|
||||
|
||||
theme/custom_font="res://fonts/MonaspaceKrypton-Regular.otf"
|
||||
|
||||
[physics]
|
||||
|
||||
; Godot's physics is switched off: Ymir is the only physics world. ArenaSession ticks at 60 Hz.
|
||||
|
|
|
|||
Loading…
Reference in a new issue