forked from akanyan/mu3-mods
Now a dialog. * Also fix the new BetterGiveUp panic restart * Also move SortByInternal's PNG away from the root namespace
87 lines
2.1 KiB
C#
87 lines
2.1 KiB
C#
using MU3.Collab;
|
|
using MU3.DB;
|
|
using MU3.Game;
|
|
using MU3.Notes;
|
|
using MU3.Util;
|
|
using System.Collections;
|
|
using System.Reflection;
|
|
using UnityEngine;
|
|
|
|
namespace MU3.Battle;
|
|
|
|
class patch_GameEngine: GameEngine {
|
|
private static readonly float PAUSE_CD = 5f;
|
|
|
|
private NotesManager _notesManager;
|
|
|
|
private static bool _paused;
|
|
private float _pauseTimer;
|
|
private UIDialog _dialog;
|
|
|
|
public extern void orig_reset();
|
|
public new void reset() {
|
|
orig_reset();
|
|
togglePause(false);
|
|
_pauseTimer = 0;
|
|
|
|
if(_dialog != null) {
|
|
_dialog.forceCancel();
|
|
_dialog = null;
|
|
}
|
|
}
|
|
|
|
public extern void orig_execute();
|
|
public new void execute() {
|
|
if(_paused) {
|
|
return;
|
|
}
|
|
|
|
orig_execute();
|
|
|
|
_pauseTimer -= Time.deltaTime;
|
|
|
|
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.Service)) {
|
|
if(_pauseTimer < 0f && !isPartyPlay() && notesManager.isPlaying) {
|
|
togglePause(true);
|
|
_dialog = UIDialog.create(DialogID.LackOfGP, "Pause", (int _, bool _) => togglePause(false));
|
|
StartCoroutine(killTimer(_dialog));
|
|
}
|
|
}
|
|
}
|
|
|
|
private void togglePause(bool value) {
|
|
((patch_GameBGM)Singleton<GameSound>.instance.gameBGM).pause(value);
|
|
_paused = value;
|
|
_notesManager.setPause(value);
|
|
_pauseTimer = PAUSE_CD;
|
|
}
|
|
|
|
private IEnumerator killTimer(UIDialog dialog) {
|
|
var fi = typeof(UIDialog).GetField("uiTimer_", BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
if(fi == null) {
|
|
yield break;
|
|
}
|
|
|
|
int limit = 500;
|
|
UITimer timer;
|
|
do {
|
|
yield return new WaitForEndOfFrame();
|
|
timer = (UITimer)fi.GetValue(dialog);
|
|
if(--limit == 0) {
|
|
yield break;
|
|
}
|
|
} while(timer == null);
|
|
|
|
timer.Pause = true;
|
|
timer.Show = false;
|
|
timer.enabled = false;
|
|
|
|
yield break;
|
|
}
|
|
|
|
private bool isPartyPlay() {
|
|
Party.IManager manager = Party.get();
|
|
return manager != null && manager.isJoinAndActive();
|
|
}
|
|
} |