Sync playback to the actual beat count rather than relying on BPM #5

Open
ratijas wants to merge 43 commits from ratijas/muzika-gromche:work/r/beats into master
1 changed files with 23 additions and 1 deletions
Showing only changes of commit 730f125d62 - Show all commits

View File

@ -528,7 +528,9 @@ namespace MuzikaGromche
}
Config = new Config(base.Config);
DiscoBallManager.Initialize();
new Harmony(PluginInfo.PLUGIN_NAME).PatchAll(typeof(JesterPatch));
var harmony = new Harmony(PluginInfo.PLUGIN_NAME);
harmony.PatchAll(typeof(JesterPatch));
harmony.PatchAll(typeof(EnemyAIPatch));
}
else
{
@ -1875,6 +1877,26 @@ namespace MuzikaGromche
}
}
[HarmonyPatch(typeof(EnemyAI))]
internal class EnemyAIPatch
{
// JesterAI class does not override abstract method OnDestroy,
// so we have to patch its superclass directly.
[HarmonyPatch(nameof(EnemyAI.OnDestroy))]
[HarmonyPrefix]
public static void CleanUpOnDestroy(EnemyAI __instance)
{
if (__instance is JesterAI)
{
Plugin.ResetLightColor();
DiscoBallManager.Disable();
// Just in case if players have spawned multiple Jesters,
// Don't reset Plugin.CurrentTrack and Plugin.BeatTimeState to null,
// so that the code wouldn't crash without extra null checks.
}
}
}
internal class State
{
public AudioSource farAudio;