From eba1af5ff0bc575f62f5e2f14aef88e613e83652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20St=C4=99pie=C5=84?= Date: Sat, 22 Aug 2026 22:23:02 +0200 Subject: [PATCH] feat: add noclip console command --- .../Application/Commands/NoclipCommand.cs | 20 +++++++++++++++++++ .../Application/Commands/NoclipCommand.cs.uid | 1 + src/Godot/GameBootstrap.cs | 3 +++ src/Godot/Scenes/GameWorld.tscn | 3 ++- 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/Features/Console/Application/Commands/NoclipCommand.cs create mode 100644 src/Features/Console/Application/Commands/NoclipCommand.cs.uid diff --git a/src/Features/Console/Application/Commands/NoclipCommand.cs b/src/Features/Console/Application/Commands/NoclipCommand.cs new file mode 100644 index 0000000..5e727d7 --- /dev/null +++ b/src/Features/Console/Application/Commands/NoclipCommand.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using Game.Features.Console.Contracts; +using Game.Features.Players.Contracts; + +namespace Game.Features.Console.Application.Commands; + +public sealed class NoclipCommand(IMovementModeSwitcher movementModeSwitcher) : ICommand +{ + public string Name => "noclip"; + public string Description => "Toggles noclip movement mode."; + public IReadOnlyList Args { get; } = []; + + public CommandResult Execute(CommandArgValues args) + { + MovementMode next = movementModeSwitcher.ActiveMovementMode == MovementMode.Noclip ? MovementMode.Ground : MovementMode.Noclip; + movementModeSwitcher.SetMovementMode(next); + + return CommandResult.Ok(next == MovementMode.Noclip ? "Noclip enabled." : "Noclip disabled."); + } +} diff --git a/src/Features/Console/Application/Commands/NoclipCommand.cs.uid b/src/Features/Console/Application/Commands/NoclipCommand.cs.uid new file mode 100644 index 0000000..acb9430 --- /dev/null +++ b/src/Features/Console/Application/Commands/NoclipCommand.cs.uid @@ -0,0 +1 @@ +uid://de2nlceiv1per diff --git a/src/Godot/GameBootstrap.cs b/src/Godot/GameBootstrap.cs index 7227fc7..e796a66 100644 --- a/src/Godot/GameBootstrap.cs +++ b/src/Godot/GameBootstrap.cs @@ -1,6 +1,7 @@ using Game.Features.Console.Application.Commands; using Game.Features.Console.Godot; using Game.Features.Console.Infrastructure; +using Game.Features.Players.Godot; using Game.Godot.Extensions; using Game.Godot.Mappings; using Godot; @@ -10,6 +11,7 @@ namespace Game.Godot; public partial class GameBootstrap : Node { [Export] public ConsoleController Console; + [Export] public PlayerController Player; private void RegisterConsoleCommands() { @@ -17,6 +19,7 @@ public partial class GameBootstrap : Node registry.Register(new HelpCommand(registry)); registry.Register(new EchoCommand()); registry.Register(new ClearCommand()); + registry.Register(new NoclipCommand(Player)); Console.UseCommandRegistry(registry); } diff --git a/src/Godot/Scenes/GameWorld.tscn b/src/Godot/Scenes/GameWorld.tscn index 2c3d8f7..b37fd22 100644 --- a/src/Godot/Scenes/GameWorld.tscn +++ b/src/Godot/Scenes/GameWorld.tscn @@ -17,9 +17,10 @@ background_mode = 2 sky = SubResource("Sky_1kpcd") glow_enabled = true -[node name="GameWorld" type="Node" unique_id=222644234 node_paths=PackedStringArray("Console")] +[node name="GameWorld" type="Node" unique_id=222644234 node_paths=PackedStringArray("Console", "Player")] script = ExtResource("3_bootstrap") Console = NodePath("Console") +Player = NodePath("Player") [node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1669211403] transform = Transform3D(-0.8660254, -0.43301278, 0.25, 0, 0.49999997, 0.86602545, -0.50000006, 0.75, -0.43301266, 0, 0, 0)