Skip to content

Commit e3fc9f4

Browse files
committed
[+] AddPlayCountWhenQuickRetry
1 parent 351f44e commit e3fc9f4

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System.Linq;
2+
using AquaMai.Config.Attributes;
3+
using AquaMai.Core.Attributes;
4+
using AquaMai.Core.Helpers;
5+
using HarmonyLib;
6+
using MAI2.Util;
7+
using Manager;
8+
using MelonLoader;
9+
10+
namespace AquaMai.Mods.GameSystem;
11+
12+
[ConfigSection(
13+
defaultOn: true,
14+
en: "Add play count when quick retry (regardless of trigger type).",
15+
zh: "在一键重开(无论何种触发方式)时,增加当前谱面的游玩次数")]
16+
[EnableGameVersion(23000)]
17+
public class AddPlayCountWhenQuickRetry
18+
{
19+
[HarmonyPrefix]
20+
[HarmonyPatch(typeof(GamePlayManager), nameof(GamePlayManager.SetQuickRetryFrag))]
21+
public static void SetQuickRetryFrag(bool flag, bool ____isQuickRetry, GamePlayManager __instance)
22+
{
23+
if (!flag) return;
24+
if (____isQuickRetry) return;
25+
var userData = Singleton<UserDataManager>.Instance.GetUserData(0);
26+
for (int i = 0; i < 2; i++)
27+
{
28+
if (!userData.IsEntry) continue;
29+
MelonLogger.Msg($"[AddPlayCountWhenQuickRetry] Player {i} MusicID {GameManager.SelectMusicID[i]} Difficulty {GameManager.SelectDifficultyID[i]}");
30+
var score = Shim.GetUserScoreList(userData)[GameManager.SelectDifficultyID[i]].FirstOrDefault(it => it.id == GameManager.SelectMusicID[i]);
31+
if (score != null)
32+
{
33+
score.playcount++;
34+
}
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)