move ReserveSpawnBuilding out of Plane.Tick and name it

This commit is contained in:
Chris Forbes
2011-07-17 11:57:07 +12:00
parent 2d8b72a5ff
commit 8b78bc0602
2 changed files with 18 additions and 13 deletions

View File

@@ -120,6 +120,23 @@ namespace OpenRA.Mods.RA.Air
Info = info; Info = info;
} }
protected void ReserveSpawnBuilding( Actor self )
{
if (self.Trait<IMove>().Altitude != 0)
return;
/* 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)
return;
var res = afld.Trait<Reservable>();
if (res != null)
reservation = res.Reserve(afld, self, this);
}
public int ROT { get { return Info.ROT; } } public int ROT { get { return Info.ROT; } }
public int InitialFacing { get { return Info.InitialFacing; } } public int InitialFacing { get { return Info.InitialFacing; } }

View File

@@ -33,19 +33,7 @@ namespace OpenRA.Mods.RA.Air
if (firstTick) if (firstTick)
{ {
firstTick = false; firstTick = false;
if (self.Trait<IMove>().Altitude == 0) ReserveSpawnBuilding(self);
{
/* 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);
}
}
} }
} }