Simulation bridge
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Godot;
|
||||
using Godot;
|
||||
using ReactorMaintenance.Simulation;
|
||||
using System.Text;
|
||||
|
||||
namespace ReactorMaintenance.Godot.Controls;
|
||||
|
||||
@@ -18,9 +20,31 @@ public partial class CellInspector : PanelContainer
|
||||
body.AddChild(header);
|
||||
|
||||
body.AddChild(m_Text);
|
||||
m_Text.Text = "Selected Cell: 0,0\nTerrain: service floor\nProp: none\nHazards: none\nUnderground: hidden";
|
||||
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<string>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user