Remove Selectable boolean from Selectable trait

Add work-around for ta/td bridge huts since they need actor Bounds to
be targetable by C4/engineer repair.
This commit is contained in:
reaperrr
2015-06-05 16:36:54 +02:00
parent 2afa3cfa3a
commit c23ee1be2e
15 changed files with 73 additions and 51 deletions

View File

@@ -190,12 +190,8 @@ namespace OpenRA.Graphics
public void DrawRollover(Actor unit)
{
var selectable = unit.TraitOrDefault<Selectable>();
if (selectable != null)
{
if (selectable.Info.Selectable)
new SelectionBarsRenderable(unit).Render(this);
}
if (unit.HasTrait<Selectable>())
new SelectionBarsRenderable(unit).Render(this);
}
public void DrawRangeCircle(WPos pos, WRange range, Color c)

View File

@@ -63,8 +63,7 @@ namespace OpenRA.Orders
if (underCursor != null && (mi.Modifiers.HasModifier(Modifiers.Shift) || !world.Selection.Actors.Any()))
{
var selectable = underCursor.TraitOrDefault<Selectable>();
if (selectable != null && selectable.Info.Selectable)
if (underCursor.HasTrait<Selectable>())
useSelect = true;
}

View File

@@ -15,9 +15,9 @@ using OpenRA.Graphics;
namespace OpenRA.Traits
{
[Desc("This actor is selectable. Defines bounds of selectable area and selection priority.")]
public class SelectableInfo : ITraitInfo
{
public readonly bool Selectable = true;
public readonly int Priority = 10;
[Desc("Bounds for the selectable area.")]
public readonly int[] Bounds = null;

View File

@@ -92,7 +92,7 @@ namespace OpenRA.Widgets
{
if (!hasBox && World.Selection.Actors.Any() && !multiClick)
{
if (!(World.ScreenMap.ActorsAt(xy).Where(x => x.HasTrait<Selectable>() && x.Trait<Selectable>().Info.Selectable &&
if (!(World.ScreenMap.ActorsAt(xy).Where(x => x.HasTrait<Selectable>() &&
(x.Owner.IsAlliedWith(World.RenderPlayer) || !World.FogObscures(x))).Any() && !mi.Modifiers.HasModifier(Modifiers.Ctrl) &&
!mi.Modifiers.HasModifier(Modifiers.Alt) && UnitOrderGenerator.InputOverridesSelection(World, xy, mi)))
{
@@ -292,7 +292,7 @@ namespace OpenRA.Widgets
var s = a.TraitOrDefault<Selectable>();
// sc == null means that units, that meet all other criteria, get selected
return s != null && s.Info.Selectable && (selectionClasses == null || selectionClasses.Contains(s.Class));
return s != null && (selectionClasses == null || selectionClasses.Contains(s.Class));
});
}
@@ -303,11 +303,7 @@ namespace OpenRA.Widgets
a = b;
return world.ScreenMap.ActorsInBox(a, b)
.Where(x =>
{
var s = x.TraitOrDefault<Selectable>();
return s != null && s.Info.Selectable && (x.Owner.IsAlliedWith(world.RenderPlayer) || !world.FogObscures(x));
})
.Where(x => x.HasTrait<Selectable>() && (x.Owner.IsAlliedWith(world.RenderPlayer) || !world.FogObscures(x)))
.GroupBy(x => x.GetSelectionPriority())
.OrderByDescending(g => g.Key)
.Select(g => g.AsEnumerable())