Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Get the aqueduct that can be built from the current
- * tile. Aqueducts are only build on sloped tiles.
- */
- function Canal::_GetAqueduct(last_node, cur_node, aqueduct_dir)
- {
- local slope = AITile.GetSlope(cur_node);
- local offset;
- if (slope == AITile.SLOPE_NE) {
- offset = AIMap.GetTileIndex(-1, 0);
- } else if (slope == AITile.SLOPE_SE) {
- offset = AIMap.GetTileIndex(0, 1);
- } else if (slope == AITile.SLOPE_NW) {
- offset = AIMap.GetTileIndex(0, -1);
- } else if (slope == AITile.SLOPE_SW) {
- offset = AIMap.GetTileIndex(1, 0);
- } else {
- return [];
- }
- if (last_node != cur_node + offset) {
- return [];
- }
- local s_min_height = AITile.GetMinHeight(cur_node);
- local s_max_height = AITile.GetMaxHeight(cur_node);
- for (local i = 1; i < this._max_aqueduct_length; i++) {
- local next_tile = cur_node + i * (cur_node - last_node);
- local aqueduct = AIBridge.BuildBridge(AIVehicle.VT_WATER, 0, cur_node, next_tile);
- if (!AIMap.IsValidTile(next_tile)) {
- return [];
- }
- local e_max_height = AITile.GetMaxHeight(next_tile);
- if (e_max_height < s_max_height) {
- continue;
- }
- local e_min_height = AITile.GetMinHeight(next_tile);
- if (e_max_height > s_max_height || e_min_height < s_min_height) {
- return [];
- }
- if (AIBridge.BuildBridge(AIVehicle.VT_WATER, 0, cur_node, next_tile)) {
- return [next_tile, aqueduct_dir, AITileList()];
- } else {
- return [];
- }
- }
- return [];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement