using UnityEngine; namespace Ubisoft.Hotel.Device { public class NetworkDriver { private const string PREFS_INTERNET_REACHABILITY = "Hotel.UnityEngine.InternetReachability"; #if HT_CHEATS_ON private static readonly string[] NETWORK_REACHABILITY_NAMES = System.Enum.GetNames(typeof(NetworkReachability)); private static readonly NetworkReachability[] NETWORK_REACHABILITY_VALUES = (NetworkReachability[])System.Enum.GetValues(typeof(NetworkReachability)); public static readonly int NETWORK_REACHABILITY_COUNT = NETWORK_REACHABILITY_NAMES.Length; public static NetworkReachability InternetReachability { get { NetworkReachability returnValue; if (PlayerPrefs.HasKey(PREFS_INTERNET_REACHABILITY)) { returnValue = NETWORK_REACHABILITY_VALUES[PlayerPrefs.GetInt(PREFS_INTERNET_REACHABILITY)]; } else { returnValue = UnityInternetReachability; } return returnValue; } } public static int InternetReachabilityAsInt { get { if (PlayerPrefs.HasKey(PREFS_INTERNET_REACHABILITY)) { return PlayerPrefs.GetInt(PREFS_INTERNET_REACHABILITY); } else { return NETWORK_REACHABILITY_COUNT; } } set { if (value == NETWORK_REACHABILITY_COUNT) { if (PlayerPrefs.HasKey(PREFS_INTERNET_REACHABILITY)) { PlayerPrefs.DeleteKey(PREFS_INTERNET_REACHABILITY); } } else { PlayerPrefs.SetInt(PREFS_INTERNET_REACHABILITY, value); } } } public static string InternetReachabilityAsString { get { if (InternetReachabilityAsInt == NETWORK_REACHABILITY_COUNT) { return "AsProduction"; } else { return NETWORK_REACHABILITY_NAMES[InternetReachabilityAsInt]; } } } #else public static NetworkReachability InternetReachability { get { return UnityInternetReachability; } } #endif private static NetworkReachability UnityInternetReachability { get { #if UNITY_2021_1_OR_NEWER return UnityEngine.Device.Application.internetReachability; #else return Application.internetReachability; #endif } } } }