summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XShell.cs
blob: 81f4ee457dccdbe2cee52abe18e5758500a982ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
using System;
using System.Reflection;
using UnityEngine;
using UnityEngine.SceneManagement;
using XUtliPoolLib;

namespace XUpdater
{
	public sealed class XShell : XSingleton<XShell>
	{
		public bool Pause
		{
			get
			{
				return this._bPause;
			}
			set
			{
				bool isDone = XSingleton<XUpdater>.singleton.IsDone;
				if (isDone)
				{
					this._bPauseTrigger = value;
				}
			}
		}

		public float CurrentTimeMagic
		{
			get
			{
				return Time.timeScale;
			}
		}

		public static readonly int TargetFrame = 30;

		private float _time_scale = 1f;

		private bool _bPause = false;

		private bool _bPauseTrigger = false;

		private IEntrance _entrance = null;

		public void PreLaunch()
		{
			this._entrance.Awake();
			bool flag = this._entrance != null;
			if (flag)
			{
				IPlatform xplatform = XSingleton<XUpdater>.singleton.XPlatform;
				bool flag2 = xplatform != null;
				if (flag2)
				{
					this._entrance.SetQualityLevel(xplatform.GetQualityLevel());
				}
			}
		}

		public void Launch()
		{
			this._entrance.Awake();
		}

		public bool Launched()
		{
			return this._entrance.Awaked;
		}

		public void StartGame()
		{
			this._entrance.Start();
		}

		public void Awake()
		{
			bool flag = !XSingleton<XUpdater>.singleton.IsDone;
			if (flag)
			{
				XSingleton<XUpdater>.singleton.Init();
			}
		}

		public void Start()
		{
			Screen.sleepTimeout = -1;
			Application.targetFrameRate = -1;
		}

		private void NetUpdate()
		{
			this._entrance.NetUpdate();
		}

		public void PreUpdate()
		{
			this.NetUpdate();
			bool pause = this.Pause;
			if (!pause)
			{
				this._entrance.PreUpdate();
			}
		}

		public void Update()
		{
			bool isDone = XSingleton<XUpdater>.singleton.IsDone;
			if (isDone)
			{
				XSingleton<XTimerMgr>.singleton.updateStartTime = Time.time;
				this.PreUpdate();
				bool pause = this.Pause;
				if (!pause)
				{
					bool update = XSingleton<XTimerMgr>.singleton.update;
					if (update)
					{
						XSingleton<XTimerMgr>.singleton.Update(Time.deltaTime);
					}
					bool needFixedUpdate = XSingleton<XTimerMgr>.singleton.NeedFixedUpdate;
					if (needFixedUpdate)
					{
						XSingleton<XResourceLoaderMgr>.singleton.Update(Time.deltaTime);
					}
					XSingleton<XEngineCommandMgr>.singleton.Update();
					this._entrance.Update();
				}
			}
			else
			{
				XSingleton<XTimerMgr>.singleton.Update(Time.deltaTime);
				XSingleton<XUpdater>.singleton.Update();
			}
		}

		public void PostUpdate()
		{
			bool isDone = XSingleton<XUpdater>.singleton.IsDone;
			if (isDone)
			{
				this.PauseChecker();
				this._entrance.FadeUpdate();
				bool pause = this.Pause;
				if (pause)
				{
					return;
				}
				this._entrance.PostUpdate();
				XSingleton<XTimerMgr>.singleton.PostUpdate();
			}
			bool reboot = XSingleton<XUpdater>.singleton.Reboot;
			if (reboot)
			{
				this.Quit();
				SceneManager.LoadScene(0);
			}
		}

		public void Quit()
		{
			bool isDone = XSingleton<XUpdater>.singleton.IsDone;
			if (isDone)
			{
				this._entrance.Quit();
			}
			XSingleton<XUpdater>.singleton.Uninit();
		}

		public void MakeEntrance(Assembly main)
		{
			Type type = main.GetType("XMainClient.XGameEntrance");
			MethodInfo method = type.GetMethod("Fire");
			method.Invoke(null, null);
			this._entrance = XSingleton<XInterfaceMgr>.singleton.GetInterface<IEntrance>(0u);
		}

		//!
		public void _MakeEntrance()
		{
			XMainClient.XGameEntrance.Fire();
			this._entrance = XSingleton<XInterfaceMgr>.singleton.GetInterface<IEntrance>(0u);
		}

		public float TimeMagic(float value)
		{
			bool flag = Time.timeScale == 1f && !this._bPause;
			if (flag)
			{
				Time.timeScale = value;
				this._time_scale = value;
			}
			return Time.timeScale;
		}

		public void TimeMagicBack()
		{
			Time.timeScale = 1f;
			this._time_scale = 1f;
		}

		private void PauseChecker()
		{
			bool flag = this._bPause == this._bPauseTrigger;
			if (!flag)
			{
				this._bPause = this._bPauseTrigger;
				Time.timeScale = (this._bPause ? 0f : this._time_scale);
			}
		}

		public override bool Init()
		{
			return true;
		}

		public override void Uninit()
		{
		}

		public void MonoObjectRegister(string key, MonoBehaviour behavior)
		{
			bool flag = this._entrance != null;
			if (flag)
			{
				this._entrance.MonoObjectRegister(key, behavior);
			}
		}
	}
}