mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2024-12-30 23:17:53 +02:00
Fix deep jungle
This commit is contained in:
parent
c55edffc12
commit
840937015b
@ -2,10 +2,10 @@ local Task = require 'utils.task'
|
|||||||
local Token = require 'utils.token'
|
local Token = require 'utils.token'
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Terrain = require 'maps.deep_jungle.terrain'
|
local Terrain = require 'maps.deep_jungle.terrain'
|
||||||
|
local DPT = require 'maps.deep_jungle.table'
|
||||||
|
|
||||||
local Public = {}
|
local Public = {}
|
||||||
|
|
||||||
local force_chunk = false
|
|
||||||
local ceil = math.ceil
|
local ceil = math.ceil
|
||||||
local queue_task = Task.queue_task
|
local queue_task = Task.queue_task
|
||||||
local tiles_per_call = 12
|
local tiles_per_call = 12
|
||||||
@ -496,7 +496,11 @@ local do_chunk = Public.do_chunk
|
|||||||
local schedule_chunk = Public.schedule_chunk
|
local schedule_chunk = Public.schedule_chunk
|
||||||
|
|
||||||
local function on_chunk(event)
|
local function on_chunk(event)
|
||||||
if force_chunk then
|
local settings = DPT.get('settings')
|
||||||
|
if settings.stop_chunk then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if settings.force_chunk then
|
||||||
do_chunk(event)
|
do_chunk(event)
|
||||||
else
|
else
|
||||||
schedule_chunk(event)
|
schedule_chunk(event)
|
||||||
|
@ -4,32 +4,22 @@ require 'modules.biters_yield_coins'
|
|||||||
require 'modules.rocks_yield_coins'
|
require 'modules.rocks_yield_coins'
|
||||||
require 'modules.flashlight_toggle_button'
|
require 'modules.flashlight_toggle_button'
|
||||||
require 'maps.deep_jungle.generate'
|
require 'maps.deep_jungle.generate'
|
||||||
local Global = require 'utils.global'
|
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local map_functions = require 'tools.map_functions'
|
local map_functions = require 'tools.map_functions'
|
||||||
|
local Task = require 'utils.task'
|
||||||
|
local DPT = require 'maps.deep_jungle.table'
|
||||||
local random = math.random
|
local random = math.random
|
||||||
|
|
||||||
local this = {
|
|
||||||
chunks_charted = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
Global.register(
|
|
||||||
this,
|
|
||||||
function(tbl)
|
|
||||||
this = tbl
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
local Public = {}
|
|
||||||
|
|
||||||
local function on_chunk_charted(event)
|
local function on_chunk_charted(event)
|
||||||
|
local settings = DPT.get('settings')
|
||||||
local surface = game.get_surface(event.surface_index)
|
local surface = game.get_surface(event.surface_index)
|
||||||
local deco = game.decorative_prototypes
|
local deco = game.decorative_prototypes
|
||||||
local position = event.position
|
local position = event.position
|
||||||
if this.chunks_charted[tostring(position.x) .. tostring(position.y)] then
|
if settings.chunks_charted[tostring(position.x) .. tostring(position.y)] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
this.chunks_charted[tostring(position.x) .. tostring(position.y)] = true
|
settings.chunks_charted[tostring(position.x) .. tostring(position.y)] = true
|
||||||
|
|
||||||
local decorative_names = {}
|
local decorative_names = {}
|
||||||
for k, v in pairs(deco) do
|
for k, v in pairs(deco) do
|
||||||
@ -113,8 +103,29 @@ local function on_entity_died(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function chunk_load()
|
||||||
|
local tick = game.tick
|
||||||
|
local settings = DPT.get('settings')
|
||||||
|
if settings.chunk_load_tick then
|
||||||
|
if settings.chunk_load_tick < tick then
|
||||||
|
settings.force_chunk = false
|
||||||
|
DPT.remove('settings', 'chunk_load_tick')
|
||||||
|
Task.set_queue_speed(8)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local on_tick = function()
|
||||||
|
local tick = game.tick
|
||||||
|
if tick % 40 == 0 then
|
||||||
|
chunk_load()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function on_init()
|
local function on_init()
|
||||||
local map_gen_settings = {}
|
local map_gen_settings = {}
|
||||||
|
local settings = DPT.get('settings')
|
||||||
|
|
||||||
map_gen_settings.moisture = 0.99
|
map_gen_settings.moisture = 0.99
|
||||||
map_gen_settings.water = 'none'
|
map_gen_settings.water = 'none'
|
||||||
map_gen_settings.starting_area = 'normal'
|
map_gen_settings.starting_area = 'normal'
|
||||||
@ -130,13 +141,14 @@ local function on_init()
|
|||||||
}
|
}
|
||||||
game.create_surface('deep_jungle', map_gen_settings)
|
game.create_surface('deep_jungle', map_gen_settings)
|
||||||
game.forces.player.set_spawn_position({0, 0}, game.surfaces['deep_jungle'])
|
game.forces.player.set_spawn_position({0, 0}, game.surfaces['deep_jungle'])
|
||||||
|
settings.force_chunk = true
|
||||||
|
settings.chunk_load_tick = game.tick + 200
|
||||||
end
|
end
|
||||||
|
|
||||||
Event.on_init(on_init)
|
Event.on_init(on_init)
|
||||||
Event.add(defines.events.on_chunk_charted, on_chunk_charted)
|
Event.add(defines.events.on_chunk_charted, on_chunk_charted)
|
||||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||||
|
Event.on_nth_tick(10, on_tick)
|
||||||
|
|
||||||
require 'modules.rocks_yield_ore'
|
require 'modules.rocks_yield_ore'
|
||||||
|
|
||||||
return Public
|
|
||||||
|
48
maps/deep_jungle/table.lua
Normal file
48
maps/deep_jungle/table.lua
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
local Global = require 'utils.global'
|
||||||
|
|
||||||
|
local this = {
|
||||||
|
settings = {
|
||||||
|
chunk_load_tick = false,
|
||||||
|
chunks_charted = {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Global.register(
|
||||||
|
this,
|
||||||
|
function(tbl)
|
||||||
|
this = tbl
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
local Public = {}
|
||||||
|
|
||||||
|
function Public.get(key)
|
||||||
|
if key then
|
||||||
|
return this[key]
|
||||||
|
else
|
||||||
|
return this
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Public.set(key, value)
|
||||||
|
if key and (value or value == false) then
|
||||||
|
this[key] = value
|
||||||
|
return this[key]
|
||||||
|
elseif key then
|
||||||
|
return this[key]
|
||||||
|
else
|
||||||
|
return this
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Public.remove(key, sub_key)
|
||||||
|
if key then
|
||||||
|
if this[key] and this[key][sub_key] then
|
||||||
|
this[key][sub_key] = nil
|
||||||
|
elseif this[key] then
|
||||||
|
this[key] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return Public
|
Loading…
Reference in New Issue
Block a user