1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-02-03 13:11:21 +02:00

Migrate collision layers

This commit is contained in:
RedRafe 2024-10-26 23:40:41 +02:00
parent 37b06d39e0
commit 78a9ae41c1
27 changed files with 99 additions and 99 deletions

View File

@ -22,7 +22,7 @@ local floor = math.floor
local ceil = math.ceil
local fast_remove = table.fast_remove
local collision_mask = {'floor-layer', 'object-layer', 'resource-layer'}
local collision_mask = {'floor', 'object', 'resource'}
local whitelist = defines.deconstruction_item.tile_filter_mode.whitelist
local entity_whitelist = defines.deconstruction_item.entity_filter_mode.whitelist

View File

@ -93,9 +93,9 @@ local function run_terrain_module(x, y, world)
if
math.floor(terrain_D) % 5 == 1 and math.random(1, 70) == 1 and
surface.can_place_entity {name = 'rock-big', position = pos}
surface.can_place_entity {name = 'big-rock', position = pos}
then
surface.create_entity {name = 'rock-big', position = pos}
surface.create_entity {name = 'big-rock', position = pos}
end
else
if terrain_D >= 20 then

View File

@ -68,7 +68,7 @@ local function spawn_ores_on_death(event)
ore_type = found_ores[math.random(1,#found_ores)].name
end
if surface.get_tile(position).collides_with("ground-tile") then
if surface.get_tile(position).collides_with("ground_tile") then
surface.create_entity{name = ore_type, position = position, amount = ore_amount_to_add}
end
--return since we might have changed found_ores

View File

@ -70,7 +70,7 @@ local function drop_meteors()
local map_position = {x = chunk_position.x * 32 + rand_x, y = chunk_position.y * 32 + rand_y}
-- Spawn Rock
if surface.get_tile(map_position).collides_with('ground-tile') then
if surface.get_tile(map_position).collides_with('ground_tile') then
surface.create_entity({name = 'huge-rock', position = map_position, move_stuck_players = true,})
surface.create_entity({name = 'massive-explosion', position = map_position,})
end
@ -113,7 +113,7 @@ local function drop_meteors()
if b < a then
ore_amount = math.random(b * ORE_DENSITY - b * (ORE_DENSITY - 8), b * ORE_DENSITY + b * (ORE_DENSITY - 8))
end
if surface.get_tile(map_position.x + x, map_position.y + y).collides_with('ground-tile') then
if surface.get_tile(map_position.x + x, map_position.y + y).collides_with('ground_tile') then
if ores == 'mixed' then
ore_type = BASIC_ORES[math.random(1, #BASIC_ORES)]
end
@ -130,7 +130,7 @@ local function drop_meteors()
local biter_position = {
map_position.x + math.random(-METEOR_SIZE, METEOR_SIZE),
map_position.y + math.random(-METEOR_SIZE, METEOR_SIZE)}
if surface.get_tile(biter_position).collides_with('ground-tile') then
if surface.get_tile(biter_position).collides_with('ground_tile') then
surface.create_entity{
name = biters[unit_index],
position = biter_position,

View File

@ -64,7 +64,7 @@ local function on_built_miner(event)
if rand >= MAX_RAND*(1 - extra_percent) then
local rand_ore = table.get_random_weighted(ORES)
if (rand_ore ~= ore.name) and surface.get_tile(ore.position.x, ore.position.y).collides_with('ground-tile') then
if (rand_ore ~= ore.name) and surface.get_tile(ore.position.x, ore.position.y).collides_with('ground_tile') then
local amount = ore.amount
local ore_position = ore.position
ore.destroy()

View File

@ -184,7 +184,7 @@ local function create_collapse_template(positions, surface)
end
local function create_collapse_alert(surface, position)
local target = surface.create_entity({ position = position, name = 'rock-big' })
local target = surface.create_entity({ position = position, name = 'big-rock' })
for _, player in pairs(game.connected_players) do
player.add_custom_alert(target, collapse_alert, { 'diggy.cave_collapse' }, true)
end

View File

@ -174,19 +174,19 @@ end
Template.diggy_rocks = {
'rock-huge-volcanic',
'rock-big-volcanic',
'big-rock-volcanic',
'rock-huge-black',
'rock-big-black',
'big-rock-black',
'rock-huge-grey',
'rock-big-grey',
'big-rock-grey',
'rock-huge-red',
'rock-big-red',
'big-rock-red',
'rock-huge-white',
'rock-big-white',
'big-rock-white',
'rock-huge-brown',
'rock-big-brown',
'big-rock-brown',
'rock-huge-dustyrose',
'rock-big-dustyrose',
'big-rock-dustyrose',
}
Template.diggy_rocks_map = util.list_to_map(Template.diggy_rocks)

View File

@ -46,13 +46,13 @@ Event.on_init(function()
game.forces.player.technologies['laser-shooting-speed-5'].enabled = false
game.forces.player.technologies['laser-shooting-speed-6'].enabled = false
game.forces.player.technologies['laser-shooting-speed-7'].enabled = false
game.forces.player.technologies['energy-weapons-damage-1'].enabled = false
game.forces.player.technologies['energy-weapons-damage-2'].enabled = false
game.forces.player.technologies['energy-weapons-damage-3'].enabled = false
game.forces.player.technologies['energy-weapons-damage-4'].enabled = false
game.forces.player.technologies['energy-weapons-damage-5'].enabled = false
game.forces.player.technologies['energy-weapons-damage-6'].enabled = false
game.forces.player.technologies['energy-weapons-damage-7'].enabled = false
game.forces.player.technologies['laser-weapons-damage-1'].enabled = false
game.forces.player.technologies['laser-weapons-damage-2'].enabled = false
game.forces.player.technologies['laser-weapons-damage-3'].enabled = false
game.forces.player.technologies['laser-weapons-damage-4'].enabled = false
game.forces.player.technologies['laser-weapons-damage-5'].enabled = false
game.forces.player.technologies['laser-weapons-damage-6'].enabled = false
game.forces.player.technologies['laser-weapons-damage-7'].enabled = false
game.forces.player.technologies['distractor'].enabled = false
game.forces.player.technologies['destroyer'].enabled = false
end)

View File

@ -216,7 +216,7 @@ return function(_, _, world) -- luacheck: ignore 561
end
if noise_trees < -0.5 and (tile_to_insert == 'sand-3' or tile_to_insert == 'sand-1') and random(15) == 1 then
insert(entities, {name = 'rock-big'})
insert(entities, {name = 'big-rock'})
end
local noise_water_1 = perlin.noise(((world.x + seed) / 200), ((world.y + seed) / 200), 0)

View File

@ -182,7 +182,7 @@ local function cutscene_function(player_index, waypoint_index, params)
local radius = 10
local entity
repeat
entity = RS.get_surface().find_entities_filtered {position = {0, 0}, radius = radius, name = 'rock-big', limit = 1}
entity = RS.get_surface().find_entities_filtered {position = {0, 0}, radius = radius, name = 'big-rock', limit = 1}
if radius <= 10 then
radius = 0
end

View File

@ -141,7 +141,7 @@ local function create_collapse_template(positions, surface)
end
local function create_collapse_alert(surface, position)
local target = surface.create_entity({position = position, name = 'rock-big'})
local target = surface.create_entity({position = position, name = 'big-rock'})
for _, player in pairs(game.connected_players) do
player.add_custom_alert(target, collapse_alert, {'diggy.cave_collapse'}, true)
end
@ -215,7 +215,7 @@ local function on_collapse_triggered(event)
local x_t = new_tile_map[x]
if x_t and x_t[y] then
template_insert(surface, {}, {{position = position, name = 'rock-big'}})
template_insert(surface, {}, {{position = position, name = 'big-rock'}})
return
end
spawn_collapse_text(surface, position)

View File

@ -76,7 +76,7 @@ local function update_robot_mining_damage()
robot_mining.damage = old_modifier + robot_mining.active_modifier
end
---Triggers a diggy diggy hole for a given big-rock, rock-big or huge-rock.
---Triggers a diggy diggy hole for a given big-rock, big-rock or huge-rock.
---@param entity LuaEntity
local function diggy_hole(entity)
local tiles = {}
@ -115,7 +115,7 @@ local function diggy_hole(entity)
if predicted < 0.2 then
rocks[i] = {name = 'huge-rock', position = void_position}
elseif predicted < 0.6 then
rocks[i] = {name = 'rock-big', position = void_position}
rocks[i] = {name = 'big-rock', position = void_position}
else
rocks[i] = {name = 'big-rock', position = void_position}
end

View File

@ -208,7 +208,7 @@ local function on_player_mined_entity(event)
local exp = 0
if name == 'big-rock' then
exp = sand_rock_xp + floor(level / 5)
elseif name == 'rock-big' then
elseif name == 'big-rock' then
exp = rock_big_xp + floor(level / 5)
elseif name == 'huge-rock' then
exp = rock_huge_xp + floor(level / 5)
@ -294,7 +294,7 @@ local function on_entity_died(event)
local level = get_force_data(force).current_level
if entity_name == 'big-rock' then
exp = floor((sand_rock_xp + level * 0.2) * 0.5)
elseif entity_name == 'rock-big' then
elseif entity_name == 'big-rock' then
exp = floor((rock_big_xp + level * 0.2) * 0.5)
elseif entity_name == 'huge-rock' then
exp = floor((rock_huge_xp + level * 0.2) * 0.5)
@ -613,7 +613,7 @@ function Experience.register(cfg)
-- Prevents table lookup thousands of times
sand_rock_xp = config.XP['big-rock']
rock_big_xp = config.XP['rock-big']
rock_big_xp = config.XP['big-rock']
rock_huge_xp = config.XP['huge-rock']
end

View File

@ -63,7 +63,7 @@ function StartingZone.register(config)
end
if (distance > rock_range) then
insert(rocks, {name = 'rock-big', position = {x = x, y = y}})
insert(rocks, {name = 'big-rock', position = {x = x, y = y}})
end
-- hack to avoid starting area from collapsing

View File

@ -93,7 +93,7 @@ local config = {
['nuclear-reactor'] = 4,
['stone-wall'] = 3,
['big-rock'] = 2,
['rock-big'] = 2,
['big-rock'] = 2,
['huge-rock'] = 2.5,
['out-of-map'] = 1,
['stone-path'] = 0.03,
@ -359,7 +359,7 @@ local config = {
mining_speed_productivity_multiplier = 5,
XP = {
['big-rock'] = 5,
['rock-big'] = 5,
['big-rock'] = 5,
['huge-rock'] = 10,
['rocket_launch'] = 0.05, -- XP reward in percentage of total experience when a rocket launches (Diggy default: 0.05 which equals 5%)
['rocket_launch_max'] = 500000, -- Max XP reward from rocket launches (Diggy default: 500000)

View File

@ -93,7 +93,7 @@ local config = {
['nuclear-reactor'] = 4,
['stone-wall'] = 3,
['big-rock'] = 2,
['rock-big'] = 2,
['big-rock'] = 2,
['huge-rock'] = 2.5,
['out-of-map'] = 1,
['stone-path'] = 0.03,
@ -359,7 +359,7 @@ local config = {
mining_speed_productivity_multiplier = 5,
XP = {
['big-rock'] = 5,
['rock-big'] = 5,
['big-rock'] = 5,
['huge-rock'] = 10,
['rocket_launch'] = 0.05, -- XP reward in percentage of total experience when a rocket launches (Diggy default: 0.05 which equals 5%)
['rocket_launch_max'] = 500000, -- Max XP reward from rocket launches (Diggy default: 500000)
@ -483,13 +483,13 @@ local config = {
'laser-turret',
'personal-laser-defense-equipment',
'discharge-defense-equipment',
'energy-weapons-damage-1',
'energy-weapons-damage-2',
'energy-weapons-damage-3',
'energy-weapons-damage-4',
'energy-weapons-damage-5',
'energy-weapons-damage-6',
'energy-weapons-damage-7',
'laser-weapons-damage-1',
'laser-weapons-damage-2',
'laser-weapons-damage-3',
'laser-weapons-damage-4',
'laser-weapons-damage-5',
'laser-weapons-damage-6',
'laser-weapons-damage-7',
'laser-shooting-speed-1',
'laser-shooting-speed-2',
'laser-shooting-speed-3',

View File

@ -93,7 +93,7 @@ local config = {
['nuclear-reactor'] = 4,
['stone-wall'] = 3,
['big-rock'] = 2,
['rock-big'] = 2,
['big-rock'] = 2,
['huge-rock'] = 2.5,
['out-of-map'] = 1,
['stone-path'] = 0.03,
@ -359,7 +359,7 @@ local config = {
mining_speed_productivity_multiplier = 5,
XP = {
['big-rock'] = 5,
['rock-big'] = 5,
['big-rock'] = 5,
['huge-rock'] = 10,
['rocket_launch'] = 0.05, -- XP reward in percentage of total experience when a rocket launches (Diggy default: 0.05 which equals 5%)
['rocket_launch_max'] = 500000, -- Max XP reward from rocket launches (Diggy default: 500000)

View File

@ -182,12 +182,12 @@ function Template.resources(surface, resources)
end
end
Template.diggy_rocks = {'big-rock', 'rock-big', 'huge-rock'}
Template.diggy_rocks = {'big-rock', 'big-rock', 'huge-rock'}
---Returns true if the entity name is that of a diggy rock.
---@param entity_name string
function Template.is_diggy_rock(entity_name)
return entity_name == 'big-rock' or entity_name == 'rock-big' or entity_name == 'huge-rock'
return entity_name == 'big-rock' or entity_name == 'big-rock' or entity_name == 'huge-rock'
end
return Template

View File

@ -243,7 +243,7 @@ function Terrain.rich_rocks(surface, area)
end
for _ = 1, this.rock_richness do
local rock_name = math_random() < 0.4 and 'huge-rock' or 'rock-big'
local rock_name = math_random() < 0.4 and 'huge-rock' or 'big-rock'
place_rock(rock_name)
end
end
@ -444,24 +444,24 @@ function Terrain.clear_area(args)
y = position.y + cb.right_bottom.y,
}
}
for _, e in pairs(surface.find_entities_filtered{ area = area, collision_mask = {'player-layer', 'object-layer'}}) do
for _, e in pairs(surface.find_entities_filtered{ area = area, collision_mask = {'player', 'object'}}) do
e.destroy()
end
local tiles = {}
for _, t in pairs(surface.find_tiles_filtered{ area = area }) do
if t.collides_with('item-layer') then
if t.collides_with('item_layer') then
tiles[#tiles +1] = { name = 'nuclear-ground', position = t.position }
end
end
surface.set_tiles(tiles, true)
return true
elseif args.radius then
for _, e in pairs(surface.find_entities_filtered{ position = position, radius = args.radius, collision_mask = {'player-layer', 'object-layer'}}) do
for _, e in pairs(surface.find_entities_filtered{ position = position, radius = args.radius, collision_mask = {'player', 'object'}}) do
e.destroy()
end
local tiles = {}
for _, t in pairs(surface.find_tiles_filtered{ position = position, radius = args.radius }) do
if t.collides_with('item-layer') then
if t.collides_with('item_layer') then
tiles[#tiles +1] = { name = 'nuclear-ground', position = t.position }
end
end
@ -479,12 +479,12 @@ function Terrain.clear_area(args)
y = position.y + size,
}
}
for _, e in pairs(surface.find_entities_filtered{ area = area, collision_mask = {'player-layer', 'object-layer'}}) do
for _, e in pairs(surface.find_entities_filtered{ area = area, collision_mask = {'player', 'object'}}) do
e.destroy()
end
local tiles = {}
for _, t in pairs(surface.find_tiles_filtered{ area = area }) do
if t.collides_with('item-layer') then
if t.collides_with('item_layer') then
tiles[#tiles +1] = { name = 'nuclear-ground', position = t.position }
end
end

View File

@ -91,7 +91,7 @@ local function sprinkle(_, _, world)
}
end
local rock_names = {'rock-big', 'huge-rock', 'big-rock'}
local rock_names = {'big-rock', 'huge-rock', 'big-rock'}
local function rocks_func()
local rock = rock_names[math.random(#rock_names)]
return {name = rock}

View File

@ -27,7 +27,7 @@ local oil =
b.resource(b.throttle_world_xy(ore_shape, 1, 8, 1, 8), 'crude-oil', value(150000, 5, 1.05), true)
)
local tree = b.apply_entity(b.full_shape, b.entity(ore_shape, 'tree-01'))
local rock = b.apply_entity(b.full_shape, b.entity(ore_shape, 'rock-big'))
local rock = b.apply_entity(b.full_shape, b.entity(ore_shape, 'big-rock'))
local walk_spiral1 = b.circular_spiral_n_threads(3, 512, 8)
walk_spiral1 = b.flip_x(walk_spiral1)

View File

@ -154,12 +154,12 @@ local function map(x, y, world)
if tile_to_insert == 'sand-1' or tile_to_insert == 'sand-3' then
if random(1, 200) == 1 then
entities[#entities + 1] = {name = 'rock-big'}
entities[#entities + 1] = {name = 'big-rock'}
end
end
if tile_to_insert == 'grass-1' or tile_to_insert == 'grass-2' or tile_to_insert == 'grass-3' then
if random(1, 2000) == 1 then
entities[#entities + 1] = {name = 'rock-big'}
entities[#entities + 1] = {name = 'big-rock'}
end
end

View File

@ -127,7 +127,7 @@ start_circle = b.translate(start_circle, 0, -32)
map = b.any{start_circle, map}
map = b.change_map_gen_collision_tile(map, "water-tile", "grass-1")
map = b.change_map_gen_collision_tile(map, "water_tile", "grass-1")
map = b.rotate(map, degrees(90))
map = b.scale(map, 3, 3)

View File

@ -353,7 +353,7 @@ local function quadrants(x, y)
end
if (abs_x <= 200 and abs_y <= 200) then
if game.surfaces[2].get_tile(x, y).collides_with('water-tile') then
if game.surfaces[2].get_tile(x, y).collides_with('water_tile') then
game.surfaces[2].set_tiles({{name = 'grass-1', position = {x, y}}}, true)
end
local entities = game.surfaces[2].find_entities({{x - 0.5, y - 0.5}, {x + 0.5, y + 0.5}})

View File

@ -6,7 +6,7 @@ local spawn_position = {x = 20, y = 20}
local function is_not_water_tile(_, _, world)
local gen_tile = world.surface.get_tile(world.x, world.y)
return not gen_tile.collides_with('water-tile')
return not gen_tile.collides_with('water_tile')
end
local station_length = 40

View File

@ -148,7 +148,7 @@ local function on_built_pumpjack(event)
if entity.name == 'pumpjack' then
for x = center_x - size, center_x + size do
for y = center_y - size, center_y + size do
if entity.surface.get_tile(x, y).collides_with("ground-tile") then
if entity.surface.get_tile(x, y).collides_with("ground_tile") then
entity.surface.create_entity({name="stone", amount=density, position={x, y}})
end
end

View File

@ -1904,40 +1904,40 @@ function Builders.set_hidden_tile(shape, hidden_tile)
end
local collision_map = {
['concrete'] = 'ground-tile',
['deepwater-green'] = 'water-tile',
['deepwater'] = 'water-tile',
['dirt-1'] = 'ground-tile',
['dirt-2'] = 'ground-tile',
['dirt-3'] = 'ground-tile',
['dirt-4'] = 'ground-tile',
['dirt-5'] = 'ground-tile',
['dirt-6'] = 'ground-tile',
['dirt-7'] = 'ground-tile',
['dry-dirt'] = 'ground-tile',
['grass-1'] = 'ground-tile',
['grass-2'] = 'ground-tile',
['grass-3'] = 'ground-tile',
['grass-4'] = 'ground-tile',
['hazard-concrete-left'] = 'ground-tile',
['hazard-concrete-right'] = 'ground-tile',
['lab-dark-1'] = 'ground-tile',
['lab-dark-2'] = 'ground-tile',
['lab-white'] = 'ground-tile',
['concrete'] = 'ground_tile',
['deepwater-green'] = 'water_tile',
['deepwater'] = 'water_tile',
['dirt-1'] = 'ground_tile',
['dirt-2'] = 'ground_tile',
['dirt-3'] = 'ground_tile',
['dirt-4'] = 'ground_tile',
['dirt-5'] = 'ground_tile',
['dirt-6'] = 'ground_tile',
['dirt-7'] = 'ground_tile',
['dry-dirt'] = 'ground_tile',
['grass-1'] = 'ground_tile',
['grass-2'] = 'ground_tile',
['grass-3'] = 'ground_tile',
['grass-4'] = 'ground_tile',
['hazard-concrete-left'] = 'ground_tile',
['hazard-concrete-right'] = 'ground_tile',
['lab-dark-1'] = 'ground_tile',
['lab-dark-2'] = 'ground_tile',
['lab-white'] = 'ground_tile',
['out-of-map'] = false,
['red-desert-0'] = 'ground-tile',
['red-desert-1'] = 'ground-tile',
['red-desert-2'] = 'ground-tile',
['red-desert-3'] = 'ground-tile',
['sand-1'] = 'ground-tile',
['sand-2'] = 'ground-tile',
['sand-3'] = 'ground-tile',
['stone-path'] = 'ground-tile',
['water-green'] = 'water-tile',
['water'] = 'water-tile',
['refined-concrete'] = 'ground-tile',
['refined-hazard-concrete-left'] = 'ground-tile',
['refined-hazard-concrete-right'] = 'ground-tile'
['red-desert-0'] = 'ground_tile',
['red-desert-1'] = 'ground_tile',
['red-desert-2'] = 'ground_tile',
['red-desert-3'] = 'ground_tile',
['sand-1'] = 'ground_tile',
['sand-2'] = 'ground_tile',
['sand-3'] = 'ground_tile',
['stone-path'] = 'ground_tile',
['water-green'] = 'water_tile',
['water'] = 'water_tile',
['refined-concrete'] = 'ground_tile',
['refined-hazard-concrete-left'] = 'ground_tile',
['refined-hazard-concrete-right'] = 'ground_tile'
}
--- Docs: https://github.com/Refactorio/RedMew/wiki/Using-the-Builders#builderschange_collision_tile
@ -2096,7 +2096,7 @@ function Builders.overlay_tile_land(shape, tile_shape)
return function(x, y, world)
local function handle_tile(tile)
if type(tile) == 'boolean' then
return tile and not world.surface.get_tile(world.x, world.y).collides_with('water-tile')
return tile and not world.surface.get_tile(world.x, world.y).collides_with('water_tile')
else
return not bad_tiles[tile]
end
@ -2136,7 +2136,7 @@ function Builders.fish(shape, spawn_rate)
return {name = 'fish'}
end
elseif tile then
if world.surface.get_tile(world.x, world.y).collides_with('water-tile') and spawn_rate >= random() then
if world.surface.get_tile(world.x, world.y).collides_with('water_tile') and spawn_rate >= random() then
return {name = 'fish'}
end
end