Heli pips and separation

This commit is contained in:
Paul Chote
2010-06-13 15:39:00 +12:00
parent 3edbfc3345
commit e5ee2b9479
5 changed files with 33 additions and 49 deletions

View File

@@ -50,15 +50,7 @@ namespace OpenRA.Mods.RA.Activities
return this;
}
// Prevent multiple units from stacking together
var otherHelis = self.World.FindUnitsInCircle(self.CenterLocation, info.IdealSeparation)
.Where(a => a.traits.Contains<Helicopter>());
var f = otherHelis
.Select(h => GetRepulseForce(self, h))
.Aggregate(float2.Zero, (a, b) => a + b);
var dist = Dest - self.CenterLocation + f;
var dist = Dest - self.CenterLocation;
if (float2.WithinEpsilon(float2.Zero, dist, 2))
{
self.CenterLocation = Dest;
@@ -76,19 +68,6 @@ namespace OpenRA.Mods.RA.Activities
return this;
}
// Todo: Duplicated from HeliAttack
const float Epsilon = .5f;
float2 GetRepulseForce(Actor self, Actor h)
{
if (self == h)
return float2.Zero;
var d = self.CenterLocation - h.CenterLocation;
if (d.LengthSquared < Epsilon)
return float2.FromAngle((float)self.World.SharedRandom.NextDouble() * 3.14f);
return (2 / d.LengthSquared) * d;
}
public void Cancel(Actor self) { isCanceled = true; NextActivity = null; }
}