forked from akanyan/mu3-mods
fix(BetterGiveUp): a better way
This commit is contained in:
@ -9,18 +9,26 @@ using UnityEngine;
|
||||
namespace MU3.Sequence;
|
||||
|
||||
class patch_PlayMusic: PlayMusic {
|
||||
private static readonly TimeSpan HOLD_DURATION = TimeSpan.FromSeconds(1.0f);
|
||||
private static readonly TimeSpan HOLD_DURATION = TimeSpan.FromSeconds(0.67f);
|
||||
private static readonly TimeSpan ROLL_DURATION = TimeSpan.FromSeconds(0.5f);
|
||||
|
||||
private double fadeOut(double progress, double min, double max)
|
||||
=> min + (max - min) * (1.0 - Math.Pow(1.0 - progress, 2.0));
|
||||
private double fadeIn(double progress, double min, double max)
|
||||
=> min + (max - min) * Math.Pow(progress, 2.0);
|
||||
private bool isHolding
|
||||
=> Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuLeft)
|
||||
|| Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuRight);
|
||||
private patch_NotesManager ntMgr => (patch_NotesManager)_gameEngine?.notesManager;
|
||||
|
||||
private GameEngine _gameEngine;
|
||||
private SessionInfo _sessionInfo;
|
||||
private patch_NotesManager ntMgr => (patch_NotesManager)_gameEngine?.notesManager;
|
||||
private bool _isForceEndBattle;
|
||||
|
||||
private bool _pressedYellow;
|
||||
private bool _isRolling;
|
||||
private bool _isHoldingAck;
|
||||
private float _totalRollingFrame;
|
||||
private DateTime _rollingStartTime;
|
||||
private bool _isHoldingAck;
|
||||
private DateTime _holdingStartTime;
|
||||
private float _enemyPosX;
|
||||
|
||||
@ -34,9 +42,6 @@ class patch_PlayMusic: PlayMusic {
|
||||
return;
|
||||
}
|
||||
|
||||
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuRight)) {
|
||||
_pressedYellow = true;
|
||||
}
|
||||
if(_isRolling) {
|
||||
TimeSpan timeSpan = CustomDateTime.Now - _rollingStartTime;
|
||||
if(timeSpan <= ROLL_DURATION) {
|
||||
@ -49,7 +54,7 @@ class patch_PlayMusic: PlayMusic {
|
||||
} else {
|
||||
endRolling();
|
||||
}
|
||||
} else if(isHolding()) {
|
||||
} else if(isHolding) {
|
||||
if(!_isHoldingAck) {
|
||||
_holdingStartTime = CustomDateTime.Now;
|
||||
_isHoldingAck = true;
|
||||
@ -58,93 +63,84 @@ class patch_PlayMusic: PlayMusic {
|
||||
TimeSpan ts = CustomDateTime.Now - _holdingStartTime;
|
||||
if(ts > HOLD_DURATION) {
|
||||
if(Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuRight)) {
|
||||
if(ntMgr.retireResult != RetireResult.None) {
|
||||
hardReset();
|
||||
} else {
|
||||
startRolling();
|
||||
}
|
||||
startRolling();
|
||||
} else {
|
||||
Singleton<Mod.State>.instance.SkipPlay = true;
|
||||
setNextState(EState.End);
|
||||
destroy();
|
||||
ntMgr.stopPlay();
|
||||
_gameEngine.destroyAllies();
|
||||
_gameEngine.finishGame();
|
||||
_gameEngine.playFinish();
|
||||
skipPlay();
|
||||
}
|
||||
}
|
||||
orig_Execute_Play();
|
||||
} else {
|
||||
_isHoldingAck = false;
|
||||
orig_Execute_Play();
|
||||
}
|
||||
}
|
||||
|
||||
private static double fadeOut(double progress, double min, double max) {
|
||||
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();
|
||||
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 void Execute_DispCombo() {
|
||||
orig_Execute_DispCombo();
|
||||
|
||||
listenForPanicRestart();
|
||||
if(Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuRight) && ntMgr.retireResult != RetireResult.None && !isPartyPlay()) {
|
||||
startRolling();
|
||||
endRolling();
|
||||
_gameEngine.battleUI.skipDispRetireResult();
|
||||
setNextState(EState.Play);
|
||||
}
|
||||
}
|
||||
|
||||
private extern void orig_Execute_DispFinish();
|
||||
private void Execute_DispFinish() {
|
||||
orig_Execute_DispFinish();
|
||||
|
||||
listenForPanicRestart();
|
||||
if(Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuRight) && ntMgr.retireResult != RetireResult.None && !isPartyPlay()) {
|
||||
ntMgr.stopPlay();
|
||||
ntMgr.setPause(false);
|
||||
_gameEngine.reset();
|
||||
Singleton<GameSound>.instance.gameBGM.stop();
|
||||
setNextState(EState.Init);
|
||||
}
|
||||
}
|
||||
|
||||
private void startRolling() {
|
||||
_isRolling = true;
|
||||
_totalRollingFrame = ntMgr.getCurrentFrame();
|
||||
_rollingStartTime = CustomDateTime.Now;
|
||||
_enemyPosX = ntMgr.getEnemyPos().x;
|
||||
_gameEngine.destroyAllies();
|
||||
ntMgr.forceRecover(recover: 100);
|
||||
Singleton<GameSound>.instance.gameBGM.stop();
|
||||
}
|
||||
|
||||
private void endRolling() {
|
||||
_isRolling = false;
|
||||
_isForceEndBattle = false;
|
||||
|
||||
ntMgr.stopPlay();
|
||||
ntMgr.setPause(false);
|
||||
ntMgr.reset();
|
||||
|
||||
// This has to go first or otherwise enemies will shrink
|
||||
_gameEngine.createPlayers();
|
||||
|
||||
_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 skipPlay() {
|
||||
Singleton<Mod.State>.instance.SkipPlay = true;
|
||||
setNextState(EState.End);
|
||||
destroy();
|
||||
ntMgr.stopPlay();
|
||||
_gameEngine.destroyAllies();
|
||||
_gameEngine.finishGame();
|
||||
_gameEngine.playFinish();
|
||||
}
|
||||
}
|
@ -127,7 +127,7 @@ class TestModePageModConfig: TestModePage {
|
||||
"QuickStart",
|
||||
_onOff,
|
||||
0,
|
||||
typeof(Sequence.PlayMusic).GetMethod("orig_updateState") != null,
|
||||
typeof(Notes.NotesManager).GetMethod("orig_reset") != null,
|
||||
"Sequence"
|
||||
));
|
||||
|
||||
|
Reference in New Issue
Block a user