Selection box size now defaults to Selectable.Bounds if VisualBounds are null

This commit is contained in:
reaperrr
2015-06-17 21:42:15 +02:00
parent 2986277490
commit f2d8e32b01
5 changed files with 5 additions and 16 deletions

View File

@@ -115,11 +115,13 @@ namespace OpenRA
visualBounds = Exts.Lazy(() =>
{
var sd = Info.Traits.GetOrDefault<ISelectionDecorationsInfo>();
var size = (sd != null && sd.SelectionBoxBounds != null) ? new int2(sd.SelectionBoxBounds[0], sd.SelectionBoxBounds[1]) :
TraitsImplementing<IAutoSelectionSize>().Select(x => x.SelectionSize(this)).FirstOrDefault();
if (sd == null || sd.SelectionBoxBounds == null)
return bounds.Value;
var size = new int2(sd.SelectionBoxBounds[0], sd.SelectionBoxBounds[1]);
var offset = -size / 2;
if (sd != null && sd.SelectionBoxBounds != null && sd.SelectionBoxBounds.Length > 2)
if (sd.SelectionBoxBounds.Length > 2)
offset += new int2(sd.SelectionBoxBounds[2], sd.SelectionBoxBounds[3]);
return new Rectangle(offset.X, offset.Y, size.X, size.Y);

View File

@@ -33,7 +33,6 @@
Beach: 50
ROT: 5
SelectionDecorations:
VisualBounds: 24,24
Selectable:
Bounds: 24,24
TargetableUnit:
@@ -82,7 +81,6 @@
Beach: 70
ROT: 5
SelectionDecorations:
VisualBounds: 24,24
Selectable:
Bounds: 24,24
TargetableUnit:
@@ -128,7 +126,6 @@
TargetTypes: Air
GroundedTargetTypes: Ground
SelectionDecorations:
VisualBounds: 24,24
Selectable:
Bounds: 24,24
Helicopter:
@@ -183,7 +180,6 @@
PathingCost: 300
Beach: 80
SelectionDecorations:
VisualBounds: 12,17,0,-6
Selectable:
Bounds: 12,17,0,-6
TargetableUnit:
@@ -305,7 +301,6 @@
BlueTiberium: 70
Beach: 80
SelectionDecorations:
VisualBounds: 24,24
Selectable:
Bounds: 24,24
TargetableUnit:
@@ -337,7 +332,6 @@
AppearsOnRadar:
UseLocation: yes
SelectionDecorations:
VisualBounds: 24,24
Selectable:
Bounds: 24,24
TargetableUnit:

View File

@@ -34,7 +34,6 @@
Dune: 60
ROT: 5
SelectionDecorations:
VisualBounds: 32,32
Selectable:
Bounds: 32,32
TargetableUnit:
@@ -91,7 +90,6 @@
Dune: 70
ROT: 5
SelectionDecorations:
VisualBounds: 32,32
Selectable:
Bounds: 32,32
TargetableUnit:
@@ -217,7 +215,6 @@
Dune: 60
Rough: 70
SelectionDecorations:
VisualBounds: 12,18,0,-6
Selectable:
Bounds: 12,18,0,-6
TargetableUnit:
@@ -275,7 +272,6 @@
AppearsOnRadar:
UseLocation: yes
SelectionDecorations:
VisualBounds: 32,32
Selectable:
Bounds: 32,32
TargetableAircraft:

View File

@@ -181,7 +181,6 @@
Gems: 80
Beach: 80
SelectionDecorations:
VisualBounds: 12,18,0,-8
Selectable:
Bounds: 12,18,0,-8
TargetableUnit:

View File

@@ -212,7 +212,6 @@
BlueTiberium: 80
SelectionDecorations:
Palette: pips
VisualBounds: 14,23,-1,-9
Selectable:
Bounds: 14,23,-1,-9
Voiced:
@@ -500,7 +499,6 @@
BlueTiberium: 100
SelectionDecorations:
Palette: pips
VisualBounds: 26,26,0,-3
Selectable:
Bounds: 26,26,0,-3
TargetableUnit: