feat: add noclip console command
This commit is contained in:
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user