Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. /**
  2. * Get the aqueduct that can be build from the
  3. * current tile. Aqueducts are only build on sloped tiles.
  4. */
  5. function Canal::_GetAqueduct(last_node, cur_node, aqueduct_dir)
  6. {
  7. if (!this._IsInclinedTile(cur_node)) return [];
  8.  
  9. for (local i = 1; i < this._max_aqueduct_length; i++) {
  10. local next_tile = cur_node + i * (cur_node - last_node);
  11. if (!AIMap.IsValidTile(next_tile)) {
  12. return [];
  13. }
  14. if (AIBridge.BuildBridge(AIVehicle.VT_WATER, 0, cur_node, next_tile)) {
  15. return [next_tile, aqueduct_dir, AITileList()];
  16. }
  17. }
  18.  
  19. return [];
  20. }
  21.  
  22. function Canal::_IsInclinedTile(tile)
  23. {
  24. local slope = AITile.GetSlope(tile);
  25. return slope == AITile.SLOPE_SW || slope == AITile.SLOPE_NW || slope == AITile.SLOPE_SE || slope == AITile.SLOPE_NE;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement