mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-30 04:30:58 +02:00
Merge pull request #1034 from grilledham/crashsite_world
crashsite world map
This commit is contained in:
commit
1e708bf27f
72
map_gen/maps/crash_site/presets/world.lua
Normal file
72
map_gen/maps/crash_site/presets/world.lua
Normal file
@ -0,0 +1,72 @@
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local MGSP = require 'resources.map_gen_settings'
|
||||
|
||||
local type = type
|
||||
local water_tiles = b.water_tiles
|
||||
local path_tiles = b.path_tiles
|
||||
|
||||
local pic = require 'map_gen.data.presets.world-map'
|
||||
local world_map = b.picture(pic)
|
||||
|
||||
local x_offset, y_offset = -369, 46
|
||||
world_map = b.translate(world_map, x_offset, y_offset)
|
||||
|
||||
local scale = 0.75
|
||||
local height = 2653 * scale
|
||||
local width = 3820 * scale
|
||||
|
||||
world_map = b.scale(world_map, scale)
|
||||
|
||||
local bounds = b.rectangle(width, height)
|
||||
bounds = b.translate(bounds, x_offset * scale, y_offset * scale)
|
||||
|
||||
local config = {
|
||||
scenario_name = 'crashsite-world',
|
||||
map_gen_settings = {
|
||||
MGSP.starting_area_very_low,
|
||||
MGSP.ore_oil_none,
|
||||
MGSP.enemy_none,
|
||||
MGSP.cliff_none
|
||||
},
|
||||
grid_number_of_blocks = 15,
|
||||
mini_grid_number_of_blocks = 29,
|
||||
bounds_shape = bounds
|
||||
}
|
||||
|
||||
local Scenario = require 'map_gen.maps.crash_site.scenario'
|
||||
local crashsite = Scenario.init(config)
|
||||
|
||||
local function get_tile_name(tile)
|
||||
if type(tile) == 'table' then
|
||||
return tile.tile
|
||||
else
|
||||
return tile
|
||||
end
|
||||
end
|
||||
|
||||
local function map(x, y, world)
|
||||
local tile = world_map(x, y, world)
|
||||
if not tile then
|
||||
return tile
|
||||
end
|
||||
|
||||
local world_tile_name = get_tile_name(tile)
|
||||
if not world_tile_name or water_tiles[world_tile_name] then
|
||||
return tile
|
||||
end
|
||||
|
||||
local crashsite_tile = crashsite(x, y, world)
|
||||
local crashsite_tile_name = get_tile_name(crashsite_tile)
|
||||
if path_tiles[crashsite_tile_name] then
|
||||
return crashsite_tile
|
||||
end
|
||||
|
||||
if type(crashsite_tile) == 'table' then
|
||||
crashsite_tile.tile = world_tile_name
|
||||
return crashsite_tile
|
||||
end
|
||||
|
||||
return tile
|
||||
end
|
||||
|
||||
return map
|
@ -31,7 +31,10 @@ local default_map_gen_settings = {
|
||||
MGSP.cliff_none
|
||||
}
|
||||
|
||||
local configuration
|
||||
|
||||
local function control(config)
|
||||
configuration = config
|
||||
local CSCommand = require 'map_gen.maps.crash_site.commands'
|
||||
CSCommand.control(config)
|
||||
|
||||
@ -137,14 +140,14 @@ local spawn_callback =
|
||||
)
|
||||
|
||||
local function cutscene_builder(name, x, y)
|
||||
return game.surfaces.cutscene.create_entity{name = name, position = {x, y}, force = game.forces.enemy}
|
||||
return game.surfaces.cutscene.create_entity {name = name, position = {x, y}, force = game.forces.enemy}
|
||||
end
|
||||
|
||||
local function cutscene_outpost()
|
||||
local tiles = {}
|
||||
for i = -11, 12 do
|
||||
for j = -11, 12 do
|
||||
table.insert(tiles, {name = "stone-path", position = {i, j}})
|
||||
table.insert(tiles, {name = 'stone-path', position = {i, j}})
|
||||
end
|
||||
end
|
||||
for i = 0, 22 do
|
||||
@ -166,7 +169,7 @@ local function cutscene_outpost()
|
||||
for i = -2, 2 do
|
||||
for j = 3, 5 do
|
||||
local loot_box = cutscene_builder('steel-chest', i, j)
|
||||
loot_box.insert{name = "iron-plate", count = 50}
|
||||
loot_box.insert {name = 'iron-plate', count = 50}
|
||||
end
|
||||
end
|
||||
cutscene_builder('market', -4, 0)
|
||||
@ -175,7 +178,7 @@ local function cutscene_outpost()
|
||||
game.surfaces.cutscene.set_tiles(tiles)
|
||||
end
|
||||
|
||||
local function init()
|
||||
local function init(config)
|
||||
local on_init = (_LIFECYCLE == _STAGE.init)
|
||||
|
||||
local outpost_random = Random.new(outpost_seed, outpost_seed * 2)
|
||||
@ -184,8 +187,8 @@ local function init()
|
||||
|
||||
if on_init then
|
||||
game.create_surface('cutscene', default_map_gen_settings)
|
||||
game.surfaces.cutscene.always_day = true
|
||||
game.surfaces.cutscene.request_to_generate_chunks({0,0}, 2)
|
||||
game.surfaces.cutscene.always_day = true
|
||||
game.surfaces.cutscene.request_to_generate_chunks({0, 0}, 2)
|
||||
game.surfaces.cutscene.force_generate_chunk_requests()
|
||||
cutscene_outpost()
|
||||
Cutscene.on_init()
|
||||
@ -193,6 +196,16 @@ local function init()
|
||||
Cutscene.on_load()
|
||||
end
|
||||
|
||||
local outpost_offset = 59
|
||||
local grid_block_size = 180
|
||||
local grid_number_of_blocks = config.grid_number_of_blocks or 9
|
||||
local middle = math.ceil(grid_number_of_blocks / 2)
|
||||
|
||||
local mini_outpost_offset = 36
|
||||
local mini_grid_block_size = 96
|
||||
local mini_grid_number_of_blocks = config.mini_grid_number_of_blocks or 21
|
||||
local mini_middle = math.ceil(mini_grid_number_of_blocks / 2)
|
||||
|
||||
local stage1a = {
|
||||
small_iron_plate_factory,
|
||||
small_gear_factory,
|
||||
@ -201,10 +214,10 @@ local function init()
|
||||
}
|
||||
|
||||
local stage1a_pos = {
|
||||
{4, 5},
|
||||
{5, 4},
|
||||
{5, 6},
|
||||
{6, 5}
|
||||
{middle - 1, middle},
|
||||
{middle, middle - 1},
|
||||
{middle, middle + 1},
|
||||
{middle + 1, middle}
|
||||
}
|
||||
|
||||
local stage1b = {
|
||||
@ -216,14 +229,14 @@ local function init()
|
||||
}
|
||||
|
||||
local stage1b_pos = {
|
||||
{4, 4},
|
||||
{4, 6},
|
||||
{6, 4},
|
||||
{6, 6},
|
||||
{3, 5},
|
||||
{5, 3},
|
||||
{5, 7},
|
||||
{7, 5}
|
||||
{middle - 1, middle - 1},
|
||||
{middle - 1, middle + 1},
|
||||
{middle + 1, middle - 1},
|
||||
{middle + 1, middle + 1},
|
||||
{middle - 2, middle},
|
||||
{middle, middle - 2},
|
||||
{middle, middle + 2},
|
||||
{middle + 2, middle}
|
||||
}
|
||||
|
||||
local stage2 = {
|
||||
@ -243,22 +256,22 @@ local function init()
|
||||
}
|
||||
|
||||
local stage2_pos = {
|
||||
{2, 5},
|
||||
{5, 2},
|
||||
{5, 8},
|
||||
{8, 5},
|
||||
{3, 3},
|
||||
{3, 4},
|
||||
{3, 6},
|
||||
{3, 7},
|
||||
{4, 3},
|
||||
{4, 7},
|
||||
{6, 3},
|
||||
{6, 7},
|
||||
{7, 3},
|
||||
{7, 4},
|
||||
{7, 6},
|
||||
{7, 7}
|
||||
{middle - 3, middle},
|
||||
{middle, middle - 3},
|
||||
{middle, middle + 3},
|
||||
{middle + 3, middle},
|
||||
{middle - 2, middle - 2},
|
||||
{middle - 2, middle - 1},
|
||||
{middle - 2, middle + 1},
|
||||
{middle - 2, middle + 2},
|
||||
{middle - 1, middle - 2},
|
||||
{middle - 1, middle + 2},
|
||||
{middle + 1, middle - 2},
|
||||
{middle + 1, middle + 2},
|
||||
{middle + 2, middle - 2},
|
||||
{middle + 2, middle - 1},
|
||||
{middle + 2, middle + 1},
|
||||
{middle + 2, middle + 2}
|
||||
}
|
||||
|
||||
local stage3 = {
|
||||
@ -432,14 +445,6 @@ local function init()
|
||||
start_outpost
|
||||
}
|
||||
|
||||
local outpost_offset = 59
|
||||
local grid_block_size = 180
|
||||
local grid_number_of_blocks = 9
|
||||
|
||||
local mini_outpost_offset = 36
|
||||
local mini_grid_block_size = 96
|
||||
local mini_grid_number_of_blocks = 21
|
||||
|
||||
local pattern = {}
|
||||
|
||||
for r = 1, grid_number_of_blocks do
|
||||
@ -447,9 +452,9 @@ local function init()
|
||||
pattern[r] = row
|
||||
end
|
||||
|
||||
pattern[5][5] = start_outpost
|
||||
pattern[middle][middle] = start_outpost
|
||||
|
||||
local half_total_size = grid_block_size * 0.5 * 8
|
||||
local half_total_size = grid_block_size * 0.5 * (grid_number_of_blocks - 1)
|
||||
|
||||
for _, pos in ipairs(stage1a_pos) do
|
||||
local r, c = pos[1], pos[2]
|
||||
@ -496,9 +501,9 @@ local function init()
|
||||
row[c] = shape
|
||||
end
|
||||
|
||||
for r = 2, 8 do
|
||||
for r = middle - 3, middle + 3 do
|
||||
local row = pattern[r]
|
||||
for c = 2, 8 do
|
||||
for c = middle - 3, middle + 3 do
|
||||
if not row[c] then
|
||||
local template = stage3_iter()
|
||||
local shape = outpost_builder:do_outpost(template, on_init)
|
||||
@ -534,16 +539,16 @@ local function init()
|
||||
mini_pattern[r] = {}
|
||||
end
|
||||
|
||||
for r = 11, 11 do
|
||||
for r = mini_middle, mini_middle do
|
||||
local row = mini_pattern[r]
|
||||
for c = 11, 11 do
|
||||
for c = mini_middle, mini_middle do
|
||||
row[c] = b.empty_shape
|
||||
end
|
||||
end
|
||||
|
||||
for r = 8, 14 do
|
||||
for r = mini_middle - 3, mini_middle + 3 do
|
||||
local row = mini_pattern[r]
|
||||
for c = 8, 14 do
|
||||
for c = mini_middle - 3, mini_middle + 3 do
|
||||
if not row[c] then
|
||||
local template = mini1_iter()
|
||||
local shape = outpost_builder:do_outpost(template, on_init)
|
||||
@ -557,9 +562,9 @@ local function init()
|
||||
end
|
||||
end
|
||||
|
||||
for r = 6, 16 do
|
||||
for r = mini_middle - 5, mini_middle + 5 do
|
||||
local row = mini_pattern[r]
|
||||
for c = 6, 16 do
|
||||
for c = mini_middle - 5, mini_middle + 5 do
|
||||
if not row[c] then
|
||||
local template = mini2_iter()
|
||||
local shape = outpost_builder:do_outpost(template, on_init)
|
||||
@ -822,7 +827,7 @@ local function init()
|
||||
|
||||
map = b.choose(b.rectangle(16, 16), spawn_shape, map)
|
||||
|
||||
local bounds = b.rectangle(grid_block_size * (grid_number_of_blocks) + 1)
|
||||
local bounds = config.bounds_shape or b.rectangle(grid_block_size * (grid_number_of_blocks) + 1)
|
||||
map = b.choose(bounds, map, b.empty_shape)
|
||||
|
||||
return map
|
||||
@ -840,7 +845,7 @@ Global.register_init(
|
||||
function(tbl)
|
||||
outpost_seed = tbl.outpost_seed
|
||||
ore_seed = tbl.ore_seed
|
||||
map = init()
|
||||
map = init(configuration)
|
||||
end
|
||||
)
|
||||
|
||||
|
1
map_gen/maps/crash_site_world.lua
Normal file
1
map_gen/maps/crash_site_world.lua
Normal file
@ -0,0 +1 @@
|
||||
return require 'map_gen.maps.crash_site.presets.world'
|
@ -1887,6 +1887,8 @@ local water_tiles = {
|
||||
['deepwater-green'] = true
|
||||
}
|
||||
|
||||
Builders.water_tiles = water_tiles
|
||||
|
||||
--- Docs: https://github.com/Refactorio/RedMew/wiki/Using-the-Builders#buildersfish
|
||||
function Builders.fish(shape, spawn_rate)
|
||||
return function(x, y, world)
|
||||
|
Loading…
x
Reference in New Issue
Block a user