using System; using SUISS.Core; using SUISS.Core.Utilities; using SUISS.Storage; using SUISSEngine; using UnityEngine; public sealed class GameInterface : Singleton { public void RegisterOnApplicationPauseHandler(Action action) { if (this._listener == null) { GameObject gameObject = new GameObject(); gameObject.name = "OnApplicationPauseListener"; this._listener = gameObject.AddComponent(); UnityEngine.Object.DontDestroyOnLoad(gameObject); } this._listener.applicationPauseEvent += delegate(bool x) { action(x); }; } public long GetUserId() { if (SingletonMonobehaviour.IsAvailable) { return SingletonMonobehaviour.Instance.UserId; } Storage storage = Storage.Get(StorageLifecycle.Player); return storage.Root.GetLong("userId", -1L); } public string GetUserKey() { if (SingletonMonobehaviour.IsAvailable) { return SingletonMonobehaviour.Instance.UserKey; } Storage storage = Storage.Get(StorageLifecycle.Player); return storage.Root.GetString("userKey", string.Empty); } public bool IsWebServiceAvailable() { return SingletonMonobehaviour.IsAvailable; } public void RegisterPullRequestCompletedHandler(Action action) { if (SingletonMonobehaviour.IsAvailable) { SingletonMonobehaviour.Instance.PullRequestCompleted += delegate() { action(); }; } else { UnityEngine.Debug.LogWarning("GameInterface.RegisterPullRequestCompletedHandler: no CIGWebService instance available."); } } public void ForcePullRequest() { if (SingletonMonobehaviour.IsAvailable) { SingletonMonobehaviour.Instance.ForcePullRequest(); } else { UnityEngine.Debug.LogWarning("GameInterface.ForcePullRequest: no CIGWebService instance available."); } } public void MuteAudio() { if (SingletonMonobehaviour.IsAvailable) { SingletonMonobehaviour.Instance.Mute(); } } public void RestoreAudio() { if (SingletonMonobehaviour.IsAvailable) { SingletonMonobehaviour.Instance.Unmute(); } } public long GetTotalMinutesPlayed() { if (SingletonMonobehaviour.IsAvailable) { return SingletonMonobehaviour.Instance.TotalMinutesPlayed; } return 0L; } public bool ShowAdInfoPopup() { return false; } private ApplicationPauseListener _listener; }