|
| 1 | +local b = require 'map_gen.shared.builders' |
| 2 | +local MGSP = require 'resources.map_gen_settings' |
| 3 | + |
| 4 | +local type = type |
| 5 | +local water_tiles = b.water_tiles |
| 6 | +local path_tiles = b.path_tiles |
| 7 | + |
| 8 | +local pic = require 'map_gen.data.presets.UK' |
| 9 | +local world_map = b.picture(pic) |
| 10 | + |
| 11 | +local x_offset, y_offset = -50, 50 |
| 12 | +world_map = b.translate(world_map, x_offset, y_offset) |
| 13 | + |
| 14 | + |
| 15 | +local scale = 3 |
| 16 | +local height = 2000 * scale |
| 17 | +local width = 2000 * scale |
| 18 | + |
| 19 | +world_map = b.scale(world_map, scale) |
| 20 | + |
| 21 | + |
| 22 | +local bounds = b.rectangle(width, height) |
| 23 | +bounds = b.translate(bounds, x_offset * scale, y_offset * scale) |
| 24 | + |
| 25 | +local config = { |
| 26 | + scenario_name = 'crashsite-brexit', |
| 27 | + map_gen_settings = { |
| 28 | + MGSP.starting_area_very_low, |
| 29 | + MGSP.ore_oil_none, |
| 30 | + MGSP.enemy_none, |
| 31 | + MGSP.cliff_none |
| 32 | + }, |
| 33 | + grid_number_of_blocks = 15, |
| 34 | + mini_grid_number_of_blocks = 29, |
| 35 | + bounds_shape = bounds |
| 36 | +} |
| 37 | + |
| 38 | +local Scenario = require 'map_gen.maps.crash_site.scenario' |
| 39 | +local crashsite = Scenario.init(config) |
| 40 | + |
| 41 | +local function get_tile_name(tile) |
| 42 | + if type(tile) == 'table' then |
| 43 | + return tile.tile |
| 44 | + else |
| 45 | + return tile |
| 46 | + end |
| 47 | +end |
| 48 | + |
| 49 | +local function map(x, y, world) |
| 50 | + local tile = world_map(x, y, world) |
| 51 | + if not tile then |
| 52 | + return tile |
| 53 | + end |
| 54 | + |
| 55 | + local world_tile_name = get_tile_name(tile) |
| 56 | + if not world_tile_name or water_tiles[world_tile_name] then |
| 57 | + return tile |
| 58 | + end |
| 59 | + |
| 60 | + local crashsite_tile = crashsite(x, y, world) |
| 61 | + local crashsite_tile_name = get_tile_name(crashsite_tile) |
| 62 | + if path_tiles[crashsite_tile_name] then |
| 63 | + return crashsite_tile |
| 64 | + end |
| 65 | + |
| 66 | + if type(crashsite_tile) == 'table' then |
| 67 | + crashsite_tile.tile = world_tile_name |
| 68 | + return crashsite_tile |
| 69 | + end |
| 70 | + |
| 71 | + return tile |
| 72 | +end |
| 73 | + |
| 74 | +return map |
0 commit comments