forked from nikita/muzika-gromche
Patch Jester destructor to reset the light show
It is needed to despawn Jester via Imperium's Object Explorer.
This commit is contained in:
parent
8e065d3e51
commit
730f125d62
|
@ -528,7 +528,9 @@ namespace MuzikaGromche
|
||||||
}
|
}
|
||||||
Config = new Config(base.Config);
|
Config = new Config(base.Config);
|
||||||
DiscoBallManager.Initialize();
|
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
|
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
|
internal class State
|
||||||
{
|
{
|
||||||
public AudioSource farAudio;
|
public AudioSource farAudio;
|
||||||
|
|
Loading…
Reference in New Issue