#nullable enable using System; using System.Globalization; using System.Linq; using System.Threading.Tasks; using Godot; using SideScrollerGame.Debug.Commands; namespace SideScrollerGame.Debug; public partial class DebugSandboxController : Control { public override void _Ready() { ProcessMode = ProcessModeEnum.Always; m_CommandNode = GetNodeOrNull("/root/GameRoot/DebugCommandNode"); if (m_CommandNode is null) { GD.PushError("Debug sandbox needs /root/GameRoot/DebugCommandNode."); return; } BindSceneNodes(); BindCommandService(); RefreshLabels(); if (ShouldRunFoundationSmoke()) { _ = RunFoundationSmokeAsync(); } } public override void _UnhandledInput(InputEvent @event) { if (m_CommandNode is null) { return; } if (@event.IsActionPressed("debug_overlay")) { Execute(DebugCommandId.ToggleOverlay); } else if (@event.IsActionPressed("pause_game") || @event.IsActionPressed("debug_pause")) { Execute(DebugCommandId.TogglePause); } else if (@event.IsActionPressed("debug_frame_step")) { Execute(DebugCommandId.FrameStep); } else if (@event.IsActionPressed("debug_time_slower")) { Execute(DebugCommandId.SetTimeScale, NextTimeScale(-1)); } else if (@event.IsActionPressed("debug_time_faster")) { Execute(DebugCommandId.SetTimeScale, NextTimeScale(1)); } else if (@event.IsActionPressed("debug_spawn_actor")) { Execute(DebugCommandId.SpawnActor, "enemy.serial"); } else if (@event.IsActionPressed("debug_jump_marker")) { Execute(DebugCommandId.JumpToMarker, "cluster.opening"); } else if (@event.IsActionPressed("debug_toggle_invulnerability")) { Execute(DebugCommandId.ToggleInvulnerability); } else if (@event.IsActionPressed("debug_toggle_infinite_special_ammo")) { Execute(DebugCommandId.ToggleInfiniteSpecialAmmo); } else if (@event.IsActionPressed("debug_toggle_no_enemy_fire")) { Execute(DebugCommandId.ToggleNoEnemyFire); } else if (@event.IsActionPressed("debug_toggle_collision_shapes")) { Execute(DebugCommandId.ToggleCollisionShapes); } else if (@event.IsActionPressed("debug_toggle_gameplay_bounds")) { Execute(DebugCommandId.ToggleGameplayBounds); } else if (@event.IsActionPressed("quick_restart")) { Execute(DebugCommandId.RestartMission); } } private void BindSceneNodes() { m_MarkerLabel = GetNodeOrNull