diff --git a/maps/dungeons/functions.lua b/maps/dungeons/functions.lua index e5a3d1ba..dd5e405c 100644 --- a/maps/dungeons/functions.lua +++ b/maps/dungeons/functions.lua @@ -358,6 +358,26 @@ function Public.create_scrap(surface, position) surface.create_entity({name = scraps[math_random(1, #scraps)], position = position, force = 'neutral'}) end +function Public.on_marked_for_deconstruction(event) + local disabled_for_deconstruction = { + ['fish'] = true, + ['rock-huge'] = true, + ['rock-big'] = true, + ['sand-rock-big'] = true, + ['crash-site-spaceship-wreck-small-1'] = true, + ['crash-site-spaceship-wreck-small-2'] = true, + ['crash-site-spaceship-wreck-small-3'] = true, + ['crash-site-spaceship-wreck-small-4'] = true, + ['crash-site-spaceship-wreck-small-5'] = true, + ['crash-site-spaceship-wreck-small-6'] = true + } + if event.entity and event.entity.valid then + if disabled_for_deconstruction[event.entity.name] then + event.entity.cancel_deconstruction(game.players[event.player_index].force.name) + end + end +end + -- old function 0 - 250 floor 0; 250-500 floor 1; 500 floor 2+ -- new function 25 - 75 floor 0; 50-100 floor 1; 75-125 floor 2; ...; 500 floor 19 -- diff --git a/maps/dungeons/main.lua b/maps/dungeons/main.lua index 8b955b41..47375670 100644 --- a/maps/dungeons/main.lua +++ b/maps/dungeons/main.lua @@ -30,19 +30,6 @@ local math_abs = math.abs local math_floor = math.floor local math_round = math.round -local disabled_for_deconstruction = { - ['fish'] = true, - ['rock-huge'] = true, - ['rock-big'] = true, - ['sand-rock-big'] = true, - ['crash-site-spaceship-wreck-small-1'] = true, - ['crash-site-spaceship-wreck-small-2'] = true, - ['crash-site-spaceship-wreck-small-3'] = true, - ['crash-site-spaceship-wreck-small-4'] = true, - ['crash-site-spaceship-wreck-small-5'] = true, - ['crash-site-spaceship-wreck-small-6'] = true -} - local function get_biome(position) --if not a then return "concrete" end if position.x ^ 2 + position.y ^ 2 < 6400 then @@ -359,12 +346,6 @@ local function on_entity_died(event) expand(entity.surface, entity.position) end -local function on_marked_for_deconstruction(event) - if disabled_for_deconstruction[event.entity.name] then - event.entity.cancel_deconstruction(game.players[event.player_index].force.name) - end -end - local function on_init() local dungeontable = DungeonsTable.get_dungeontable() local force = game.create_force('dungeon') @@ -445,7 +426,7 @@ end local Event = require 'utils.event' Event.on_init(on_init) --Event.add(defines.events.on_tick, on_tick) -Event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction) +Event.add(defines.events.on_marked_for_deconstruction, Functions.on_marked_for_deconstruction) Event.add(defines.events.on_player_joined_game, on_player_joined_game) Event.add(defines.events.on_player_mined_entity, on_player_mined_entity) Event.add(defines.events.on_chunk_generated, on_chunk_generated) diff --git a/maps/dungeons/tiered_dungeon.lua b/maps/dungeons/tiered_dungeon.lua index c45b7ee6..59447d31 100644 --- a/maps/dungeons/tiered_dungeon.lua +++ b/maps/dungeons/tiered_dungeon.lua @@ -41,19 +41,6 @@ Biomes.laboratory = require 'maps.dungeons.biome_laboratory' local math_random = math.random local math_round = math.round -local disabled_for_deconstruction = { - ['fish'] = true, - ['rock-huge'] = true, - ['rock-big'] = true, - ['sand-rock-big'] = true, - ['crash-site-spaceship-wreck-small-1'] = true, - ['crash-site-spaceship-wreck-small-2'] = true, - ['crash-site-spaceship-wreck-small-3'] = true, - ['crash-site-spaceship-wreck-small-4'] = true, - ['crash-site-spaceship-wreck-small-5'] = true, - ['crash-site-spaceship-wreck-small-6'] = true -} - local function enable_hard_rooms(position, surface_index) local dungeon_table = DungeonsTable.get_dungeontable() local floor = surface_index - dungeon_table.original_surface_index @@ -515,14 +502,6 @@ local function on_entity_died(event) expand(entity.surface, entity.position) end -local function on_marked_for_deconstruction(event) - if event.entity and event.entity.valid then - if disabled_for_deconstruction[event.entity.name] then - event.entity.cancel_deconstruction(game.players[event.player_index].force.name) - end - end -end - local function get_map_gen_settings() local settings = { ['seed'] = math_random(1, 1000000), @@ -853,7 +832,7 @@ end local Event = require 'utils.event' Event.on_init(on_init) Event.on_nth_tick(60, on_tick) -Event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction) +Event.add(defines.events.on_marked_for_deconstruction, Functions.on_marked_for_deconstruction) Event.add(defines.events.on_player_joined_game, on_player_joined_game) Event.add(defines.events.on_player_mined_entity, on_player_mined_entity) Event.add(defines.events.on_built_entity, on_built_entity)