namespace Ubisoft { /// /// Interface responsible for hiding the implementation for Hotel 'PlayerPrefs' which takes after Unity 'PlayerPrefs' class (https://docs.unity3d.com/ScriptReference/PlayerPrefs.html), /// which is typically used to store Player preferences between game sessions. /// /// By using 'IHtPlayerPrefs' interface you will be able to change implementations with little or no impact in your code, for example /// if local storage is not enough and you need to store Player preferences in server. /// /// This class expands Unity 'PlayerPrefs' by supporting bool type: GetBool(), SetBool(), GetLong(), SetLong() /// public interface IHtPlayerPrefs { public enum EType { Bool, Float, Int, Long, String, None } /// /// Channel to store preferences to. /// string Channel { get; } /// /// Removes all keys and values from the preferences.Use with caution. /// void DeleteAll(); /// /// Removes the given key from the PlayerPrefs.If the key does not exist, DeleteKey has no impact. /// /// Key to remove. void DeleteKey(string key); /// /// Returns the value corresponding to key in the preference file if it exists. /// /// Key which value needs to be retrieved. /// Value to return if key doesn't exist. /// Bool value corresponding to key. bool GetBool(string key, bool defaultValue = false); /// /// Returns the value corresponding to key in the preference file if it exists. /// /// Key which value needs to be retrieved. /// Value to return if key doesn't exist. /// Float value corresponding to key. float GetFloat(string key, float defaultValue = 0f); /// /// Returns the value corresponding to key in the preference file if it exists. /// /// Key which value needs to be retrieved. /// Value to return if key doesn't exist. /// int value corresponding to key. int GetInt(string key, int defaultValue = 0); /// /// Returns the value corresponding to key in the preference file if it exists. /// /// Key which value needs to be retrieved. /// Value to return if key doesn't exist. /// long value corresponding to key. long GetLong(string key, long defaultValue = 0); /// /// Returns the value corresponding to key in the preference file if it exists. /// /// Key which value needs to be retrieved. /// Value to return if key doesn't exist. /// String value corresponding to key. string GetString(string key, string defaultValue = ""); /// /// Returns the value corresponding to key in the preference file as object /// /// Key which value needs to be retrieved. /// Object value corresponding to key. object GetAsObject(string key); /// /// Returns true if the given key exists is stored, otherwise returns false. /// /// Key to check if it exists. /// true if key exists, false otherwise. bool HasKey(string key); /// /// Returns the EType value of the key passed in if there's a value stored for this key, otherwise it returns EType.None. /// /// Key which type needs to be retrieved. /// The EType value of the key passed in if there's a value stored for this key, otherwise EType.None. EType GetType(string key); /// /// When enabled preferences are saved automatically with no need to call Save() explicitly. /// This is useful for implementations that store preferences locally, which involves writing them to disk. /// These implementation save preferences to disk during OnApplicationQuit(). In cases when the game crashes or /// otherwise prematuraly exits, you might want to write the PlayerPrefs at sensible 'checkpoints' in your game. /// Writing to disk potentially causing a small hiccup, therefore it is not recommended to call during actual gameplay. /// bool AutomaticSave { get; set; } /// /// Returns true when some preferences have gotten updated and haven't been saved yet. /// bool NeedsToSave { get; set; } /// /// Makes sure preferences are saved immediately. /// This is useful for implementations that store preferences locally, which involves writing them to disk. /// These implementation save preferences to disk during OnApplicationQuit(). In cases when the game crashes or /// otherwise prematuraly exits, you might want to write the PlayerPrefs at sensible 'checkpoints' in your game. /// Writing to disk potentially causing a small hiccup, therefore it is not recommended to call during actual gameplay. /// void Save(); /// /// /// void Update(); /// /// Sets the bool value of the preference identified by the given key. You can use GetBool() to retrieve this value. /// /// Key to set. /// Value to set. void SetBool(string key, bool value); /// /// Sets the float value of the preference identified by the given key. You can use GetFloat() to retrieve this value. /// /// Key to set. /// Value to set. void SetFloat(string key, float value); /// /// Sets the int value of the preference identified by the given key. You can use GetInt() to retrieve this value. /// /// Key to set. /// Value to set. void SetInt(string key, int value); /// /// Sets the long value of the preference identified by the given key. You can use GetLong() to retrieve this value. /// /// Key to set. /// Value to set. void SetLong(string key, long value); /// /// Sets the string value of the preference identified by the given key. You can use GetString() to retrieve this value. /// /// Key to set. /// Value to set. void SetString(string key, string value); /// /// Returns a string that represents the current object. /// /// A string that represents the current object. string ToString(); } }