using System; using Engine.DependencyTree; using SUISS.Core; using UnityEngine; public class CIGChangeWatcher : MonoBehaviour { protected void Start() { this.StartWatching(); } protected void OnDestroy() { this.EndWatching(); } protected void StartWatching() { if (!this._watchingGameState && SingletonMonobehaviour.IsAvailable) { SingletonMonobehaviour.Instance.ValueChangedEvent += this.GameStateValueChanged; this._watchingGameState = true; } if (!this._watchingGameStats && SingletonMonobehaviour.IsAvailable) { SingletonMonobehaviour.Instance.ValueChangedEvent += this.GameStatsValueChanged; this._watchingGameStats = true; } if (!this._watchingDependencyTree && SingletonMonobehaviour.IsAvailable) { SingletonMonobehaviour.Instance.DependencyAchievedChangedEvent += this.DependencyAchievedChanged; this._watchingDependencyTree = true; } } protected void EndWatching() { if (this._watchingGameState && SingletonMonobehaviour.IsAvailable) { SingletonMonobehaviour.Instance.ValueChangedEvent -= this.GameStateValueChanged; this._watchingGameState = false; } if (this._watchingGameStats && SingletonMonobehaviour.IsAvailable) { SingletonMonobehaviour.Instance.ValueChangedEvent -= this.GameStatsValueChanged; this._watchingGameStats = false; } if (this._watchingDependencyTree && SingletonMonobehaviour.IsAvailable) { SingletonMonobehaviour.Instance.DependencyAchievedChangedEvent -= this.DependencyAchievedChanged; this._watchingDependencyTree = false; } } protected void GameStateValueChanged(string key, object oldValue, object newValue) { if (key != null) { if (key == "TotalMinutesPlayed" || key == "TotalFiveMinuteSessions" || key == "currentRetentionReward" || key == "retentionRewardTimestamp") { return; } } UnityEngine.Debug.LogError(string.Format("GameStateValueChanged(string key '{0}', object oldValue '{1}', object newValue '{2}')", key, oldValue, newValue)); } protected void GameStatsValueChanged(string key, object oldValue, object newValue) { if (key != null) { if (key == "InterstitialsWatched" || key == "InterstitialsClicked" || key == "NumberOfScreenViews") { return; } } UnityEngine.Debug.LogErrorFormat("GameStatsValueChanged(string key '{0}', object oldValue '{1}', object newValue '{2}')", new object[] { key, oldValue, newValue }); } protected void DependencyAchievedChanged(Dependency dependency, bool achieved) { UnityEngine.Debug.LogError(string.Format("DependencyAchievedChanged(Dependency dependency '{0}', bool achieved '{1}')", dependency.Title ?? dependency.ToString(), achieved)); } private bool _watchingGameState; private bool _watchingGameStats; private bool _watchingDependencyTree; }