-
Notifications
You must be signed in to change notification settings - Fork 54
[+] ReviveFinaleVSlide #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| using System.Collections.Generic; | ||
| using System.Reflection.Emit; | ||
| using AquaMai.Core.Attributes; | ||
| using AquaMai.Config.Attributes; | ||
| using HarmonyLib; | ||
| using Manager; | ||
| using MelonLoader; | ||
|
|
||
| namespace AquaMai.Mods.GameSystem; | ||
|
|
||
| [ConfigSection( | ||
| en: "Allow v-shaped slide with the same starting and ending point, such as \"1v1\" in Simai notation", | ||
| zh: "允许形如 \"1v1\" 的,起点和终点相同的 v 型星星")] | ||
| public static class ReviveFinaleVSlide | ||
| { | ||
| public static List<string> InsertData(List<string> list) | ||
| { | ||
| MelonLogger.Msg("[ReviveFinaleVSlide] Insert SVG data"); | ||
|
|
||
| list[0] = "V_1.svg"; | ||
| return list; | ||
| } | ||
|
|
||
| public static List<List<SlideManager.HitArea>> InsertHitArea(List<List<SlideManager.HitArea>> list) | ||
| { | ||
| MelonLogger.Msg("[ReviveFinaleVSlide] Insert hit area list");; | ||
|
|
||
| list[0] = [ | ||
| new SlideManager.HitArea | ||
| { | ||
| HitPoints = [InputManager.TouchPanelArea.A1], | ||
| PushDistance = 156.42124938964844, | ||
| ReleaseDistance = 43.27423858642578 | ||
| }, | ||
| new SlideManager.HitArea | ||
| { | ||
| HitPoints = [InputManager.TouchPanelArea.B1], | ||
| PushDistance = 128.9917755126953, | ||
| ReleaseDistance = 42.19921875 | ||
| }, | ||
| new SlideManager.HitArea | ||
| { | ||
| HitPoints = [InputManager.TouchPanelArea.C1], | ||
| PushDistance = 218.6302947998047, | ||
| ReleaseDistance = 42.19921875 | ||
| }, | ||
| new SlideManager.HitArea | ||
| { | ||
| HitPoints = [InputManager.TouchPanelArea.B1], | ||
| PushDistance = 128.9917755126953, | ||
| ReleaseDistance = 43.27423858642578 | ||
| }, | ||
| new SlideManager.HitArea | ||
| { | ||
| HitPoints = [InputManager.TouchPanelArea.A1], | ||
| PushDistance = 156.42124938964844, | ||
| ReleaseDistance = 0.0 | ||
| } | ||
| ]; | ||
| return list; | ||
| } | ||
|
|
||
| [HarmonyPatch(typeof(SlideManager), MethodType.Constructor)] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (bug_risk): 修补所有构造函数可能会产生意外的副作用。 如果 SlideManager 有多个构造函数,修补所有构造函数可能会导致问题。请指定构造函数签名以仅针对预期的构造函数。 建议的实现: // Example: If the intended constructor is SlideManager(int a, string b), use:
[HarmonyPatch(typeof(SlideManager), MethodType.Constructor, new Type[] { typeof(int), typeof(string) })]
public static class SlideDataPatch
{你必须更新 Original comment in Englishsuggestion (bug_risk): Patching all constructors may have unintended side effects. If SlideManager has multiple constructors, patching all of them may cause issues. Specify the constructor signature to target only the intended one. Suggested implementation: // Example: If the intended constructor is SlideManager(int a, string b), use:
[HarmonyPatch(typeof(SlideManager), MethodType.Constructor, new Type[] { typeof(int), typeof(string) })]
public static class SlideDataPatch
{You must update the |
||
| public static class SlideDataPatch | ||
| { | ||
| public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
sourcery-ai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| var vDataList = AccessTools.Field(typeof(SlideManager), "_vDataList"); | ||
| var vHitAreaList = AccessTools.Field(typeof(SlideManager), "_vHitAreaList"); | ||
|
|
||
| foreach (var insn in instructions) | ||
| { | ||
| if (insn.StoresField(vDataList)) | ||
| { | ||
| yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(ReviveFinaleVSlide), "InsertData")); | ||
| } | ||
| else if (insn.StoresField(vHitAreaList)) | ||
|
Comment on lines
+73
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): 用方法调用替换字段存储指令可能会扰乱预期的堆栈行为。 请验证 InsertData 和 InsertHitArea 返回的值是否适合字段赋值,并确认这些方法调用后堆栈保持一致。 Original comment in Englishissue (bug_risk): Replacing field store instructions with method calls may disrupt expected stack behavior. Verify that InsertData and InsertHitArea return values suitable for field assignment, and confirm the stack remains consistent after these method calls. |
||
| { | ||
| yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(ReviveFinaleVSlide), "InsertHitArea")); | ||
| } | ||
|
|
||
| yield return insn; | ||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: 直接覆盖 list[0] 可能会在列表为空时导致问题。
在不检查列表是否非空的情况下赋值给 list[0] 将会引发异常。请添加长度检查或使用安全处理空列表的方法。
Original comment in English
issue: Directly overwriting list[0] may cause issues if the list is empty.
Assigning to list[0] without checking if the list is non-empty will raise an exception. Add a length check or use a method that safely handles empty lists.