Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of EnemyPitchTimePatcher v1.0.0
EnemyPitchTimePatch.dll
Decompiled 21 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace EnemyPitchTimePatch { public static class MyPluginInfo { public const string PLUGIN_GUID = "EnemyPitchTimePatch"; public const string PLUGIN_NAME = "Clay Surgeon Patch"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace EnemyPitchPatch { [HarmonyPatch] public static class EnemyPitchPatch { [HarmonyPatch(typeof(EnemyAI), "Start")] [HarmonyPostfix] private static void EnemyStartPostfix(EnemyAI __instance) { ApplyPitch(__instance); } [HarmonyPatch(typeof(EnemyAI), "Update")] [HarmonyPostfix] private static void EnemyUpdatePostfix(EnemyAI __instance) { ApplyPitch(__instance); } private static void ApplyPitch(EnemyAI enemy) { if ((Object)(object)enemy == (Object)null) { return; } float pitch = GetPitch(enemy); if (pitch == -1f) { return; } AudioSource[] componentsInChildren = ((Component)enemy).GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val in componentsInChildren) { if ((Object)(object)val != (Object)null && !Mathf.Approximately(val.pitch, pitch)) { val.pitch = pitch; } } } private static float GetPitch(EnemyAI enemy) { switch (((object)enemy).GetType().Name) { case "HoarderBugAI": return EnemyPitchSettings.HoarderBug.Value; case "FlowermanAI": return EnemyPitchSettings.Bracken.Value; case "SpringManAI": return EnemyPitchSettings.CoilHead.Value; case "JesterAI": return EnemyPitchSettings.Jester.Value; case "GirlAI": return EnemyPitchSettings.GhostGirl.Value; case "MaskedPlayerEnemy": return EnemyPitchSettings.Masked.Value; case "ClaySurgeonAI": return EnemyPitchSettings.Barber.Value; case "NutcrackerEnemyAI": return EnemyPitchSettings.Nutcracker.Value; case "CrawlerAI": return EnemyPitchSettings.Thumper.Value; case "SandSpiderAI": case "SpiderAI": return EnemyPitchSettings.Spider.Value; case "CentipedeAI": return EnemyPitchSettings.SnareFlea.Value; case "ForestGiantAI": return EnemyPitchSettings.ForestKeeper.Value; case "MouthDogAI": return EnemyPitchSettings.EyelessDog.Value; case "BaboonBirdAI": return EnemyPitchSettings.BaboonHawk.Value; case "BushWolfEnemy": return EnemyPitchSettings.KidnapperFox.Value; case "ButlerEnemyAI": return EnemyPitchSettings.Butler.Value; case "DoublewingAI": return EnemyPitchSettings.TulipSnake.Value; case "DocileLocustBeesAI": return EnemyPitchSettings.Locusts.Value; default: return -1f; } } } public static class EnemyPitchSettings { public static ConfigEntry<float> HoarderBug { get; private set; } public static ConfigEntry<float> Bracken { get; private set; } public static ConfigEntry<float> CoilHead { get; private set; } public static ConfigEntry<float> Jester { get; private set; } public static ConfigEntry<float> GhostGirl { get; private set; } public static ConfigEntry<float> Masked { get; private set; } public static ConfigEntry<float> Barber { get; private set; } public static ConfigEntry<float> Nutcracker { get; private set; } public static ConfigEntry<float> Thumper { get; private set; } public static ConfigEntry<float> Spider { get; private set; } public static ConfigEntry<float> SnareFlea { get; private set; } public static ConfigEntry<float> EarthLeviathan { get; private set; } public static ConfigEntry<float> ForestKeeper { get; private set; } public static ConfigEntry<float> EyelessDog { get; private set; } public static ConfigEntry<float> BaboonHawk { get; private set; } public static ConfigEntry<float> KidnapperFox { get; private set; } public static ConfigEntry<float> Butler { get; private set; } public static ConfigEntry<float> TulipSnake { get; private set; } public static ConfigEntry<float> Manticoil { get; private set; } public static ConfigEntry<float> CircuitBees { get; private set; } public static ConfigEntry<float> Locusts { get; private set; } public static ConfigEntry<float> BarberStepInterval { get; private set; } public static ConfigEntry<float> JesterWindupTime { get; private set; } public static ConfigEntry<float> MaskedApproachDuration { get; private set; } public static ConfigEntry<float> MaskedGlowDuration { get; private set; } public static ConfigEntry<float> MaskedInfectionDuration { get; private set; } public static void Initialize(ConfigFile config) { HoarderBug = BindPitch(config, "Enemy Pitch", "HoarderBug"); Bracken = BindPitch(config, "Enemy Pitch", "Bracken"); CoilHead = BindPitch(config, "Enemy Pitch", "CoilHead"); Jester = BindPitch(config, "Enemy Pitch", "Jester"); GhostGirl = BindPitch(config, "Enemy Pitch", "GhostGirl"); Masked = BindPitch(config, "Enemy Pitch", "Masked"); Barber = BindPitch(config, "Enemy Pitch", "Barber"); Nutcracker = BindPitch(config, "Enemy Pitch", "Nutcracker"); Thumper = BindPitch(config, "Enemy Pitch", "Thumper"); Spider = BindPitch(config, "Enemy Pitch", "Spider"); SnareFlea = BindPitch(config, "Enemy Pitch", "SnareFlea"); EarthLeviathan = BindPitch(config, "Enemy Pitch", "EarthLeviathan"); ForestKeeper = BindPitch(config, "Enemy Pitch", "ForestKeeper"); EyelessDog = BindPitch(config, "Enemy Pitch", "EyelessDog"); BaboonHawk = BindPitch(config, "Enemy Pitch", "BaboonHawk"); KidnapperFox = BindPitch(config, "Enemy Pitch", "KidnapperFox"); Butler = BindPitch(config, "Enemy Pitch", "Butler"); TulipSnake = BindPitch(config, "Enemy Pitch", "TulipSnake"); Manticoil = BindPitch(config, "Enemy Pitch", "Manticoil"); CircuitBees = BindPitch(config, "Enemy Pitch", "CircuitBees"); Locusts = BindPitch(config, "Enemy Pitch", "Locusts"); BarberStepInterval = config.Bind<float>("Enemy Timers", "BarberStepInterval", -1f, "Clay Surgeon step interval in seconds. -1 keeps the original."); JesterWindupTime = config.Bind<float>("Enemy Timers", "JesterWindupTime", -1f, "Jester windup duration in seconds. -1 keeps the original."); MaskedApproachDuration = config.Bind<float>("Masked Infection", "ApproachDuration", -1f, "Override the original 0.3 second wait. -1 keeps the original."); MaskedGlowDuration = config.Bind<float>("Masked Infection", "GlowDuration", -1f, "Override the original 1.2 second wait. -1 keeps the original."); MaskedInfectionDuration = config.Bind<float>("Masked Infection", "InfectionDuration", -1f, "Override the original 1.5 second wait. -1 keeps the original."); } private static ConfigEntry<float> BindPitch(ConfigFile config, string section, string key) { return config.Bind<float>(section, key, -1f, "Audio pitch multiplier. -1 keeps the original pitch; any other value sets the pitch."); } } [HarmonyPatch] public static class EnemyTimePatch { private static bool IsHost { get { if ((Object)(object)GameNetworkManager.Instance != (Object)null) { return GameNetworkManager.Instance.isHostingGame; } return false; } } [HarmonyPatch(typeof(JesterAI), "SetJesterInitialValues")] [HarmonyPostfix] private static void JesterInitialValuesPostfix(JesterAI __instance) { if (IsHost && !((Object)(object)__instance == (Object)null)) { float value = EnemyPitchSettings.JesterWindupTime.Value; if (!(value < 0f)) { __instance.popUpTimer = Mathf.Max(0.1f, value); } } } [HarmonyPatch(typeof(ClaySurgeonAI), "HourChanged")] [HarmonyPostfix] private static void BarberHourChangedPostfix(ClaySurgeonAI __instance) { if (IsHost && !((Object)(object)__instance == (Object)null)) { float value = EnemyPitchSettings.BarberStepInterval.Value; if (!(value < 0f)) { __instance.endingInterval = (__instance.startingInterval = (__instance.currentInterval = Mathf.Max(0.1f, value))); } } } } [HarmonyPatch] public static class MaskedCutsceneTimePatch { private static MethodBase TargetMethod() { return AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(MaskedPlayerEnemy), "killAnimation", (Type[])null, (Type[])null)); } [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldc_R4 && instruction.operand is float num) { if (num == 0.3f) { yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MaskedCutsceneTimePatch), "GetApproachDuration", (Type[])null, (Type[])null)); continue; } if (num == 1.2f) { yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MaskedCutsceneTimePatch), "GetGlowDuration", (Type[])null, (Type[])null)); continue; } if (num == 1.5f) { yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MaskedCutsceneTimePatch), "GetInfectionDuration", (Type[])null, (Type[])null)); continue; } } yield return instruction; } } private static float GetApproachDuration() { float value = EnemyPitchSettings.MaskedApproachDuration.Value; if (value != -1f) { return Mathf.Max(0f, value); } return 0.3f; } private static float GetGlowDuration() { float value = EnemyPitchSettings.MaskedGlowDuration.Value; if (value != -1f) { return Mathf.Max(0f, value); } return 1.2f; } private static float GetInfectionDuration() { float value = EnemyPitchSettings.MaskedInfectionDuration.Value; if (value != -1f) { return Mathf.Max(0f, value); } return 1.5f; } } [BepInPlugin("superkiesel.enemypitchpatch", "EnemyPitchPatch", "1.0.0")] public class Plugin : BaseUnityPlugin { private Harmony harmony; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown EnemyPitchSettings.Initialize(((BaseUnityPlugin)this).Config); harmony = new Harmony("superkiesel.enemypitchpatch"); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"EnemyPitchPatch loaded."); } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } }