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 ModPatcher v0.0.3
EurekaRyka-ModPatcher.dll
Decompiled a month agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Audio; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("EurekaRyka-ModPatcher")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EurekaRyka-ModPatcher")] [assembly: AssemblyTitle("EurekaRyka-ModPatcher")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace EurekaRyka_ModPatcher { [BepInPlugin("EurekaRyka.ModPatcher", "EurekaRyka Mod Patcher", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { private float nextScan; private AudioMixerGroup soundMixer; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) new Harmony("EurekaRyka.ModPatcher").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"EurekaRyka Mod Patcher loaded."); } private void Update() { if (Time.unscaledTime < nextScan) { return; } nextScan = Time.unscaledTime + 0.25f; if ((Object)(object)soundMixer == (Object)null) { soundMixer = GetSoundMixer(); } if ((Object)(object)soundMixer == (Object)null) { return; } AudioSource[] array = Object.FindObjectsOfType<AudioSource>(true); AudioSource[] array2 = array; foreach (AudioSource val in array2) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.outputAudioMixerGroup != (Object)null)) { bool flag = IsEnemyAudio(((Component)val).transform); bool flag2 = IsFromModAssembly(((Component)val).transform, "EmpressBackrooms"); if (flag || flag2) { val.outputAudioMixerGroup = soundMixer; string text = (flag ? "enemy" : "Backrooms"); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Fixed unmixed " + text + " audio source: " + ((Object)val).name + " | " + GetPath(((Component)val).transform))); } } } } private static bool IsEnemyAudio(Transform transform) { Transform val = transform; while ((Object)(object)val != (Object)null) { Component[] components = ((Component)val).GetComponents<Component>(); Component[] array = components; foreach (Component val2 in array) { if (!((Object)(object)val2 == (Object)null)) { string name = ((object)val2).GetType().Name; if (name == "Enemy" || name == "EnemyParent") { return true; } } } val = val.parent; } return false; } private static AudioMixerGroup GetSoundMixer() { Type type = AccessTools.TypeByName("AudioManager"); if (type == null) { return null; } FieldInfo fieldInfo = AccessTools.Field(type, "instance"); if (fieldInfo == null) { return null; } object value = fieldInfo.GetValue(null); if (value == null) { return null; } FieldInfo fieldInfo2 = AccessTools.Field(type, "SoundMasterGroup"); if (fieldInfo2 != null) { object? value2 = fieldInfo2.GetValue(value); return (AudioMixerGroup)((value2 is AudioMixerGroup) ? value2 : null); } PropertyInfo propertyInfo = AccessTools.Property(type, "SoundMasterGroup"); if (propertyInfo != null) { object? value3 = propertyInfo.GetValue(value, null); return (AudioMixerGroup)((value3 is AudioMixerGroup) ? value3 : null); } return null; } private static string GetPath(Transform transform) { string text = ((Object)transform).name; while ((Object)(object)transform.parent != (Object)null) { transform = transform.parent; text = ((Object)transform).name + "/" + text; } return text; } private static bool IsFromModAssembly(Transform transform, string assemblyName) { Transform val = transform; while ((Object)(object)val != (Object)null) { Component[] components = ((Component)val).GetComponents<Component>(); Component[] array = components; foreach (Component val2 in array) { if (!((Object)(object)val2 == (Object)null)) { string name = ((object)val2).GetType().Assembly.GetName().Name; if (string.Equals(name, assemblyName, StringComparison.OrdinalIgnoreCase)) { return true; } } } val = val.parent; } return false; } } [HarmonyPatch] internal static class CoilheadSpawnPatch { private const float CoilheadChance = 100f; private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("EnemyDirector"); return AccessTools.Method(type, "AmountSetup", (Type[])null, (Type[])null); } private static void Prefix(object __instance) { if (__instance == null) { return; } Type type = __instance.GetType(); IList list = AccessTools.Field(type, "enemiesDifficulty1")?.GetValue(__instance) as IList; IList list2 = AccessTools.Field(type, "enemiesDifficulty2")?.GetValue(__instance) as IList; IList list3 = AccessTools.Field(type, "enemiesDifficulty3")?.GetValue(__instance) as IList; object obj = FindEnemy(list); if (obj == null) { obj = FindEnemy(list2); } if (obj == null) { obj = FindEnemy(list3); } if (obj == null) { return; } if (list2 != null && list2.Contains(obj)) { list2.Remove(obj); } if (list3 != null && list3.Contains(obj)) { list3.Remove(obj); } if (list != null && !list.Contains(obj)) { list.Add(obj); } object obj2 = AccessTools.Field(obj.GetType(), "rarityPreset")?.GetValue(obj); if (obj2 != null) { FieldInfo fieldInfo = AccessTools.Field(obj2.GetType(), "chance"); if (fieldInfo != null) { fieldInfo.SetValue(obj2, 100f); } } } private static object FindEnemy(IList list) { if (list == null) { return null; } foreach (object item in list) { Object val = (Object)((item is Object) ? item : null); if (val != null && val.name == "Enemy - Coilhead") { return item; } } return null; } } [HarmonyPatch] internal static class CoilheadRuntimeDifficultyPatch { private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("EnemyDirector"); return AccessTools.Method(type, "FirstSpawnPointAdd", (Type[])null, (Type[])null); } private static void Prefix(object _enemyParent) { if (_enemyParent == null) { return; } Type type = _enemyParent.GetType(); string text = AccessTools.Field(type, "enemyName")?.GetValue(_enemyParent) as string; if (!(text != "Coilhead")) { FieldInfo fieldInfo = AccessTools.Field(type, "difficulty"); if (!(fieldInfo == null)) { fieldInfo.SetValue(_enemyParent, Enum.ToObject(fieldInfo.FieldType, 0)); } } } } }