1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-28 03:57:22 +02:00

silo fixes

Changes:
- Area under silo is cleared (from trees, rocks, etc.) first before being created.
This commit is contained in:
Piratux 2023-01-08 21:28:39 +02:00
parent 8586a88cb0
commit e4f3f402d3
7 changed files with 64 additions and 48 deletions

View File

@ -1,6 +1,6 @@
require 'utils.data_stages'
_LIFECYCLE = _STAGE.control -- Control stage
_DEBUG = false
_DEBUG = true
_DUMP_ENV = false
require 'utils.server'
@ -113,7 +113,7 @@ require 'utils.freeplay'
--require 'maps.chronosphere.main'
--![[Adventure as a crew of pirates]]--
-- require 'maps.pirates.main'
require 'maps.pirates.main'
--![[Launch rockets in increasingly harder getting worlds.]]--
--require 'maps.journey.main'

View File

@ -16,20 +16,20 @@ local Roles = require 'maps.pirates.roles.roles'
local Progression = require 'maps.pirates.progression'
local Crowsnest = require 'maps.pirates.surfaces.crowsnest'
local Hold = require 'maps.pirates.surfaces.hold'
local Cabin = require 'maps.pirates.surfaces.cabin'
-- local Cabin = require 'maps.pirates.surfaces.cabin'
local Balance = require 'maps.pirates.balance'
local Common = require 'maps.pirates.common'
local CoreData = require 'maps.pirates.coredata'
local Overworld = require 'maps.pirates.overworld'
local Utils = require 'maps.pirates.utils_local'
local Crew = require 'maps.pirates.crew'
local Parrot = require 'maps.pirates.parrot'
-- local Parrot = require 'maps.pirates.parrot'
local Math = require 'maps.pirates.math'
local _inspect = require 'utils.inspect'.inspect
local Kraken = require 'maps.pirates.surfaces.sea.kraken'
local Quest = require 'maps.pirates.quest'
local ShopDock = require 'maps.pirates.shop.dock'
-- local ShopDock = require 'maps.pirates.shop.dock'
local QuestStructures = require 'maps.pirates.structures.quest_structures.quest_structures'
local Public = {}
@ -436,40 +436,6 @@ function Public.pick_up_tick(tickinterval)
end
end
local function cached_structure_delete_existing_entities_if_needed(surface, position, special)
if (not special.doNotDestroyExistingEntities) then
-- destroy existing entities
local area = {left_top = {position.x - special.width/2, position.y - special.height/2}, right_bottom = {position.x + special.width/2 + 0.5, position.y + special.height/2 + 0.5}}
surface.destroy_decoratives{area=area}
local existing = surface.find_entities_filtered{area = area}
if existing then
for _, e in pairs(existing) do
if not (((special.name == 'small_primitive_mining_base' or special.name == 'small_mining_base') and (e.name == 'iron-ore' or e.name == 'copper-ore' or e.name == 'stone')) or (special.name == 'uranium_miners' and e.name == 'uranium-ore')) then
if not (e.name and e.name == 'rocket-silo') then
e.destroy()
end
end
end
end
end
end
local function cached_structure_delete_existing_unwalkable_tiles_if_needed(surface, position, special)
local area = {left_top = {position.x - special.width/2, position.y - special.height/2}, right_bottom = {position.x + special.width/2 + 0.5, position.y + special.height/2 + 0.5}}
local existing = surface.find_tiles_filtered{area = area, collision_mask = "water-tile"}
if existing then
local tiles = {}
for _, t in pairs(existing) do
tiles[#tiles + 1] = {name = "landfill", position = t.position}
end
if #tiles > 0 then
surface.set_tiles(tiles, true)
end
end
end
function Public.interpret_shorthanded_force_name(shorthanded_name)
local memory = Memory.get_crew_memory()
@ -533,8 +499,10 @@ function Public.place_cached_structures(tickinterval)
Common.ensure_chunks_at(surface, position, Common.structure_ensure_chunk_radius)
cached_structure_delete_existing_entities_if_needed(surface, position, special)
cached_structure_delete_existing_unwalkable_tiles_if_needed(surface, position, special)
if not special.doNotDestroyExistingEntities then
Common.delete_entities(surface, position, special.width, special.height)
end
Common.replace_unwalkable_tiles(surface, position, special.width, special.height)
local saved_components = {}
for k = 1, #special.components do

View File

@ -1203,8 +1203,10 @@ if _DEBUG then
player.insert{name='uranium-rounds-magazine', count = 200}
player.insert{name='raw-fish', count = 100}
player.insert{name='coin', count = 50000}
player.insert{name='grenade', count = 100}
player.insert{name='cluster-grenade', count = 100}
player.insert{name='steel-chest', count = 50}
player.insert{name='express-loader', count = 50}
player.insert{name='burner-inserter', count = 50}
end
end)

View File

@ -1670,4 +1670,37 @@ function Public.force_connect_poles(pole1, pole2)
end
end
-- position here refers to middle position
function Public.delete_entities(surface, position, width, height)
local area = {left_top = {position.x - width/2, position.y - height/2}, right_bottom = {position.x + width/2 + 0.5, position.y + height/2 + 0.5}}
surface.destroy_decoratives{area = area}
local existing = surface.find_entities_filtered{area = area}
if not existing then return end
for _, e in pairs(existing) do
if not (e.name == 'iron-ore' or e.name == 'copper-ore' or e.name == 'stone' or e.name == 'uranium-ore' or e.name == 'crude-oil') then
if not (e.name == 'rocket-silo') then
e.destroy()
end
end
end
end
function Public.replace_unwalkable_tiles(surface, position, width, height)
local area = {left_top = {position.x - width/2, position.y - height/2}, right_bottom = {position.x + width/2 + 0.5, position.y + height/2 + 0.5}}
local existing = surface.find_tiles_filtered{area = area, collision_mask = "water-tile"}
if not existing then return end
local tiles = {}
for _, t in pairs(existing) do
tiles[#tiles + 1] = {name = "landfill", position = t.position}
end
if #tiles > 0 then
surface.set_tiles(tiles, true)
end
end
return Public

View File

@ -284,8 +284,12 @@ function Public.join_spectators(player, crewid)
Common.notify_force(force, {'pirates.lobby_to_spectator', player.name})
Common.notify_lobby({'pirates.lobby_to_spectator_2', player.name, memory.name})
end
memory.spectatorplayerindices[#memory.spectatorplayerindices + 1] = player.index
memory.tempbanned_from_joining_data[player.index] = game.tick
if not _DEBUG then
memory.tempbanned_from_joining_data[player.index] = game.tick
end
-- if #Common.crew_get_crew_members() == 0 then
-- memory.crew_disband_tick = game.tick + 30
-- -- memory.crew_disband_tick = game.tick + 60*60*2 --give players time to log back in after a crash or save

View File

@ -288,8 +288,13 @@ function Public.spawn_silo_setup(points_to_avoid)
if silo_count >= 2 then game.print('debug - silo count: ' .. silo_count) end
end
for i=1,silo_count do
local silo = surface.create_entity({name = 'rocket-silo', position = {p_silo.x + 9*(i-1), p_silo.y}, force = force, create_build_effect_smoke = false})
for i = 1, silo_count do
local pos = {x = p_silo.x + 9*(i-1), y = p_silo.y}
Common.delete_entities(surface, pos, 11, 11)
Common.replace_unwalkable_tiles(surface, pos, 11, 11)
local silo = surface.create_entity({name = 'rocket-silo', position = pos, force = force, create_build_effect_smoke = false})
if silo and silo.valid then
if not destination.dynamic_data.rocketsilos then destination.dynamic_data.rocketsilos = {} end
destination.dynamic_data.rocketsilos[#destination.dynamic_data.rocketsilos + 1]= silo

View File

@ -382,9 +382,13 @@ function Public.destination_on_arrival(destination)
-- game.print('spawning silo')
if destination.subtype ~= IslandEnum.enum.RADIOACTIVE then
local silo_position = Islands.spawn_silo_setup(points_to_avoid)
if silo_position then
points_to_avoid[#points_to_avoid + 1] = {x = silo_position.x, y = silo_position.y, r = 22}
local first_silo_pos = Islands.spawn_silo_setup(points_to_avoid)
if first_silo_pos then
local silo_count = Balance.silo_count()
for i = 1, silo_count do
local avoid_pos = {x = first_silo_pos.x + 9 * (i-1), y = first_silo_pos.y}
points_to_avoid[#points_to_avoid + 1] = {x = avoid_pos.x, y = avoid_pos.y, r = 22}
end
end
end