Bug Fix: Helicopters spawning under each other

This commit is contained in:
Mike Bundy
2011-04-10 23:36:49 +01:00
parent 7a63858812
commit bca2797bb4

View File

@@ -31,6 +31,7 @@ namespace OpenRA.Mods.RA.Air
class Helicopter : Aircraft, ITick, IIssueOrder, IResolveOrder, IOrderVoice
{
HelicopterInfo Info;
bool firstTick = true;
public Helicopter( ActorInitializer init, HelicopterInfo info) : base( init, info )
{
@@ -121,6 +122,24 @@ namespace OpenRA.Mods.RA.Air
public void Tick(Actor self)
{
if (firstTick)
{
firstTick = false;
if (self.Trait<IMove>().Altitude == 0)
{
/* not spawning in the air, so try to assoc. with our afld. this is a hack. */
var afld = self.World.FindUnits(self.CenterLocation, self.CenterLocation)
.FirstOrDefault(a => a.HasTrait<Reservable>());
if (afld != null)
{
var res = afld.Trait<Reservable>();
if (res != null)
reservation = res.Reserve(afld, self, this);
}
}
}
var aircraft = self.Trait<Aircraft>();
if (aircraft.Altitude <= 0)
return;