diff --git a/OpenRA.Mods.RA/ChatCommands.cs b/OpenRA.Mods.RA/Console/ChatCommands.cs similarity index 100% rename from OpenRA.Mods.RA/ChatCommands.cs rename to OpenRA.Mods.RA/Console/ChatCommands.cs diff --git a/OpenRA.Mods.RA/DevCommands.cs b/OpenRA.Mods.RA/Console/DevCommands.cs similarity index 100% rename from OpenRA.Mods.RA/DevCommands.cs rename to OpenRA.Mods.RA/Console/DevCommands.cs diff --git a/OpenRA.Mods.RA/HelpCommand.cs b/OpenRA.Mods.RA/Console/HelpCommand.cs similarity index 99% rename from OpenRA.Mods.RA/HelpCommand.cs rename to OpenRA.Mods.RA/Console/HelpCommand.cs index 62f8b35b90..16a9b254c3 100644 --- a/OpenRA.Mods.RA/HelpCommand.cs +++ b/OpenRA.Mods.RA/Console/HelpCommand.cs @@ -38,9 +38,9 @@ namespace OpenRA.Mods.RA } public void InvokeCommand(string name, string arg) - { + { Game.Debug("Here are the available commands:"); - + foreach (var key in console.Commands.Keys) { var description = ""; diff --git a/OpenRA.Mods.RA/Console/PlayerCommands.cs b/OpenRA.Mods.RA/Console/PlayerCommands.cs new file mode 100644 index 0000000000..5df5326dbd --- /dev/null +++ b/OpenRA.Mods.RA/Console/PlayerCommands.cs @@ -0,0 +1,50 @@ +#region Copyright & License Information +/* + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using OpenRA.Graphics; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + public class PlayerCommandsInfo : TraitInfo { } + + public class PlayerCommands : IChatCommand, IWorldLoaded + { + World world; + + public PlayerCommands() { } + + public void WorldLoaded(World w, WorldRenderer wr) + { + world = w; + var console = world.WorldActor.Trait(); + var help = world.WorldActor.Trait(); + + console.RegisterCommand("pause", this); + help.RegisterHelp("pause", "pause or unpause the game"); + console.RegisterCommand("surrender", this); + help.RegisterHelp("surrender", "self-destruct everything and lose the game"); + } + + public void InvokeCommand(string name, string arg) + { + switch (name) + { + case "pause": + world.IssueOrder(new Order("PauseGame", null, false) + { TargetString = world.Paused ? "UnPause" : "Pause" }); + break; + case "surrender": + world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false)); + break; + } + } + } +} \ No newline at end of file diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 9f58aaed35..683a94eec1 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -523,9 +523,10 @@ - - - + + + + @@ -574,5 +575,6 @@ cd "$(SolutionDir)" + \ No newline at end of file diff --git a/mods/cnc/rules/world.yaml b/mods/cnc/rules/world.yaml index 887ad1e34f..f40d5491ca 100644 --- a/mods/cnc/rules/world.yaml +++ b/mods/cnc/rules/world.yaml @@ -1,6 +1,7 @@ World: ChatCommands: DevCommands: + PlayerCommands: HelpCommand: ScreenMap: ActorMap: diff --git a/mods/d2k/rules/world.yaml b/mods/d2k/rules/world.yaml index 2287278f01..f6f6141b76 100644 --- a/mods/d2k/rules/world.yaml +++ b/mods/d2k/rules/world.yaml @@ -1,6 +1,7 @@ World: ChatCommands: DevCommands: + PlayerCommands: HelpCommand: ScreenMap: ActorMap: diff --git a/mods/ra/rules/world.yaml b/mods/ra/rules/world.yaml index 4bc3c40787..f86e32085d 100644 --- a/mods/ra/rules/world.yaml +++ b/mods/ra/rules/world.yaml @@ -1,6 +1,7 @@ World: ChatCommands: DevCommands: + PlayerCommands: HelpCommand: ScreenMap: ActorMap: diff --git a/mods/ts/rules/world.yaml b/mods/ts/rules/world.yaml index c7dbd97836..3e346f1406 100644 --- a/mods/ts/rules/world.yaml +++ b/mods/ts/rules/world.yaml @@ -1,6 +1,7 @@ World: ChatCommands: DevCommands: + PlayerCommands: HelpCommand: ScreenMap: ActorMap: