-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathGameSystem.cs
1182 lines (1032 loc) · 28.3 KB
/
GameSystem.cs
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using Assets.Scripts.Core.AssetManagement;
using Assets.Scripts.Core.Audio;
using Assets.Scripts.Core.Buriko;
using Assets.Scripts.Core.History;
using Assets.Scripts.Core.Interfaces;
using Assets.Scripts.Core.Scene;
using Assets.Scripts.Core.State;
using Assets.Scripts.Core.SteamWorks;
using Assets.Scripts.Core.TextWindow;
using Assets.Scripts.UI;
using Assets.Scripts.UI.CGGallery;
using Assets.Scripts.UI.Choice;
using Assets.Scripts.UI.Config;
using Assets.Scripts.UI.Prompt;
using MOD.Scripts.Core;
using MOD.Scripts.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using UnityEngine;
namespace Assets.Scripts.Core
{
public class GameSystem : MonoBehaviour
{
private const float maxProcTime = 0.01f;
private static GameSystem _instance;
public AssetManager AssetManager;
public AudioController AudioController;
public SceneController SceneController;
public MainUIController MainUIController;
public TextController TextController;
public TextHistory TextHistory;
public KeyHook KeyHook;
public GameObject UIControl;
public SteamController SteamController;
public LoggingLevel ConsoleLoggingLevel = LoggingLevel.All;
public LoggingLevel FileLoggingLevel = LoggingLevel.WarningsAndErrors;
public ChoiceController ChoiceController;
public IScriptInterpreter ScriptSystem;
public string ScriptInterpreterName;
public GameObject MenuPrefab;
public GameObject ScenePrefab;
public GameObject HistoryPrefab;
public GameObject TitlePrefab;
public GameObject PromptPrefab;
public GameObject ConfigPrefab;
public GameObject SaveLoadPrefab;
public GameObject ChapterJumpPrefab;
public GameObject GalleryPrefab;
public GameObject ChapterScreenPrefab;
public GameObject ExtraScreenPrefab;
public GameObject TipsPrefab;
public GameObject ChapterPreviewPrefab;
private PreparedAction actions;
public bool IsInitialized;
public bool IsSkipping;
public bool IsForceSkip;
public bool IsAuto;
public bool IsRunning;
public bool ForceForceSkip;
public bool CanSkip = true;
public bool CanSave = true;
public bool CanInput = true;
public bool CanReturn;
public bool UsePrompts = true;
public bool SkipUnreadMessages;
public bool SkipModeDelay = true;
public bool ClickDuringAuto;
public bool RightClickMenu = true;
public bool StopVoiceOnClick;
public bool UseSystemSounds = true;
public bool UseEnglishText = true;
public bool DisableUI;
private float skipWait = 0.1f;
private bool CanAdvance = true;
public bool CanExit;
private GameState gameState;
public bool MessageBoxVisible;
public float MessageWindowOpacity = 0.5f;
private bool ReopenMessageBox;
public readonly List<Wait> WaitList = new List<Wait>();
private MenuUIController menuUIController;
public MenuUIController MenuUIController() => menuUIController;
private HistoryWindow historyWindow;
private PromptController promptController;
private ConfigManager configManager;
public ConfigManager ConfigManager() => configManager;
private GalleryManager galleryManager;
private MGHelper.InputHandler inputHandler;
private IGameState curStateObj;
private float blockInputTime;
private int SystemInit = 1;
private Resolution fullscreenResolution;
private int screenModeSet = -1;
private Stack<StateEntry> stateStack = new Stack<StateEntry>();
public bool HasFocus;
public float AspectRatio;
private Thread CompileThread;
// Set to True to ignore normal gameplay inputs:
// - Disables normal inputs (e.g to advance text) in main GameSystem loop
// - Disables some GUI inputs by manually added checks in each button type
private bool _MODIgnoreInputs;
public bool MODIgnoreInputs() => _MODIgnoreInputs;
public void SetMODIgnoreInputs(bool value) => _MODIgnoreInputs = value;
// Unity will attempt to deserialize public properties and these aren't in the AssetBundle,
// so use private ones with public accessors
private bool _isFullscreen;
public bool IsFullscreen
{
get => _isFullscreen;
private set => _isFullscreen = value;
}
private bool hasBrokenWindowResize;
private float defaultAspect;
private float _configMenuFontSize = 0;
public float ConfigMenuFontSize
{
get => _configMenuFontSize;
set => _configMenuFontSize = value;
}
private float _chapterJumpFontSizeJapanese = 0;
private float _chapterJumpFontSizeEnglish = 0;
public float ChapterJumpFontSize => ChooseJapaneseEnglish(japanese: _chapterJumpFontSizeJapanese, english: _chapterJumpFontSizeEnglish);
public void SetChapterJumpFontSize(float japanese, float english)
{
_chapterJumpFontSizeJapanese = japanese;
_chapterJumpFontSizeEnglish = english;
}
private float _outlineWidth = 0.15f;
public float OutlineWidth
{
get => _outlineWidth;
set => _outlineWidth = value;
}
public static GameSystem Instance => _instance ?? (_instance = GameObject.Find("_GameSystem").GetComponent<GameSystem>());
public GameState GameState
{
get
{
return gameState;
}
set
{
Debug.Log("Changing game state to " + value);
gameState = value;
}
}
private void Initialize()
{
Logger.Log($"GameSystem: Starting GameSystem - DLL Version: {MODUtility.InformationalVersion()}");
MainUIController.InitializeToaster();
MODLocalization.LoadFromJSON();
IsInitialized = true;
AssetManager = new AssetManager();
AudioController = new AudioController();
TextController = new TextController();
TextHistory = new TextHistory();
IsRunning = false;
GameState = GameState.Normal;
curStateObj = new StateNormal();
IGameState obj = curStateObj;
inputHandler = obj.InputHandler;
MessageBoxVisible = false;
hasBrokenWindowResize = MODUtility.HasBrokenWindowResize() && MODUtility.PatchWindowResizeFunction();
if (!PlayerPrefs.HasKey("width"))
{
PlayerPrefs.SetInt("width", 1280);
}
if (!PlayerPrefs.HasKey("height"))
{
PlayerPrefs.SetInt("height", 720);
}
if (PlayerPrefs.GetInt("width") < 640)
{
PlayerPrefs.SetInt("width", 640);
}
if (PlayerPrefs.GetInt("height") < 480)
{
PlayerPrefs.SetInt("height", 480);
}
IsFullscreen = PlayerPrefs.GetInt("is_fullscreen", 0) == 1;
fullscreenResolution.width = 0;
fullscreenResolution.height = 0;
fullscreenResolution = GetFullscreenResolution();
if (IsFullscreen)
{
SetResolution(fullscreenResolution.width, fullscreenResolution.height, fullscreen: true);
}
else if (PlayerPrefs.HasKey("height") && PlayerPrefs.HasKey("width"))
{
int width = PlayerPrefs.GetInt("width");
int height = PlayerPrefs.GetInt("height");
Debug.Log("Requesting window size " + width + "x" + height + " based on config file");
SetResolution(width, height, fullscreen: false);
}
if ((Screen.width < 640 || Screen.height < 480) && !IsFullscreen)
{
SetResolution(640, 480, fullscreen: false);
}
Debug.Log("Starting compile thread...");
CompileThread = new Thread(CompileScripts)
{
IsBackground = true
};
CompileThread.Start();
if (Application.platform == RuntimePlatform.WindowsPlayer)
{
KeyHook = new KeyHook();
}
}
public void SetResolution(int width, int height, bool fullscreen)
{
Screen.SetResolution(width, height, fullscreen);
if (hasBrokenWindowResize)
{
MODUtility.X11ManualSetWindowSize(width, height);
}
}
public void StartScriptSystem()
{
Logger.Log("GameSystem: Starting ScriptInterpreter");
Type type = Type.GetType(ScriptInterpreterName);
if (type == null)
{
throw new Exception("Cannot find class " + ScriptInterpreterName + " through reflection!");
}
ScriptSystem = (Activator.CreateInstance(type) as IScriptInterpreter);
if (ScriptSystem == null)
{
throw new Exception("Failed to instantiate ScriptSystem!");
}
ScriptSystem.Initialize(this);
}
public void CompileScripts()
{
try
{
Debug.Log("Compiling!");
AssetManager.CompileIfNeeded();
}
catch (Exception arg)
{
Logger.LogError($"Unable to load Script Interpreter of type {ScriptInterpreterName}!\r\n{arg}");
throw;
}
}
public void PostLoading()
{
StartScriptSystem();
MainUIController.InitializeModMenu(this);
}
public void SetDefaultAspect(float defaultAspect)
{
this.defaultAspect = defaultAspect;
}
public void UpdateAspectRatio() => UpdateAspectRatio(defaultAspect);
public void UpdateAspectRatio(float newratio)
{
AspectRatio = newratio;
if (BurikoMemory.Instance.GetGlobalFlag("GRyukishiMode43Aspect").IntValue() != 0)
{
AspectRatio = 4f / 3f;
}
// Text window may need to be resized to fit different screen size due to aspect ratio change
MODActions.SetTextWindowAppearance((MODActions.ModPreset)MODActions.GetADVNVLRyukishiModeFromFlags(), showInfoToast: false);
if (!IsFullscreen)
{
int width = Mathf.RoundToInt((float)Screen.height * AspectRatio);
SetResolution(width, Screen.height, fullscreen: false);
}
PlayerPrefs.SetInt("width", Mathf.RoundToInt(PlayerPrefs.GetInt("height") * AspectRatio));
MainUIController.UpdateBlackBars();
SceneController.UpdateScreenSize();
}
public void CheckinSystem()
{
SystemInit--;
}
public void ForceReturnNormalState()
{
stateStack.Clear();
curStateObj = new StateNormal();
IGameState obj = curStateObj;
inputHandler = obj.InputHandler;
GameState = GameState.Normal;
}
public void PopStateStack()
{
if (stateStack.Count == 0)
{
Debug.Log("PopStateStack has no state to remove.");
curStateObj = new StateNormal();
IGameState obj = curStateObj;
inputHandler = obj.InputHandler;
GameState = GameState.Normal;
}
else
{
if (curStateObj != null)
{
Debug.Log("PopStateStack - Calling OnLeaveState");
curStateObj.OnLeaveState();
curStateObj = null;
}
StateEntry stateEntry = stateStack.Pop();
inputHandler = stateEntry.InputHandler;
GameState = stateEntry.State;
curStateObj = stateEntry.StateObject;
if (curStateObj != null)
{
curStateObj.OnRestoreState();
}
Debug.Log("StateStack now has " + stateStack.Count + " entries.");
}
}
private void PushStateStack(MGHelper.InputHandler newHandler, GameState newState)
{
if (curStateObj != null)
{
stateStack.Push(new StateEntry(curStateObj, GameState));
}
else
{
stateStack.Push(new StateEntry(inputHandler, GameState));
}
inputHandler = newHandler;
GameState = newState;
curStateObj = null;
}
public void PushStateObject(IGameState stateObject)
{
if (curStateObj != null)
{
stateStack.Push(new StateEntry(curStateObj, GameState));
}
else
{
stateStack.Push(new StateEntry(inputHandler, GameState));
}
curStateObj = stateObject;
IGameState obj = curStateObj;
inputHandler = obj.InputHandler;
GameState = curStateObj.GetStateType();
}
public IGameState GetStateObject()
{
return curStateObj;
}
public void ClearActions()
{
actions = null;
}
public void RegisterAction(PreparedAction action)
{
actions = (PreparedAction)Delegate.Combine(actions, action);
}
public void ExecuteActions()
{
StartCoroutine(ActionRunner());
CanAdvance = false;
}
private IEnumerator ActionRunner()
{
Resources.UnloadUnusedAssets();
yield return (object)null;
yield return (object)null;
if (actions != null)
{
actions();
}
actions = null;
CanAdvance = true;
}
public void HideUIControls()
{
DisableUI = true;
UIControl.SetActive(value: false);
}
public void ShowUIControls()
{
DisableUI = false;
UIControl.SetActive(value: true);
}
public void CloseChoiceIfExists()
{
if (ChoiceController != null)
{
if (GameSystem.Instance.GameState == GameState.ChoiceScreen)
{
// If you're currently on the choice screen, then cleanly leave the choices state and delete the choice controller
LeaveChoices();
}
else
{
// If you're on another screen layered ontop of the choice screen (eg the load screen), just delete the choice controller and hope for the best.
ChoiceController.Destroy();
ChoiceController = null;
}
}
}
public void LeaveChoices()
{
PopStateStack();
AddWait(new Wait(ChoiceButton.fadeTime, WaitTypes.WaitForTime, delegate
{
ChoiceController.Destroy();
ChoiceController = null;
}));
ExecuteActions();
}
public void DisplayChoices(List<string> options, int count)
{
if (ChoiceController != null)
{
ChoiceController.Destroy();
ChoiceController = null;
}
PushStateStack(ChoiceHandleInput, GameState.ChoiceScreen);
ChoiceController = new ChoiceController();
ChoiceController.Create(options, count);
}
private bool ChoiceHandleInput()
{
if (Input.GetKeyDown(KeyCode.Space))
{
SwitchToViewMode();
return false;
}
if (Input.GetMouseButtonDown(1))
{
if (IsSkipping && !IsForceSkip)
{
IsSkipping = false;
return false;
}
if (IsAuto)
{
IsAuto = false;
return false;
}
}
if (Input.GetMouseButtonDown(1) && MessageBoxVisible)
{
SwitchToRightClickMenu();
return false;
}
return false;
}
private bool HiddenMessageWindowHandleInput()
{
if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Escape))
{
PopStateStack();
UpdateWaits();
MessageBoxVisible = true;
MainUIController.FadeIn(0.2f);
SceneController.RevealFace(0.2f);
ExecuteActions();
blockInputTime = 0.25f;
}
return false;
}
public void LeaveMenu(MenuUIController.MenuCloseDelegate onClose, bool doPop)
{
menuUIController.LeaveMenu(delegate
{
if (doPop)
{
PopStateStack();
}
UpdateWaits();
ExecuteActions();
if (onClose != null)
{
onClose();
}
}, showMessage: false);
}
public void SwitchToHiddenWindow2()
{
MainUIController.FadeOut(0.3f, isBlocking: false);
SceneController.HideFace(0.3f);
ExecuteActions();
PushStateStack(HiddenMessageWindowHandleInput, GameState.HiddenMessageWindow);
}
public void SwitchToHiddenWindow()
{
menuUIController.LeaveMenu(delegate
{
PopStateStack();
UpdateWaits();
ExecuteActions();
PushStateStack(HiddenMessageWindowHandleInput, GameState.HiddenMessageWindow);
}, showMessage: false);
}
public void LeaveGalleryScreen(GalleryManager.GalleryCloseCallback callback)
{
if (!(galleryManager == null))
{
inputHandler = null;
galleryManager.Close(delegate
{
PopStateStack();
ExecuteActions();
galleryManager = null;
if (callback != null)
{
callback();
}
});
}
}
public void LeaveConfigScreen(ConfigManager.LeaveConfigDelegate callback)
{
inputHandler = null;
configManager.Leave(delegate
{
PopStateStack();
ExecuteActions();
if (callback != null)
{
callback();
}
});
}
public void RevealMessageBox()
{
MessageBoxVisible = true;
MainUIController.FadeIn(0.5f);
SceneController.RevealFace(0.5f);
ExecuteActions();
}
private bool MenuHandleInput()
{
if (Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.Escape))
{
menuUIController.LeaveMenu(delegate
{
PopStateStack();
UpdateWaits();
MessageBoxVisible = true;
MainUIController.ShowMessageBox();
ExecuteActions();
}, showMessage: true);
}
return false;
}
private void UpdateCarret()
{
if (IsSkipping || IsAuto || GameState != GameState.Normal)
{
MainUIController.HideCarret();
}
else if (WaitList.Exists((Wait a) => a.Type == WaitTypes.WaitForInput) && !WaitList.Exists((Wait a) => a.Type == WaitTypes.WaitForText) && !TextController.IsTyping() && MessageBoxVisible)
{
MainUIController.ShowCarret();
}
else
{
MainUIController.HideCarret();
}
}
public void SwitchToConfig(int configtype, bool showMessageWindow)
{
ReopenMessageBox = showMessageWindow;
RegisterAction(delegate
{
PushStateStack(ConfigHandleInput, GameState.ConfigScreen);
GameObject gameObject = UnityEngine.Object.Instantiate(ConfigPrefab);
configManager = gameObject.GetComponent<ConfigManager>();
if (configManager == null)
{
throw new Exception("Failed to instantiate configManager!");
}
configManager.Open(configtype, showMessageWindow);
});
ExecuteActions();
}
public void SwitchToGallery()
{
if (galleryManager != null)
{
Debug.Log(galleryManager);
PushStateStack(GalleryHandleInput, GameState.CGGallery);
ExecuteActions();
}
else
{
RegisterAction(delegate
{
PushStateStack(GalleryHandleInput, GameState.CGGallery);
GameObject gameObject = UnityEngine.Object.Instantiate(GalleryPrefab);
galleryManager = gameObject.GetComponent<GalleryManager>();
if (galleryManager == null)
{
throw new Exception("Failed to instantiate GalleryManager!");
}
galleryManager.Open();
});
ExecuteActions();
}
}
public void SwitchToViewMode()
{
PushStateStack(HiddenMessageWindowHandleInput, GameState.HiddenMessageWindow);
MainUIController.FadeOut(0.2f, isBlocking: false);
SceneController.HideFace(0.2f);
ExecuteActions();
blockInputTime = 0.25f;
}
public void SwitchToHistoryScreen()
{
PushStateObject(new StateHistory());
}
public void SwitchToRightClickMenu()
{
PushStateStack(MenuHandleInput, GameState.RightClickMenu);
GameObject gameObject = UnityEngine.Object.Instantiate(MenuPrefab);
menuUIController = gameObject.GetComponent<MenuUIController>();
if (menuUIController == null)
{
throw new Exception("Failed to instantiate MenuUIController!");
}
MainUIController.FadeOut(0.3f, isBlocking: false);
SceneController.HideFace(0.3f);
ExecuteActions();
}
private bool GalleryHandleInput()
{
if (Input.GetMouseButtonDown(1))
{
PopStateStack();
BurikoMemory.Instance.SetFlag("LOCALWORK_NO_RESULT", 0);
return false;
}
return false;
}
private bool ConfigHandleInput()
{
if (Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.Escape))
{
LeaveConfigScreen(null);
}
return false;
}
public void ClearAllWaits()
{
WaitList.ForEach(delegate(Wait a)
{
a.Finish();
});
WaitList.RemoveAll((Wait a) => a.IsActive);
}
public bool HasWaitOfType(WaitTypes type)
{
return WaitList.Exists((Wait f) => f.Type == type);
}
public void ClearTextWait(bool finish)
{
List<Wait> list = (from a in WaitList
where a.Type == WaitTypes.WaitForText
select a).ToList();
foreach (Wait item in list)
{
if (finish)
{
item.Finish();
}
WaitList.Remove(item);
}
TextController.FinishTyping();
}
public void ClearVoiceWaits()
{
WaitList.RemoveAll((Wait a) => a.Type == WaitTypes.WaitForVoice);
}
public void ClearInputWaits()
{
if (IsAuto)
{
}
}
public void ClearWait()
{
if (WaitList.Exists((Wait a) => a.Type == WaitTypes.WaitForText) && !IsSkipping)
{
ClearTextWait(finish: true);
}
else
{
WaitList.ForEach(delegate(Wait a)
{
a.Finish();
});
WaitList.RemoveAll((Wait a) => a.IsActive);
if (StopVoiceOnClick)
{
AudioController.StopAllVoice();
}
}
}
public void AddWait(Wait newWait)
{
WaitList.Add(newWait);
}
private bool HasExistingWaits()
{
bool result = WaitList.Count != 0;
WaitList.RemoveAll((Wait a) => !a.IsRunning());
if (IsAuto)
{
WaitList.RemoveAll((Wait a) => a.Type == WaitTypes.WaitForInput);
}
return result;
}
public void UpdateWaits()
{
WaitList.ForEach(delegate(Wait a)
{
a.Update();
});
}
public IEnumerator FrameWaitForFullscreen(int width, int height, bool fullscreen)
{
yield return (object)new WaitForEndOfFrame();
yield return (object)new WaitForFixedUpdate();
IsFullscreen = fullscreen;
PlayerPrefs.SetInt("is_fullscreen", fullscreen ? 1 : 0);
SetResolution(width, height, fullscreen);
while (Screen.width != width || Screen.height != height)
{
yield return (object)null;
}
}
public void GoFullscreen()
{
IsFullscreen = true;
PlayerPrefs.SetInt("is_fullscreen", 1);
Resolution resolution = GetFullscreenResolution();
SetResolution(resolution.width, resolution.height, fullscreen: true);
Debug.Log(resolution.width + " , " + resolution.height);
PlayerPrefs.SetInt("fullscreen_width", resolution.width);
PlayerPrefs.SetInt("fullscreen_height", resolution.height);
}
public void DeFullscreen(int width, int height)
{
IsFullscreen = false;
PlayerPrefs.SetInt("is_fullscreen", 0);
SetResolution(width, height, fullscreen: false);
}
private void OnApplicationFocus(bool focusStatus)
{
HasFocus = focusStatus;
}
private void LateUpdate()
{
if (screenModeSet == -1)
{
screenModeSet = 0;
fullscreenResolution = Screen.currentResolution;
if (PlayerPrefs.HasKey("fullscreen_width") && PlayerPrefs.HasKey("fullscreen_height") && Screen.fullScreen)
{
fullscreenResolution.width = PlayerPrefs.GetInt("fullscreen_width");
fullscreenResolution.height = PlayerPrefs.GetInt("fullscreen_height");
}
Debug.Log("Fullscreen Resolution: " + fullscreenResolution.width + ", " + fullscreenResolution.height);
}
}
private bool CheckInitialization()
{
if (!IsInitialized)
{
Initialize();
return false;
}
if (!IsRunning)
{
if (CompileThread == null || CompileThread.IsAlive)
{
if (AssetManager.MaxLoading > 0)
{
MODToaster.Show("Preparing scripts (" + AssetManager.CurrentLoading + " of " + AssetManager.MaxLoading + ")...", maybeSound: null);
}
return false;
}
IsRunning = true;
PostLoading();
}
if (SystemInit > 0)
{
return false;
}
return true;
}
private void Update()
{
if (!CheckInitialization())
{
return;
}
Logger.Update();
if (blockInputTime <= 0f)
{
if ((CanInput || GameState != GameState.Normal) && (MODIgnoreInputs() || inputHandler == null || !inputHandler()))
{
return;
}
}
else
{
blockInputTime -= Time.deltaTime;
}
if (IsRunning && CanAdvance)
{
UpdateWaits();
UpdateCarret();
try
{
if (GameState == GameState.Normal)
{
TextController.Update();
if (!IsSkipping)
{
goto IL_0112;
}
skipWait -= Time.deltaTime;
if (!(skipWait <= 0f))
{
goto IL_0112;
}
if (!HasExistingWaits())
{
if (SkipModeDelay)
{
skipWait = 0.1f;
}
goto IL_0112;
}
ClearAllWaits();
}
goto end_IL_00a2;
IL_0112:
float num = Time.time + 0.01f;
while (!HasExistingWaits() && !(Time.time > num) && !HasExistingWaits() && CanAdvance)
{
ScriptSystem.Advance();
}
end_IL_00a2:;
}
catch (Exception)
{
IsRunning = false;
throw;
IL_0178:;
}
}
}