Merge pull request #8777 from pchote/base-key

Fall back to oldest building if no BaseBuildings exist.
This commit is contained in:
Matthias Mailänder
2015-07-28 20:35:12 +02:00
2 changed files with 15 additions and 1 deletions

View File

@@ -36,6 +36,7 @@ Also thanks to:
* Barnaby Smith (mvi)
* Bellator
* Braxton Williams (Buddytex)
* Bryan Wilbur
* Bugra Cuhadaroglu (BugraC)
* Christer Ulfsparre (Holloweye)
* Chris Grant (Unit158)

View File

@@ -15,6 +15,7 @@ using OpenRA.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Orders;
using OpenRA.Primitives;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets
@@ -191,8 +192,20 @@ namespace OpenRA.Mods.Common.Widgets
.Select(b => b.Actor)
.ToList();
// If no BaseBuilding exist pick the first selectable Building.
if (!bases.Any())
return true;
{
var building = world.ActorsWithTrait<Building>()
.Select(b => b.Actor)
.FirstOrDefault(a => a.Owner == world.LocalPlayer && a.HasTrait<Selectable>());
// No buildings left
if (building == null)
return true;
world.Selection.Combine(world, new Actor[] { building }, false, true);
return ToSelection();
}
var next = bases
.SkipWhile(b => !world.Selection.Actors.Contains(b))