using Godot; using ReactorMaintenance.Simulation; using System.Text; namespace ReactorMaintenance.Godot.Controls; public partial class CellInspector : PanelContainer { public override void _Ready() { var body = new VBoxContainer(); AddChild(body); var header = new HBoxContainer(); header.AddChild(FrontendAssets.CreateIcon(FrontendAssets.ScannerEyeIcon, new(34, 34))); header.AddChild(new Label { Text = "Inspector", VerticalAlignment = VerticalAlignment.Center }); body.AddChild(header); body.AddChild(m_Text); m_Text.AutowrapMode = TextServer.AutowrapMode.WordSmart; } public void SetCellInfo(GridPosition? position, ECellTerrain terrain, EPropType prop, EConsumerServiceState serviceState, float fuelHazard, float coolantHazard, float electricityHazard, float heatHazard) { var pos = position ?? new(-1, -1); var sb = new StringBuilder(); sb.AppendLine($"Selected Cell: {pos.X},{pos.Y}"); sb.AppendLine($"Terrain: {terrain}"); sb.AppendLine($"Prop: {prop}"); if (prop != EPropType.None) sb.AppendLine($"Service: {serviceState}"); sb.AppendLine($"Hazards: {FormatHazards(fuelHazard, coolantHazard, electricityHazard, heatHazard)}"); m_Text.Text = sb.ToString(); } private static string FormatHazards(float fuel, float coolant, float electricity, float heat) { var parts = new List(); if (fuel > 0) parts.Add($"fuel {fuel:F1}"); if (coolant > 0) parts.Add($"coolant {coolant:F1}"); if (electricity > 0) parts.Add($"electricity {electricity:F1}"); if (heat > 0) parts.Add($"heat {heat:F1}"); return parts.Count > 0 ? string.Join(", ", parts) : "none"; } private readonly Label m_Text = new(); }