scoreboard players set global exitEnabled 0

#make sure water doesn't mess with the concrete powder
execute positioned 0 80 0 run fill ~ ~ ~ ~31 ~ ~31 light_gray_concrete_powder replace light_gray_concrete

#progression
#area 1
execute if block 4 12 2 redstone_block if block 5 12 2 redstone_block if block 6 12 2 redstone_block if block 7 12 2 redstone_block if block 8 12 2 redstone_block run setblock 2 12 2 redstone_block
execute if block 4 12 3 redstone_block if block 5 12 3 redstone_block if block 6 12 3 redstone_block if block 7 12 3 redstone_block if block 8 12 3 redstone_block run setblock 2 12 3 redstone_block
execute if block 4 12 4 redstone_block if block 5 12 4 redstone_block if block 6 12 4 redstone_block if block 7 12 4 redstone_block if block 8 12 4 redstone_block run setblock 2 12 4 redstone_block
execute if block 4 12 5 redstone_block if block 5 12 5 redstone_block if block 6 12 5 redstone_block if block 7 12 5 redstone_block if block 8 12 5 redstone_block run setblock 2 12 5 redstone_block
execute if block 4 12 6 redstone_block if block 5 12 6 redstone_block if block 6 12 6 redstone_block if block 7 12 6 redstone_block if block 8 12 6 redstone_block run setblock 2 12 6 redstone_block

#won game? all levels open, always
execute if score #dozeoff wonGame matches 1 run function bd:__open_all_levels_dozeoff

#blocks to get further in hub
execute if block 2 12 2 redstone_block run fill 11 80 25 11 80 29 smooth_stone
execute if block 2 12 3 redstone_block run fill 20 80 15 22 80 15 smooth_stone
execute if block 2 12 4 redstone_block unless block 10 12 4 redstone_block run setblock 11 82 22 ice
execute if block 10 12 4 redstone_block run setblock 29 81 21 ice
execute if block 10 12 4 redstone_block run fill 25 80 21 26 80 21 light_gray_concrete
execute if block 2 12 5 redstone_block run fill 20 81 15 22 81 15 scaffolding
execute if block 2 12 5 redstone_block unless block 10 12 5 redstone_block run setblock 11 82 10 barrel[facing=west]
execute if block 10 12 5 redstone_block run setblock 28 81 6 barrel[facing=west]
execute if block 10 12 5 redstone_block run setblock 19 81 6 piston[facing=up]
execute if block 2 12 6 redstone_block run setblock 2 83 5 piston[facing=up]

#level entry points
#area 1
scoreboard players set global setLevel 2101
execute unless block 4 12 2 redstone_block positioned 22 81 27 run function bd:levels/entities/level_entry_face3
scoreboard players set global setLevel 2102
execute unless block 5 12 2 redstone_block positioned 21 81 18 run function bd:levels/entities/level_entry_face5
scoreboard players set global setLevel 2103
execute unless block 6 12 2 redstone_block positioned 16 81 22 run function bd:levels/entities/level_entry_face1
scoreboard players set global setLevel 2104
execute unless block 7 12 2 redstone_block positioned 14 81 26 run function bd:levels/entities/level_entry_face3
scoreboard players set global setLevel 2105
execute unless block 8 12 2 redstone_block positioned 13 81 28 run function bd:levels/entities/level_entry_face7

#area 2
scoreboard players set global setLevel 2201
execute if block 2 12 2 redstone_block unless block 4 12 3 redstone_block positioned 8 81 27 run function bd:levels/entities/level_entry_face7
scoreboard players set global setLevel 2202
execute if block 2 12 2 redstone_block unless block 5 12 3 redstone_block positioned 5 81 23 run function bd:levels/entities/level_entry_face5
scoreboard players set global setLevel 2203
execute if block 2 12 2 redstone_block unless block 6 12 3 redstone_block positioned 2 81 29 run function bd:levels/entities/level_entry_face5
scoreboard players set global setLevel 2204
execute if block 2 12 2 redstone_block unless block 7 12 3 redstone_block positioned 6 81 18 run function bd:levels/entities/level_entry_face7
scoreboard players set global setLevel 2205
execute if block 2 12 2 redstone_block unless block 8 12 3 redstone_block positioned 7 81 16 run function bd:levels/entities/level_entry_face3

#area 3
scoreboard players set global setLevel 2301
execute if block 2 12 3 redstone_block unless block 4 12 4 redstone_block positioned 14 82 10 run function bd:levels/entities/level_entry_face3
scoreboard players set global setLevel 2302
execute if block 2 12 3 redstone_block unless block 5 12 4 redstone_block positioned 18 82 15 run function bd:levels/entities/level_entry_face7
scoreboard players set global setLevel 2303
execute if block 2 12 3 redstone_block unless block 6 12 4 redstone_block positioned 9 82 22 run function bd:levels/entities/level_entry_face1
scoreboard players set global setLevel 2304
execute if block 2 12 3 redstone_block unless block 7 12 4 redstone_block positioned 0 82 13 run function bd:levels/entities/level_entry_face1
scoreboard players set global setLevel 2305
execute if block 2 12 3 redstone_block unless block 8 12 4 redstone_block positioned 4 83 10 run function bd:levels/entities/level_entry_face7

#area 4
scoreboard players set global setLevel 2401
execute if block 2 12 4 redstone_block unless block 4 12 5 redstone_block positioned 28 81 23 run function bd:levels/entities/level_entry_face3
scoreboard players set global setLevel 2402
execute if block 2 12 4 redstone_block unless block 5 12 5 redstone_block positioned 24 82 20 run function bd:levels/entities/level_entry_face5
scoreboard players set global setLevel 2403
execute if block 2 12 4 redstone_block unless block 6 12 5 redstone_block positioned 28 82 16 run function bd:levels/entities/level_entry_face5
scoreboard players set global setLevel 2404
execute if block 2 12 4 redstone_block unless block 7 12 5 redstone_block positioned 25 82 7 run function bd:levels/entities/level_entry_face3
scoreboard players set global setLevel 2405
execute if block 2 12 4 redstone_block unless block 8 12 5 redstone_block positioned 19 82 9 run function bd:levels/entities/level_entry_face1

#area 5
scoreboard players set global setLevel 2501
execute if block 2 12 5 redstone_block unless block 4 12 6 redstone_block positioned 29 82 2 run function bd:levels/entities/level_entry_face5
scoreboard players set global setLevel 2502
execute if block 2 12 5 redstone_block unless block 5 12 6 redstone_block positioned 21 83 5 run function bd:levels/entities/level_entry_face7
scoreboard players set global setLevel 2503
execute if block 2 12 5 redstone_block unless block 6 12 6 redstone_block positioned 18 84 1 run function bd:levels/entities/level_entry_face7
scoreboard players set global setLevel 2504
execute if block 2 12 5 redstone_block unless block 7 12 6 redstone_block positioned 6 84 1 run function bd:levels/entities/level_entry_face3
scoreboard players set global setLevel 2505
execute if block 2 12 5 redstone_block unless block 8 12 6 redstone_block positioned 5 84 7 run function bd:levels/entities/level_entry_face1

#final "level"
scoreboard players set global setLevel 2999
execute if block 2 12 6 redstone_block positioned 2 85 2 run function bd:levels/entities/level_entry_face1