Remove Actor.HasTrait<T>()
This commit is contained in:
@@ -226,11 +226,6 @@ namespace OpenRA
|
||||
return World.TraitDict.WithInterface<T>(this);
|
||||
}
|
||||
|
||||
public bool HasTrait<T>()
|
||||
{
|
||||
return World.TraitDict.Contains<T>(this);
|
||||
}
|
||||
|
||||
public void AddTrait(object trait)
|
||||
{
|
||||
World.TraitDict.AddTrait(this, trait);
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace OpenRA.Graphics
|
||||
if (World.Type == WorldType.Regular && Game.Settings.Game.AlwaysShowStatusBars)
|
||||
{
|
||||
foreach (var g in World.Actors.Where(a => !a.Disposed
|
||||
&& a.HasTrait<Selectable>()
|
||||
&& a.Info.Traits.Contains<SelectableInfo>()
|
||||
&& !World.FogObscures(a)
|
||||
&& !World.Selection.Actors.Contains(a)))
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
public void DrawRollover(Actor unit)
|
||||
{
|
||||
if (unit.HasTrait<Selectable>())
|
||||
if (unit.Info.Traits.Contains<SelectableInfo>())
|
||||
new SelectionBarsRenderable(unit).Render(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Orders
|
||||
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
|
||||
{
|
||||
var underCursor = world.ScreenMap.ActorsAt(mi)
|
||||
.Where(a => !world.FogObscures(a) && a.HasTrait<ITargetable>())
|
||||
.Where(a => !world.FogObscures(a) && a.Info.Traits.Contains<ITargetableInfo>())
|
||||
.WithHighestSelectionPriority();
|
||||
|
||||
Target target;
|
||||
@@ -58,12 +58,12 @@ namespace OpenRA.Orders
|
||||
{
|
||||
var useSelect = false;
|
||||
var underCursor = world.ScreenMap.ActorsAt(mi)
|
||||
.Where(a => !world.FogObscures(a) && a.HasTrait<ITargetable>())
|
||||
.Where(a => !world.FogObscures(a) && a.Info.Traits.Contains<ITargetableInfo>())
|
||||
.WithHighestSelectionPriority();
|
||||
|
||||
if (underCursor != null && (mi.Modifiers.HasModifier(Modifiers.Shift) || !world.Selection.Actors.Any()))
|
||||
{
|
||||
if (underCursor.HasTrait<Selectable>())
|
||||
if (underCursor.Info.Traits.Contains<SelectableInfo>())
|
||||
useSelect = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,12 +84,6 @@ namespace OpenRA
|
||||
throw new InvalidOperationException("Attempted to get trait from destroyed object ({0})".F(actor));
|
||||
}
|
||||
|
||||
public bool Contains<T>(Actor actor)
|
||||
{
|
||||
CheckDestroyed(actor);
|
||||
return InnerGet<T>().GetMultiple(actor.ActorID).Any();
|
||||
}
|
||||
|
||||
public T Get<T>(Actor actor)
|
||||
{
|
||||
CheckDestroyed(actor);
|
||||
|
||||
@@ -144,13 +144,13 @@ namespace OpenRA.Traits
|
||||
Player Owner { get; }
|
||||
}
|
||||
|
||||
public interface IToolTip
|
||||
public interface ITooltip
|
||||
{
|
||||
ITooltipInfo TooltipInfo { get; }
|
||||
Player Owner { get; }
|
||||
}
|
||||
|
||||
public interface ITooltipInfo
|
||||
public interface ITooltipInfo : ITraitInfo
|
||||
{
|
||||
string TooltipForPlayerStance(Stance stance);
|
||||
bool IsOwnerRowVisible { get; }
|
||||
@@ -226,6 +226,7 @@ namespace OpenRA.Traits
|
||||
public interface ITags { IEnumerable<TagType> GetTags(); }
|
||||
public interface ISelectionBar { float GetValue(); Color GetColor(); }
|
||||
|
||||
public interface IPositionableInfo : ITraitInfo { }
|
||||
public interface IPositionable : IOccupySpace
|
||||
{
|
||||
bool IsLeavingCell(CPos location, SubCell subCell = SubCell.Any);
|
||||
@@ -296,6 +297,7 @@ namespace OpenRA.Traits
|
||||
public interface INotifyBecomingIdle { void OnBecomingIdle(Actor self); }
|
||||
public interface INotifyIdle { void TickIdle(Actor self); }
|
||||
|
||||
public interface IBlocksProjectilesInfo : ITraitInfo { }
|
||||
public interface IBlocksProjectiles { }
|
||||
public interface IRenderInfantrySequenceModifier
|
||||
{
|
||||
@@ -309,7 +311,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public interface IPostRenderSelection { IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr); }
|
||||
|
||||
public interface ITargetableInfo
|
||||
public interface ITargetableInfo : ITraitInfo
|
||||
{
|
||||
HashSet<string> GetTargetTypes();
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
if (!hasBox && World.Selection.Actors.Any() && !multiClick)
|
||||
{
|
||||
if (!(World.ScreenMap.ActorsAt(xy).Where(x => x.HasTrait<Selectable>() &&
|
||||
if (!(World.ScreenMap.ActorsAt(xy).Where(x => x.Info.Traits.Contains<SelectableInfo>() &&
|
||||
(x.Owner.IsAlliedWith(World.RenderPlayer) || !World.FogObscures(x))).Any() && !mi.Modifiers.HasModifier(Modifiers.Ctrl) &&
|
||||
!mi.Modifiers.HasModifier(Modifiers.Alt) && UnitOrderGenerator.InputOverridesSelection(World, xy, mi)))
|
||||
{
|
||||
@@ -301,7 +301,7 @@ namespace OpenRA.Widgets
|
||||
a = b;
|
||||
|
||||
return world.ScreenMap.ActorsInBox(a, b)
|
||||
.Where(x => x.HasTrait<Selectable>() && (x.Owner.IsAlliedWith(world.RenderPlayer) || !world.FogObscures(x)))
|
||||
.Where(x => x.Info.Traits.Contains<SelectableInfo>() && (x.Owner.IsAlliedWith(world.RenderPlayer) || !world.FogObscures(x)))
|
||||
.SubsetWithHighestSelectionPriority();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user