Loading

Paste #pkbdlajme

  1. function Utils::GetStationCoverageCargoProduction(stationId, cargoClass) {
  2.     local tileList = AITileList();
  3.     local stationTiles = AITileList_StationType(stationId, AIStation.STATION_ANY);
  4.     local airportTiles = AITileList_StationType(stationId, AIStation.STATION_AIRPORT);
  5.     airportTiles.Sort(AIList.SORT_BY_ITEM, AIList.SORT_ASCENDING);
  6.     local airport_tile = airportTiles.Count() == 0 ? AIMap.TILE_INVALID : airportTiles.Begin();
  7.     for (local tile = stationTiles.Begin(); !stationTiles.IsEnd(); tile = stationTiles.Next()) {
  8.         if (!AIAirport.IsAirportTile(tile)) {
  9.             local type = cargoClass == AICargo.CC_PASSENGERS ? AIStation.STATION_BUS_STOP : AIStation.STATION_TRUCK_STOP;
  10.             local radius = AIStation.GetCoverageRadius(type);
  11.             tileList.AddRectangle(Utils.getValidOffsetTile(tile, -radius, -radius), Utils.getValidOffsetTile(tile, radius, radius));
  12.         } else if (AIMap.IsValidTile(airport_tile) && tile == airport_tile) {
  13.             local type = AIAirport.GetAirportType(tile);
  14.             local radius = AIAirport.GetAirportCoverageRadius(type);
  15.             local width = AIAirport.GetAirportWidth(type);
  16.             local height = AIAirport.GetAirportHeight(type);
  17.             tileList.AddRectangle(Utils.getValidOffsetTile(tile, -radius, -radius), Utils.getValidOffsetTile(AIMap.GetTileIndex(AIMap.GetTileX(tile) + width - 1, AIMap.GetTileY(tile) + height - 1), radius, radius));
  18.         }
  19.     }
  20.     local removeTiles = AITileList();
  21.     for (local remove_tile = tileList.Begin(); !tileList.IsEnd(); remove_tile = tileList.Next()) {
  22.         if (stationTiles.HasItem(remove_tile)) {
  23.             removeTiles.AddTile(remove_tile);
  24.         }
  25.     }
  26.     tileList.RemoveList(removeTiles);
  27.     for (local tile = tileList.Begin(); !tileList.IsEnd(); tile = tileList.Next()) {
  28.         AISign.BuildSign(tile, "x");
  29.     }
  30.     // TODO - how to compute cargo production of each tile in tileList
  31. }

Comments