#leave
execute as @e[type=interaction,tag=leave,tag=button] on attacker at @s run reload

#difficulty
execute as @e[type=interaction,tag=difficulty] on attacker at @s run function main:hub/objects/teleport/difficulty_1

#tp
execute positioned 29 -59 9 positioned ~-4 ~-2.5 ~-4 as @a[dx=7,dy=4,dz=7,tag=!leave_text] run function main:hub/objects/leave/on
execute positioned 29 -59 9 positioned ~-4 ~-2.5 ~-4 unless entity @a[dx=7,dy=4,dz=7,tag=leave_text] as @a[tag=leave_text] run function main:hub/objects/leave/off

#tp
execute positioned 71 -59 9 positioned ~-3 ~-0.5 ~-4 as @a[dx=7,dy=4,dz=7,tag=!teleport_text] run function main:hub/objects/teleport/teleport_on
execute as @a[tag=teleport_text] positioned 75 -57 9 run particle minecraft:trial_spawner_detection_ominous ~ ~1 ~ 0.75 1 0.75 0 5
execute positioned 71 -59 9 positioned ~-3 ~-0.5 ~-4 unless entity @a[dx=7,dy=4,dz=7,tag=teleport_text] as @a run function main:hub/objects/teleport/teleport_off

execute positioned 75 -57 9 positioned ~-0.5 ~-0.5 ~-0.5 if entity @a[dx=0,dz=0,dy=2] run scoreboard players add .teleport hub 1
execute positioned 75 -57 9 positioned ~-0.5 ~-0.5 ~-0.5 unless entity @a[dx=0,dz=0,dy=2] run scoreboard players set .teleport hub 0
execute if score .teleport hub matches 1.. run function main:hub/objects/teleport/teleport
execute if score .teleport hub matches ..0 run kill @e[type=text_display,tag=teleport_countdown]

#class chose
execute positioned 64 -59 15 positioned ~-3 ~-0.5 ~-1 as @a[dx=7,dy=4,dz=5,tag=!classes_text,tag=!upgrade_starting] run function main:hub/objects/classes/on
execute positioned 64 -59 15 positioned ~-3 ~-0.5 ~-1 unless entity @a[dx=7,dy=4,dz=5,tag=classes_text] as @a[tag=classes_text] run function main:hub/objects/classes/off

#workshop
execute positioned 62 -58 1 positioned ~-2.5 ~-2.5 ~-2.5 as @a[dx=5,dy=5,dz=5,tag=!workshop_text] run function main:hub/objects/workshop/on
execute positioned 62 -58 1 positioned ~-2.5 ~-2.5 ~-2.5 unless entity @a[dx=5,dy=5,dz=5,tag=workshop_text] as @a[tag=workshop_text] run function main:hub/objects/workshop/off

#npc
execute if entity @a[tag=hub_dialogs] at @e[type=interaction,tag=npc_workshop] positioned ~ ~2.5 ~ run function main:particles/yellow_indicator
execute as @e[type=interaction,tag=npc_workshop] on attacker at @s[tag=hub_dialogs] run function main:dialog/id/hub/l30/check

#dummy
function main:hub/objects/dummy/tick

#62 -59 5
function main:hub/objects/workshop/tick
function main:hub/objects/classes/tick
execute as @e[type=interaction,tag=button] run data remove entity @s attack
execute as @e[type=interaction,tag=dummy] run data remove entity @s attack
execute as @e[type=interaction,tag=speed] run data remove entity @s attack

execute unless entity @e[type=armor_stand,tag=launcher_aim] as @a if score @s health < @s health_max run scoreboard players add @a health 999
execute unless entity @e[type=armor_stand,tag=launcher_aim] as @a if score @s shield < @s shield_max run scoreboard players add @a shield 999

execute as @a[scores={health=..0}] run scoreboard players set @a health 1

execute positioned 37 -53 25 if entity @a[dx=1,dy=1,dz=1] run tp @a 42 -40 8 -90 0
execute positioned 38 -40 8 if entity @a[dx=1,dy=1,dz=1] run tp @a 37 -53 22 180 0