Skip to content

Commit 2f7ac49

Browse files
authored
Merge pull request #1236 from Refactorio/Claude477-crashsite-UK
Crashsite(UK)-scenario
2 parents a39ce85 + 9970a9f commit 2f7ac49

File tree

4 files changed

+79
-2
lines changed

4 files changed

+79
-2
lines changed

map_gen/data/presets/UK.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
return {
1+
local b = require 'map_gen.shared.builders'
2+
return b.decompress({
23
height = 1000,
34
width = 802,
45
data = {
@@ -1003,4 +1004,4 @@ data = {
10031004
{5,802,},
10041005
{5,802,},
10051006
}
1006-
}
1007+
})
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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

map_gen/maps/crash_site_UK.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
return require 'map_gen.maps.crash_site.presets.UK'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
return require 'map_gen.maps.crash_site_UK'

0 commit comments

Comments
 (0)