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

View File

@ -1,4 +1,5 @@
using MU3.Battle; using MonoMod;
using MU3.Battle;
using MU3.Game; using MU3.Game;
using MU3.Notes; using MU3.Notes;
using MU3.Util; using MU3.Util;
@ -21,7 +22,9 @@ class patch_PlayMusic: PlayMusic {
private DateTime _holdingStartTime; private DateTime _holdingStartTime;
private float enemyPosX; private float enemyPosX;
private patch_NotesManager ntMgr => (patch_NotesManager)_gameEngine?.notesManager; 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) { public static double FadeOut(double progress, double min, double max) {
return min + (max - min) * (1.0 - Math.Pow(1.0 - progress, 2.0)); 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); ntMgr.led.setGameColor(true);
} }
private extern void orig_Execute_Play();
private void Execute_Play() { private void Execute_Play() {
if(isPartyPlay()) {
return;
}
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuRight)) { if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuRight)) {
_pressedYellow = true; _pressedYellow = true;
} }

View File

@ -1,4 +1,5 @@
using MU3.Battle; using MonoMod;
using MU3.Battle;
using MU3.Game; using MU3.Game;
using MU3.Notes; using MU3.Notes;
using MU3.Util; using MU3.Util;
@ -13,17 +14,21 @@ class patch_PlayMusic: PlayMusic {
private patch_GameBGM pgm => (patch_GameBGM)Singleton<GameSound>.instance.gameBGM; private patch_GameBGM pgm => (patch_GameBGM)Singleton<GameSound>.instance.gameBGM;
public static bool Paused = false; public static bool Paused = false;
private float pauseTimer = 0f; 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 extern void orig_Enter_SetupScene();
private void Enter_SetupScene() { private void Enter_SetupScene() {
orig_Enter_SetupScene(); orig_Enter_SetupScene();
Paused = false; Paused = false;
} }
public extern bool orig_updateState(float deltaTime = -1f);
public override bool updateState(float deltaTime = -1f) { public override bool updateState(float deltaTime = -1f) {
pauseTimer += deltaTime; pauseTimer += deltaTime;
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.Service) && !Singleton<UIInput>.instance.getStateOn(UIInput.Key.Test)) { 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; Paused = !Paused;
pgm.pause(Paused); pgm.pause(Paused);
ntMgr.setPause(Paused); ntMgr.setPause(Paused);

View File

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