Skip to content

Commit

Permalink
[+] Extend notes pool to support some odd charts
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Sep 12, 2024
1 parent 5341326 commit b7004b3
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 0 deletions.
1 change: 1 addition & 0 deletions AquaMai/AquaMai.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@
<Compile Include="Config.cs" />
<Compile Include="Fix\BasicFix.cs" />
<Compile Include="Fix\DisableReboot.cs" />
<Compile Include="Fix\ExtendNotesPool.cs" />
<Compile Include="Fix\FixCharaCrash.cs" />
<Compile Include="Fix\ForceAsServer.cs" />
<Compile Include="Fix\ForceFreePlay.cs" />
Expand Down
2 changes: 2 additions & 0 deletions AquaMai/AquaMai.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions AquaMai/AquaMai.zh.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ RemoveEncryption=true
# 如果要配置店内招募的话,应该要把这个关闭
ForceAsServer=true
ForceFreePlay=true
# 增加更多待命的音符贴图,防止奇怪的自制谱用完音符贴图池
ExtendNotesPool=128

[Utils]
# 登录时将 UserID 输出到日志
Expand Down
1 change: 1 addition & 0 deletions AquaMai/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
126 changes: 126 additions & 0 deletions AquaMai/Fix/ExtendNotesPool.cs
Original file line number Diff line number Diff line change
@@ -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<TapNote> ____tapObjectList,
GameObject ____holdListParent, List<HoldNote> ____holdObjectList,
GameObject ____breakHoldListParent, List<BreakHoldNote> ____breakHoldObjectList,
GameObject ____starListParent, List<StarNote> ____starObjectList,
GameObject ____breakStarListParent, List<BreakStarNote> ____breakStarObjectList,
GameObject ____breakListParent, List<BreakNote> ____breakObjectList,
GameObject ____touchListParent, List<TouchNoteB> ____touchBObjectList,
GameObject ____touchCTapListParent, List<TouchNoteC> ____touchCTapObjectList,
GameObject ____touchCHoldListParent, List<TouchHoldC> ____touchCHoldObjectList,
GameObject ____slideListParent, List<SlideRoot> ____slideObjectList,
GameObject ____fanSlideListParent, List<SlideFan> ____fanSlideObjectList,
GameObject ____slideJudgeListParent, List<SlideJudge> ____judgeSlideObjectList,
GameObject ____guideListParent, List<NoteGuide> ____guideObjectList,
GameObject ____barGuideListParent, List<BarGuide> ____barGuideObjectList,
List<SpriteRenderer> ____arrowObjectList, List<BreakSlide> ____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<GamePlayManager>.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);
}
}
1 change: 1 addition & 0 deletions AquaMai/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit b7004b3

Please sign in to comment.