2018-01-21 17:31:20 +02:00
|
|
|
map_gen_decoratives = false -- Generate our own decoratives
|
|
|
|
map_gen_rows_per_tick = 8 -- Inclusive integer between 1 and 32. Used for map_gen_threaded, higher numbers will generate map quicker but cause more lag.
|
|
|
|
|
|
|
|
-- Recommend to use generate, but generate_not_threaded may be useful for testing / debugging.
|
|
|
|
--require "map_gen.shared.generate_not_threaded"
|
2018-01-19 23:33:54 +02:00
|
|
|
require "map_gen.shared.generate"
|
2017-10-23 12:27:36 +02:00
|
|
|
|
2018-05-08 18:47:34 +02:00
|
|
|
local function no_resources(x, y, world, tile)
|
|
|
|
for _, e in ipairs(world.surface.find_entities_filtered({type = "resource", area = {{world.x, world.y}, {world.x + 1, world.y + 1}}})) do
|
2017-10-23 12:27:36 +02:00
|
|
|
e.destroy()
|
|
|
|
end
|
2018-02-23 14:18:32 +02:00
|
|
|
|
2018-05-07 13:18:18 +02:00
|
|
|
return tile
|
2017-10-23 12:27:36 +02:00
|
|
|
end
|
|
|
|
|
2018-05-08 18:47:34 +02:00
|
|
|
local function less_resources(x, y, world, tile)
|
|
|
|
for _, e in ipairs(world.surface.find_entities_filtered({type = "resource", area = {{world.x, world.y}, {world.x + 1, world.y + 1}}})) do
|
2017-10-23 12:27:36 +02:00
|
|
|
if e.name == "crude-oil" then
|
2018-02-23 14:18:32 +02:00
|
|
|
-- e.amount = .995 * e.amount
|
|
|
|
else
|
2017-10-23 12:27:36 +02:00
|
|
|
e.amount = 0.33 * e.amount
|
|
|
|
end
|
|
|
|
end
|
2018-02-23 14:18:32 +02:00
|
|
|
|
2018-05-07 13:18:18 +02:00
|
|
|
return tile
|
2017-10-23 12:27:36 +02:00
|
|
|
end
|
|
|
|
|
2018-05-08 18:47:34 +02:00
|
|
|
local function no_enemies(x, y, world, tile)
|
|
|
|
for _, e in ipairs(world.surface.find_entities_filtered({force = "enemy", position = {world.x, world.y}})) do
|
2017-10-23 12:27:36 +02:00
|
|
|
e.destroy()
|
|
|
|
end
|
2018-02-23 14:18:32 +02:00
|
|
|
|
2018-05-07 13:18:18 +02:00
|
|
|
return tile
|
2017-10-23 12:27:36 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local small_dot = circle_builder(96)
|
|
|
|
local mediumn_dot = circle_builder(128)
|
|
|
|
local big_dot = circle_builder(160)
|
|
|
|
|
|
|
|
local arms = path_builder(48)
|
|
|
|
arms = change_tile(arms, true, "water")
|
|
|
|
|
|
|
|
local arms2 = rotate(arms, degrees(45))
|
|
|
|
|
2018-02-23 14:18:32 +02:00
|
|
|
local shape = compound_or{translate(arms2, 480, 0), translate(arms2, -480, 0), mediumn_dot, arms}
|
2018-01-24 21:52:40 +02:00
|
|
|
shape = apply_effect(shape, no_resources)
|
|
|
|
--shape = apply_effect(shape, less_resources)
|
|
|
|
shape = apply_effect(shape, no_enemies)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
|
|
|
|
2018-02-23 14:18:32 +02:00
|
|
|
local shape2 = compound_and{big_dot, invert(small_dot)}
|
2017-10-23 12:27:36 +02:00
|
|
|
shape2 = choose(big_dot, shape2, compound_or{arms, rotate(arms, degrees(45))})
|
|
|
|
--shape2 = apply_effect(shape2, less_resources)
|
|
|
|
local start = apply_effect(mediumn_dot, no_resources)
|
|
|
|
|
|
|
|
local iron = circle_builder(16)
|
2018-02-23 14:18:32 +02:00
|
|
|
iron = translate(iron, 0, -96)
|
2017-10-23 12:27:36 +02:00
|
|
|
--iron = rotate(iron, degrees(0))
|
2018-02-23 14:18:32 +02:00
|
|
|
iron = resource_module_builder(iron, "iron-ore", function(x, y) return 700 end)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
|
|
|
local copper = circle_builder(12)
|
2018-02-23 14:18:32 +02:00
|
|
|
copper = translate(copper, 0, -96)
|
2017-10-23 12:27:36 +02:00
|
|
|
copper = rotate(copper, degrees(72))
|
2018-02-23 14:18:32 +02:00
|
|
|
copper = resource_module_builder(copper, "copper-ore", function(x, y) return 600 end)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
|
|
|
local stone = circle_builder(8)
|
2018-02-23 14:18:32 +02:00
|
|
|
stone = translate(stone, 0, -96)
|
2017-10-23 12:27:36 +02:00
|
|
|
stone = rotate(stone, degrees(144))
|
2018-02-23 14:18:32 +02:00
|
|
|
stone = resource_module_builder(stone, "stone", function(x, y) return 1500 end)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
|
|
|
local coal = circle_builder(10)
|
2018-02-23 14:18:32 +02:00
|
|
|
coal = translate(coal, 0, -96)
|
2017-10-23 12:27:36 +02:00
|
|
|
coal = rotate(coal, degrees(216))
|
2018-02-23 14:18:32 +02:00
|
|
|
coal = resource_module_builder(coal, "coal", function(x, y) return 850 end)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
|
|
|
local oil = circle_builder(5)
|
|
|
|
oil = throttle_xy(oil, 1, 3, 1, 3)
|
2018-02-23 14:18:32 +02:00
|
|
|
oil = translate(oil, 0, -96)
|
2017-10-23 12:27:36 +02:00
|
|
|
oil = rotate(oil, degrees(288))
|
2018-02-23 14:18:32 +02:00
|
|
|
oil = resource_module_builder(oil, "crude-oil", function(x, y) return 60000 end)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
2018-01-24 21:52:40 +02:00
|
|
|
start = builder_with_resource(mediumn_dot, compound_or{iron, copper, stone, coal, oil})
|
|
|
|
|
|
|
|
start = apply_effect(start, no_resources)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
|
|
|
local pattern =
|
2018-02-23 14:18:32 +02:00
|
|
|
{
|
|
|
|
{shape, shape2},
|
|
|
|
{shape2, shape}
|
|
|
|
}
|
2017-10-23 12:27:36 +02:00
|
|
|
|
2018-02-23 14:18:32 +02:00
|
|
|
local map = grid_pattern_builder(pattern, 2, 2, 480, 480)
|
2017-10-23 12:27:36 +02:00
|
|
|
map = choose(mediumn_dot, start, map)
|
|
|
|
|
2018-02-23 14:18:32 +02:00
|
|
|
map = change_map_gen_collision_tile(map, "water-tile", "grass-1")
|
2017-10-23 12:27:36 +02:00
|
|
|
|
|
|
|
return map
|