2018-05-08 22:23:07 +02:00
|
|
|
local b = require "map_gen.shared.builders"
|
|
|
|
|
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
|
|
|
|
|
2018-05-08 22:23:07 +02:00
|
|
|
local small_dot = b.circle(96)
|
|
|
|
local mediumn_dot = b.circle(128)
|
|
|
|
local big_dot = b.circle(160)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
2018-05-08 22:23:07 +02:00
|
|
|
local arms = b.path(48)
|
|
|
|
arms = b.change_tile(arms, true, "water")
|
2017-10-23 12:27:36 +02:00
|
|
|
|
2018-05-08 22:23:07 +02:00
|
|
|
local arms2 = b.rotate(arms, degrees(45))
|
2017-10-23 12:27:36 +02:00
|
|
|
|
2018-05-08 22:23:07 +02:00
|
|
|
local shape = b.any{b.translate(arms2, 480, 0), b.translate(arms2, -480, 0), mediumn_dot, arms}
|
|
|
|
shape = b.apply_effect(shape, no_resources)
|
|
|
|
--shape = b.apply_effect(shape, less_resources)
|
|
|
|
shape = b.apply_effect(shape, no_enemies)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
|
|
|
|
2018-05-08 22:23:07 +02:00
|
|
|
local shape2 = b.all{big_dot, b.invert(small_dot)}
|
|
|
|
shape2 = b.choose(big_dot, shape2, b.any{arms, b.rotate(arms, degrees(45))})
|
|
|
|
--shape2 = b.apply_effect(shape2, less_resources)
|
|
|
|
local start = b.apply_effect(mediumn_dot, no_resources)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
2018-05-08 22:23:07 +02:00
|
|
|
local iron = b.circle(16)
|
|
|
|
iron = b.translate(iron, 0, -96)
|
|
|
|
--iron = b.rotate(iron, degrees(0))
|
|
|
|
iron = b.resource(iron, "iron-ore", function(x, y) return 700 end)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
2018-05-08 22:23:07 +02:00
|
|
|
local copper = b.circle(12)
|
|
|
|
copper = b.translate(copper, 0, -96)
|
|
|
|
copper = b.rotate(copper, degrees(72))
|
|
|
|
copper = b.resource(copper, "copper-ore", function(x, y) return 600 end)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
2018-05-08 22:23:07 +02:00
|
|
|
local stone = b.circle(8)
|
|
|
|
stone = b.translate(stone, 0, -96)
|
|
|
|
stone = b.rotate(stone, degrees(144))
|
|
|
|
stone = b.resource(stone, "stone", function(x, y) return 1500 end)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
2018-05-08 22:23:07 +02:00
|
|
|
local coal = b.circle(10)
|
|
|
|
coal = b.translate(coal, 0, -96)
|
|
|
|
coal = b.rotate(coal, degrees(216))
|
|
|
|
coal = b.resource(coal, "coal", function(x, y) return 850 end)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
2018-05-08 22:23:07 +02:00
|
|
|
local oil = b.circle(5)
|
|
|
|
oil = b.throttle_xy(oil, 1, 3, 1, 3)
|
|
|
|
oil = b.translate(oil, 0, -96)
|
|
|
|
oil = b.rotate(oil, degrees(288))
|
|
|
|
oil = b.resource(oil, "crude-oil", function(x, y) return 60000 end)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
2018-05-08 22:23:07 +02:00
|
|
|
start = b.apply_entity(mediumn_dot, b.any{iron, copper, stone, coal, oil})
|
2018-01-24 21:52:40 +02:00
|
|
|
|
2018-05-08 22:23:07 +02:00
|
|
|
start = b.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-05-08 22:23:07 +02:00
|
|
|
local map = b.grid_pattern(pattern, 2, 2, 480, 480)
|
|
|
|
map = b.choose(mediumn_dot, start, map)
|
2017-10-23 12:27:36 +02:00
|
|
|
|
2018-05-08 22:23:07 +02:00
|
|
|
map = b.change_map_gen_collision_tile(map, "water-tile", "grass-1")
|
2017-10-23 12:27:36 +02:00
|
|
|
|
|
|
|
return map
|