1
0
forked from akanyan/mu3-mods

feat(BetterGiveUp): yeet

This commit is contained in:
2025-01-12 00:00:49 +00:00
parent e3b1f1885c
commit 31fa3ce028
5 changed files with 85 additions and 83 deletions

View File

@ -0,0 +1,19 @@
using MonoMod;
using UnityEngine;
namespace MU3.Battle;
class patch_PlayerControl(PlayerParam param): PlayerControl(param) {
private Vector3? _positionForce = null;
public extern Vector3 orig_get__playPosition();
[MonoModPublic]
public new Vector3 _playPosition {
get {
return _positionForce ?? orig_get__playPosition();
}
set {
_positionForce = value;
}
}
}

View File

@ -1,16 +0,0 @@
using System.Collections.Generic;
namespace MU3.Game;
class patch_GameLED: GameLED {
private patch_ButtonList _buttonList = new();
public extern void orig_initialize();
public new void initialize() {
_buttonList.Clear();
orig_initialize();
}
private class patch_ButtonParam { }
private class patch_ButtonList: List<patch_ButtonParam> { }
}

View File

@ -1,18 +0,0 @@
using UnityEngine;
namespace MU3.Notes;
class patch_FieldObject: FieldObject {
class patch_BarNotes {
class patch_Bar: BarNotes.Bar {
public extern void orig_update(NotesManager mgr, float width = 1f);
public new void update(NotesManager mgr, float width = 1f) {
orig_update(mgr, width);
if(frameAppear <= (double)mgr.getCurrentFrame() || itemBar == null) {
return;
}
itemBar.go.transform.localScale = Vector3.zero;
}
}
}
}

View File

@ -3,14 +3,8 @@
namespace MU3.Notes; namespace MU3.Notes;
class patch_NotesManager: NotesManager { class patch_NotesManager: NotesManager {
public Vector3 enemyOffset { get; set; } public Vector3? EnemyPositionForce { private get; set; } = null;
public extern Vector3 orig_getEnemyPos(); public extern Vector3 orig_getEnemyPos();
public new Vector3 getEnemyPos() => orig_getEnemyPos() + enemyOffset; public new Vector3 getEnemyPos() => EnemyPositionForce ?? orig_getEnemyPos();
public extern void orig_reset();
public new void reset() {
enemyOffset = Vector3.zero;
orig_reset();
}
} }

View File

@ -4,6 +4,8 @@ using MU3.Game;
using MU3.Notes; using MU3.Notes;
using MU3.Util; using MU3.Util;
using System; using System;
using System.Collections;
using System.Reflection;
using UnityEngine; using UnityEngine;
namespace MU3.Sequence; namespace MU3.Sequence;
@ -12,14 +14,8 @@ 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); private static readonly TimeSpan ROLL_DURATION = TimeSpan.FromSeconds(0.5f);
private double fadeOut(double progress, double min, double max) [MonoModIgnore]
=> min + (max - min) * (1.0 - Math.Pow(1.0 - progress, 2.0)); private patch_NotesManager ntMgr => null;
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 GameEngine _gameEngine;
private SessionInfo _sessionInfo; private SessionInfo _sessionInfo;
@ -27,10 +23,7 @@ class patch_PlayMusic: PlayMusic {
private bool _isRolling; private bool _isRolling;
private bool _isHoldingAck; private bool _isHoldingAck;
private float _totalRollingFrame;
private DateTime _rollingStartTime;
private DateTime _holdingStartTime; private DateTime _holdingStartTime;
private float _enemyPosX;
[MonoModIgnore] [MonoModIgnore]
private extern bool isPartyPlay(); private extern bool isPartyPlay();
@ -43,36 +36,27 @@ class patch_PlayMusic: PlayMusic {
} }
if(_isRolling) { if(_isRolling) {
TimeSpan timeSpan = CustomDateTime.Now - _rollingStartTime; return;
if(timeSpan <= ROLL_DURATION) { }
double num1 = fadeOut(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.enemyOffset = new Vector3(
ntMgr.enemyOffset.x + (_enemyPosX - ntMgr.getEnemyPos().x), 20f * (float)num2, 0.0f
);
} else {
endRolling();
}
} else if(isHolding) {
if(!_isHoldingAck) {
_holdingStartTime = CustomDateTime.Now;
_isHoldingAck = true;
}
TimeSpan ts = CustomDateTime.Now - _holdingStartTime; if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuLeft) || Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuRight)) {
if(ts > HOLD_DURATION) { _holdingStartTime = CustomDateTime.Now;
_isHoldingAck = true;
}
if(_isHoldingAck && (Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuLeft) || Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuRight))) {
if(CustomDateTime.Now - _holdingStartTime > HOLD_DURATION) {
if(Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuRight)) { if(Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuRight)) {
startRolling(); restartPlay(shouldRoll: true);
} else { } else {
skipPlay(); skipPlay();
} }
} }
orig_Execute_Play();
} else { } else {
_isHoldingAck = false; _isHoldingAck = false;
orig_Execute_Play();
} }
orig_Execute_Play();
} }
private extern void orig_Execute_DispCombo(); private extern void orig_Execute_DispCombo();
@ -80,8 +64,7 @@ class patch_PlayMusic: PlayMusic {
orig_Execute_DispCombo(); orig_Execute_DispCombo();
if(Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuRight) && ntMgr.retireResult != RetireResult.None && !isPartyPlay()) { if(Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuRight) && ntMgr.retireResult != RetireResult.None && !isPartyPlay()) {
startRolling(); restartPlay(shouldRoll: false);
endRolling();
_gameEngine.battleUI.skipDispRetireResult(); _gameEngine.battleUI.skipDispRetireResult();
setNextState(EState.Play); setNextState(EState.Play);
} }
@ -100,18 +83,22 @@ class patch_PlayMusic: PlayMusic {
} }
} }
private void startRolling() { private void restartPlay(bool shouldRoll) {
_isRolling = true; _isHoldingAck = false;
_totalRollingFrame = ntMgr.getCurrentFrame();
_rollingStartTime = CustomDateTime.Now;
_enemyPosX = ntMgr.getEnemyPos().x;
_gameEngine.destroyAllies(); _gameEngine.destroyAllies();
ntMgr.forceRecover(recover: 100); ntMgr.forceRecover(recover: 100);
Singleton<GameSound>.instance.gameBGM.stop(); Singleton<GameSound>.instance.gameBGM.stop();
if(shouldRoll) {
_isRolling = true;
_gameEngine.StartCoroutine(roll());
} else {
finishRestart();
}
} }
private void endRolling() { private void finishRestart() {
_isRolling = false;
_isForceEndBattle = false; _isForceEndBattle = false;
ntMgr.stopPlay(); ntMgr.stopPlay();
@ -134,6 +121,42 @@ class patch_PlayMusic: PlayMusic {
Singleton<GameSound>.instance.gameBGM.playMusic(_sessionInfo.musicData, 0); Singleton<GameSound>.instance.gameBGM.playMusic(_sessionInfo.musicData, 0);
} }
private IEnumerator roll() {
static float fadeOut(float progress, float min, float max)
=> min + (max - min) * (1f - Mathf.Pow(1f - progress, 2f));
static float fadeIn(float progress, float min, float max)
=> min + (max - min) * Mathf.Pow(progress, 2f);
FieldInfo fi = typeof(Player).GetField("_object", BindingFlags.Instance | BindingFlags.NonPublic);
var po = (PlayerObject)fi.GetValue(_gameEngine.player);
var control = (patch_PlayerControl)po.control;
po.leaveField();
var enemyPos = ntMgr.getEnemyPos();
var playerPos = control._playPosition;
var finalRollingFrame = ntMgr.getCurrentFrame();
var rollingStartTime = CustomDateTime.Now;
while(_isRolling) {
TimeSpan timeSpan = CustomDateTime.Now - rollingStartTime;
if(timeSpan <= ROLL_DURATION) {
float frame = (float)(timeSpan.TotalMilliseconds / ROLL_DURATION.TotalMilliseconds);
float num1 = fadeOut(frame, 0f, 1f);
float num2 = fadeIn(frame, 0f, 1f);
ntMgr.setFrameForce(finalRollingFrame * (1f - num1));
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);
} else {
_isRolling = false;
ntMgr.EnemyPositionForce = null;
finishRestart();
yield break;
}
yield return new WaitForEndOfFrame();
}
}
private void skipPlay() { private void skipPlay() {
Singleton<Mod.State>.instance.SkipPlay = true; Singleton<Mod.State>.instance.SkipPlay = true;
setNextState(EState.End); setNextState(EState.End);