Add hero runtime

This commit is contained in:
2026-04-21 22:54:14 +02:00
parent 67737f3ba8
commit 762c8969ab
29 changed files with 1327 additions and 12 deletions

View File

@@ -37,7 +37,7 @@ public sealed class DebugCommandService
DebugCommandId.ToggleInvulnerability => ToggleFlag(commandId, nameof(State.Invulnerable)),
DebugCommandId.ToggleInfiniteSpecialAmmo => ToggleFlag(commandId, nameof(State.InfiniteSpecialAmmo)),
DebugCommandId.ToggleNoEnemyFire => ToggleFlag(commandId, nameof(State.NoEnemyFire)),
_ => DebugCommandResult.Failure(commandId, $"Unsupported debug command '{commandId}'.", argument)
_ => ExecuteRegisteredCommand(commandId, argument)
};
CommandExecuted?.Invoke(result);
@@ -64,6 +64,16 @@ public sealed class DebugCommandService
m_RestartHandler = handler;
}
public void RegisterCommandHandler(DebugCommandId commandId, Func<string?, DebugCommandResult> handler)
{
m_CommandHandlers[commandId] = handler;
}
public void ClearCommandHandler(DebugCommandId commandId)
{
m_CommandHandlers.Remove(commandId);
}
public DebugRuntimeState State { get; }
public event Action<DebugRuntimeState>? StateChanged;
@@ -218,6 +228,11 @@ public sealed class DebugCommandService
return DebugCommandResult.Success(commandId, message);
}
private DebugCommandResult ExecuteRegisteredCommand(DebugCommandId commandId, string? argument)
{
return m_CommandHandlers.TryGetValue(commandId, out Func<string?, DebugCommandResult>? handler) ? handler(argument) : DebugCommandResult.Failure(commandId, $"Unsupported debug command '{commandId}'.", argument);
}
private string ToggleShowCollisionShapes()
{
State.ShowCollisionShapes = !State.ShowCollisionShapes;
@@ -276,6 +291,7 @@ public sealed class DebugCommandService
private static readonly HashSet<double> s_SupportedTimeScales = [0.25, 0.5, 1.0, 2.0, 4.0];
private readonly ContentRegistry m_Registry;
private readonly Dictionary<DebugCommandId, Func<string?, DebugCommandResult>> m_CommandHandlers = [];
private Func<string, DebugCommandResult>? m_SpawnHandler;
private Func<string, DebugCommandResult>? m_TimelineJumpHandler;
private Func<DebugCommandResult>? m_ReloadHandler;