Skip to content

Commit ed79115

Browse files
committed
IsRestartPending
1 parent ed341ee commit ed79115

4 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎Torch.API/ITorchBase.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ public interface ITorchBase
133133
/// Event raised when <see cref="GameState"/> changes.
134134
/// </summary>
135135
event TorchGameStateChangedDel GameStateChanged;
136+
137+
/// <summary>
138+
/// Has a restart been requested?
139+
/// </summary>
140+
bool IsRestartPending { get; set; }
136141
}
137142

138143
/// <summary>

‎Torch.Server/TorchServer.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class TorchServer : TorchBase, ITorchServer
4848
private bool _isRunning;
4949
private float _simRatio;
5050
private ServerState _state;
51+
private bool _isRestartPending;
5152
private Stopwatch _uptime;
5253
private Timer _watchdog;
5354
private int _players;
@@ -137,6 +138,8 @@ public float SimulationRatio
137138

138139
public event Action<ITorchServer> Initialized;
139140

141+
public bool IsRestartPending { get => _isRestartPending; set => SetValue(ref _isRestartPending, value); }
142+
140143
/// <inheritdoc />
141144
public string InstancePath => Config?.InstancePath;
142145

‎Torch/Commands/TorchCommands.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ public void Restart(int countdownSeconds = 10, bool save = true)
265265
}
266266

267267
_restartPending = true;
268+
TorchBase.Instance.IsRestartPending = _restartPending;
268269

269270
Task.Run(() =>
270271
{
@@ -367,6 +368,8 @@ private IEnumerable RestartCountdown(int countdown, bool save)
367368
Log.Warn("Restart cancelled by user.");
368369

369370
_restartPending = false;
371+
TorchBase.Instance.IsRestartPending = _restartPending;
372+
370373
_cancelRestart = false;
371374
yield break;
372375
}

‎Torch/TorchBase.cs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ static TorchBase()
8484
/// Hack because *keen*.
8585
/// Use only if necessary, prefer dependency injection.
8686
/// </summary>
87-
[Obsolete("This is a hack, don't use it.")]
8887
public static ITorchBase Instance { get; private set; }
8988

9089
/// <inheritdoc />

0 commit comments

Comments
 (0)