From 667f92bc75dd47968e87b08a4192f155fc224042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Tue, 13 May 2014 10:35:13 +0200 Subject: [PATCH] add a console command to surrender the game --- OpenRA.Mods.RA/Console/SurrenderCommand.cs | 39 ++++++++++++++++++++++ OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 1 + mods/cnc/rules/world.yaml | 1 + mods/d2k/rules/world.yaml | 1 + mods/ra/rules/world.yaml | 1 + mods/ts/rules/world.yaml | 1 + 6 files changed, 44 insertions(+) create mode 100644 OpenRA.Mods.RA/Console/SurrenderCommand.cs diff --git a/OpenRA.Mods.RA/Console/SurrenderCommand.cs b/OpenRA.Mods.RA/Console/SurrenderCommand.cs new file mode 100644 index 0000000000..35baf2e4b6 --- /dev/null +++ b/OpenRA.Mods.RA/Console/SurrenderCommand.cs @@ -0,0 +1,39 @@ +#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 SurrenderCommandInfo : TraitInfo { } + + public class SurrenderCommand : IChatCommand, IWorldLoaded + { + World world; + + public SurrenderCommand() { } + + public void WorldLoaded(World w, WorldRenderer wr) + { + world = w; + var console = world.WorldActor.Trait(); + var help = world.WorldActor.Trait(); + + console.RegisterCommand("surrender", this); + help.RegisterHelp("surrender", "self-destruct everything and lose the game"); + } + + public void InvokeCommand(string name, string arg) + { + world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false)); + } + } +} \ 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 9e18adc616..69e4662d08 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -527,6 +527,7 @@ + diff --git a/mods/cnc/rules/world.yaml b/mods/cnc/rules/world.yaml index 12c18a3c49..23897fd534 100644 --- a/mods/cnc/rules/world.yaml +++ b/mods/cnc/rules/world.yaml @@ -2,6 +2,7 @@ World: ChatCommands: DevCommands: PauseCommand: + SurrenderCommand: HelpCommand: ScreenMap: ActorMap: diff --git a/mods/d2k/rules/world.yaml b/mods/d2k/rules/world.yaml index 751667fda9..0f9faac9cf 100644 --- a/mods/d2k/rules/world.yaml +++ b/mods/d2k/rules/world.yaml @@ -2,6 +2,7 @@ World: ChatCommands: DevCommands: PauseCommand: + SurrenderCommand: HelpCommand: ScreenMap: ActorMap: diff --git a/mods/ra/rules/world.yaml b/mods/ra/rules/world.yaml index 87d22a36f3..53c22165b1 100644 --- a/mods/ra/rules/world.yaml +++ b/mods/ra/rules/world.yaml @@ -2,6 +2,7 @@ World: ChatCommands: DevCommands: PauseCommand: + SurrenderCommand: HelpCommand: ScreenMap: ActorMap: diff --git a/mods/ts/rules/world.yaml b/mods/ts/rules/world.yaml index b7b8aa4618..b0738be03a 100644 --- a/mods/ts/rules/world.yaml +++ b/mods/ts/rules/world.yaml @@ -2,6 +2,7 @@ World: ChatCommands: DevCommands: PauseCommand: + SurrenderCommand: HelpCommand: ScreenMap: ActorMap: