1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00

removed void from collapse #229

This commit is contained in:
Maik Wild 2018-10-15 13:53:22 +02:00
parent 646e629c69
commit 164e807e9c

View File

@ -79,60 +79,32 @@ DiggyCaveCollapse.events = {
local function create_collapse_template(positions, surface) local function create_collapse_template(positions, surface)
local entities = {} local entities = {}
local tiles = {}
local map = {}
for _, position in pairs(positions) do
local x = position.x
local y = position.y
map[x] = map[x] or {}
map[x][y] = map[x][y] or true
insert(tiles, {position = {x = x, y = y}, name = 'out-of-map'})
end
for x, y_tbl in pairs(map) do
for y, _ in pairs(y_tbl) do
if not map[x] or not map[x][y - 1] then
insert(entities, {position = {x = x, y = y - 1}, name = 'sand-rock-big'})
end
if not map[x] or not map[x][y + 1] then
insert(entities, {position = {x = x, y = y + 1}, name = 'sand-rock-big'})
end
if not map[x - 1] or not map[x - 1][y] then
insert(entities, {position = {x = x - 1, y = y}, name = 'sand-rock-big'})
end
if not map[x + 1] or not map[x + 1][y] then
insert(entities, {position = {x = x + 1, y = y}, name = 'sand-rock-big'})
end
end
end
local find_entities_filtered = surface.find_entities_filtered local find_entities_filtered = surface.find_entities_filtered
for _, new_spawn in pairs({entities, tiles}) do for _, position in pairs(positions) do
for _, tile in pairs(new_spawn) do local x = position.x
for _, entity in pairs(find_entities_filtered({position = tile.position})) do local y = position.y
pcall(function() insert(entities, {position = {x = x, y = y}, name = 'sand-rock-big'})
local strength = support_beam_entities[entity.name]
local position = entity.position
entity.die() for _, entity in pairs(find_entities_filtered({position = position})) do
if strength then pcall(function()
stress_map_blur_add(surface, position, strength) local strength = support_beam_entities[entity.name]
end local position = entity.position
end) entity.die()
end if strength then
stress_map_blur_add(surface, position, strength)
end
end)
end end
end end
return entities
return tiles, entities
end end
local function collapse(args) local function collapse(args)
local position = args.position local position = args.position
local surface = args.surface local surface = args.surface
local positions = {} local positions = {}
local tiles = {}
local entities
local strength = config.collapse_threshold_total_strength local strength = config.collapse_threshold_total_strength
mask_disc_blur( mask_disc_blur(
position.x, position.y, position.x, position.y,
@ -148,8 +120,8 @@ local function collapse(args)
) )
end end
) )
tiles, entities = create_collapse_template(positions, surface) local entities = create_collapse_template(positions, surface)
Template.insert(surface, tiles, entities) Template.insert(surface, {}, entities)
end end
local on_collapse_timeout_finished = Token.register(collapse) local on_collapse_timeout_finished = Token.register(collapse)