1
0
forked from akanyan/mu3-mods

feat(BetterGiveUp): arbitrary rolling

This commit is contained in:
2025-01-26 14:11:12 +00:00
parent 52a15722a8
commit b2e0fc8929
3 changed files with 22 additions and 7 deletions

View File

@ -0,0 +1,5 @@
namespace MU3.Mod;
class TestMenuEnable {
public class BetterGiveUp { };
}

View File

@ -12,7 +12,8 @@ namespace MU3.Sequence;
class patch_PlayMusic: PlayMusic { class patch_PlayMusic: PlayMusic {
private static readonly TimeSpan HOLD_DURATION = TimeSpan.FromSeconds(0.67f); private static readonly TimeSpan HOLD_DURATION = TimeSpan.FromSeconds(0.67f);
private static readonly TimeSpan ROLL_DURATION = TimeSpan.FromSeconds(0.5f);
public double TargetFrame { get; set; } = 0f;
[MonoModIgnore] [MonoModIgnore]
private patch_NotesManager ntMgr => null; private patch_NotesManager ntMgr => null;
@ -116,9 +117,10 @@ class patch_PlayMusic: PlayMusic {
_gameEngine.enemyManager.initialize(); _gameEngine.enemyManager.initialize();
_gameEngine.reset(); _gameEngine.reset();
ntMgr.startPlay(0.0f); double targetMs = TargetFrame * 16.6666667;
ntMgr.startPlay((float)targetMs);
ntMgr.led.setGameColor(true); ntMgr.led.setGameColor(true);
Singleton<GameSound>.instance.gameBGM.playMusic(_sessionInfo.musicData, 0); Singleton<GameSound>.instance.gameBGM.playMusic(_sessionInfo.musicData, (int)Math.Round(targetMs));
} }
private IEnumerator roll() { private IEnumerator roll() {
@ -135,16 +137,19 @@ class patch_PlayMusic: PlayMusic {
var enemyPos = ntMgr.getEnemyPos(); var enemyPos = ntMgr.getEnemyPos();
var playerPos = control._playPosition; var playerPos = control._playPosition;
var finalRollingFrame = ntMgr.getCurrentFrame(); var rollingStartFrame = ntMgr.getCurrentFrame();
var rollingStartTime = CustomDateTime.Now; var rollingStartTime = CustomDateTime.Now;
var rollDuration = TimeSpan.FromSeconds(
Math.Max(0.5, Math.Sqrt(Math.Abs(rollingStartFrame - TargetFrame) * 16.6666667) / 300.0)
);
while(_isRolling) { while(_isRolling) {
TimeSpan timeSpan = CustomDateTime.Now - rollingStartTime; TimeSpan timeSpan = CustomDateTime.Now - rollingStartTime;
if(timeSpan <= ROLL_DURATION) { if(timeSpan <= rollDuration) {
float frame = (float)(timeSpan.TotalMilliseconds / ROLL_DURATION.TotalMilliseconds); float frame = (float)(timeSpan.TotalMilliseconds / rollDuration.TotalMilliseconds);
float num1 = fadeOut(frame, 0f, 1f); float num1 = fadeOut(frame, 0f, 1f);
float num2 = fadeIn(frame, 0f, 1f); float num2 = fadeIn(frame, 0f, 1f);
ntMgr.setFrameForce(finalRollingFrame * (1f - num1)); ntMgr.setFrameForce(rollingStartFrame + ((float)TargetFrame - rollingStartFrame) * num1);
ntMgr.EnemyPositionForce = new Vector3(enemyPos.x, enemyPos.y + num2 * 215f, enemyPos.z + num2 * 1600f); ntMgr.EnemyPositionForce = new Vector3(enemyPos.x, enemyPos.y + num2 * 215f, enemyPos.z + num2 * 1600f);
control._playPosition = new Vector3(playerPos.x, playerPos.y, playerPos.z - num2 * 10f); control._playPosition = new Vector3(playerPos.x, playerPos.y, playerPos.z - num2 * 10f);
} else { } else {

View File

@ -0,0 +1,5 @@
namespace MU3.Mod;
class TestMenuEnable {
public class Pause { };
}