Align frontend pulse contract and tasks

This commit is contained in:
2026-05-14 10:26:56 +02:00
parent 830c7aef14
commit 6decf2a9d2
13 changed files with 129 additions and 90 deletions

View File

@@ -32,7 +32,7 @@ public partial class ForecastList : PanelContainer
{
var pos = forecast.Position;
var posStr = pos != null ? $" [{pos.X},{pos.Y}]" : "";
return $"Turn +{forecast.Turns}: {forecast.Message}{posStr}";
return $"Pulse +{forecast.Turns}: {forecast.Message}{posStr}";
}
private static void ApplyForecastColor(Label label, EForecastKind kind)

View File

@@ -514,6 +514,9 @@ public partial class GridViewport : Control
EPropType.Consumer => new(0.36f, 0.48f, 0.67f),
EPropType.Junction => new(0.56f, 0.44f, 0.70f),
EPropType.AllSeeingEyeTerminal => new(0.33f, 0.59f, 0.61f),
EPropType.IsolationValve => CarrierColor(prop.Carrier),
EPropType.SprinklerControl => new(0.21f, 0.59f, 0.73f),
EPropType.SprinklerValve => new(0.15f, 0.44f, 0.59f),
EPropType.RemedySupply => new(0.30f, 0.57f, 0.34f),
EPropType.ReactorControl => new(0.69f, 0.28f, 0.29f),
_ => Colors.Gray
@@ -527,6 +530,9 @@ public partial class GridViewport : Control
EPropType.Consumer => "CON",
EPropType.Junction => $"J {prop.JunctionMode}",
EPropType.AllSeeingEyeTerminal => "EYE",
EPropType.IsolationValve => prop.IsOpen ? "V OPEN" : "V CLOSED",
EPropType.SprinklerControl => prop.IsEnabled ? "SPR ON" : "SPR OFF",
EPropType.SprinklerValve => "SPR",
EPropType.RemedySupply => RemedyShort(prop.RemedyType),
EPropType.ReactorControl => "REACT",
_ => string.Empty

View File

@@ -6,7 +6,7 @@ public sealed class GameSession
{
public event StateChangedHandler? LevelStateChanged;
public event StateChangedHandler? RobotMoved;
public event StateChangedHandler? TurnAdvanced;
public event StateChangedHandler? PulseAdvanced;
public event StateChangedHandler? LevelWon;
public event StateChangedHandler? LevelLost;
@@ -31,20 +31,13 @@ public sealed class GameSession
return true;
}
public LevelState EndTurn()
{
LevelState = m_Engine.EndTurn(LevelState);
OnTurnAdvanced();
return LevelState;
}
public bool InteractProp()
{
if (LevelState.Global.LevelState is ELevelState.Lost or ELevelState.Won)
return false;
LevelState = m_Engine.InteractProp(LevelState);
OnTurnAdvanced();
OnPulseAdvanced();
return true;
}
@@ -54,7 +47,7 @@ public sealed class GameSession
return false;
LevelState = m_Engine.InteractLeak(LevelState, carrier, useRemedy);
OnTurnAdvanced();
OnPulseAdvanced();
return true;
}
@@ -64,7 +57,7 @@ public sealed class GameSession
return false;
LevelState = m_Engine.ApplyHeatShield(LevelState);
OnTurnAdvanced();
OnPulseAdvanced();
return true;
}
@@ -89,10 +82,10 @@ public sealed class GameSession
LevelStateChanged?.Invoke(this);
}
private void OnTurnAdvanced()
private void OnPulseAdvanced()
{
CheckOutcome();
TurnAdvanced?.Invoke(this);
PulseAdvanced?.Invoke(this);
}
private void CheckOutcome()

View File

@@ -1,5 +1,5 @@
{
"Version": 3,
"Version": 4,
"Level": {
"Name": "Black Start",
"Width": 10,
@@ -3971,4 +3971,4 @@
},
"Forecasts": []
}
}
}

View File

@@ -1,5 +1,5 @@
{
"Version": 3,
"Version": 4,
"Level": {
"Name": "Coolant Restart",
"Width": 8,
@@ -2795,4 +2795,4 @@
},
"Forecasts": []
}
}
}

View File

@@ -1,5 +1,5 @@
{
"Version": 3,
"Version": 4,
"Level": {
"Name": "Fuel Bleed",
"Width": 8,
@@ -2808,4 +2808,4 @@
},
"Forecasts": []
}
}
}

View File

@@ -56,7 +56,7 @@ public partial class LevelScreen : ScreenBase
UpdateUI();
m_Session.LevelStateChanged += OnLevelStateChanged;
m_Session.RobotMoved += OnRobotMoved;
m_Session.TurnAdvanced += OnTurnAdvanced;
m_Session.PulseAdvanced += OnPulseAdvanced;
}
private GridViewport CreateGridViewport()
@@ -131,7 +131,6 @@ public partial class LevelScreen : ScreenBase
actions.AddChild(CreateButton("Move", OnMoveAction, "Move robot to adjacent floor cell"));
actions.AddChild(CreateButton("Interact", OnInteractAction, "Interact with prop at robot position"));
actions.AddChild(CreateButton("Repair", OnRepairAction, "Repair leak at robot position"));
actions.AddChild(CreateButton("End Turn", OnEndTurnAction));
actions.AddChild(CreateButton("Main Menu", () => m_App?.ShowMainMenu()));
return actions;
}
@@ -168,11 +167,6 @@ public partial class LevelScreen : ScreenBase
}
}
private void OnEndTurnAction()
{
m_Session?.EndTurn();
}
private void UpdateUI()
{
if (m_Session is null || m_Inspector is null || m_ForecastList is null || m_InventoryStrip is null)
@@ -228,7 +222,7 @@ public partial class LevelScreen : ScreenBase
UpdateUI();
}
private void OnTurnAdvanced(GameSession sender)
private void OnPulseAdvanced(GameSession sender)
{
UpdateUI();
if (sender.LevelState.Global.LevelState is ELevelState.Lost or ELevelState.Won)