1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00

made tiles not support neighbors (except void) #229

This commit is contained in:
Maik Wild 2018-10-15 14:48:48 +02:00
parent 639a7a1a8a
commit 178920f394
2 changed files with 22 additions and 16 deletions

View File

@ -37,7 +37,7 @@ local disc_value = 0
local ring_value = 0 local ring_value = 0
local enable_stress_grid = 0 local enable_stress_grid = 0
local stress_map_blur_add local stress_map_add
local mask_disc_blur local mask_disc_blur
local stress_map_check_stress_in_threshold local stress_map_check_stress_in_threshold
local support_beam_entities local support_beam_entities
@ -93,7 +93,7 @@ local function create_collapse_template(positions, surface)
local position = entity.position local position = entity.position
entity.die() entity.die()
if strength then if strength then
stress_map_blur_add(surface, position, strength) stress_map_add(surface, position, strength)
end end
end) end)
end end
@ -172,14 +172,15 @@ end
local function on_built_tile(surface, new_tile, tiles) local function on_built_tile(surface, new_tile, tiles)
local new_tile_strength = support_beam_entities[new_tile.name] local new_tile_strength = support_beam_entities[new_tile.name]
for _, tile in pairs(tiles) do for _, tile in pairs(tiles) do
if new_tile_strength then if new_tile_strength then
stress_map_blur_add(surface, tile.position, -1 * new_tile_strength) stress_map_add(surface, tile.position, -1 * new_tile_strength, true)
end end
local old_tile_strength = support_beam_entities[tile.old_tile.name] local old_tile_strength = support_beam_entities[tile.old_tile.name]
if (old_tile_strength) then if (old_tile_strength) then
stress_map_blur_add(surface, tile.position, old_tile_strength) stress_map_add(surface, tile.position, old_tile_strength, true)
end end
end end
end end
@ -190,7 +191,7 @@ local function on_robot_mined_tile(event)
local strength = support_beam_entities[tile.old_tile.name] local strength = support_beam_entities[tile.old_tile.name]
if strength then if strength then
surface = surface or event.robot.surface surface = surface or event.robot.surface
stress_map_blur_add(surface, tile.position, strength) stress_map_add(surface, tile.position, strength, true)
end end
end end
end end
@ -201,7 +202,7 @@ local function on_player_mined_tile(event)
local strength = support_beam_entities[tile.old_tile.name] local strength = support_beam_entities[tile.old_tile.name]
if strength then if strength then
stress_map_blur_add(surface, tile.position, strength) stress_map_add(surface, tile.position, strength, true)
end end
end end
end end
@ -211,7 +212,7 @@ local function on_mined_entity(event)
local strength = support_beam_entities[entity.name] local strength = support_beam_entities[entity.name]
if strength then if strength then
stress_map_blur_add(entity.surface, entity.position, strength) stress_map_add(entity.surface, entity.position, strength)
end end
end end
@ -220,7 +221,7 @@ local function on_built_entity(event)
local strength = support_beam_entities[entity.name] local strength = support_beam_entities[entity.name]
if strength then if strength then
stress_map_blur_add(entity.surface, entity.position, -1 * strength) stress_map_add(entity.surface, entity.position, -1 * strength)
end end
end end
@ -228,7 +229,7 @@ local function on_placed_entity(event)
local strength = support_beam_entities[event.entity.name] local strength = support_beam_entities[event.entity.name]
if strength then if strength then
stress_map_blur_add(event.entity.surface, event.entity.position, -1 * strength) stress_map_add(event.entity.surface, event.entity.position, -1 * strength)
end end
end end
@ -245,7 +246,7 @@ local function on_void_removed(event)
local position = event.old_tile.position local position = event.old_tile.position
if strength then if strength then
stress_map_blur_add(event.surface, position, strength) stress_map_add(event.surface, position, strength)
end end
local x = position.x local x = position.x
@ -267,7 +268,7 @@ end
local function on_void_added(event) local function on_void_added(event)
local strength = support_beam_entities['out-of-map'] local strength = support_beam_entities['out-of-map']
if strength then if strength then
stress_map_blur_add(event.surface, event.old_tile.position, -1 * strength) stress_map_add(event.surface, event.old_tile.position, -1 * strength)
end end
end end
@ -357,7 +358,7 @@ to reinforce it further.
local strength = support_beam_entities[tilename] local strength = support_beam_entities[tilename]
if strength then if strength then
stress_map_blur_add(surface, {x=x,y=y}, - strength) stress_map_add(surface, {x =x, y=y}, - strength)
end end
for _, entity in pairs(surface.find_entities_filtered({position = {x=x,y=y}})) do for _, entity in pairs(surface.find_entities_filtered({position = {x=x,y=y}})) do
pcall(function() pcall(function()
@ -365,7 +366,7 @@ to reinforce it further.
local position = entity.position local position = entity.position
entity.die() entity.die()
if strength then if strength then
stress_map_blur_add(surface, position, strength) stress_map_add(surface, position, strength)
end end
end end
) )
@ -529,7 +530,7 @@ stress_map_check_stress_in_threshold = function(surface, position, threshold, ca
end end
end end
stress_map_blur_add = function(surface, position, factor) stress_map_add = function(surface, position, factor, no_blur)
local x_start = floor(position.x) local x_start = floor(position.x)
local y_start = floor(position.y) local y_start = floor(position.y)
@ -538,6 +539,11 @@ stress_map_blur_add = function(surface, position, factor)
return return
end end
if no_blur then
add_fraction(stress_map, x_start, y_start, factor)
return
end
if radius > abs(x_start) or radius > abs(y_start) then if radius > abs(x_start) or radius > abs(y_start) then
for x = -radius, radius do for x = -radius, radius do
for y = -radius, radius do for y = -radius, radius do
@ -585,7 +591,7 @@ stress_map_blur_add = function(surface, position, factor)
end end
end end
DiggyCaveCollapse.stress_map_blur_add = stress_map_blur_add DiggyCaveCollapse.stress_map_add = stress_map_add
-- --
-- MASK -- MASK

View File

@ -56,7 +56,7 @@ function StartingZone.register(config)
-- hack to avoid starting area from collapsing -- hack to avoid starting area from collapsing
if (distance > floor(starting_zone_size / 10)) then if (distance > floor(starting_zone_size / 10)) then
DiggyCaveCollapse.stress_map_blur_add(surface, {x = x, y = y}, -0.3) DiggyCaveCollapse.stress_map_add(surface, {x = x, y = y}, -0.3)
end end
end end
end end