mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-05-13 21:56:29 +02:00
new map
This commit is contained in:
parent
bc38e122a8
commit
fa53e9bd9f
67
maps/mountain_race/main.lua
Normal file
67
maps/mountain_race/main.lua
Normal file
@ -0,0 +1,67 @@
|
||||
--local Collapse = require "modules.collapse"
|
||||
local Terrain = require 'maps.mountain_race.terrain'
|
||||
local Global = require 'utils.global'
|
||||
|
||||
local mountain_race = {}
|
||||
Global.register(
|
||||
mountain_race,
|
||||
function(tbl)
|
||||
mountain_race = tbl
|
||||
end
|
||||
)
|
||||
|
||||
local function on_chunk_generated(event)
|
||||
local surface = event.surface
|
||||
if surface.index ~= 1 then return end
|
||||
local left_top = event.area.left_top
|
||||
if left_top.y >= mountain_race.playfield_height or left_top.y < mountain_race.playfield_height * -1 or left_top.x < -64 then
|
||||
Terrain.draw_out_of_map_chunk(surface, left_top)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
end
|
||||
|
||||
local function init(mountain_race)
|
||||
end
|
||||
|
||||
local function game_in_progress(mountain_race)
|
||||
local tick = game.tick
|
||||
if tick % 120 == 0 then
|
||||
Terrain.clone_south_to_north(mountain_race)
|
||||
end
|
||||
end
|
||||
|
||||
local gamestates = {
|
||||
["init"] = init,
|
||||
["game_in_progress"] = game_in_progress,
|
||||
}
|
||||
|
||||
local function on_tick()
|
||||
--Terrain.mirror_queue(mountain_race)
|
||||
gamestates[mountain_race.gamestate](mountain_race)
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
mountain_race.gamestate = "game_in_progress"
|
||||
mountain_race.border_width = 4
|
||||
mountain_race.border_half_width = mountain_race.border_width * 0.5
|
||||
mountain_race.playfield_height = 128
|
||||
mountain_race.clone_x = -3
|
||||
end
|
||||
|
||||
|
||||
local Event = require 'utils.event'
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_tick, on_tick)
|
||||
Event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
53
maps/mountain_race/terrain.lua
Normal file
53
maps/mountain_race/terrain.lua
Normal file
@ -0,0 +1,53 @@
|
||||
local Public = {}
|
||||
|
||||
local function draw_border(surface, left_x, height)
|
||||
local tiles = {}
|
||||
local i = 1
|
||||
for x = left_x, left_x + 31, 1 do
|
||||
for y = height * -1, height - 1, 1 do
|
||||
tiles[i] = {name = "out-of-map", position = {x = x, y = y}}
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles, true)
|
||||
end
|
||||
|
||||
function Public.clone_south_to_north(mountain_race)
|
||||
if game.tick < 60 then return end
|
||||
local surface = game.surfaces.nauvis
|
||||
if not surface.is_chunk_generated({mountain_race.clone_x + 2, 0}) then return end
|
||||
|
||||
local area = {{mountain_race.clone_x * 32, 0}, {mountain_race.clone_x * 32 + 32, mountain_race.playfield_height}}
|
||||
local offset = mountain_race.playfield_height + mountain_race.border_half_width
|
||||
|
||||
draw_border(surface, mountain_race.clone_x * 32, mountain_race.border_half_width)
|
||||
|
||||
surface.clone_area({
|
||||
source_area = area,
|
||||
destination_area = {{area[1][1], area[1][2] - offset}, {area[2][1], area[2][2] - offset}},
|
||||
destination_surface = surface,
|
||||
--destination_force = …,
|
||||
clone_tiles = true,
|
||||
clone_entities = true,
|
||||
clone_decoratives = true,
|
||||
clear_destination_entities = true,
|
||||
clear_destination_decoratives = true,
|
||||
expand_map = true,
|
||||
})
|
||||
|
||||
mountain_race.clone_x = mountain_race.clone_x + 1
|
||||
end
|
||||
|
||||
function Public.draw_out_of_map_chunk(surface, left_top)
|
||||
local tiles = {}
|
||||
local i = 1
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
tiles[i] = {name = "out-of-map", position = {x = left_top.x + x, y = left_top.y + y}}
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles, true)
|
||||
end
|
||||
|
||||
return Public
|
Loading…
x
Reference in New Issue
Block a user