forked from akanyan/mu3-mods
fix(BetterGiveUp): proper hard resets
This commit is contained in:
7
Enhancements/BetterGiveUp/MU3.Mod/State.cs
Normal file
7
Enhancements/BetterGiveUp/MU3.Mod/State.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
using MU3.Util;
|
||||||
|
|
||||||
|
namespace MU3.Mod;
|
||||||
|
|
||||||
|
class State: Singleton<State> {
|
||||||
|
public bool SkipPlay { get; set; }
|
||||||
|
}
|
@ -11,81 +11,45 @@ namespace MU3.Sequence;
|
|||||||
class patch_PlayMusic: PlayMusic {
|
class patch_PlayMusic: PlayMusic {
|
||||||
private static readonly TimeSpan HOLD_DURATION = TimeSpan.FromSeconds(1.0f);
|
private static readonly TimeSpan HOLD_DURATION = TimeSpan.FromSeconds(1.0f);
|
||||||
private static readonly TimeSpan ROLL_DURATION = TimeSpan.FromSeconds(0.5f);
|
private static readonly TimeSpan ROLL_DURATION = TimeSpan.FromSeconds(0.5f);
|
||||||
public static bool QuickSkip = false;
|
|
||||||
private GameEngine _gameEngine;
|
private GameEngine _gameEngine;
|
||||||
private SessionInfo _sessionInfo;
|
private SessionInfo _sessionInfo;
|
||||||
|
private patch_NotesManager ntMgr => (patch_NotesManager)_gameEngine?.notesManager;
|
||||||
|
|
||||||
private bool _pressedYellow;
|
private bool _pressedYellow;
|
||||||
private bool _isRolling;
|
private bool _isRolling;
|
||||||
private float _totalRollingFrame;
|
private float _totalRollingFrame;
|
||||||
private DateTime _rollingStartTime;
|
private DateTime _rollingStartTime;
|
||||||
private bool _isHoldingAck;
|
private bool _isHoldingAck;
|
||||||
private DateTime _holdingStartTime;
|
private DateTime _holdingStartTime;
|
||||||
private float enemyPosX;
|
private float _enemyPosX;
|
||||||
private patch_NotesManager ntMgr => (patch_NotesManager)_gameEngine?.notesManager;
|
|
||||||
|
|
||||||
[MonoModIgnore]
|
[MonoModIgnore]
|
||||||
private extern bool isPartyPlay();
|
private extern bool isPartyPlay();
|
||||||
|
|
||||||
public static double FadeOut(double progress, double min, double max) {
|
|
||||||
return min + (max - min) * (1.0 - Math.Pow(1.0 - progress, 2.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double FadeIn(double progress, double min, double max) {
|
|
||||||
return min + (max - min) * Math.Pow(progress, 2.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsHolding() {
|
|
||||||
return Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuLeft)
|
|
||||||
^ (_pressedYellow && Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuRight));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void StartRolling() {
|
|
||||||
_pressedYellow = false;
|
|
||||||
_isRolling = true;
|
|
||||||
_totalRollingFrame = ntMgr.getCurrentFrame();
|
|
||||||
_rollingStartTime = CustomDateTime.Now;
|
|
||||||
enemyPosX = ntMgr.getEnemyPos().x;
|
|
||||||
ntMgr.forceRecover(recover: 100);
|
|
||||||
Singleton<GameSound>.instance.gameBGM.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EndRolling() {
|
|
||||||
_isRolling = false;
|
|
||||||
ntMgr.stopPlay();
|
|
||||||
ntMgr.setPause(false);
|
|
||||||
ntMgr.reset();
|
|
||||||
ntMgr.reloadScore(_gameEngine.IsStageDazzling);
|
|
||||||
_gameEngine.counters.reset();
|
|
||||||
_gameEngine.battleReward.initialize(_sessionInfo);
|
|
||||||
_gameEngine.enemyManager.destroy();
|
|
||||||
_gameEngine.enemyManager.initialize();
|
|
||||||
_gameEngine.reset();
|
|
||||||
Singleton<GameSound>.instance.gameBGM.playMusic(_sessionInfo.musicData, 0);
|
|
||||||
ntMgr.startPlay(0.0f);
|
|
||||||
ntMgr.led.setGameColor(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private extern void orig_Execute_Play();
|
private extern void orig_Execute_Play();
|
||||||
private void Execute_Play() {
|
private void Execute_Play() {
|
||||||
if(isPartyPlay()) {
|
if(isPartyPlay() || _sessionInfo.isTutorial) {
|
||||||
|
orig_Execute_Play();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuRight)) {
|
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuRight)) {
|
||||||
_pressedYellow = true;
|
_pressedYellow = true;
|
||||||
}
|
}
|
||||||
if(_isRolling) {
|
if(_isRolling) {
|
||||||
TimeSpan timeSpan = CustomDateTime.Now - _rollingStartTime;
|
TimeSpan timeSpan = CustomDateTime.Now - _rollingStartTime;
|
||||||
if(timeSpan <= ROLL_DURATION) {
|
if(timeSpan <= ROLL_DURATION) {
|
||||||
double num1 = FadeOut(timeSpan.TotalMilliseconds / ROLL_DURATION.TotalMilliseconds, 0.0, 1.0);
|
double num1 = fadeOut(timeSpan.TotalMilliseconds / ROLL_DURATION.TotalMilliseconds, 0.0, 1.0);
|
||||||
double num2 = FadeIn(timeSpan.TotalMilliseconds / ROLL_DURATION.TotalMilliseconds, 0.0, 1.0);
|
double num2 = fadeIn(timeSpan.TotalMilliseconds / ROLL_DURATION.TotalMilliseconds, 0.0, 1.0);
|
||||||
ntMgr.setFrameForce(_totalRollingFrame * (float)(1.0 - num1));
|
ntMgr.setFrameForce(_totalRollingFrame * (float)(1.0 - num1));
|
||||||
ntMgr.enemyOffset = new Vector3(
|
ntMgr.enemyOffset = new Vector3(
|
||||||
ntMgr.enemyOffset.x + (enemyPosX - ntMgr.getEnemyPos().x), 20f * (float)num2, 0.0f
|
ntMgr.enemyOffset.x + (_enemyPosX - ntMgr.getEnemyPos().x), 20f * (float)num2, 0.0f
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
EndRolling();
|
endRolling();
|
||||||
}
|
}
|
||||||
} else if(IsHolding() && !_sessionInfo.isTutorial) {
|
} else if(isHolding()) {
|
||||||
if(!_isHoldingAck) {
|
if(!_isHoldingAck) {
|
||||||
_holdingStartTime = CustomDateTime.Now;
|
_holdingStartTime = CustomDateTime.Now;
|
||||||
_isHoldingAck = true;
|
_isHoldingAck = true;
|
||||||
@ -95,12 +59,12 @@ class patch_PlayMusic: PlayMusic {
|
|||||||
if(ts > HOLD_DURATION) {
|
if(ts > HOLD_DURATION) {
|
||||||
if(Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuRight)) {
|
if(Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuRight)) {
|
||||||
if(ntMgr.retireResult != RetireResult.None) {
|
if(ntMgr.retireResult != RetireResult.None) {
|
||||||
setNextState(EState.Init);
|
hardReset();
|
||||||
} else {
|
} else {
|
||||||
StartRolling();
|
startRolling();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QuickSkip = true;
|
Singleton<Mod.State>.instance.SkipPlay = true;
|
||||||
setNextState(EState.End);
|
setNextState(EState.End);
|
||||||
destroy();
|
destroy();
|
||||||
ntMgr.stopPlay();
|
ntMgr.stopPlay();
|
||||||
@ -115,11 +79,59 @@ class patch_PlayMusic: PlayMusic {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void listenForPanicRestart() {
|
private static double fadeOut(double progress, double min, double max) {
|
||||||
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuRight) && ntMgr.retireResult != RetireResult.None && !isPartyPlay()) {
|
return min + (max - min) * (1.0 - Math.Pow(1.0 - progress, 2.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double fadeIn(double progress, double min, double max) {
|
||||||
|
return min + (max - min) * Math.Pow(progress, 2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool isHolding() {
|
||||||
|
return Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuLeft)
|
||||||
|
^ (_pressedYellow && Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuRight));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hardReset() {
|
||||||
|
ntMgr.stopPlay();
|
||||||
|
ntMgr.setPause(false);
|
||||||
|
_gameEngine.reset();
|
||||||
Singleton<GameSound>.instance.gameBGM.stop();
|
Singleton<GameSound>.instance.gameBGM.stop();
|
||||||
setNextState(EState.Init);
|
setNextState(EState.Init);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startRolling() {
|
||||||
|
_pressedYellow = false;
|
||||||
|
_isRolling = true;
|
||||||
|
_totalRollingFrame = ntMgr.getCurrentFrame();
|
||||||
|
_rollingStartTime = CustomDateTime.Now;
|
||||||
|
_enemyPosX = ntMgr.getEnemyPos().x;
|
||||||
|
ntMgr.forceRecover(recover: 100);
|
||||||
|
Singleton<GameSound>.instance.gameBGM.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void endRolling() {
|
||||||
|
_isRolling = false;
|
||||||
|
|
||||||
|
ntMgr.stopPlay();
|
||||||
|
ntMgr.setPause(false);
|
||||||
|
ntMgr.reset();
|
||||||
|
_gameEngine.counters.reset();
|
||||||
|
_gameEngine.enemyManager.destroy();
|
||||||
|
|
||||||
|
ntMgr.reloadScore(_gameEngine.IsStageDazzling);
|
||||||
|
_gameEngine.battleReward.initialize(_sessionInfo);
|
||||||
|
_gameEngine.enemyManager.initialize();
|
||||||
|
_gameEngine.reset();
|
||||||
|
ntMgr.startPlay(0.0f);
|
||||||
|
ntMgr.led.setGameColor(true);
|
||||||
|
Singleton<GameSound>.instance.gameBGM.playMusic(_sessionInfo.musicData, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void listenForPanicRestart() {
|
||||||
|
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuRight) && ntMgr.retireResult != RetireResult.None && !isPartyPlay()) {
|
||||||
|
hardReset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private extern void orig_Execute_DispCombo();
|
private extern void orig_Execute_DispCombo();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using MU3.Sequence;
|
using MU3.Util;
|
||||||
|
|
||||||
namespace MU3;
|
namespace MU3;
|
||||||
|
|
||||||
@ -6,8 +6,8 @@ class patch_Scene_32_PrePlayMusic_MusicSelect: Scene_32_PrePlayMusic_MusicSelect
|
|||||||
private bool _playVoice;
|
private bool _playVoice;
|
||||||
private extern void orig_Enter_Select();
|
private extern void orig_Enter_Select();
|
||||||
private void Enter_Select() {
|
private void Enter_Select() {
|
||||||
if(patch_PlayMusic.QuickSkip) {
|
if(Singleton<Mod.State>.instance.SkipPlay) {
|
||||||
patch_PlayMusic.QuickSkip = false;
|
Singleton<Mod.State>.instance.SkipPlay = false;
|
||||||
_playVoice = false;
|
_playVoice = false;
|
||||||
}
|
}
|
||||||
orig_Enter_Select();
|
orig_Enter_Select();
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using MonoMod;
|
using MonoMod;
|
||||||
using MU3.Sequence;
|
|
||||||
using MU3.Util;
|
using MU3.Util;
|
||||||
|
|
||||||
namespace MU3;
|
namespace MU3;
|
||||||
@ -15,7 +14,7 @@ class patch_Scene_37_Result: Scene_37_Result {
|
|||||||
private extern void orig_Init_Init();
|
private extern void orig_Init_Init();
|
||||||
private void Init_Init() {
|
private void Init_Init() {
|
||||||
orig_Init_Init();
|
orig_Init_Init();
|
||||||
if(patch_PlayMusic.QuickSkip) {
|
if(Singleton<Mod.State>.instance.SkipPlay) {
|
||||||
mode_.set(State.End);
|
mode_.set(State.End);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using MonoMod;
|
using MonoMod;
|
||||||
using MU3.Sequence;
|
|
||||||
using MU3.Util;
|
using MU3.Util;
|
||||||
|
|
||||||
namespace MU3;
|
namespace MU3;
|
||||||
@ -18,7 +17,7 @@ class patch_Scene_38_End: Scene_38_End {
|
|||||||
private void Init_Init() {
|
private void Init_Init() {
|
||||||
orig_Init_Init();
|
orig_Init_Init();
|
||||||
|
|
||||||
if(patch_PlayMusic.QuickSkip) {
|
if(Singleton<Mod.State>.instance.SkipPlay) {
|
||||||
result_ = 0;
|
result_ = 0;
|
||||||
mode_.set(State.End);
|
mode_.set(State.End);
|
||||||
}
|
}
|
||||||
@ -27,7 +26,7 @@ class patch_Scene_38_End: Scene_38_End {
|
|||||||
private void End_Init() {
|
private void End_Init() {
|
||||||
SystemUI instance = SingletonMonoBehaviour<SystemUI>.instance;
|
SystemUI instance = SingletonMonoBehaviour<SystemUI>.instance;
|
||||||
instance.Panel.popState();
|
instance.Panel.popState();
|
||||||
if(!patch_PlayMusic.QuickSkip) {
|
if(!Singleton<Mod.State>.instance.SkipPlay) {
|
||||||
instance.fadeOut();
|
instance.fadeOut();
|
||||||
}
|
}
|
||||||
commonWindow_.end();
|
commonWindow_.end();
|
||||||
|
Reference in New Issue
Block a user