Merge pull request #5302 from Mailaender/console-commands
Added pause and surrender console commands
This commit is contained in:
50
OpenRA.Mods.RA/Console/PlayerCommands.cs
Normal file
50
OpenRA.Mods.RA/Console/PlayerCommands.cs
Normal file
@@ -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<PlayerCommands> { }
|
||||||
|
|
||||||
|
public class PlayerCommands : IChatCommand, IWorldLoaded
|
||||||
|
{
|
||||||
|
World world;
|
||||||
|
|
||||||
|
public PlayerCommands() { }
|
||||||
|
|
||||||
|
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");
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -523,9 +523,10 @@
|
|||||||
<Compile Include="Scripting\Global\CameraGlobal.cs" />
|
<Compile Include="Scripting\Global\CameraGlobal.cs" />
|
||||||
<Compile Include="Scripting\Properties\ChronosphereProperties.cs" />
|
<Compile Include="Scripting\Properties\ChronosphereProperties.cs" />
|
||||||
<Compile Include="Scripting\ScriptInvulnerable.cs" />
|
<Compile Include="Scripting\ScriptInvulnerable.cs" />
|
||||||
<Compile Include="DevCommands.cs" />
|
<Compile Include="Console\ChatCommands.cs" />
|
||||||
<Compile Include="HelpCommand.cs" />
|
<Compile Include="Console\DevCommands.cs" />
|
||||||
<Compile Include="ChatCommands.cs" />
|
<Compile Include="Console\HelpCommand.cs" />
|
||||||
|
<Compile Include="Console\PlayerCommands.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||||
@@ -574,5 +575,6 @@ cd "$(SolutionDir)"</PostBuildEvent>
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Scripting\Global\" />
|
<Folder Include="Scripting\Global\" />
|
||||||
<Folder Include="Scripting\Properties\" />
|
<Folder Include="Scripting\Properties\" />
|
||||||
|
<Folder Include="Console\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
World:
|
World:
|
||||||
ChatCommands:
|
ChatCommands:
|
||||||
DevCommands:
|
DevCommands:
|
||||||
|
PlayerCommands:
|
||||||
HelpCommand:
|
HelpCommand:
|
||||||
ScreenMap:
|
ScreenMap:
|
||||||
ActorMap:
|
ActorMap:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
World:
|
World:
|
||||||
ChatCommands:
|
ChatCommands:
|
||||||
DevCommands:
|
DevCommands:
|
||||||
|
PlayerCommands:
|
||||||
HelpCommand:
|
HelpCommand:
|
||||||
ScreenMap:
|
ScreenMap:
|
||||||
ActorMap:
|
ActorMap:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
World:
|
World:
|
||||||
ChatCommands:
|
ChatCommands:
|
||||||
DevCommands:
|
DevCommands:
|
||||||
|
PlayerCommands:
|
||||||
HelpCommand:
|
HelpCommand:
|
||||||
ScreenMap:
|
ScreenMap:
|
||||||
ActorMap:
|
ActorMap:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
World:
|
World:
|
||||||
ChatCommands:
|
ChatCommands:
|
||||||
DevCommands:
|
DevCommands:
|
||||||
|
PlayerCommands:
|
||||||
HelpCommand:
|
HelpCommand:
|
||||||
ScreenMap:
|
ScreenMap:
|
||||||
ActorMap:
|
ActorMap:
|
||||||
|
|||||||
Reference in New Issue
Block a user