function Utils::AreOtherStationsNearby(tile, stationId) {
//check if there are other stations squareSize squares nearby
local square = AITileList();
local squareSize = 0;
if(!AIController.GetSetting("is_friendly")) {
//dont care about enemy stations when is_friendly is off
squareSize = (stationId == null) ? 5 : 2; //6 tiles distance between new stations, 3 tiles distance between adjacent stations
square.AddRectangle(Utils.getOffsetTile(tile, (-1) * squareSize, (-1) * squareSize),
Utils.getOffsetTile(tile, squareSize, squareSize));
//if another station is nearby return true
for(local tile = square.Begin(); square.HasNext(); tile = square.Next()) {
if(AITile.IsStationTile(tile) && (AITile.GetOwner(tile) == AICompany.ResolveCompanyID(AICompany.COMPANY_SELF)) ) { //negate second expression to merge your statitions
return true;
}
}
}
else {
squareSize = 3;
square.AddRectangle(Utils.getOffsetTile(tile, (-1) * squareSize, (-1) * squareSize),
Utils.getOffsetTile(tile, squareSize, squareSize));
//if another station is nearby return true
for(local tile = square.Begin(); square.HasNext(); tile = square.Next()) {
if(AITile.IsStationTile(tile)) {
return true;
}
}
}
if(! ((AITile.IsBuildable(tile) || AIRoad.IsRoadTile(tile)) && AITile.GetSlope(tile) == AITile.SLOPE_FLAT)) {
return true;
}
return false;
};
/// valuateTruckStopTile
///
/// @param tile - The starting tile to valuate.
/// @param cargoClass - should be either AICargo.CC_MAIL, or AICargo.CC_PASSENGERS to get correct cargo acceptance.
/// @return - The tile value.
function Utils::valuateTruckStopTile(tile, cargoClass, stationId, cargoType) {
local radiusType;
if(cargoClass == AICargo.CC_MAIL) {
radiusType = AIStation.STATION_TRUCK_STOP;
}
else {
radiusType = AIStation.STATION_BUS_STOP;
}
if(AITile.GetCargoAcceptance(tile,
cargoType,
1,
1,
AIStation.GetCoverageRadius(radiusType)) < 8) {
return 0;
}
local value = AITile.GetCargoProduction(tile,
cargoType,
1,
1,
AIStation.GetCoverageRadius(radiusType));
return value;
}