merged Pause/Surrender into PlayerCommands

This commit is contained in:
Matthias Mailänder
2014-05-17 14:13:44 +02:00
parent 667f92bc75
commit 8e79879ee8
7 changed files with 20 additions and 53 deletions

View File

@@ -1,39 +0,0 @@
#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 PauseCommandInfo : TraitInfo<PauseCommand> { }
public class PauseCommand : IChatCommand, IWorldLoaded
{
World world;
public PauseCommand() { }
public void WorldLoaded(World w, WorldRenderer wr)
{
world = w;
var console = world.WorldActor.Trait<ChatCommands>();
var help = world.WorldActor.Trait<HelpCommand>();
console.RegisterCommand("pause", this);
help.RegisterHelp("pause", "pause or unpause the game");
}
public void InvokeCommand(string name, string arg)
{
world.IssueOrder(new Order("PauseGame", null, false) { TargetString = world.Paused ? "UnPause" : "Pause" });
}
}
}

View File

@@ -13,13 +13,13 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
public class SurrenderCommandInfo : TraitInfo<SurrenderCommand> { }
public class PlayerCommandsInfo : TraitInfo<PlayerCommands> { }
public class SurrenderCommand : IChatCommand, IWorldLoaded
public class PlayerCommands : IChatCommand, IWorldLoaded
{
World world;
public SurrenderCommand() { }
public PlayerCommands() { }
public void WorldLoaded(World w, WorldRenderer wr)
{
@@ -27,13 +27,24 @@ namespace OpenRA.Mods.RA
var console = world.WorldActor.Trait<ChatCommands>();
var help = world.WorldActor.Trait<HelpCommand>();
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)
{
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
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;
}
}
}
}

View File

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

View File

@@ -1,8 +1,7 @@
World:
ChatCommands:
DevCommands:
PauseCommand:
SurrenderCommand:
PlayerCommands:
HelpCommand:
ScreenMap:
ActorMap:

View File

@@ -1,8 +1,7 @@
World:
ChatCommands:
DevCommands:
PauseCommand:
SurrenderCommand:
PlayerCommands:
HelpCommand:
ScreenMap:
ActorMap:

View File

@@ -1,8 +1,7 @@
World:
ChatCommands:
DevCommands:
PauseCommand:
SurrenderCommand:
PlayerCommands:
HelpCommand:
ScreenMap:
ActorMap:

View File

@@ -1,8 +1,7 @@
World:
ChatCommands:
DevCommands:
PauseCommand:
SurrenderCommand:
PlayerCommands:
HelpCommand:
ScreenMap:
ActorMap: