add a console command to surrender the game

This commit is contained in:
Matthias Mailänder
2014-05-13 10:35:13 +02:00
parent 83a3835802
commit 667f92bc75
6 changed files with 44 additions and 0 deletions

View File

@@ -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<SurrenderCommand> { }
public class SurrenderCommand : IChatCommand, IWorldLoaded
{
World world;
public SurrenderCommand() { }
public void WorldLoaded(World w, WorldRenderer wr)
{
world = w;
var console = world.WorldActor.Trait<ChatCommands>();
var help = world.WorldActor.Trait<HelpCommand>();
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));
}
}
}

View File

@@ -527,6 +527,7 @@
<Compile Include="Console\DevCommands.cs" />
<Compile Include="Console\HelpCommand.cs" />
<Compile Include="Console\PauseCommand.cs" />
<Compile Include="Console\SurrenderCommand.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">

View File

@@ -2,6 +2,7 @@ World:
ChatCommands:
DevCommands:
PauseCommand:
SurrenderCommand:
HelpCommand:
ScreenMap:
ActorMap:

View File

@@ -2,6 +2,7 @@ World:
ChatCommands:
DevCommands:
PauseCommand:
SurrenderCommand:
HelpCommand:
ScreenMap:
ActorMap:

View File

@@ -2,6 +2,7 @@ World:
ChatCommands:
DevCommands:
PauseCommand:
SurrenderCommand:
HelpCommand:
ScreenMap:
ActorMap:

View File

@@ -2,6 +2,7 @@ World:
ChatCommands:
DevCommands:
PauseCommand:
SurrenderCommand:
HelpCommand:
ScreenMap:
ActorMap: