extends Node3D

func _ready():
    Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
    if GameInfo.game_data.ship_in_space:
        %TakeOffAnimationPlayer.play("TookOff")

    if GameInfo.game_data:
        %Planet3d.fertility_factor = (GameInfo.game_data.progression_data.get_story_progression() * 0.5)

    %Ship.take_off.connect(_on_ship_take_off)
    %Ship.land.connect(_on_ship_land)
    
    # var region_data := GameInfo.game_data.current_region_data

    # if not GameInfo.game_data.current_region_data:
    #     %ExitAction.hide()
    #     %ExitAction.interactable = false
    
    # if region_data:
    #     var state := region_data.get_state()
    #     match state:
    #         RegionData.State.IN_PROGRESS:
    #             %StateAnimationPlayer.play("InProgress")
    #             %MapAction.hide()
    #             %MapAction.interactable = false
    #         RegionData.State.FAILED:
    #             %StateAnimationPlayer.play("Failed")
    #         RegionData.State.SUCCEEDED:
    #             %StateAnimationPlayer.play("Succeeded")
    #     update_screen_info(region_data)

func _on_ship_take_off():
    %TakeOffAnimationPlayer.play("TakeOff")
    AudioManager.play_sfx("Decollage")

func _on_ship_land():
    %TakeOffAnimationPlayer.play("Land")
    AudioManager.play_sfx("Atterrissage")

func _on_exit_action_clicked():
    if GameInfo.game_data.current_region_data != null:
        SceneManager.change_to_scene(RegionScene.new(GameInfo.game_data.current_region_data))
