1
0
forked from akanyan/mu3-mods

fix: party play fixes

Also, stop using a finalizer
This commit is contained in:
2024-12-21 22:38:19 +00:00
parent 25ca07edd6
commit 7acd754397
4 changed files with 38 additions and 16 deletions

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.ObjectModel;
using System.IO;
using UnityEngine;
namespace MU3.Operation;
@ -9,13 +10,6 @@ class patch_OperationManager: OperationManager {
private int _movieIndex;
private string _fileName;
~patch_OperationManager() {
try {
File.WriteAllText(_fileName, MovieIndex.ToString());
} catch(Exception ex) {
System.Console.WriteLine(ex);
}
}
public int MovieIndex {
set {
if(_movieDataList.Count > 0) {
@ -23,6 +17,12 @@ class patch_OperationManager: OperationManager {
} else {
_movieIndex = 0;
}
try {
File.WriteAllText(_fileName, MovieIndex.ToString());
} catch(Exception ex) {
Debug.Log(ex);
}
}
get {
return _movieIndex;
@ -38,7 +38,6 @@ class patch_OperationManager: OperationManager {
}
public extern void orig_initialize();
public new void initialize() {
orig_initialize();

View File

@ -1,4 +1,5 @@
using MU3.Battle;
using MonoMod;
using MU3.Battle;
using MU3.Game;
using MU3.Notes;
using MU3.Util;
@ -21,7 +22,9 @@ class patch_PlayMusic: PlayMusic {
private DateTime _holdingStartTime;
private float enemyPosX;
private patch_NotesManager ntMgr => (patch_NotesManager)_gameEngine?.notesManager;
private extern void orig_Execute_Play();
[MonoModIgnore]
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));
@ -62,7 +65,11 @@ class patch_PlayMusic: PlayMusic {
ntMgr.led.setGameColor(true);
}
private extern void orig_Execute_Play();
private void Execute_Play() {
if(isPartyPlay()) {
return;
}
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuRight)) {
_pressedYellow = true;
}

View File

@ -1,4 +1,5 @@
using MU3.Battle;
using MonoMod;
using MU3.Battle;
using MU3.Game;
using MU3.Notes;
using MU3.Util;
@ -13,17 +14,21 @@ class patch_PlayMusic: PlayMusic {
private patch_GameBGM pgm => (patch_GameBGM)Singleton<GameSound>.instance.gameBGM;
public static bool Paused = false;
private float pauseTimer = 0f;
public extern bool orig_updateState(float deltaTime = -1f);
public extern void orig_destroy();
[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)) {
if((!Paused && pauseTimer >= PAUSE_CD) || (Paused && pauseTimer >= UNPAUSE_CD) && !isPartyPlay()) {
Paused = !Paused;
pgm.pause(Paused);
ntMgr.setPause(Paused);

View File

@ -1,3 +1,4 @@
using MonoMod;
using MU3.Battle;
using MU3.Data;
using MU3.Game;
@ -10,6 +11,10 @@ class patch_PlayMusic: PlayMusic {
private SessionInfo _sessionInfo;
private bool _nuclearSkip = false;
public static bool ForceSkipped { get; private set; }
[MonoModIgnore]
private extern bool isPartyPlay();
private extern void orig_Execute_StartCutscene();
private void Execute_StartCutscene() {
orig_Execute_StartCutscene();
@ -17,15 +22,21 @@ class patch_PlayMusic: PlayMusic {
if(Singleton<Sys.System>.instance.config.isQuickStart || Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuLeft)) {
ForceSkipped = true;
_gameEngine.skipStartCutscene();
if(isPartyPlay()) {
setNextState(EState.PartyWaitReady);
} else {
setNextState(EState.Countdown);
}
}
}
public extern bool orig_updateState(float deltaTime);
public override bool updateState(float deltaTime = -1f) {
var state = getCurrentState();
if(state >= EState.PlayEnd && Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuLeft)) {
if(!isPartyPlay() || state > EState.CalcResult) {
_nuclearSkip = true;
}
}
if(_nuclearSkip) {
bool isTutorial = SingletonMonoBehaviour<GameEngine>.instance.sessionInfo.isTutorial;
if(!isTutorial) {