From 8c4502429c4e2b16f7fa5b45705d50e1f3390755 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 3 May 2010 17:47:08 +1200 Subject: [PATCH] add 'h' hotkey to cycle through bases (fact/mcv) --- OpenRA.Game/Controller.cs | 18 ++++++++++++++++++ OpenRA.Game/Game.cs | 3 +++ OpenRA.Game/Traits/Player/VictoryConditions.cs | 5 +++++ mods/ra/structures.yaml | 1 + mods/ra/vehicles.yaml | 1 + 5 files changed, 28 insertions(+) diff --git a/OpenRA.Game/Controller.cs b/OpenRA.Game/Controller.cs index 9fc4402b15..55004947f2 100644 --- a/OpenRA.Game/Controller.cs +++ b/OpenRA.Game/Controller.cs @@ -146,5 +146,23 @@ namespace OpenRA public void SetModifiers(Modifiers mods) { modifiers = mods; } public Modifiers GetModifiers() { return modifiers; } + + public void GotoNextBase() + { + var bases = Game.world.Queries.OwnedBy[Game.world.LocalPlayer].WithTrait().ToArray(); + if (!bases.Any()) return; + + var next = bases + .Select( b => b.Actor ) + .SkipWhile(b => Game.controller.selection.Actors.Contains(b)) + .Skip(1) + .FirstOrDefault(); + + if (next == null) + next = bases.Select(b => b.Actor).First(); + + Game.controller.selection.Combine(Game.world, new Actor[] { next }, false, true); + Game.viewport.Center(Game.controller.selection.Actors); + } } } diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index ba20f490e3..e5fc89f5d0 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -500,6 +500,9 @@ namespace OpenRA if (c >= '0' && c <= '9') Game.controller.selection.DoControlGroup(world, c - '0', modifiers); + + if (c == 'h') + Game.controller.GotoNextBase(); } if( sync != Game.world.SyncHash() ) diff --git a/OpenRA.Game/Traits/Player/VictoryConditions.cs b/OpenRA.Game/Traits/Player/VictoryConditions.cs index 8529367605..8a9865333a 100644 --- a/OpenRA.Game/Traits/Player/VictoryConditions.cs +++ b/OpenRA.Game/Traits/Player/VictoryConditions.cs @@ -71,4 +71,9 @@ namespace OpenRA.Traits class MustBeDestroyedInfo : TraitInfo { } class MustBeDestroyed { } + + /* tag trait for "bases": mcv/fact */ + + class BaseBuildingInfo : TraitInfo { } + class BaseBuilding { } } diff --git a/mods/ra/structures.yaml b/mods/ra/structures.yaml index 84d82514ce..96ffe98828 100644 --- a/mods/ra/structures.yaml +++ b/mods/ra/structures.yaml @@ -415,6 +415,7 @@ FACT: Description: Construction Yard CustomSellValue: Value: 2500 + BaseBuilding: PROC: Inherits: ^Building diff --git a/mods/ra/vehicles.yaml b/mods/ra/vehicles.yaml index 933f37c715..3722d39fa2 100644 --- a/mods/ra/vehicles.yaml +++ b/mods/ra/vehicles.yaml @@ -280,6 +280,7 @@ MCV: NoTransformSounds: nodeply1.aud RenderUnit: MustBeDestroyed: + BaseBuilding: JEEP: Inherits: ^Vehicle