#nullable enable using System; using System.Globalization; using System.Linq; using System.Threading.Tasks; using Godot; using SideScrollerGame.Content.Samples; using SideScrollerGame.Debug.Commands; using SideScrollerGame.Hero; using SideScrollerGame.Hero.Rules; namespace SideScrollerGame.Debug; public partial class HeroSandboxController : Control { public override void _Ready() { ProcessMode = ProcessModeEnum.Always; m_CommandNode = GetNodeOrNull("/root/GameRoot/DebugCommandNode"); m_Overlay = GetNodeOrNull("/root/GameRoot/DebugOverlay"); if (m_CommandNode is null) { GD.PushError("Hero sandbox needs /root/GameRoot/DebugCommandNode."); return; } BindSceneNodes(); RegisterHeroCommands(); CreateHeroRuntime(); CreateButtons(); m_CommandNode.Service.CommandExecuted += HandleCommandExecuted; m_CommandNode.Service.RegisterRestartHandler(RestartSandbox); if (ShouldRunHeroSmoke()) { _ = RunHeroSmokeAsync(); } } public override void _UnhandledInput(InputEvent @event) { if (@event.IsActionPressed("debug_damage_hero")) { Execute(DebugCommandId.DamageHero); } else if (@event.IsActionPressed("debug_kill_hero")) { Execute(DebugCommandId.KillHero); } else if (@event.IsActionPressed("debug_rebirth_hero")) { Execute(DebugCommandId.RebirthHero); } else if (@event.IsActionPressed("debug_add_points")) { Execute(DebugCommandId.AddHeroPoints, "100"); } else if (@event.IsActionPressed("debug_add_shield")) { Execute(DebugCommandId.AddHeroShield); } else if (@event.IsActionPressed("debug_remove_shield")) { Execute(DebugCommandId.RemoveHeroShield); } else if (@event.IsActionPressed("debug_toggle_primary_slot")) { Execute(DebugCommandId.TogglePrimaryWeaponSlot); } else if (@event.IsActionPressed("debug_clear_hero_inventory")) { Execute(DebugCommandId.ClearHeroInventory); } else if (@event.IsActionPressed("debug_toggle_invulnerability")) { Execute(DebugCommandId.ToggleInvulnerability); } 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("quick_restart")) { Execute(DebugCommandId.RestartMission); } } private void BindSceneNodes() { m_Hero = GetNodeOrNull("Playfield/Hero"); m_Hud = GetNodeOrNull("HudPanel"); m_LogLabel = GetNodeOrNull