extends Node3D


var run_data : RunData

func _ready():
    run_data = GameInfo.game_data.current_run
    if run_data:
        set_up_artefacts_displayers(run_data.artefacts)
    else :
        set_up_artefacts_displayers([])

func set_up_artefacts_displayers(artefacts : Array[Artefact]):
    var artefact_displayers = %ArtefactsDisplayers.get_children() as Array[ArtefactDisplayer]
    for i in range(len(artefact_displayers)):
        var artefact_displayer = artefact_displayers[i]
        if not artefact_displayer.is_node_ready():
            await artefact_displayer.ready
        if i < len(artefacts):
            artefact_displayer.artefact = artefacts[i]
            artefact_displayer.inspectable = true
        else:
            artefact_displayer.artefact = null
            artefact_displayer.inspectable = false
