non-turreted AutoTarget is sensible now
This commit is contained in:
@@ -106,19 +106,18 @@ namespace OpenRa.Game
|
|||||||
.FirstOrDefault( x => x != null );
|
.FirstOrDefault( x => x != null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public RectangleF Bounds
|
public RectangleF GetBounds(bool useAltitude)
|
||||||
{
|
{
|
||||||
get
|
var size = SelectedSize;
|
||||||
|
var loc = CenterLocation - 0.5f * size;
|
||||||
|
|
||||||
|
if (useAltitude)
|
||||||
{
|
{
|
||||||
var size = SelectedSize;
|
|
||||||
var loc = CenterLocation - 0.5f * size;
|
|
||||||
var unit = traits.GetOrDefault<Unit>();
|
var unit = traits.GetOrDefault<Unit>();
|
||||||
|
if (unit != null) loc -= new float2(0, unit.Altitude);
|
||||||
if (unit != null)
|
|
||||||
loc -= new float2(0, unit.Altitude);
|
|
||||||
|
|
||||||
return new RectangleF(loc.X, loc.Y, size.X, size.Y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new RectangleF(loc.X, loc.Y, size.X, size.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsDead { get { return Health <= 0; } }
|
public bool IsDead { get { return Health <= 0; } }
|
||||||
|
|||||||
@@ -269,13 +269,19 @@ namespace OpenRa.Game
|
|||||||
var rect = new RectangleF(min.X, min.Y, max.X - min.X, max.Y - min.Y);
|
var rect = new RectangleF(min.X, min.Y, max.X - min.X, max.Y - min.Y);
|
||||||
|
|
||||||
return world.Actors
|
return world.Actors
|
||||||
.Where(x => x.Bounds.IntersectsWith(rect));
|
.Where(x => x.GetBounds(true).IntersectsWith(rect));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<Actor> FindUnitsInCircle(float2 a, float r)
|
public static IEnumerable<Actor> FindUnitsInCircle(float2 a, float r)
|
||||||
{
|
{
|
||||||
return FindUnits(a - new float2(r, r), a + new float2(r, r))
|
var min = a - new float2(r, r);
|
||||||
.Where(x => (x.CenterLocation - a).LengthSquared < r * r);
|
var max = a + new float2(r, r);
|
||||||
|
|
||||||
|
var rect = new RectangleF(min.X, min.Y, max.X - min.X, max.Y - min.Y);
|
||||||
|
|
||||||
|
var inBox = world.Actors.Where(x => x.GetBounds(false).IntersectsWith(rect));
|
||||||
|
|
||||||
|
return inBox.Where(x => (x.CenterLocation - a).LengthSquared < r * r);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<int2> FindTilesInCircle(int2 a, int r)
|
public static IEnumerable<int2> FindTilesInCircle(int2 a, int r)
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ namespace OpenRa.Game.Graphics
|
|||||||
|
|
||||||
public void DrawSelectionBox(Actor selectedUnit, Color c, bool drawHealthBar)
|
public void DrawSelectionBox(Actor selectedUnit, Color c, bool drawHealthBar)
|
||||||
{
|
{
|
||||||
var bounds = selectedUnit.Bounds;
|
var bounds = selectedUnit.GetBounds(true);
|
||||||
|
|
||||||
var xy = new float2(bounds.Left, bounds.Top);
|
var xy = new float2(bounds.Left, bounds.Top);
|
||||||
var Xy = new float2(bounds.Right, bounds.Top);
|
var Xy = new float2(bounds.Right, bounds.Top);
|
||||||
|
|||||||
@@ -16,16 +16,23 @@ namespace OpenRa.Game.Traits
|
|||||||
attack.ResolveOrder(self, new Order("Attack", self, target, int2.Zero, null));
|
attack.ResolveOrder(self, new Order("Attack", self, target, int2.Zero, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float GetMaximumRange(Actor self)
|
||||||
|
{
|
||||||
|
return new[] { self.Info.Primary, self.Info.Secondary }
|
||||||
|
.Where(w => w != null)
|
||||||
|
.Max(w => Rules.WeaponInfo[w].Range);
|
||||||
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (!self.IsIdle) return;
|
if (!self.IsIdle) return;
|
||||||
|
|
||||||
var attack = self.traits.WithInterface<AttackBase>().First();
|
var attack = self.traits.WithInterface<AttackBase>().First();
|
||||||
var range = Rules.WeaponInfo[self.Info.Primary].Range;
|
var range = GetMaximumRange(self);
|
||||||
|
|
||||||
if (attack.target == null ||
|
if (attack.target == null ||
|
||||||
(attack.target.Location - self.Location).LengthSquared > range * range + 2)
|
(attack.target.Location - self.Location).LengthSquared > range * range + 2)
|
||||||
attack.target = ChooseTarget(self, range);
|
AttackTarget(self, ChooseTarget(self, range));
|
||||||
}
|
}
|
||||||
|
|
||||||
Actor ChooseTarget(Actor self, float range)
|
Actor ChooseTarget(Actor self, float range)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace OpenRa.Game.Traits
|
|||||||
{
|
{
|
||||||
if (doneBuilding) roof.Tick();
|
if (doneBuilding) roof.Tick();
|
||||||
|
|
||||||
var b = self.Bounds;
|
var b = self.GetBounds(false);
|
||||||
if (isOpen && !Game.UnitInfluence.GetUnitsAt(((1/24f) * self.CenterLocation).ToInt2()).Any())
|
if (isOpen && !Game.UnitInfluence.GetUnitsAt(((1/24f) * self.CenterLocation).ToInt2()).Any())
|
||||||
{
|
{
|
||||||
isOpen = false;
|
isOpen = false;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ E3 AA weapon doesn't work.
|
|||||||
E4 Flamer origin is wrong
|
E4 Flamer origin is wrong
|
||||||
E6 Capture action missing, repair action missing
|
E6 Capture action missing, repair action missing
|
||||||
E7 C4 action missing
|
E7 C4 action missing
|
||||||
MEDI Heal doesn't work
|
MEDI Heal targeting is wrong
|
||||||
SPY Infiltrate action missing
|
SPY Infiltrate action missing
|
||||||
THF Steal action missing
|
THF Steal action missing
|
||||||
C1,C2,Einstein,Kosygin Not implemented
|
C1,C2,Einstein,Kosygin Not implemented
|
||||||
|
|||||||
@@ -6,5 +6,6 @@
|
|||||||
[UNITS]
|
[UNITS]
|
||||||
s0=Multi0,mcv,600,2841,0,Guard,None
|
s0=Multi0,mcv,600,2841,0,Guard,None
|
||||||
s1=Multi2,mcv,600,12445,0,Guard,None
|
s1=Multi2,mcv,600,12445,0,Guard,None
|
||||||
s2=Multi1,mcv,600,12505,0,Guard,None
|
;s2=Multi1,mcv,600,12505,0,Guard,None
|
||||||
|
s2=Multi1,e3,600,12505,0,Guard,None
|
||||||
s3=Multi3,mcv,600,2910,0,Guard,None
|
s3=Multi3,mcv,600,2910,0,Guard,None
|
||||||
Reference in New Issue
Block a user