Remove legacy bounds code.
This commit is contained in:
@@ -16,65 +16,29 @@ using OpenRA.Graphics;
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
[Desc("This actor is selectable. Defines bounds of selectable area, selection class and selection priority.")]
|
||||
public class SelectableInfo : ITraitInfo, IDecorationBoundsInfo
|
||||
public class SelectableInfo : InteractableInfo
|
||||
{
|
||||
public readonly int Priority = 10;
|
||||
|
||||
[Desc("Bounds for the selectable area.")]
|
||||
public readonly int[] Bounds = null;
|
||||
|
||||
[Desc("Area outside the visible selection box that is enabled for selection")]
|
||||
public readonly int Margin = 0;
|
||||
|
||||
[Desc("All units having the same selection class specified will be selected with select-by-type commands (e.g. double-click). "
|
||||
+ "Defaults to the actor name when not defined or inherited.")]
|
||||
public readonly string Class = null;
|
||||
|
||||
[VoiceReference] public readonly string Voice = "Select";
|
||||
|
||||
public object Create(ActorInitializer init) { return new Selectable(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new Selectable(init.Self, this); }
|
||||
}
|
||||
|
||||
public class Selectable : IMouseBounds, IDecorationBounds
|
||||
public class Selectable : Interactable
|
||||
{
|
||||
public readonly string Class = null;
|
||||
|
||||
public SelectableInfo Info;
|
||||
public readonly SelectableInfo Info;
|
||||
|
||||
public Selectable(Actor self, SelectableInfo info)
|
||||
: base(info)
|
||||
{
|
||||
Class = string.IsNullOrEmpty(info.Class) ? self.Info.Name : info.Class;
|
||||
Info = info;
|
||||
}
|
||||
|
||||
Rectangle IMouseBounds.MouseoverBounds(Actor self, WorldRenderer wr)
|
||||
{
|
||||
if (Info.Bounds == null)
|
||||
return Rectangle.Empty;
|
||||
|
||||
var size = new int2(Info.Bounds[0], Info.Bounds[1]);
|
||||
|
||||
var offset = -size / 2 - new int2(Info.Margin, Info.Margin);
|
||||
if (Info.Bounds.Length > 2)
|
||||
offset += new int2(Info.Bounds[2], Info.Bounds[3]);
|
||||
|
||||
var xy = wr.ScreenPxPosition(self.CenterPosition) + offset;
|
||||
return new Rectangle(xy.X, xy.Y, size.X + 2 * Info.Margin, size.Y + 2 * Info.Margin);
|
||||
}
|
||||
|
||||
Rectangle IDecorationBounds.DecorationBounds(Actor self, WorldRenderer wr)
|
||||
{
|
||||
if (Info.Bounds == null)
|
||||
return Rectangle.Empty;
|
||||
|
||||
var size = new int2(Info.Bounds[0], Info.Bounds[1]);
|
||||
|
||||
var offset = -size / 2;
|
||||
if (Info.Bounds.Length > 2)
|
||||
offset += new int2(Info.Bounds[2], Info.Bounds[3]);
|
||||
|
||||
var xy = wr.ScreenPxPosition(self.CenterPosition) + offset;
|
||||
return new Rectangle(xy.X, xy.Y, size.X, size.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user