fix helicopters landing in silly places

This commit is contained in:
Chris Forbes
2010-11-11 18:59:10 +13:00
parent c1eacc225d
commit bc7a9c14d0
4 changed files with 16 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ namespace OpenRA.Mods.RA.Air
public readonly int InitialFacing = 128;
public readonly int ROT = 255;
public readonly int Speed = 1;
public readonly string[] LandableTerrainTypes = { };
public virtual object Create( ActorInitializer init ) { return new Aircraft( init , this ); }
}
@@ -102,5 +103,17 @@ namespace OpenRA.Mods.RA.Air
var angle = facing * Math.PI / 128.0;
return new int2( (int)Math.Truncate( 1024 * Math.Sin( angle ) ), (int)Math.Truncate( 1024 * Math.Cos( angle ) ) );
}
public bool CanLand(int2 cell)
{
if (!self.World.Map.IsInMap(cell))
return false;
if (self.World.WorldActor.Trait<UnitInfluence>().AnyUnitsAt(cell))
return false;
var type = self.World.GetTerrainType(cell);
return Info.LandableTerrainTypes.Contains(type);
}
}
}

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Air
if (aircraft.Altitude == 0)
return NextActivity;
if (requireSpace && !aircraft.CanEnterCell(self.Location))
if (requireSpace && !aircraft.CanLand(self.Location))
return this;
--aircraft.Altitude;

View File

@@ -468,6 +468,7 @@ TRAN:
ROT: 5
Speed: 15
InitialFacing: 0
LandableTerrainTypes: Clear,Rough,Road,Ore,Beach
Health:
HP: 90
Armor:

View File

@@ -802,6 +802,7 @@ TRAN:
InitialFacing: 0
ROT: 5
Speed: 12
LandableTerrainTypes: Clear,Rough,Road,Ore,Beach
RenderUnitRotor:
PrimaryOffset: 0,14,0,-8
SecondaryOffset: 0,-14,0,-5