// methods
    public bool GetUnlockState(UnlockStateID id)
    {
        ushort idx = (ushort)id;

        if (idx >= UnlockStates.Count)
        {
            while (UnlockStates.Count <= idx)
            {
                UnlockStates.Add(false);
            }
        }

        return(UnlockStates[(int)idx]);
    }
    public Unlockable GetUnlockable(UnlockStateID id)
    {
        if (!UnlockCosts.ContainsKey(id))
        {
            Debug.LogError(string.Format("Unlock State ID {0} cost not defined!", id.ToString("g")));
            return(new Unlockable(new[] { "We forgot to add this one" }, 0));
        }

        if (IgnoreUnlockCosts)
        {
            return(new Unlockable(UnlockCosts[id].Descriptions, 0));
        }

        return(UnlockCosts[id]);
    }
    public void SetUnlockState(UnlockStateID id, bool state)
    {
        ushort idx = (ushort)id;

        if (idx >= UnlockStates.Count)
        {
            while (UnlockStates.Count <= idx)
            {
                UnlockStates.Add(false);
            }
        }

        bool oldState = UnlockStates[idx];

        UnlockStates[idx] = state;

        UnlockStateChanged?.Invoke(id, oldState, state);
    }
    // Update is called once per frame
    void Update()
    {
        if (!Resetting)
        {
            return;
        }

        if (SkipResetFrame)
        {
            SkipResetFrame = false;
            return;
        }

        WorldState state = LastWorldState;

        Currency = state.PlayerCurrency;

        GameObject player = GameObject.FindWithTag("Player");

        player.GetComponent <IDamageable>()?.HealAmount(state.PlayerHealth, true);
        player.transform.position = state.CheckPointPosition;
        UnlockStates.Clear();
        for (int i = 0; i < state.UnlockStates.Count; ++i)
        {
            UnlockStateID id = (UnlockStateID)i;
            SetUnlockState(id, state.UnlockStates[i]);
        }

        foreach (var setting in state.Settings)
        {
            SettingController.Instance.SetSettable(setting.Key, setting.Value);
        }

        Resetting      = false;
        SkipResetFrame = true;
    }