1
0
forked from akanyan/mu3-mods

feat: implement SelectBGM

This commit is contained in:
2024-07-30 02:22:25 +09:00
parent 920d2386d5
commit 07ee892b43
6 changed files with 88 additions and 1 deletions

View File

@ -0,0 +1,38 @@
using MU3.Data;
using MU3.Game;
using MU3.Util;
using System;
namespace MU3.Sequence;
class patch_Play: Play {
private LocalSessionInfo _localSessionInfo;
public static int RecentID = 6;
private extern void orig_Enter_Login();
private void Enter_Login() {
orig_Enter_Login();
using IniFile iniFile = new("mu3.ini");
var index = iniFile.getIntValue("Extra", "BGM", 6);
if(index == 0) {
var rnd = new Random();
index = rnd.Next(1, 7);
}
if(index < 0 || index > 6) {
index = 6;
}
RecentID = index;
Singleton<GameSound>.instance.gameBGM.playBGM(233, index);
}
private extern void orig_Enter_ChapterSelect();
private void Enter_ChapterSelect() {
patch_GameBGM.WithholdPlay = true;
orig_Enter_ChapterSelect();
patch_GameBGM.WithholdPlay = false;
int selectorID = SingletonStateMachine<DataManager, DataManager.EState>.instance.getMemoryChapterData(
_localSessionInfo.chapterSelection.memoryChapterId
)?.getMemoryChapterSelectorID() ?? RecentID;
Singleton<GameSound>.instance.gameBGM.playBGM(233, selectorID);
}
}