function WrightAI::GetBestRouteEngine(tile_1, tile_2) {
local engine_list = AIEngineList(AIVehicle.VT_AIR);
engine_list.Valuate(AIEngine.CanRefitCargo, this.cargoId);
engine_list.KeepValue(1);
local small_aircraft = AIAirport.GetAirportType(tile_1) == AIAirport.AT_SMALL || AIAirport.GetAirportType(tile_2) == AIAirport.AT_SMALL ||
AIAirport.GetAirportType(tile_1) == AIAirport.AT_COMMUTER || AIAirport.GetAirportType(tile_2) == AIAirport.AT_COMMUTER;
if (small_aircraft) {
engine_list.Valuate(AIEngine.GetPlaneType);
engine_list.RemoveValue(AIAirport.PT_BIG_PLANE);
}
local helicopter = AIAirport.GetAirportType(tile_1) == AIAirport.AT_HELIPORT || AIAirport.GetAirportType(tile_2) == AIAirport.AT_HELIPORT ||
AIAirport.GetAirportType(tile_1) == AIAirport.AT_HELIDEPOT || AIAirport.GetAirportType(tile_2) == AIAirport.AT_HELIDEPOT ||
AIAirport.GetAirportType(tile_1) == AIAirport.AT_HELISTATION || AIAirport.GetAirportType(tile_2) == AIAirport.AT_HELISTATION;
if (helicopter) {
engine_list.Valuate(AIEngine.GetPlaneType);
engine_list.KeepValue(AIAirport.PT_HELICOPTER);
}
engine_list.Valuate(AIEngine.GetMaxSpeed);
engine_list.Sort(AIList.SORT_BY_VALUE, AIList.SORT_DESCENDING);
local dist = AIMap.DistanceSquare(tile_1, tile_2);
engine_list.Valuate(WrightAI.GetMaximumOrderDistance);
engine_list.KeepAboveValue(dist - 1);
engine_list.Sort(AIList.SORT_BY_VALUE, AIList.SORT_DESCENDING);
AILog.Warning(AIEngine.GetName(engine_list.Begin()) + " maximum distance is " + engine_list.GetValue(engine_list.Begin()));
if (engine_list.Count() == 0) {
return null;
} else {
return engine_list.Begin();
}
}
function::WrightAI::GetMaximumOrderDistance(engine) {
local dist = AIEngine.GetMaximumOrderDistance(engine);
return dist == 0 ? 0xFFFFFFFF : dist;
}