forked from akanyan/mu3-mods
feat: implement SelectBGM
This commit is contained in:
38
SelectBGM/MU3.Sequence/patch_Play.cs
Normal file
38
SelectBGM/MU3.Sequence/patch_Play.cs
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user