Merge pull request #3233 from ScottNZ/follow

Add unit following/guarding
This commit is contained in:
Chris Forbes
2013-05-16 14:02:32 -07:00
9 changed files with 154 additions and 8 deletions

View File

@@ -208,6 +208,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
SetupKeyBinding(deployKey, "Deploy:", () => keyConfig.DeployKey, k => keyConfig.DeployKey = k);
unitCommandHotkeyList.AddChild(deployKey);
var guardKey = ScrollItemWidget.Setup(unitCommandHotkeyTemplate, () => false, () => { });
SetupKeyBinding(guardKey, "Guard: ", () => keyConfig.GuardKey, k => keyConfig.GuardKey = k);
unitCommandHotkeyList.AddChild(guardKey);
// Debug
var debug = bg.Get("DEBUG_PANE");

View File

@@ -70,6 +70,9 @@ namespace OpenRA.Mods.RA.Widgets
if (e.KeyName == Game.Settings.Keys.StanceCycleKey)
return PerformStanceCycle();
if (e.KeyName == Game.Settings.Keys.GuardKey)
return PerformGuard();
}
return false;
@@ -79,12 +82,11 @@ namespace OpenRA.Mods.RA.Widgets
bool PerformAttackMove()
{
var actors = World.Selection.Actors
.Where(a => a.Owner == World.LocalPlayer).ToArray();
var actors = World.Selection.Actors.Where(a => a.Owner == World.LocalPlayer).ToArray();
if (actors.Length > 0)
World.OrderGenerator = new GenericSelectTarget(actors, "AttackMove",
"attackmove", Game.mouseButtonPreference.Action);
if (actors.Any())
World.OrderGenerator = new GenericSelectTarget(actors,
"AttackMove", "attackmove", Game.mouseButtonPreference.Action);
return true;
}
@@ -146,6 +148,16 @@ namespace OpenRA.Mods.RA.Widgets
return true;
}
bool PerformGuard()
{
var actors = World.Selection.Actors.Where(a => a.Owner == World.LocalPlayer && a.HasTrait<Guard>());
if (actors.Any())
World.OrderGenerator = new GuardOrderGenerator(actors);
return true;
}
bool CycleBases()
{
var bases = World.ActorsWithTrait<BaseBuilding>()