Add /kill and /dispose chat commands
This commit is contained in:
committed by
Paul Chote
parent
fc07391c8c
commit
5ac0625f97
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Commands
|
|||||||
var command = Commands.FirstOrDefault(x => x.Key == name);
|
var command = Commands.FirstOrDefault(x => x.Key == name);
|
||||||
|
|
||||||
if (command.Value != null)
|
if (command.Value != null)
|
||||||
command.Value.InvokeCommand(name.ToLowerInvariant(), message.Substring(1 + name.Length));
|
command.Value.InvokeCommand(name.ToLowerInvariant(), message.Substring(1 + name.Length).Trim());
|
||||||
else
|
else
|
||||||
Game.Debug("{0} is not a valid command.", name);
|
Game.Debug("{0} is not a valid command.", name);
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
@@ -54,6 +55,8 @@ namespace OpenRA.Mods.Common.Commands
|
|||||||
register("crash", "crashes the game.");
|
register("crash", "crashes the game.");
|
||||||
register("levelup", "adds a specified number of levels to the selected actors.");
|
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.");
|
register("poweroutage", "causes owners of selected actors to have a 5 second power outage.");
|
||||||
|
register("kill", "kills selected actors.");
|
||||||
|
register("dispose", "disposes selected actors.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InvokeCommand(string name, string arg)
|
public void InvokeCommand(string name, string arg)
|
||||||
@@ -129,6 +132,36 @@ namespace OpenRA.Mods.Common.Commands
|
|||||||
foreach (var player in world.Selection.Actors.Select(a => a.Owner.PlayerActor).Distinct())
|
foreach (var player in world.Selection.Actors.Select(a => a.Owner.PlayerActor).Distinct())
|
||||||
world.IssueOrder(new Order("PowerOutage", player, false) { ExtraData = 250 });
|
world.IssueOrder(new Order("PowerOutage", player, false) { ExtraData = 250 });
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "kill":
|
||||||
|
var args = arg.Split(' ');
|
||||||
|
var damageTypes = new HashSet<string>();
|
||||||
|
|
||||||
|
foreach (var damageType in args)
|
||||||
|
damageTypes.Add(damageType);
|
||||||
|
|
||||||
|
foreach (var actor in world.Selection.Actors)
|
||||||
|
{
|
||||||
|
if (actor.IsDead)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var health = actor.TraitOrDefault<Health>();
|
||||||
|
if (health != null)
|
||||||
|
health.InflictDamage(actor, actor, new Damage(health.HP, damageTypes), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "dispose":
|
||||||
|
foreach (var actor in world.Selection.Actors)
|
||||||
|
{
|
||||||
|
if (actor.Disposed)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
actor.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user