From b7004b3866496c9b9d36d2ea3f567d07a7177997 Mon Sep 17 00:00:00 2001 From: Clansty Date: Thu, 12 Sep 2024 21:54:37 +0800 Subject: [PATCH] [+] Extend notes pool to support some odd charts --- AquaMai/AquaMai.csproj | 1 + AquaMai/AquaMai.toml | 2 + AquaMai/AquaMai.zh.toml | 2 + AquaMai/Config.cs | 1 + AquaMai/Fix/ExtendNotesPool.cs | 126 +++++++++++++++++++++++++++++++++ AquaMai/Main.cs | 1 + 6 files changed, 133 insertions(+) create mode 100644 AquaMai/Fix/ExtendNotesPool.cs diff --git a/AquaMai/AquaMai.csproj b/AquaMai/AquaMai.csproj index 6e17f172..d60a9092 100644 --- a/AquaMai/AquaMai.csproj +++ b/AquaMai/AquaMai.csproj @@ -291,6 +291,7 @@ + diff --git a/AquaMai/AquaMai.toml b/AquaMai/AquaMai.toml index 2b64e367..f8d101cf 100644 --- a/AquaMai/AquaMai.toml +++ b/AquaMai/AquaMai.toml @@ -69,6 +69,8 @@ SkipVersionCheck=true RemoveEncryption=true ForceAsServer=true ForceFreePlay=true +# Add notes sprite to the pool to prevent use up +ExtendNotesPool=128 [Utils] # Log user ID on login diff --git a/AquaMai/AquaMai.zh.toml b/AquaMai/AquaMai.zh.toml index 99ed18c2..9db0287d 100644 --- a/AquaMai/AquaMai.zh.toml +++ b/AquaMai/AquaMai.zh.toml @@ -85,6 +85,8 @@ RemoveEncryption=true # 如果要配置店内招募的话,应该要把这个关闭 ForceAsServer=true ForceFreePlay=true +# 增加更多待命的音符贴图,防止奇怪的自制谱用完音符贴图池 +ExtendNotesPool=128 [Utils] # 登录时将 UserID 输出到日志 diff --git a/AquaMai/Config.cs b/AquaMai/Config.cs index 790c57a2..dfd0c511 100644 --- a/AquaMai/Config.cs +++ b/AquaMai/Config.cs @@ -55,6 +55,7 @@ public class FixConfig public bool RemoveEncryption { get; set; } public bool ForceAsServer { get; set; } = true; public bool ForceFreePlay { get; set; } = true; + public int ExtendNotesPool { get; set; } } public class UtilsConfig diff --git a/AquaMai/Fix/ExtendNotesPool.cs b/AquaMai/Fix/ExtendNotesPool.cs new file mode 100644 index 00000000..f41ff7b7 --- /dev/null +++ b/AquaMai/Fix/ExtendNotesPool.cs @@ -0,0 +1,126 @@ +using System.Collections.Generic; +using HarmonyLib; +using MAI2.Util; +using Manager; +using MelonLoader; +using Monitor; +using Monitor.Game; +using UnityEngine; + +namespace AquaMai.Fix; + +public class ExtendNotesPool +{ + [HarmonyPostfix] + [HarmonyPatch(typeof(GameCtrl), "CreateNotePool")] + public static void CreateNotePool(ref GameCtrl __instance, + GameObject ____tapListParent, List ____tapObjectList, + GameObject ____holdListParent, List ____holdObjectList, + GameObject ____breakHoldListParent, List ____breakHoldObjectList, + GameObject ____starListParent, List ____starObjectList, + GameObject ____breakStarListParent, List ____breakStarObjectList, + GameObject ____breakListParent, List ____breakObjectList, + GameObject ____touchListParent, List ____touchBObjectList, + GameObject ____touchCTapListParent, List ____touchCTapObjectList, + GameObject ____touchCHoldListParent, List ____touchCHoldObjectList, + GameObject ____slideListParent, List ____slideObjectList, + GameObject ____fanSlideListParent, List ____fanSlideObjectList, + GameObject ____slideJudgeListParent, List ____judgeSlideObjectList, + GameObject ____guideListParent, List ____guideObjectList, + GameObject ____barGuideListParent, List ____barGuideObjectList, + List ____arrowObjectList, List ____breakArrowObjectList + ) + { + for (var i = 0; i < AquaMai.AppConfig.Fix.ExtendNotesPool; i++) + { + var tapNote = Object.Instantiate(GameNotePrefabContainer.Tap, ____tapListParent.transform); + tapNote.gameObject.SetActive(false); + tapNote.ParentTransform = ____tapListParent.transform; + ____tapObjectList.Add(tapNote); + + var holdNote = Object.Instantiate(GameNotePrefabContainer.Hold, ____holdListParent.transform); + holdNote.gameObject.SetActive(false); + holdNote.ParentTransform = ____holdListParent.transform; + ____holdObjectList.Add(holdNote); + + var breakHoldNote = Object.Instantiate(GameNotePrefabContainer.BreakHold, ____breakHoldListParent.transform); + breakHoldNote.gameObject.SetActive(false); + breakHoldNote.ParentTransform = ____holdListParent.transform; + ____breakHoldObjectList.Add(breakHoldNote); + + var starNote = Object.Instantiate(GameNotePrefabContainer.Star, ____starListParent.transform); + starNote.gameObject.SetActive(false); + starNote.ParentTransform = ____starListParent.transform; + ____starObjectList.Add(starNote); + + var breakStarNote = Object.Instantiate(GameNotePrefabContainer.BreakStar, ____breakStarListParent.transform); + breakStarNote.gameObject.SetActive(false); + breakStarNote.ParentTransform = ____breakStarListParent.transform; + ____breakStarObjectList.Add(breakStarNote); + + var breakNote = Object.Instantiate(GameNotePrefabContainer.Break, ____breakListParent.transform); + breakNote.gameObject.SetActive(false); + breakNote.ParentTransform = ____breakListParent.transform; + ____breakObjectList.Add(breakNote); + + var touchNoteB = Object.Instantiate(GameNotePrefabContainer.TouchTapB, ____touchListParent.transform); + touchNoteB.gameObject.SetActive(false); + touchNoteB.ParentTransform = ____touchListParent.transform; + ____touchBObjectList.Add(touchNoteB); + + var touchNoteC = Object.Instantiate(GameNotePrefabContainer.TouchTapC, ____touchCTapListParent.transform); + touchNoteC.gameObject.SetActive(false); + touchNoteC.ParentTransform = ____touchCTapListParent.transform; + ____touchCTapObjectList.Add(touchNoteC); + + var touchHoldC = Object.Instantiate(GameNotePrefabContainer.TouchHoldC, ____touchCHoldListParent.transform); + touchHoldC.gameObject.SetActive(false); + touchHoldC.ParentTransform = ____touchCHoldListParent.transform; + ____touchCHoldObjectList.Add(touchHoldC); + + var slideRoot = Object.Instantiate(GameNotePrefabContainer.Slide, ____slideListParent.transform); + slideRoot.gameObject.SetActive(false); + slideRoot.ParentTransform = ____slideListParent.transform; + ____slideObjectList.Add(slideRoot); + + var slideFan = Object.Instantiate(GameNotePrefabContainer.SlideFan, ____fanSlideListParent.transform); + slideFan.gameObject.SetActive(false); + slideFan.ParentTransform = ____fanSlideListParent.transform; + ____fanSlideObjectList.Add(slideFan); + + var slideJudge = Object.Instantiate(GameNotePrefabContainer.SlideJudge, ____slideJudgeListParent.transform); + slideJudge.gameObject.SetActive(false); + slideJudge.ParentTransform = ____slideJudgeListParent.transform; + slideJudge.SetOption(Singleton.Instance.GetGameScore(__instance.MonitorIndex).UserOption.DispJudge); + ____judgeSlideObjectList.Add(slideJudge); + + for (var j = 0; j < 50; j++) + { + var spriteRenderer = Object.Instantiate(GameNotePrefabContainer.Arrow, ____slideListParent.transform); + spriteRenderer.gameObject.SetActive(false); + ____arrowObjectList.Add(spriteRenderer); + + var breakSlide = Object.Instantiate(GameNotePrefabContainer.BreakArrow, ____slideListParent.transform); + breakSlide.gameObject.SetActive(false); + ____breakArrowObjectList.Add(breakSlide); + } + + var noteGuide = Object.Instantiate(GameNotePrefabContainer.Guide, ____guideListParent.transform); + noteGuide.gameObject.SetActive(false); + noteGuide.ParentTransform = ____guideListParent.transform; + ____guideObjectList.Add(noteGuide); + + var barGuide = Object.Instantiate(GameNotePrefabContainer.BarGuide, ____barGuideListParent.transform); + barGuide.gameObject.SetActive(false); + barGuide.ParentTransform = ____barGuideListParent.transform; + ____barGuideObjectList.Add(barGuide); + } + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(SlideRoot), "UpdateAlpha")] + public static void UpdateAlpha(int ____dispLaneNum) + { + MelonLogger.Msg(____dispLaneNum); + } +} diff --git a/AquaMai/Main.cs b/AquaMai/Main.cs index 54b3be79..1244b7ef 100644 --- a/AquaMai/Main.cs +++ b/AquaMai/Main.cs @@ -95,6 +95,7 @@ public override void OnInitializeMelon() Patch(typeof(FixCharaCrash)); Patch(typeof(BasicFix)); Patch(typeof(DisableReboot)); + Patch(typeof(ExtendNotesPool)); // UX Patch(typeof(CustomVersionString)); Patch(typeof(CustomPlaceName));