using System.Collections.Generic; namespace Wizard; public class PlayerPrefsCache { private Dictionary _boolCache = new Dictionary(); private Dictionary _intCache = new Dictionary(); private static PlayerPrefsCache _instance; public static PlayerPrefsCache Instance { get { if (_instance == null) { _instance = new PlayerPrefsCache(); } return _instance; } } public static void OnSoftwareReset() { _instance = null; } public int GetValue(KeyValuePair id) { if (_intCache.TryGetValue(id.Key, out var value)) { return value; } value = PlayerPrefsWrapper.GetValue(id); _intCache.Add(id.Key, value); return value; } public void SetValue(KeyValuePair id, int value) { PlayerPrefsWrapper.SetValue(id, value); _intCache[id.Key] = value; } public bool GetBool(KeyValuePair id) { if (_boolCache.TryGetValue(id.Key, out var value)) { return value; } value = PlayerPrefsWrapper.GetBool(id); _boolCache.Add(id.Key, value); return value; } public void SetBool(KeyValuePair id, bool value) { PlayerPrefsWrapper.SetBool(id, value); _boolCache[id.Key] = value; } }