Added /poweroutage dev command.

This commit is contained in:
atlimit8
2017-03-15 02:19:38 -05:00
parent 5a273700bf
commit 11933c7e2c
2 changed files with 14 additions and 1 deletions

View File

@@ -53,6 +53,7 @@ namespace OpenRA.Mods.Common.Commands
register("all", "toggles all cheats and gives you some cash for your trouble.");
register("crash", "crashes the game.");
register("levelup", "adds a specified number of levels to the selected actors.");
register("poweroutage", "causes owners of selected actors to have a 5 second power outage.");
}
public void InvokeCommand(string name, string arg)
@@ -123,6 +124,11 @@ namespace OpenRA.Mods.Common.Commands
}
break;
case "poweroutage":
foreach (var player in world.Selection.Actors.Select(a => a.Owner.PlayerActor).Distinct())
world.IssueOrder(new Order("PowerOutage", player, false) { ExtraData = 250 });
break;
}
}

View File

@@ -9,6 +9,7 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
@@ -24,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
public object Create(ActorInitializer init) { return new PowerManager(init.Self, this); }
}
public class PowerManager : ITick, ISync
public class PowerManager : ITick, ISync, IResolveOrder
{
readonly Actor self;
readonly PowerManagerInfo info;
@@ -146,5 +147,11 @@ namespace OpenRA.Mods.Common.Traits
foreach (var a in actors)
UpdateActor(a);
}
void IResolveOrder.ResolveOrder(Actor self, Order order)
{
if (devMode.Enabled && order.OrderString == "PowerOutage")
TriggerPowerOutage((int)order.ExtraData);
}
}
}