AquaDX/AquaMai/Fix/SlideAutoPlayTweak.cs

103 lines
4.1 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using HarmonyLib;
using Manager;
using Monitor;
2024-10-04 19:38:02 +08:00
namespace AquaMai.Fix;
public class SlideAutoPlayTweak
{
/* Patch bug:
* SlideFan AutoPlay ,
* method :
2024-10-04 19:38:02 +08:00
*
* if (this.IsNoteCheckTimeStartIgnoreJudgeWait())
* {
* // do something ...
* if (!GameManager.IsAutoPlay())
* {
* // do something ...
* for (int index = 0; index < this._arrowPrefubs.Length && (double) index < (double) num2 * 11.0; ++index)
* {
* // do something about displaying arrows ...
* }
* }
* else
* {
* float num4 = (currentMsec - this.StarLaunchMsec) / (this.StarArriveMsec - this.StarLaunchMsec - this.lastWaitTime);
* for (int index = 0; index < this._arrowPrefubs.Length && (double) index < (double) num4 * 1.0; ++index)
* {
* // do something about displaying arrows ...
* }
* if ((double) num4 > 1.0)
* num1 = 3;
* }
* // do something ...
* }
2024-10-04 19:38:02 +08:00
*
* bug else for , 11.0 ( 11 ), SBGA 1.0
* method 5 ldc.r4 IL Code, 10.0, 11.0, 1.0, 1.0, 0.0
* bug 1.0 11.0, 使 Transpiler
*/
[HarmonyTranspiler]
[HarmonyPatch(typeof(SlideFan), "NoteCheck")]
private static IEnumerable<CodeInstruction> FixFanAutoPlayArrow(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> instList = new List<CodeInstruction>(instructions);
bool found = false;
for (int i = 0; i < instList.Count; i++)
{
CodeInstruction inst = instList[i];
if (inst.LoadsConstant(11.0))
{
found = true;
}
if (found && inst.LoadsConstant(1.0))
{
inst.operand = 11.0f;
break;
}
}
return instList;
}
2024-10-04 19:38:02 +08:00
/* Patch Slide AutoPlay , ( this._hitIn )
* method :
*
* if (!GameManager.IsAutoPlay())
* {
* // do somethings ...
* }
* else
* {
* float num1 = (currentMsec - this.StarLaunchMsec) / (this.StarArriveMsec - this.StarLaunchMsec - this.lastWaitTime);
* this._hitIndex = (int) ((double) this._hitAreaList.Count * (double) num1);
* if (this._hitIndex >= this._hitAreaList.Count)
* this._hitIndex = this._hitAreaList.Count - 1;
* if (this._hitIndex < 0)
* this._hitIndex = 0;
* int num2 = (int) ((double) this._dispLaneNum * this.GetDeleteArrowDistance());
* // do somethings ...
* }
*
* this.GetDeleteArrowDistance()
* this._hitIn = ((float)this._hitAreaList.Count * num1 > (float)this._hitIndex + 0.5f);
* , Prefix, GetDeleteArrowDistance() , if ( AutoPlay )
*/
[HarmonyPrefix]
[HarmonyPatch(typeof(SlideRoot), "GetDeleteArrowDistance")]
private static void FixSlideAutoPlayArrow(
SlideRoot __instance, ref bool ____hitIn, int ____hitIndex, List<SlideManager.HitArea> ____hitAreaList,
float ___StarLaunchMsec, float ___StarArriveMsec, float ___lastWaitTime
)
{
if (GameManager.IsAutoPlay())
{
float prop = (NotesManager.GetCurrentMsec() - ___StarLaunchMsec) / (___StarArriveMsec - ___StarLaunchMsec - ___lastWaitTime);
____hitIn = ____hitAreaList.Count * prop > ____hitIndex + 0.5f;
}
}
2024-10-04 19:38:02 +08:00
}