feat: add noclip console command

This commit is contained in:
2026-08-22 22:23:02 +02:00
parent 76694a40f6
commit eba1af5ff0
4 changed files with 26 additions and 1 deletions
@@ -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<CommandArgSpec> 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.");
}
}
@@ -0,0 +1 @@
uid://de2nlceiv1per
+3
View File
@@ -1,6 +1,7 @@
using Game.Features.Console.Application.Commands; using Game.Features.Console.Application.Commands;
using Game.Features.Console.Godot; using Game.Features.Console.Godot;
using Game.Features.Console.Infrastructure; using Game.Features.Console.Infrastructure;
using Game.Features.Players.Godot;
using Game.Godot.Extensions; using Game.Godot.Extensions;
using Game.Godot.Mappings; using Game.Godot.Mappings;
using Godot; using Godot;
@@ -10,6 +11,7 @@ namespace Game.Godot;
public partial class GameBootstrap : Node public partial class GameBootstrap : Node
{ {
[Export] public ConsoleController Console; [Export] public ConsoleController Console;
[Export] public PlayerController Player;
private void RegisterConsoleCommands() private void RegisterConsoleCommands()
{ {
@@ -17,6 +19,7 @@ public partial class GameBootstrap : Node
registry.Register(new HelpCommand(registry)); registry.Register(new HelpCommand(registry));
registry.Register(new EchoCommand()); registry.Register(new EchoCommand());
registry.Register(new ClearCommand()); registry.Register(new ClearCommand());
registry.Register(new NoclipCommand(Player));
Console.UseCommandRegistry(registry); Console.UseCommandRegistry(registry);
} }
+2 -1
View File
@@ -17,9 +17,10 @@ background_mode = 2
sky = SubResource("Sky_1kpcd") sky = SubResource("Sky_1kpcd")
glow_enabled = true 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") script = ExtResource("3_bootstrap")
Console = NodePath("Console") Console = NodePath("Console")
Player = NodePath("Player")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1669211403] [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) transform = Transform3D(-0.8660254, -0.43301278, 0.25, 0, 0.49999997, 0.86602545, -0.50000006, 0.75, -0.43301266, 0, 0, 0)