2018-06-04 17:35:18 +02:00
local Event = require ' utils.event '
2018-11-06 14:08:33 +02:00
local degrees = require " utils.math " . degrees
2018-06-04 17:35:18 +02:00
local b = require ' map_gen.shared.builders '
2017-08-25 07:27:50 +02:00
2018-05-08 22:23:07 +02:00
local inner_circle = b.invert ( b.circle ( 48 ) )
local outer_circle = b.circle ( 64 )
local square = b.invert ( b.rectangle ( 1000 , 1000 ) )
square = b.rotate ( square , degrees ( 45 ) )
square = b.translate ( square , math.sqrt ( 2 ) * 500 , 0 )
2017-08-25 07:27:50 +02:00
2018-05-08 22:23:07 +02:00
local circle = b.all ( { inner_circle , outer_circle , square } )
2017-08-25 07:27:50 +02:00
2018-05-08 22:23:07 +02:00
local line1 = b.rectangle ( 77 , 16 )
line1 = b.rotate ( line1 , degrees ( 45 ) )
line1 = b.translate ( line1 , 66.5 , 12.6875 )
2017-08-25 07:27:50 +02:00
2018-05-08 22:23:07 +02:00
local line2 = b.rectangle ( 45 , 16 )
2019-01-16 22:33:32 +02:00
line2 = b.rotate ( line2 , degrees ( - 45 ) )
2018-05-08 22:23:07 +02:00
line2 = b.translate ( line2 , 55.5 , - 23.6875 )
2017-08-25 07:27:50 +02:00
2018-05-08 22:23:07 +02:00
--line2 =b.change_tile(line2, true, "water")
local half = b.any ( { line2 , line1 , circle } )
2017-08-25 07:27:50 +02:00
2018-05-08 22:23:07 +02:00
half = b.translate ( half , - 79.1875 , 0 )
local map = b.any ( { half , b.flip_xy ( half ) } )
map = b.scale ( map , 11 , 11 )
2017-08-25 07:27:50 +02:00
2017-08-25 16:35:53 +02:00
local function research_finished ( event )
local tech = event.research . name
2018-06-04 17:35:18 +02:00
if tech == ' rocket-silo ' then
game.forces [ ' player ' ] . recipes [ ' rocket-silo ' ] . enabled = false
2017-08-25 16:35:53 +02:00
end
end
2018-04-06 21:58:50 +02:00
Event.add ( defines.events . on_research_finished , research_finished )
2017-08-25 16:35:53 +02:00
local init = false
2019-01-16 22:33:32 +02:00
local function effect ( _ , _ , world , tile )
2017-08-25 16:35:53 +02:00
if not init then
init = true
2018-06-04 17:35:18 +02:00
game.forces [ ' player ' ] . chart ( world.surface , { { - 32 , - 32 } , { 31 , 31 } } )
2017-08-25 16:35:53 +02:00
end
2018-06-04 12:36:21 +02:00
2018-05-08 18:47:34 +02:00
if world.x == 0 and world.y == 0 then
for _ , e in ipairs ( world.surface . find_entities ( { { - 5 , - 5 } , { 5 , 5 } } ) ) do
2017-08-25 16:35:53 +02:00
e.destroy ( )
2018-02-23 14:18:32 +02:00
end
2018-06-04 12:36:21 +02:00
2018-06-04 17:35:18 +02:00
local e = world.surface . create_entity ( { name = ' rocket-silo ' , position = { 0 , 0 } , force = ' player ' } )
2017-08-25 16:35:53 +02:00
e.destructible = false
e.minable = false
end
2018-06-04 12:36:21 +02:00
2018-02-23 14:18:32 +02:00
--[[
2018-10-02 21:58:22 +02:00
2018-02-23 14:18:32 +02:00
if max_axis_distance ( world_x , world_y , - 2144 , 0 ) < safe_distance then
for _ , e in ipairs ( surface.find_entities_filtered ( { force = " enemy " , position = { world_x , world_y } } ) ) do
e.destroy ( )
end
2017-08-25 16:35:53 +02:00
elseif max_axis_distance ( world_x , world_y , 2144 , 0 ) < safe_distance then
2018-02-23 14:18:32 +02:00
for _ , e in ipairs ( surface.find_entities_filtered ( { force = " enemy " , position = { world_x , world_y } } ) ) do
e.destroy ( )
2017-08-25 16:35:53 +02:00
end
2018-02-23 14:18:32 +02:00
end
2018-10-02 21:58:22 +02:00
2017-08-25 16:35:53 +02:00
for _ , e in ipairs ( surface.find_entities_filtered ( { type = " resource " , area = { { world_x , world_y } , { world_x + 1 , world_y + 1 } } } ) ) do -- I want to use position but for some reason it doesn't seem to work for ores.
2018-02-23 14:18:32 +02:00
local dist1 = distance ( world_x , world_y , - 2144 , 0 )
local dist2 = distance ( world_x , world_y , 2144 , 0 )
local amount = math.min ( dist1 , dist2 )
2018-10-02 21:58:22 +02:00
2018-02-23 14:18:32 +02:00
local name = e.name
if name == " iron-ore " then
amount = 800 + 0.4 * amount
elseif name == " copper-ore " then
amount = 700 + 0.35 * amount
elseif name == " coal " then
amount = 600 + 0.3 * amount
elseif name == " stone " then
amount = 400 + 0.2 * amount
elseif name == " uranium-ore " then
amount = 300 + 0.15 * amount
elseif name == " crude-oil " then
amount = 50000 + 50 * amount
2017-08-25 16:35:53 +02:00
end
2018-10-02 21:58:22 +02:00
2018-02-23 14:18:32 +02:00
e.amount = amount
end
2018-10-02 21:58:22 +02:00
2018-02-23 14:18:32 +02:00
--]]
2018-05-07 13:18:18 +02:00
return tile
2017-08-25 16:35:53 +02:00
end
2018-05-08 22:23:07 +02:00
map = b.apply_effect ( map , effect )
2017-08-25 16:35:53 +02:00
2018-11-26 14:10:37 +02:00
local Spawn_Control = require ' map_gen.misc.spawn_control '
2018-11-20 12:46:19 +02:00
Spawn_Control.add_spawn ( ' left ' , - 88 , - 88 )
Spawn_Control.add_spawn ( ' right ' , 88 , 88 )
2017-08-25 16:35:53 +02:00
2017-08-25 07:27:50 +02:00
return map