mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-15 13:53:09 +02:00
removal of unused surfaces
This commit is contained in:
parent
0a84241b30
commit
62028af0f8
@ -9,6 +9,17 @@ local function request_reconstruction(icw)
|
|||||||
icw.rebuild_tick = game.tick + 15
|
icw.rebuild_tick = game.tick + 15
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function delete_empty_surfaces(icw)
|
||||||
|
for unit_number, wagon in pairs(icw.wagons) do
|
||||||
|
if not icw.trains[unit_number] then
|
||||||
|
local surface = game.surfaces[tostring(unit_number)]
|
||||||
|
if surface then
|
||||||
|
game.delete_surface(surface)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function get_wagon_for_entity(icw, entity)
|
local function get_wagon_for_entity(icw, entity)
|
||||||
local train = icw.trains[tonumber(entity.surface.name)]
|
local train = icw.trains[tonumber(entity.surface.name)]
|
||||||
if not train then return end
|
if not train then return end
|
||||||
@ -67,8 +78,8 @@ end
|
|||||||
function Public.create_room_surface(unit_number)
|
function Public.create_room_surface(unit_number)
|
||||||
if game.surfaces[tostring(unit_number)] then return game.surfaces[tostring(unit_number)] end
|
if game.surfaces[tostring(unit_number)] then return game.surfaces[tostring(unit_number)] end
|
||||||
local map_gen_settings = {
|
local map_gen_settings = {
|
||||||
["width"] = 1,
|
["width"] = 2,
|
||||||
["height"] = 1,
|
["height"] = 2,
|
||||||
["water"] = 0,
|
["water"] = 0,
|
||||||
["starting_area"] = 1,
|
["starting_area"] = 1,
|
||||||
["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
|
["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
|
||||||
@ -80,23 +91,24 @@ function Public.create_room_surface(unit_number)
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
local surface = game.create_surface(unit_number, map_gen_settings)
|
local surface = game.create_surface(unit_number, map_gen_settings)
|
||||||
|
surface.freeze_daytime = true
|
||||||
|
surface.daytime = 0.1
|
||||||
|
surface.request_to_generate_chunks({16, 16}, 1)
|
||||||
|
surface.force_generate_chunk_requests()
|
||||||
|
for _, tile in pairs(surface.find_tiles_filtered({area = {{-2, -2}, {2, 2}}})) do
|
||||||
|
surface.set_tiles({{name = "out-of-map", position = tile.position}}, true)
|
||||||
|
end
|
||||||
return surface
|
return surface
|
||||||
end
|
end
|
||||||
|
|
||||||
function Public.create_wagon_room(icw, wagon)
|
function Public.create_wagon_room(icw, wagon)
|
||||||
local surface = wagon.surface
|
local surface = wagon.surface
|
||||||
surface.freeze_daytime = true
|
|
||||||
surface.daytime = 0.1
|
|
||||||
surface.request_to_generate_chunks({16, 16}, 0)
|
|
||||||
surface.force_generate_chunk_requests()
|
|
||||||
|
|
||||||
local area = wagon.area
|
local area = wagon.area
|
||||||
for x = area.left_top.x, area.right_bottom.x - 1, 1 do
|
for x = area.left_top.x, area.right_bottom.x - 1, 1 do
|
||||||
for y = area.left_top.y, area.right_bottom.y - 1, 1 do
|
for y = area.left_top.y, area.right_bottom.y - 1, 1 do
|
||||||
surface.set_tiles({{name = "tutorial-grid", position = {x,y}}})
|
surface.set_tiles({{name = "tutorial-grid", position = {x,y}}})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
construct_wagon_doors(icw, wagon)
|
construct_wagon_doors(icw, wagon)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -233,6 +245,7 @@ function Public.reconstruct_all_trains(icw)
|
|||||||
local carriages = wagon.entity.train.carriages
|
local carriages = wagon.entity.train.carriages
|
||||||
Public.construct_train(icw, carriages)
|
Public.construct_train(icw, carriages)
|
||||||
end
|
end
|
||||||
|
delete_empty_surfaces(icw)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Public
|
return Public
|
Loading…
x
Reference in New Issue
Block a user