extends LevelTemplate

func _ready() -> void:
    var t = Timer.new()
    t.set_wait_time(3)
    t.set_one_shot(true)
    self.add_child(t)
    t.start()
    yield(t, "timeout")
    levelState.register_tutorial("move_right")
    spawn_tutorial_thingy("move_right")
    t.start()
    yield(t, "timeout")
    levelState.register_tutorial("move_left")
    spawn_tutorial_thingy("move_left")
    t.start()
    yield(t, "timeout")
    levelState.register_tutorial("jump")
    spawn_tutorial_thingy("jump")
    t.queue_free()
    

func spawn_tutorial_thingy(action: String) -> void:
    var show_prompt: bool = GlobalState.gsr["tutorial_prompts"][action]
    var thingy = ResourceLoader.load("res://src/UserInterface/TutorialThingy.tscn")
    var instance = thingy.instance()
    instance.action = action
    var center = get_tree().root.get_child(3).get_node("%BlobbyCam").get_camera_screen_center()
    var viewport = get_viewport_rect().size - Vector2(40,40)
    instance.position = Vector2(rand_range(center.x - viewport.x/2, center.x + viewport.x/2), rand_range(center.y - viewport.y/2, center.y + viewport.y/2))
    instance.velocity *= Vector2(sign(rand_range(-1,1)),sign(rand_range(-1,1)))
    add_child(instance)

    
