[O] better get player

pull/55/head
Clansty 2024-09-28 19:42:42 +08:00
parent 3d79c939e9
commit 8c3400ee41
No known key found for this signature in database
GPG Key ID: 3A6BE8BAF2EDE134
1 changed files with 20 additions and 18 deletions

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Reflection;
using AquaMai.Fix; using AquaMai.Fix;
using AquaMai.Helpers; using AquaMai.Helpers;
using HarmonyLib; using HarmonyLib;
@ -19,7 +18,7 @@ public class PractiseMode
private static double repeatStart = -1; private static double repeatStart = -1;
private static double repeatEnd = -1; private static double repeatEnd = -1;
private static float speed = 1; private static float speed = 1;
private static List<CriAtomExPlayer> players = []; private static CriAtomExPlayer player;
private static MovieMaterialMai2 movie; private static MovieMaterialMai2 movie;
private static void SetRepeatEnd(double time) private static void SetRepeatEnd(double time)
@ -47,11 +46,9 @@ public class PractiseMode
private static void SetSpeed() private static void SetSpeed()
{ {
foreach (var player in players) player.SetPitch((float)(1200 * Math.Log(speed, 2)));
{ // player.SetDspTimeStretchRatio(1 / speed);
player.SetPitch((float)(1200 * Math.Log(speed, 2))); player.UpdateAll();
player.UpdateAll();
}
movie.player.SetSpeed(speed); movie.player.SetSpeed(speed);
} }
@ -120,6 +117,7 @@ public class PractiseMode
repeatStart = -1; repeatStart = -1;
repeatEnd = -1; repeatEnd = -1;
speed = 1; speed = 1;
SetSpeed();
} }
[HarmonyPatch(typeof(GameProcess), "OnUpdate")] [HarmonyPatch(typeof(GameProcess), "OnUpdate")]
@ -161,19 +159,23 @@ public class PractiseMode
____curMSec = (float)num + ____msecStartGap; ____curMSec = (float)num + ____msecStartGap;
} }
[HarmonyPatch] [HarmonyPatch(typeof(SoundCtrl), "Initialize")]
public static class PlayerObjCreate [HarmonyPostfix]
public static void SoundCtrlPostInitialize(SoundCtrl.InitParam param, Dictionary<int, object> ____players)
{ {
public static MethodBase TargetMethod() var wrapper = ____players[2];
{ player = (CriAtomExPlayer)wrapper.GetType().GetField("Player").GetValue(wrapper);
var type = typeof(SoundCtrl).GetNestedType("PlayerObj", BindingFlags.NonPublic); // var pool = new CriAtomExStandardVoicePool(1, 8, 96000, true, 2);
return AccessTools.Method(type, "Create"); // pool.AttachDspTimeStretch();
} // player.SetVoicePoolIdentifier(pool.identifier);
public static void Postfix(CriAtomExPlayer ___Player) // debug
{ // var wrapper1 = ____players[7];
players.Add(___Player); // var player1 = (CriAtomExPlayer)wrapper1.GetType().GetField("Player").GetValue(wrapper1);
} // var pool = new CriAtomExStandardVoicePool(1, 8, 96000, true, 2);
// pool.AttachDspTimeStretch();
// player1.SetVoicePoolIdentifier(pool.identifier);
// player1.SetDspTimeStretchRatio(2);
} }
[HarmonyPatch(typeof(MovieController), "Awake")] [HarmonyPatch(typeof(MovieController), "Awake")]