Moved: BaseBuilding out of core => RA

Implemented: INotifyKeyPress for World traits (to respond on key pressed)
Moved: GotoNextBase (backspace key) out of core => RA
Added: GotoNextBase trait to both RA & CNC
This commit is contained in:
geckosoft
2010-11-10 05:57:21 +01:00
committed by Bob
parent 22e61a5700
commit ebca421856
9 changed files with 69 additions and 44 deletions

View File

@@ -134,13 +134,14 @@ namespace OpenRA.Widgets
{
world.Selection.DoControlGroup(world, e.KeyName[0] - '0', e.Modifiers);
return true;
}
if (e.KeyChar == '\b' || e.KeyChar == (char)127)
{
GotoNextBase();
return true;
}
}
bool handled = false;
foreach (var t in world.WorldActor.TraitsImplementing<INotifyKeyPress>())
handled = (t.KeyPressed(world.WorldActor, e)) ? true : handled;
if (handled) return true;
if (e.KeyChar == 'a')
{
@@ -157,24 +158,6 @@ namespace OpenRA.Widgets
world.OrderGenerator = new GenericSelectTarget(world.Selection.Actors, "AttackMove", "attackmove");
}
public void GotoNextBase()
{
var bases = world.Queries.OwnedBy[world.LocalPlayer].WithTrait<BaseBuilding>().ToArray();
if (!bases.Any()) return;
var next = bases
.Select( b => b.Actor )
.SkipWhile(b => !world.Selection.Actors.Contains(b))
.Skip(1)
.FirstOrDefault();
if (next == null)
next = bases.Select(b => b.Actor).First();
world.Selection.Combine(world, new Actor[] { next }, false, true);
Game.viewport.Center(world.Selection.Actors);
}
IEnumerable<Actor> SelectActorsInBox(World world, float2 a, float2 b)
{
return world.FindUnits(a, b)