diff --git a/.sbproj b/.sbproj index 165c0d9d..3398a582 100644 --- a/.sbproj +++ b/.sbproj @@ -143,7 +143,10 @@ "Public": true, "ReplaceTags": "sandbox game dynamic spawnmenu physgun", "CsProjName": "", - "ControlModes": {}, + "ControlModes": { + "Keyboard": true, + "Gamepad": true + }, "InputSettings": { "Actions": [ { @@ -316,6 +319,11 @@ "Name": "Noclip", "KeyboardCode": "N", "GroupName": "Movement" + }, + { + "Name": "Undo", + "KeyboardCode": "Z", + "GroupName": "Other" } ] }, diff --git a/code/undosystem/UndoSystem.cs b/code/undosystem/UndoSystem.cs index b07b7984..4be99cb6 100644 --- a/code/undosystem/UndoSystem.cs +++ b/code/undosystem/UndoSystem.cs @@ -24,6 +24,22 @@ public static void OnAddUndo( Func undoable, Entity owner ) } } + [GameEvent.Client.BuildInput] + public static void ProcessClientInput() + { + if ( Input.Pressed( "undo" ) ) + { + if ( Input.Down( "run" ) ) + { + OnRedo(); + } + else + { + OnUndo(); + } + } + } + [ConCmd.Server( "undo" )] public static async void OnUndo() { @@ -103,7 +119,7 @@ public static void OnRedo() continue; } - CreateUndoParticles( To.Single( creator ), prop.Position ); + CreateRedoParticles( To.Single( creator ), prop.Position ); Redoer.OnRedone( To.Single( creator ) ); Redoer.ResetProp( redo ); @@ -128,5 +144,14 @@ public static void CreateUndoParticles( Vector3 pos ) Game.LocalPawn?.PlaySound( "drop_001" ); } } + + [ClientRpc] + public static void CreateRedoParticles( Vector3 pos ) + { + using ( Prediction.Off() ) + { + Game.LocalPawn?.PlaySound( "drop_002" ); + } + } } }