extends Node

export var save_location: String = "res://savefile.tres"

func _ready() -> void:
    load_initial_save()
    
func load_initial_save() -> void:
    var initial_state = load(save_location)
    if !initial_state:
        initial_state = GlobalStateResource.new()
    GlobalState.gsr = initial_state
    GlobalState.reinstate()
        
func save_default() -> void:
    var signal_manager = get_tree().root.get_child(4).get_node("%SignalManager")
    for action in InputMap.get_actions():
        GlobalState.gsr.input_map[action] = InputMap.get_action_list(action)
    ResourceSaver.save(save_location, GlobalState.gsr)
    signal_manager.emit_signal("savemanager_saved")
