Wire InventoryGridControl and panel_chrome into Hud, replacing manual schematic and StyleBoxFlat
This commit is contained in:
parent
4741bc1053
commit
72c4babeb5
3 changed files with 898 additions and 164 deletions
363
client/Hud.cs
363
client/Hud.cs
|
|
@ -42,20 +42,22 @@ public partial class Hud : CanvasLayer
|
|||
|
||||
private RadarWidget _radar = null!;
|
||||
private CrosshairOverlay _crosshair = null!;
|
||||
private SchematicPanel _schematic = null!;
|
||||
private InventoryGridControl _schematic = null!;
|
||||
private Button _thermalButton = null!;
|
||||
private Label _hoverLabel = null!;
|
||||
private VBoxContainer _cargoList = null!;
|
||||
private Label _cargoHeader = null!;
|
||||
private Label _garageDetails = null!;
|
||||
private PanelContainer _topLeftPanel = null!;
|
||||
private PanelContainer _topRightPanel = null!;
|
||||
private PanelContainer _bottomLeftPanel = null!;
|
||||
private PanelContainer _chyronPanel = null!;
|
||||
private ChromePanel _topLeftPanel = null!;
|
||||
private ChromePanel _topRightPanel = null!;
|
||||
private ChromePanel _bottomLeftPanel = null!;
|
||||
private ChromePanel _chyronPanel = null!;
|
||||
|
||||
private VBoxContainer _chyronBox = null!;
|
||||
private readonly Label[] _chyronLabels = new Label[3];
|
||||
private BroadcastFeed? _lastBroadcastFeed;
|
||||
private long _lastChyronVersion = -1;
|
||||
private PanelContainer _outcomeBanner = null!;
|
||||
private ChromePanel _outcomeBanner = null!;
|
||||
private Label _outcomeLabel = null!;
|
||||
|
||||
private int _selectedCargoIndex = -1;
|
||||
|
|
@ -71,15 +73,43 @@ public partial class Hud : CanvasLayer
|
|||
}
|
||||
|
||||
public bool GarageExpanded => _garageExpanded;
|
||||
public bool ThermalMode => _schematic.ThermalEnabled;
|
||||
public InventoryGridControl Schematic => _schematic;
|
||||
|
||||
public IEnumerable<ShaderMaterial> GetChromeMaterials()
|
||||
{
|
||||
yield return _topLeftPanel.ChromeMaterial;
|
||||
yield return _topRightPanel.ChromeMaterial;
|
||||
yield return _bottomLeftPanel.ChromeMaterial;
|
||||
yield return _chyronPanel.ChromeMaterial;
|
||||
yield return _outcomeBanner.ChromeMaterial;
|
||||
}
|
||||
|
||||
public void ToggleGarage()
|
||||
{
|
||||
_garageExpanded = !_garageExpanded;
|
||||
_garageDetails.Visible = _garageExpanded;
|
||||
_schematic.CustomMinimumSize = _garageExpanded ? new Vector2(236f, 250f) : new Vector2(180f, 190f);
|
||||
_schematic.CustomMinimumSize = _garageExpanded ? new Vector2(228f, 232f) : new Vector2(180f, 188f);
|
||||
_schematic.QueueRedraw();
|
||||
}
|
||||
|
||||
public void ToggleThermal() => SetThermalMode(!_schematic.ThermalEnabled);
|
||||
|
||||
public void SetThermalMode(bool enabled, bool instant = false)
|
||||
{
|
||||
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";
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
BuildCrosshair();
|
||||
|
|
@ -100,6 +130,30 @@ public partial class Hud : CanvasLayer
|
|||
|| (_outcomeBanner.Visible && _outcomeBanner.GetGlobalRect().HasPoint(screenPos));
|
||||
}
|
||||
|
||||
public bool HasPanelOverlapOrClip(Vector2 viewportSize)
|
||||
{
|
||||
var panels = new[] { _topLeftPanel, _topRightPanel, _bottomLeftPanel, _chyronPanel };
|
||||
var bounds = new Rect2(Vector2.Zero, viewportSize + new Vector2(1f, 1f));
|
||||
for (int i = 0; i < panels.Length; i++)
|
||||
{
|
||||
if (!panels[i].Visible) continue;
|
||||
var ri = panels[i].GetGlobalRect();
|
||||
if (!bounds.Encloses(ri))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
for (int j = i + 1; j < panels.Length; j++)
|
||||
{
|
||||
if (!panels[j].Visible) continue;
|
||||
if (ri.Intersects(panels[j].GetGlobalRect()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Sync(ArenaSession session)
|
||||
{
|
||||
var state = session.State;
|
||||
|
|
@ -162,7 +216,6 @@ public partial class Hud : CanvasLayer
|
|||
|
||||
// Schematic + Cargo
|
||||
_schematic.SetGrid(player.Grid, _selectedCargoIndex);
|
||||
_schematic.QueueRedraw();
|
||||
SyncCargoButtons(player.Grid);
|
||||
|
||||
if (_garageExpanded)
|
||||
|
|
@ -177,12 +230,14 @@ public partial class Hud : CanvasLayer
|
|||
if (state.Phase == MatchPhase.Victory)
|
||||
{
|
||||
_outcomeBanner.Visible = true;
|
||||
_outcomeBanner.ChromeMaterial.SetShaderParameter("accent_color", OliveCol);
|
||||
_outcomeLabel.Text = "VICTORY — LAST RIG STANDING\n[R] New Drop";
|
||||
_outcomeLabel.Modulate = OliveCol;
|
||||
}
|
||||
else if (state.Phase == MatchPhase.Defeat)
|
||||
{
|
||||
_outcomeBanner.Visible = true;
|
||||
_outcomeBanner.ChromeMaterial.SetShaderParameter("accent_color", RedCol);
|
||||
_outcomeLabel.Text = "CHASSIS DESTROYED\n[R] Redeploy";
|
||||
_outcomeLabel.Modulate = RedCol;
|
||||
}
|
||||
|
|
@ -202,7 +257,7 @@ public partial class Hud : CanvasLayer
|
|||
|
||||
private void BuildTopLeft()
|
||||
{
|
||||
var panel = CreateStyledPanel();
|
||||
var panel = CreateStyledPanel(OliveCol);
|
||||
_topLeftPanel = panel;
|
||||
panel.AnchorLeft = 0f;
|
||||
panel.AnchorTop = 0f;
|
||||
|
|
@ -268,7 +323,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 | Wheel Zoom" };
|
||||
_controlsHint = new Label { Text = "WASD Drive | Mouse Aim | LMB Fire | E Loot/Swap | Tab Garage | T Conduits | Wheel Zoom" };
|
||||
_controlsHint.AddThemeColorOverride("font_color", TextMuted);
|
||||
_controlsHint.AddThemeFontSizeOverride("font_size", 11);
|
||||
vbox.AddChild(_controlsHint);
|
||||
|
|
@ -276,7 +331,7 @@ public partial class Hud : CanvasLayer
|
|||
|
||||
private void BuildTopRightRadar()
|
||||
{
|
||||
var panel = CreateStyledPanel();
|
||||
var panel = CreateStyledPanel(OrangeCol);
|
||||
_topRightPanel = panel;
|
||||
panel.AnchorLeft = 1f;
|
||||
panel.AnchorRight = 1f;
|
||||
|
|
@ -304,7 +359,7 @@ public partial class Hud : CanvasLayer
|
|||
|
||||
private void BuildBottomLeftSchematic()
|
||||
{
|
||||
_bottomLeftPanel = CreateStyledPanel();
|
||||
_bottomLeftPanel = CreateStyledPanel(OrangeCol);
|
||||
_bottomLeftPanel.AnchorLeft = 0f;
|
||||
_bottomLeftPanel.AnchorTop = 1f;
|
||||
_bottomLeftPanel.AnchorBottom = 1f;
|
||||
|
|
@ -322,18 +377,49 @@ public partial class Hud : CanvasLayer
|
|||
leftCol.AddThemeConstantOverride("separation", 4);
|
||||
hbox.AddChild(leftCol);
|
||||
|
||||
var title = new Label { Text = "AETHERIA HEAT & HARDPOINTS" };
|
||||
var headRow = new HBoxContainer();
|
||||
headRow.AddThemeConstantOverride("separation", 6);
|
||||
leftCol.AddChild(headRow);
|
||||
|
||||
var title = new Label
|
||||
{
|
||||
Text = "HARDPOINTS & HEAT",
|
||||
SizeFlagsHorizontal = Control.SizeFlags.ExpandFill
|
||||
};
|
||||
title.AddThemeColorOverride("font_color", OrangeCol);
|
||||
title.AddThemeFontSizeOverride("font_size", 12);
|
||||
leftCol.AddChild(title);
|
||||
headRow.AddChild(title);
|
||||
|
||||
_schematic = new SchematicPanel(OnHardpointClicked)
|
||||
_thermalButton = new Button
|
||||
{
|
||||
CustomMinimumSize = new Vector2(180f, 190f)
|
||||
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)
|
||||
};
|
||||
_schematic.HardpointClicked += OnHardpointClicked;
|
||||
_schematic.HoverChanged += OnSchematicHoverChanged;
|
||||
leftCol.AddChild(_schematic);
|
||||
|
||||
var rightCol = new VBoxContainer { CustomMinimumSize = new Vector2(178f, 0f) };
|
||||
_hoverLabel = new Label
|
||||
{
|
||||
Text = "HOVER CELL FOR TELEMETRY",
|
||||
ClipText = true,
|
||||
CustomMinimumSize = new Vector2(180f, 15f)
|
||||
};
|
||||
_hoverLabel.AddThemeColorOverride("font_color", TextMuted);
|
||||
_hoverLabel.AddThemeFontSizeOverride("font_size", 10);
|
||||
leftCol.AddChild(_hoverLabel);
|
||||
|
||||
var rightCol = new VBoxContainer { CustomMinimumSize = new Vector2(176f, 0f) };
|
||||
rightCol.AddThemeConstantOverride("separation", 4);
|
||||
hbox.AddChild(rightCol);
|
||||
|
||||
|
|
@ -349,20 +435,22 @@ public partial class Hud : CanvasLayer
|
|||
_garageDetails = new Label { Visible = false, AutowrapMode = TextServer.AutowrapMode.Word };
|
||||
_garageDetails.AddThemeColorOverride("font_color", TextMuted);
|
||||
_garageDetails.AddThemeFontSizeOverride("font_size", 11);
|
||||
_garageDetails.CustomMinimumSize = new Vector2(200f, 0f);
|
||||
_garageDetails.CustomMinimumSize = new Vector2(204f, 0f);
|
||||
hbox.AddChild(_garageDetails);
|
||||
}
|
||||
|
||||
private void BuildBottomCenterChyron()
|
||||
{
|
||||
_chyronPanel = CreateStyledPanel();
|
||||
_chyronPanel = CreateStyledPanel(GoldCol);
|
||||
var panel = _chyronPanel;
|
||||
panel.AnchorLeft = 0.5f;
|
||||
panel.AnchorRight = 0.5f;
|
||||
panel.AnchorLeft = 1f;
|
||||
panel.AnchorRight = 1f;
|
||||
panel.AnchorTop = 1f;
|
||||
panel.AnchorBottom = 1f;
|
||||
panel.OffsetLeft = -150f;
|
||||
panel.OffsetRight = 460f;
|
||||
panel.GrowHorizontal = Control.GrowDirection.Begin;
|
||||
panel.GrowVertical = Control.GrowDirection.Begin;
|
||||
panel.OffsetLeft = -584f;
|
||||
panel.OffsetRight = -14f;
|
||||
panel.OffsetTop = -104f;
|
||||
panel.OffsetBottom = -14f;
|
||||
AddChild(panel);
|
||||
|
|
@ -396,7 +484,7 @@ public partial class Hud : CanvasLayer
|
|||
|
||||
private void BuildOutcomeBanner()
|
||||
{
|
||||
_outcomeBanner = CreateStyledPanel();
|
||||
_outcomeBanner = CreateStyledPanel(OliveCol, cornerLen: 16f, borderPx: 2f);
|
||||
_outcomeBanner.AnchorLeft = 0.5f;
|
||||
_outcomeBanner.AnchorRight = 0.5f;
|
||||
_outcomeBanner.AnchorTop = 0.28f;
|
||||
|
|
@ -430,6 +518,37 @@ public partial class Hud : CanvasLayer
|
|||
}
|
||||
}
|
||||
|
||||
private void OnSchematicHoverChanged(Vector2I? cell, HardpointSpec? hp)
|
||||
{
|
||||
var grid = _schematic.Grid;
|
||||
if (cell is null || grid is null)
|
||||
{
|
||||
_hoverLabel.Text = "HOVER CELL FOR TELEMETRY";
|
||||
_hoverLabel.AddThemeColorOverride("font_color", TextMuted);
|
||||
return;
|
||||
}
|
||||
|
||||
var c = cell.Value;
|
||||
float arm = grid.Armor[c.X, c.Y];
|
||||
float maxArm = grid.MaxArmor[c.X, c.Y];
|
||||
float temp = grid.Temperature[c.X, c.Y];
|
||||
if (hp is not null)
|
||||
{
|
||||
var mounted = grid.GetMountedOn(hp.Id);
|
||||
_hoverLabel.Text = mounted is not null
|
||||
? $"{hp.Kind.ToString().ToUpperInvariant()}: {mounted.Spec.Name} {mounted.CurrentTemp:F0}°C ({mounted.CurrentPerformance * 100f:F0}%)"
|
||||
: $"{hp.Kind.ToString().ToUpperInvariant()} SLOT [{hp.Width}x{hp.Height}] EMPTY";
|
||||
_hoverLabel.AddThemeColorOverride("font_color", arm <= 0.01f ? RedCol : TextLight);
|
||||
}
|
||||
else
|
||||
{
|
||||
_hoverLabel.Text = arm <= 0.01f
|
||||
? $"CELL ({c.X},{c.Y}) STRIPPED! {temp:F0}°C"
|
||||
: $"HULL ({c.X},{c.Y}) ARM {arm:F0}/{maxArm:F0} {temp:F0}°C";
|
||||
_hoverLabel.AddThemeColorOverride("font_color", arm <= 0.01f ? RedCol : TextMuted);
|
||||
}
|
||||
}
|
||||
|
||||
private void SyncCargoButtons(ChassisGrid grid)
|
||||
{
|
||||
int hash = grid.Cargo.Count * 97 + (_selectedCargoIndex + 10);
|
||||
|
|
@ -468,7 +587,8 @@ public partial class Hud : CanvasLayer
|
|||
{
|
||||
Text = $"{(mod.IsImperial ? "★ " : "")}{mod.Name}",
|
||||
SizeFlagsHorizontal = Control.SizeFlags.ExpandFill,
|
||||
Alignment = HorizontalAlignment.Left
|
||||
Alignment = HorizontalAlignment.Left,
|
||||
FocusMode = Control.FocusModeEnum.None
|
||||
};
|
||||
selectBtn.AddThemeFontSizeOverride("font_size", 11);
|
||||
if (_selectedCargoIndex == idx)
|
||||
|
|
@ -486,7 +606,7 @@ public partial class Hud : CanvasLayer
|
|||
};
|
||||
row.AddChild(selectBtn);
|
||||
|
||||
var fitBtn = new Button { Text = "FIT" };
|
||||
var fitBtn = new Button { Text = "FIT", FocusMode = Control.FocusModeEnum.None };
|
||||
fitBtn.AddThemeFontSizeOverride("font_size", 11);
|
||||
fitBtn.Pressed += () => AutoFitCargo(grid, idx);
|
||||
row.AddChild(fitBtn);
|
||||
|
|
@ -591,22 +711,62 @@ public partial class Hud : CanvasLayer
|
|||
return string.Join("\n", lines);
|
||||
}
|
||||
|
||||
private static PanelContainer CreateStyledPanel()
|
||||
private static ChromePanel CreateStyledPanel(Color accentColor, float cornerLen = 12f, float borderPx = 1.5f)
|
||||
{
|
||||
var panel = new PanelContainer();
|
||||
var style = new StyleBoxFlat
|
||||
return new ChromePanel(accentColor, cornerLen, borderPx);
|
||||
}
|
||||
|
||||
private sealed partial class ChromePanel : PanelContainer
|
||||
{
|
||||
private static Shader? _sharedChromeShader;
|
||||
private static ImageTexture? _sharedWhiteTex;
|
||||
private readonly ShaderMaterial _material;
|
||||
|
||||
public ChromePanel(Color accentColor, float cornerLen, float borderPx)
|
||||
{
|
||||
BgColor = new Color(BgDark.R, BgDark.G, BgDark.B, 0.88f),
|
||||
BorderColor = BorderCol,
|
||||
ContentMarginLeft = 10,
|
||||
ContentMarginRight = 10,
|
||||
ContentMarginTop = 8,
|
||||
ContentMarginBottom = 8
|
||||
};
|
||||
style.SetBorderWidthAll(2);
|
||||
style.SetCornerRadiusAll(3);
|
||||
panel.AddThemeStyleboxOverride("panel", style);
|
||||
return panel;
|
||||
_sharedChromeShader ??= GD.Load<Shader>("res://panel_chrome.gdshader");
|
||||
if (_sharedWhiteTex is null)
|
||||
{
|
||||
var img = Image.CreateEmpty(1, 1, false, Image.Format.Rgba8);
|
||||
img.SetPixel(0, 0, Colors.White);
|
||||
_sharedWhiteTex = ImageTexture.CreateFromImage(img);
|
||||
}
|
||||
|
||||
_material = new ShaderMaterial { Shader = _sharedChromeShader };
|
||||
_material.SetShaderParameter("bg_color", new Color(BgDark.R, BgDark.G, BgDark.B, 0.88f));
|
||||
_material.SetShaderParameter("border_color", BorderCol);
|
||||
_material.SetShaderParameter("accent_color", accentColor);
|
||||
_material.SetShaderParameter("corner_len", cornerLen);
|
||||
_material.SetShaderParameter("border_px", borderPx);
|
||||
Material = _material;
|
||||
|
||||
var empty = new StyleBoxEmpty
|
||||
{
|
||||
ContentMarginLeft = 10,
|
||||
ContentMarginRight = 10,
|
||||
ContentMarginTop = 8,
|
||||
ContentMarginBottom = 8
|
||||
};
|
||||
AddThemeStyleboxOverride("panel", empty);
|
||||
}
|
||||
|
||||
public ShaderMaterial ChromeMaterial => _material;
|
||||
|
||||
public override void _Notification(int what)
|
||||
{
|
||||
if (what == NotificationResized)
|
||||
{
|
||||
_material.SetShaderParameter("rect_size", Size);
|
||||
QueueRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Draw()
|
||||
{
|
||||
if (Size.X < 2f || Size.Y < 2f || _sharedWhiteTex is null) return;
|
||||
_material.SetShaderParameter("rect_size", Size);
|
||||
DrawTextureRect(_sharedWhiteTex, new Rect2(Vector2.Zero, Size), false, Colors.White);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed partial class CrosshairOverlay : Control
|
||||
|
|
@ -844,127 +1004,4 @@ public partial class Hud : CanvasLayer
|
|||
|
||||
private static readonly Color PatronColor = Color.FromHtml("#4ba8a5");
|
||||
}
|
||||
|
||||
private sealed partial class SchematicPanel : Control
|
||||
{
|
||||
private readonly Action<string> _onHardpointClick;
|
||||
private readonly List<(Rect2 Rect, string HardpointId)> _hitBoxes = new();
|
||||
private ChassisGrid? _grid;
|
||||
private int _selectedCargoIndex = -1;
|
||||
|
||||
public SchematicPanel(Action<string> onHardpointClick)
|
||||
{
|
||||
_onHardpointClick = onHardpointClick;
|
||||
}
|
||||
|
||||
public void SetGrid(ChassisGrid grid, int selectedCargoIndex)
|
||||
{
|
||||
_grid = grid;
|
||||
_selectedCargoIndex = selectedCargoIndex;
|
||||
}
|
||||
|
||||
public override void _GuiInput(InputEvent @event)
|
||||
{
|
||||
if (@event is InputEventMouseButton mb && mb.Pressed && mb.ButtonIndex == MouseButton.Left)
|
||||
{
|
||||
for (int i = 0; i < _hitBoxes.Count; i++)
|
||||
{
|
||||
if (_hitBoxes[i].Rect.HasPoint(mb.Position))
|
||||
{
|
||||
_onHardpointClick(_hitBoxes[i].HardpointId);
|
||||
AcceptEvent();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Draw()
|
||||
{
|
||||
_hitBoxes.Clear();
|
||||
if (_grid is null) return;
|
||||
|
||||
var spec = _grid.Spec;
|
||||
float cellSize = MathF.Min((Size.X - 8f) / spec.Width, (Size.Y - 8f) / spec.Height);
|
||||
float originX = (Size.X - spec.Width * cellSize) * 0.5f;
|
||||
float originY = (Size.Y - spec.Height * cellSize) * 0.5f;
|
||||
|
||||
for (int y = 0; y < spec.Height; y++)
|
||||
{
|
||||
for (int x = 0; x < spec.Width; x++)
|
||||
{
|
||||
if (!spec.IsActive(x, y)) continue;
|
||||
var rect = new Rect2(originX + x * cellSize + 1.5f, originY + y * cellSize + 1.5f, cellSize - 3f, cellSize - 3f);
|
||||
|
||||
float temp = _grid.Temperature[x, y];
|
||||
Color fill = TempToColor(temp);
|
||||
DrawRect(rect, fill);
|
||||
|
||||
// Armor bar at bottom of cell
|
||||
float maxArm = MathF.Max(1f, _grid.MaxArmor[x, y]);
|
||||
float armRatio = Math.Clamp(_grid.Armor[x, y] / maxArm, 0f, 1f);
|
||||
var armRect = new Rect2(rect.Position.X + 2f, rect.End.Y - 5f, (rect.Size.X - 4f) * armRatio, 3f);
|
||||
DrawRect(armRect, OliveCol);
|
||||
|
||||
// Border radiator highlight
|
||||
Color border = _grid.BorderCells[x, y] ? CyanCol : BorderCol;
|
||||
DrawRect(rect, border, filled: false, width: _grid.BorderCells[x, y] ? 1.5f : 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
// Hardpoints & mounted module temperature badges
|
||||
ModuleSpec? selectedCargo = _selectedCargoIndex >= 0 && _selectedCargoIndex < _grid.Cargo.Count
|
||||
? _grid.Cargo[_selectedCargoIndex]
|
||||
: null;
|
||||
|
||||
for (int i = 0; i < spec.Hardpoints.Length; i++)
|
||||
{
|
||||
var hp = spec.Hardpoints[i];
|
||||
var rect = new Rect2(
|
||||
originX + hp.X * cellSize + 2f,
|
||||
originY + hp.Y * cellSize + 2f,
|
||||
hp.Width * cellSize - 4f,
|
||||
hp.Height * cellSize - 4f);
|
||||
_hitBoxes.Add((rect, hp.Id));
|
||||
|
||||
bool compatible = selectedCargo is not null && ChassisGrid.CanFit(hp, selectedCargo);
|
||||
Color hpBorder = compatible ? GoldCol : TextLight;
|
||||
DrawRect(rect, hpBorder, filled: false, width: compatible ? 2.4f : 1.4f);
|
||||
|
||||
var mounted = _grid.GetMountedOn(hp.Id);
|
||||
string tag = mounted is not null
|
||||
? $"{mounted.Spec.Kind.ToString()[..1]}:{mounted.CurrentTemp:F0}°"
|
||||
: hp.Kind.ToString()[..3].ToUpperInvariant();
|
||||
DrawString(
|
||||
ThemeDB.FallbackFont,
|
||||
rect.Position + new Vector2(3f, 13f),
|
||||
tag,
|
||||
HorizontalAlignment.Left,
|
||||
rect.Size.X - 4f,
|
||||
10,
|
||||
mounted is { Spec.IsImperial: true } ? GoldCol : TextLight);
|
||||
}
|
||||
}
|
||||
|
||||
private static Color TempToColor(float temp)
|
||||
{
|
||||
if (temp < 45f)
|
||||
{
|
||||
float t = Math.Clamp((temp - 20f) / 25f, 0f, 1f);
|
||||
return new Color(0.18f, 0.23f, 0.26f).Lerp(new Color(0.32f, 0.45f, 0.28f), t);
|
||||
}
|
||||
if (temp < 95f)
|
||||
{
|
||||
float t = Math.Clamp((temp - 45f) / 50f, 0f, 1f);
|
||||
return new Color(0.32f, 0.45f, 0.28f).Lerp(new Color(0.62f, 0.69f, 0.36f), t);
|
||||
}
|
||||
if (temp < 140f)
|
||||
{
|
||||
float t = Math.Clamp((temp - 95f) / 45f, 0f, 1f);
|
||||
return new Color(0.62f, 0.69f, 0.36f).Lerp(OrangeCol, t);
|
||||
}
|
||||
float hotT = Math.Clamp((temp - 140f) / 60f, 0f, 1f);
|
||||
return OrangeCol.Lerp(RedCol, hotT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue