add a console command to surrender the game
This commit is contained in:
39
OpenRA.Mods.RA/Console/SurrenderCommand.cs
Normal file
39
OpenRA.Mods.RA/Console/SurrenderCommand.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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">
|
||||
|
||||
@@ -2,6 +2,7 @@ World:
|
||||
ChatCommands:
|
||||
DevCommands:
|
||||
PauseCommand:
|
||||
SurrenderCommand:
|
||||
HelpCommand:
|
||||
ScreenMap:
|
||||
ActorMap:
|
||||
|
||||
@@ -2,6 +2,7 @@ World:
|
||||
ChatCommands:
|
||||
DevCommands:
|
||||
PauseCommand:
|
||||
SurrenderCommand:
|
||||
HelpCommand:
|
||||
ScreenMap:
|
||||
ActorMap:
|
||||
|
||||
@@ -2,6 +2,7 @@ World:
|
||||
ChatCommands:
|
||||
DevCommands:
|
||||
PauseCommand:
|
||||
SurrenderCommand:
|
||||
HelpCommand:
|
||||
ScreenMap:
|
||||
ActorMap:
|
||||
|
||||
@@ -2,6 +2,7 @@ World:
|
||||
ChatCommands:
|
||||
DevCommands:
|
||||
PauseCommand:
|
||||
SurrenderCommand:
|
||||
HelpCommand:
|
||||
ScreenMap:
|
||||
ActorMap:
|
||||
|
||||
Reference in New Issue
Block a user