forked from akanyan/mu3-mods
feat!: rename and reorganize
This commit is contained in:
40
Enhancements/Pause/MU3.Sequence/patch_PlayMusic.cs
Normal file
40
Enhancements/Pause/MU3.Sequence/patch_PlayMusic.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using MonoMod;
|
||||
using MU3.Battle;
|
||||
using MU3.Game;
|
||||
using MU3.Notes;
|
||||
using MU3.Util;
|
||||
|
||||
namespace MU3.Sequence;
|
||||
|
||||
class patch_PlayMusic: PlayMusic {
|
||||
private static readonly float PAUSE_CD = 5f;
|
||||
private static readonly float UNPAUSE_CD = 0.5f;
|
||||
private GameEngine _gameEngine;
|
||||
private NotesManager ntMgr => _gameEngine?.notesManager;
|
||||
private patch_GameBGM pgm => (patch_GameBGM)Singleton<GameSound>.instance.gameBGM;
|
||||
public static bool Paused = false;
|
||||
private float pauseTimer = 0f;
|
||||
|
||||
[MonoModIgnore]
|
||||
private extern bool isPartyPlay();
|
||||
|
||||
private extern void orig_Enter_SetupScene();
|
||||
private void Enter_SetupScene() {
|
||||
orig_Enter_SetupScene();
|
||||
Paused = false;
|
||||
}
|
||||
|
||||
public extern bool orig_updateState(float deltaTime = -1f);
|
||||
public override bool updateState(float deltaTime = -1f) {
|
||||
pauseTimer += deltaTime;
|
||||
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.Service) && !Singleton<UIInput>.instance.getStateOn(UIInput.Key.Test)) {
|
||||
if((!Paused && pauseTimer >= PAUSE_CD) || (Paused && pauseTimer >= UNPAUSE_CD) && !isPartyPlay()) {
|
||||
Paused = !Paused;
|
||||
pgm.pause(Paused);
|
||||
ntMgr.setPause(Paused);
|
||||
pauseTimer = 0f;
|
||||
}
|
||||
}
|
||||
return orig_updateState(deltaTime);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user