Merge pull request #5631 from pavlos256/dev-iddqd
Add "/all" dev command
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
@@ -14,10 +14,10 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
public int Cash = 20000;
|
public int Cash = 20000;
|
||||||
public int ResourceGrowth = 100;
|
public int ResourceGrowth = 100;
|
||||||
public bool FastBuild = false;
|
public bool FastBuild;
|
||||||
public bool FastCharge = false;
|
public bool FastCharge;
|
||||||
public bool DisableShroud = false;
|
public bool DisableShroud;
|
||||||
public bool PathDebug = false;
|
public bool PathDebug;
|
||||||
public bool UnlimitedPower;
|
public bool UnlimitedPower;
|
||||||
public bool BuildAnywhere;
|
public bool BuildAnywhere;
|
||||||
public bool ShowCombatGeometry;
|
public bool ShowCombatGeometry;
|
||||||
@@ -37,7 +37,7 @@ namespace OpenRA.Traits
|
|||||||
[Sync] public bool UnlimitedPower;
|
[Sync] public bool UnlimitedPower;
|
||||||
[Sync] public bool BuildAnywhere;
|
[Sync] public bool BuildAnywhere;
|
||||||
|
|
||||||
// Client size only
|
// Client side only
|
||||||
public bool ShowCombatGeometry;
|
public bool ShowCombatGeometry;
|
||||||
public bool ShowDebugGeometry;
|
public bool ShowDebugGeometry;
|
||||||
|
|
||||||
@@ -56,7 +56,8 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public void ResolveOrder(Actor self, Order order)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
if (!self.World.LobbyInfo.GlobalSettings.AllowCheats) return;
|
if (!self.World.AllowDevCommands)
|
||||||
|
return;
|
||||||
|
|
||||||
switch(order.OrderString)
|
switch(order.OrderString)
|
||||||
{
|
{
|
||||||
@@ -65,22 +66,26 @@ namespace OpenRA.Traits
|
|||||||
AllTech ^= true;
|
AllTech ^= true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "DevFastCharge":
|
case "DevFastCharge":
|
||||||
{
|
{
|
||||||
FastCharge ^= true;
|
FastCharge ^= true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "DevFastBuild":
|
case "DevFastBuild":
|
||||||
{
|
{
|
||||||
FastBuild ^= true;
|
FastBuild ^= true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "DevGiveCash":
|
case "DevGiveCash":
|
||||||
{
|
{
|
||||||
var amount = order.ExtraData != 0 ? (int)order.ExtraData : Info.Cash;
|
var amount = order.ExtraData != 0 ? (int)order.ExtraData : Info.Cash;
|
||||||
self.Trait<PlayerResources>().GiveCash(amount);
|
self.Trait<PlayerResources>().GiveCash(amount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "DevGrowResources":
|
case "DevGrowResources":
|
||||||
{
|
{
|
||||||
foreach (var a in self.World.ActorsWithTrait<ISeedableResource>())
|
foreach (var a in self.World.ActorsWithTrait<ISeedableResource>())
|
||||||
@@ -90,6 +95,7 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "DevShroudDisable":
|
case "DevShroudDisable":
|
||||||
{
|
{
|
||||||
DisableShroud ^= true;
|
DisableShroud ^= true;
|
||||||
@@ -98,38 +104,42 @@ namespace OpenRA.Traits
|
|||||||
self.World.RenderPlayer = DisableShroud ? null : self.Owner;
|
self.World.RenderPlayer = DisableShroud ? null : self.Owner;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "DevPathDebug":
|
case "DevPathDebug":
|
||||||
{
|
{
|
||||||
PathDebug ^= true;
|
PathDebug ^= true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "DevGiveExploration":
|
case "DevGiveExploration":
|
||||||
{
|
{
|
||||||
self.Owner.Shroud.ExploreAll(self.World);
|
self.Owner.Shroud.ExploreAll(self.World);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "DevResetExploration":
|
case "DevResetExploration":
|
||||||
{
|
{
|
||||||
self.Owner.Shroud.ResetExploration();
|
self.Owner.Shroud.ResetExploration();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "DevUnlimitedPower":
|
case "DevUnlimitedPower":
|
||||||
{
|
{
|
||||||
UnlimitedPower ^= true;
|
UnlimitedPower ^= true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "DevBuildAnywhere":
|
case "DevBuildAnywhere":
|
||||||
{
|
{
|
||||||
BuildAnywhere ^= true;
|
BuildAnywhere ^= true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game.Debug("Cheat used: {0} by {1}"
|
Game.Debug("Cheat used: {0} by {1}".F(order.OrderString, self.Owner.PlayerName));
|
||||||
.F(order.OrderString, self.Owner.PlayerName));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,11 @@ namespace OpenRA
|
|||||||
get { return orderManager.Connection is ReplayConnection; }
|
get { return orderManager.Connection is ReplayConnection; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool AllowDevCommands
|
||||||
|
{
|
||||||
|
get { return LobbyInfo.GlobalSettings.AllowCheats || LobbyInfo.IsSinglePlayer; }
|
||||||
|
}
|
||||||
|
|
||||||
public void SetLocalPlayer(string pr)
|
public void SetLocalPlayer(string pr)
|
||||||
{
|
{
|
||||||
if (IsReplay)
|
if (IsReplay)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
@@ -29,26 +30,25 @@ namespace OpenRA.Mods.RA
|
|||||||
var console = world.WorldActor.Trait<ChatCommands>();
|
var console = world.WorldActor.Trait<ChatCommands>();
|
||||||
var help = world.WorldActor.Trait<HelpCommand>();
|
var help = world.WorldActor.Trait<HelpCommand>();
|
||||||
|
|
||||||
console.RegisterCommand("disableshroud", this);
|
Action<string, string> register = (name, helpText) =>
|
||||||
console.RegisterCommand("givecash", this);
|
{
|
||||||
console.RegisterCommand("instantbuild", this);
|
console.RegisterCommand(name, this);
|
||||||
console.RegisterCommand("buildanywhere", this);
|
help.RegisterHelp(name, helpText);
|
||||||
console.RegisterCommand("unlimitedpower", this);
|
};
|
||||||
console.RegisterCommand("enabletech", this);
|
|
||||||
console.RegisterCommand("instantcharge", this);
|
|
||||||
|
|
||||||
help.RegisterHelp("disableshroud", "toggles shroud.");
|
register("disableshroud", "toggles shroud.");
|
||||||
help.RegisterHelp("givecash", "gives the default or specified amount of money.");
|
register("givecash", "gives the default or specified amount of money.");
|
||||||
help.RegisterHelp("instantbuild", "toggles instant building.");
|
register("instantbuild", "toggles instant building.");
|
||||||
help.RegisterHelp("buildanywhere", "toggles you the ability to build anywhere.");
|
register("buildanywhere", "toggles you the ability to build anywhere.");
|
||||||
help.RegisterHelp("unlimitedpower", "toggles infinite power.");
|
register("unlimitedpower", "toggles infinite power.");
|
||||||
help.RegisterHelp("enabletech", "toggles the ability to build everything.");
|
register("enabletech", "toggles the ability to build everything.");
|
||||||
help.RegisterHelp("instantcharge", "toggles instant support power charging.");
|
register("instantcharge", "toggles instant support power charging.");
|
||||||
|
register("all", "toggles all cheats and gives you some cash for your trouble.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InvokeCommand(string name, string arg)
|
public void InvokeCommand(string name, string arg)
|
||||||
{
|
{
|
||||||
if (!world.LobbyInfo.GlobalSettings.AllowCheats)
|
if (!world.AllowDevCommands)
|
||||||
{
|
{
|
||||||
Game.Debug("Cheats are disabled.");
|
Game.Debug("Cheats are disabled.");
|
||||||
return;
|
return;
|
||||||
@@ -74,6 +74,16 @@ namespace OpenRA.Mods.RA
|
|||||||
case "unlimitedpower": IssueDevCommand(world, "DevUnlimitedPower"); break;
|
case "unlimitedpower": IssueDevCommand(world, "DevUnlimitedPower"); break;
|
||||||
case "enabletech": IssueDevCommand(world, "DevEnableTech"); break;
|
case "enabletech": IssueDevCommand(world, "DevEnableTech"); break;
|
||||||
case "instantcharge": IssueDevCommand(world, "DevFastCharge"); break;
|
case "instantcharge": IssueDevCommand(world, "DevFastCharge"); break;
|
||||||
|
|
||||||
|
case "all":
|
||||||
|
IssueDevCommand(world, "DevShroudDisable");
|
||||||
|
IssueDevCommand(world, "DevFastBuild");
|
||||||
|
IssueDevCommand(world, "DevBuildAnywhere");
|
||||||
|
IssueDevCommand(world, "DevUnlimitedPower");
|
||||||
|
IssueDevCommand(world, "DevEnableTech");
|
||||||
|
IssueDevCommand(world, "DevFastCharge");
|
||||||
|
IssueDevCommand(world, "DevGiveCash");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (unit == null || !unit.Traits.Contains<BuildableInfo>())
|
if (unit == null || !unit.Traits.Contains<BuildableInfo>())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (self.World.LobbyInfo.GlobalSettings.AllowCheats && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild)
|
if (self.World.AllowDevCommands && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
var time = (int)(unit.GetBuildTime() * Info.BuildSpeed);
|
var time = (int)(unit.GetBuildTime() * Info.BuildSpeed);
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public virtual IEnumerable<ActorInfo> AllItems()
|
public virtual IEnumerable<ActorInfo> AllItems()
|
||||||
{
|
{
|
||||||
if (self.World.LobbyInfo.GlobalSettings.AllowCheats && self.Owner.PlayerActor.Trait<DeveloperMode>().AllTech)
|
if (self.World.AllowDevCommands && self.Owner.PlayerActor.Trait<DeveloperMode>().AllTech)
|
||||||
return Produceable.Select(a => a.Key);
|
return Produceable.Select(a => a.Key);
|
||||||
|
|
||||||
return Produceable.Where(a => a.Value.Buildable || a.Value.Visible).Select(a => a.Key);
|
return Produceable.Where(a => a.Value.Buildable || a.Value.Visible).Select(a => a.Key);
|
||||||
@@ -192,7 +192,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public virtual IEnumerable<ActorInfo> BuildableItems()
|
public virtual IEnumerable<ActorInfo> BuildableItems()
|
||||||
{
|
{
|
||||||
if (self.World.LobbyInfo.GlobalSettings.AllowCheats && self.Owner.PlayerActor.Trait<DeveloperMode>().AllTech)
|
if (self.World.AllowDevCommands && self.Owner.PlayerActor.Trait<DeveloperMode>().AllTech)
|
||||||
return Produceable.Select(a => a.Key);
|
return Produceable.Select(a => a.Key);
|
||||||
|
|
||||||
return Produceable.Where(a => a.Value.Buildable).Select(a => a.Key);
|
return Produceable.Where(a => a.Value.Buildable).Select(a => a.Key);
|
||||||
@@ -289,7 +289,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (unit == null || ! unit.Traits.Contains<BuildableInfo>())
|
if (unit == null || ! unit.Traits.Contains<BuildableInfo>())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (self.World.LobbyInfo.GlobalSettings.AllowCheats && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild)
|
if (self.World.AllowDevCommands && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
var time = unit.GetBuildTime() * Info.BuildSpeed;
|
var time = unit.GetBuildTime() * Info.BuildSpeed;
|
||||||
|
|||||||
Reference in New Issue
Block a user