extends Node3D
class_name SubterraBase

const ENERGY_DIALOG = "res://dialogs/timelines/3_subterra/2_subterra_energy.dtl"
const DATA_DIALOG = "res://dialogs/timelines/3_subterra/3_subterra_data.dtl"
const DATA_ICON : Texture = preload("res://common/icons/server-2.svg")

func _ready():
    if not Engine.is_editor_hint():
        Input.mouse_mode = Input.MOUSE_MODE_CAPTURED

    SteamConnection.unlock_achievement(SteamConnection.ACH_STW_REACH_SUBTERRA_BASE)
    %AiReceptacle.interactable = false


func _on_energyterminal_clicked():
    Dialogic.start(ENERGY_DIALOG)

    %Energyterminal.interactable = false

    await Dialogic.timeline_ended
    
    await get_tree().create_timer(2.).timeout

    %TurnOnLightsAnimationPlayer.play("LightUp")

    %AiReceptacle.interactable = true
    %AiReceptacle.screen_icon = DATA_ICON
    %AiReceptacle.screen_text = "CONNECT_TO_HADES"

func _on_ai_receptacle_clicked():
    %AiReceptacle.screen_turned_on = false
    %AiReceptacle.interactable = false
    Dialogic.start(DATA_DIALOG)

    %Energyterminal.interactable = false

    await Dialogic.timeline_ended

    %Exit3dDoor.to_scene = RelayBaseScene.new(
        "SUBTERRA_BASE",
        "006",
    )
    %Exit3dDoor.interactable = true

    AudioManager.play_sfx("DoorOpen")
