mirror of
https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git
synced 2025-01-20 02:59:53 +02:00
Making the holding pen pretty.
This commit is contained in:
parent
d133179a74
commit
f6cfc898f3
@ -134,7 +134,7 @@ script.on_event(defines.events.on_chunk_generated, function(event)
|
||||
RegrowthChunkGenerate(event)
|
||||
end
|
||||
|
||||
CreateHoldingPenChunks(event.surface, event.area)
|
||||
CreateHoldingPenChunks(event)
|
||||
SeparateSpawnsGenerateChunk(event)
|
||||
|
||||
if global.ocfg.gameplay.modified_enemy_spawning then
|
||||
|
@ -26,37 +26,121 @@ function CreateHoldingPenSurface()
|
||||
holding_pen_surface.show_clouds = false
|
||||
holding_pen_surface.generate_with_lab_tiles = true
|
||||
|
||||
RenderPermanentGroundText(holding_pen_surface, {x=-15,y=-24}, 20, "OARC", {0.9, 0.7, 0.3, 0.8})
|
||||
RenderPermanentGroundText(holding_pen_surface, {x=9,y=-7}, 5, "O", {0.9, 0.7, 0.3, 0.8}, "center")
|
||||
RenderPermanentGroundText(holding_pen_surface, {x=9,y=-4}, 5, "A", {0.9, 0.7, 0.3, 0.8}, "center")
|
||||
RenderPermanentGroundText(holding_pen_surface, {x=9,y=-1}, 5, "R", {0.9, 0.7, 0.3, 0.8}, "center")
|
||||
RenderPermanentGroundText(holding_pen_surface, {x=9,y=2}, 5, "C", {0.9, 0.7, 0.3, 0.8}, "center")
|
||||
end
|
||||
|
||||
---Creates a holding pen area
|
||||
---@param surface LuaSurface
|
||||
---@param chunkArea BoundingBox
|
||||
function CreateHoldingPenChunks(surface, chunkArea)
|
||||
---@param event EventData.on_chunk_generated
|
||||
---@return nil
|
||||
function CreateHoldingPenChunks(event)
|
||||
|
||||
local surface = event.surface
|
||||
local chunk_area = event.area
|
||||
local chunk_position = event.position
|
||||
|
||||
|
||||
if (surface.name ~= HOLDING_PEN_SURFACE_NAME) then
|
||||
return
|
||||
end
|
||||
|
||||
-- Remove ALL entities in the chunk
|
||||
for _, entity in pairs(surface.find_entities(chunkArea)) do
|
||||
for _, entity in pairs(surface.find_entities(chunk_area)) do
|
||||
if entity.type ~= "character" then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
-- Place some tutorial grid tiles for the spawn area
|
||||
-- Place tiles and trees and water for the holding pen
|
||||
local tiles = {}
|
||||
for x=chunkArea.left_top.x,chunkArea.right_bottom.x,1 do
|
||||
for y=chunkArea.left_top.y,chunkArea.right_bottom.y,1 do
|
||||
local distance = math.floor(x^2 + y^2)
|
||||
for x=chunk_area.left_top.x,chunk_area.right_bottom.x,1 do
|
||||
for y=chunk_area.left_top.y,chunk_area.right_bottom.y,1 do
|
||||
local distance_sqr = math.floor(x^2 + y^2)
|
||||
|
||||
if (distance < 10^2) then
|
||||
table.insert(tiles, {name="tutorial-grid", position={x, y}})
|
||||
if (distance_sqr < 15^2) then
|
||||
table.insert(tiles, {name="grass-1", position={x, y}})
|
||||
elseif (distance_sqr < 20^2) then
|
||||
table.insert(tiles, {name="water", position={x, y}})
|
||||
|
||||
--10% chance of fish in water
|
||||
if (math.random(1,10) == 1) then
|
||||
surface.create_entity({name="fish", position={x + 0.5, y + 0.5}})
|
||||
end
|
||||
|
||||
else
|
||||
table.insert(tiles, {name="out-of-map", position={x, y}})
|
||||
end
|
||||
|
||||
if (distance_sqr >= 13^2) and (distance_sqr <= 15^2) then
|
||||
surface.create_entity({name="tree-01", position={x + 0.5, y + 0.5}})
|
||||
end
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
|
||||
-- If this is the bottom right chunk it's safe to place stuff inside the holding pen now.
|
||||
if (chunk_position.x == 2 and chunk_position.y == 2) then
|
||||
|
||||
-- temporarily copy the nauvis config for easy use of the resources config.
|
||||
global.ocfg.surfaces_config[HOLDING_PEN_SURFACE_NAME] = {}
|
||||
global.ocfg.surfaces_config[HOLDING_PEN_SURFACE_NAME].spawn_config = global.ocfg.surfaces_config["nauvis"].spawn_config
|
||||
PlaceResourcesInSemiCircleHoldingPen(surface, {x=0,y=0}, 0.2, 0.1)
|
||||
|
||||
CreateWaterStrip(surface, {x=-2,y=-11}, 4)
|
||||
CreateWaterStrip(surface, {x=-2,y=-10}, 4)
|
||||
|
||||
surface.create_entity({
|
||||
name = "crude-oil",
|
||||
amount = 90000,
|
||||
position = { 0, 9 }
|
||||
})
|
||||
|
||||
global.ocfg.surfaces_config[HOLDING_PEN_SURFACE_NAME] = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
---A special version of PlaceResourcesInSemiCircle for the holding pen
|
||||
---@param surface LuaSurface
|
||||
---@param position TilePosition --The center of the spawn area
|
||||
---@param size_mod number
|
||||
---@param amount_mod number
|
||||
---@return nil
|
||||
function PlaceResourcesInSemiCircleHoldingPen(surface, position, size_mod, amount_mod)
|
||||
|
||||
-- Create list of resource tiles
|
||||
---@type table<string>
|
||||
local r_list = {}
|
||||
for r_name, _ in pairs(global.ocfg.surfaces_config[surface.name].spawn_config.solid_resources --[[@as table<string, OarcConfigSolidResource>]]) do
|
||||
if (r_name ~= "") then
|
||||
table.insert(r_list, r_name)
|
||||
end
|
||||
end
|
||||
---@type table<string>
|
||||
local shuffled_list = FYShuffle(r_list)
|
||||
|
||||
-- This places resources in a semi-circle
|
||||
local angle_offset = 2.32
|
||||
local num_resources = table_size(global.ocfg.surfaces_config[surface.name].spawn_config.solid_resources)
|
||||
local theta = ((4.46 - 2.32) / num_resources);
|
||||
local count = 0
|
||||
|
||||
-- Unique to the holding pen size
|
||||
local radius = 15 - 6
|
||||
|
||||
for _, r_name in pairs(shuffled_list) do
|
||||
local angle = (theta * count) + angle_offset;
|
||||
|
||||
local tx = (radius * math.cos(angle)) + position.x
|
||||
local ty = (radius * math.sin(angle)) + position.y
|
||||
|
||||
local pos = { x = math.floor(tx), y = math.floor(ty) }
|
||||
|
||||
local resourceConfig = global.ocfg.surfaces_config[surface.name].spawn_config.solid_resources[r_name]
|
||||
GenerateResourcePatch(surface, r_name, resourceConfig.size * size_mod, pos, resourceConfig.amount * amount_mod)
|
||||
count = count + 1
|
||||
end
|
||||
end
|
@ -66,8 +66,9 @@ end
|
||||
---@param scale number
|
||||
---@param text string
|
||||
---@param color Color
|
||||
---@param alignment TextAlign?
|
||||
---@return nil
|
||||
function RenderPermanentGroundText(surface, position, scale, text, color)
|
||||
function RenderPermanentGroundText(surface, position, scale, text, color, alignment)
|
||||
rendering.draw_text { text = text,
|
||||
surface = surface,
|
||||
target = position,
|
||||
@ -75,6 +76,7 @@ function RenderPermanentGroundText(surface, position, scale, text, color)
|
||||
scale = scale,
|
||||
--Allowed fonts: default-dialog-button default-game compilatron-message-font default-large default-large-semibold default-large-bold heading-1 compi
|
||||
font = "compi",
|
||||
alignment = alignment,
|
||||
draw_on_ground = true }
|
||||
end
|
||||
|
||||
@ -1508,7 +1510,7 @@ end
|
||||
---@param length integer
|
||||
function CreateWaterStrip(surface, leftPos, length)
|
||||
local waterTiles = {}
|
||||
for i = 0, length, 1 do
|
||||
for i = 0, length-1, 1 do
|
||||
table.insert(waterTiles, { name = "water", position = { leftPos.x + i, leftPos.y } })
|
||||
end
|
||||
surface.set_tiles(waterTiles)
|
||||
|
@ -282,9 +282,9 @@ function GenerateStartingResources(surface, position)
|
||||
else
|
||||
|
||||
if (global.ocfg.spawn_general.shape == SPAWN_SHAPE_CHOICE_CIRCLE) or (global.ocfg.spawn_general.shape == SPAWN_SHAPE_CHOICE_OCTAGON) then
|
||||
PlaceResourcesInSemiCircle(surface, position)
|
||||
PlaceResourcesInSemiCircle(surface, position, size_mod, amount_mod)
|
||||
elseif (global.ocfg.spawn_general.shape == SPAWN_SHAPE_CHOICE_SQUARE) then
|
||||
PlaceResourcesInSquare(surface, position)
|
||||
PlaceResourcesInSquare(surface, position, size_mod, amount_mod)
|
||||
end
|
||||
end
|
||||
|
||||
@ -310,10 +310,10 @@ end
|
||||
---Places starting resource deposits in a semi-circle around the spawn point.
|
||||
---@param surface LuaSurface
|
||||
---@param position TilePosition --The center of the spawn area
|
||||
function PlaceResourcesInSemiCircle(surface, position)
|
||||
|
||||
local size_mod = global.ocfg.resource_placement.size_multiplier
|
||||
local amount_mod = global.ocfg.resource_placement.amount_multiplier
|
||||
---@param size_mod number
|
||||
---@param amount_mod number
|
||||
---@return nil
|
||||
function PlaceResourcesInSemiCircle(surface, position, size_mod, amount_mod)
|
||||
|
||||
-- Create list of resource tiles
|
||||
---@type table<string>
|
||||
@ -351,10 +351,10 @@ end
|
||||
---Places starting resource deposits in a line starting at the top left of the spawn point.
|
||||
---@param surface LuaSurface
|
||||
---@param position TilePosition --The center of the spawn area
|
||||
function PlaceResourcesInSquare(surface, position)
|
||||
|
||||
local size_mod = global.ocfg.resource_placement.size_multiplier
|
||||
local amount_mod = global.ocfg.resource_placement.amount_multiplier
|
||||
---@param size_mod number
|
||||
---@param amount_mod number
|
||||
---@return nil
|
||||
function PlaceResourcesInSquare(surface, position, size_mod, amount_mod)
|
||||
|
||||
-- Create list of resource tiles
|
||||
---@type table<string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user