using System; using System.Collections; 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BerserkerEnemies; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("BerserkerEnemies")] [assembly: IgnoresAccessChecksTo("Discord.Sdk")] [assembly: IgnoresAccessChecksTo("Domain_Reload")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.MemoryProfiler")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Splines")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BerserkerOrbFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.0.2.0")] [assembly: AssemblyInformationalVersion("0.0.2")] [assembly: AssemblyProduct("BerserkerOrbFix")] [assembly: AssemblyTitle("BerserkerOrbFix")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 BerserkerOrbFix { [BepInPlugin("MARCROCK22.BerserkerOrbFix", "BerserkerOrbFix", "0.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static ConfigEntry configEnableHidden; internal static ConfigEntry configEnableCleanupCrew; private readonly Harmony _harmony = new Harmony("MARCROCK22.BerserkerOrbFix"); private void Awake() { Log = ((BaseUnityPlugin)this).Logger; FixContainModded(); InjectMissingEnemyConfig(); _harmony.PatchAll(typeof(DespawnTranspiler)); _harmony.PatchAll(typeof(EnemyValuableExplosionFix)); _harmony.PatchAll(typeof(MissingEnemiesFix)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"BerserkerOrbFix loaded — fixes orb drop, explosion, containModded, and missing enemies"); } private static void FixContainModded() { List list = ModBase.ListPluginFiles(); bool flag = (ModPatch.containModded = list.Contains("WesleysEnemies.dll") || list.Contains("FreddyEnemy.dll") || list.Contains("BaldiEnemy.dll") || list.Contains("Zelda_Moon_Mod.repobundle") || list.Contains("RETEMINATOR.repobundle") || list.Contains("Rolling_Giant_Enemy.repobundle") || list.Contains("MCZombieMod.dll") || list.Contains("DrillerKiller.dll")); Log.LogInfo((object)$"[BerserkerOrbFix] containModded fixed: {flag}"); } private static void InjectMissingEnemyConfig() { ConfigFile config = Chainloader.PluginInfos["Aolion.BerserkerEnemies_Reborn"].Instance.Config; configEnableHidden = config.Bind("Enemies", "Hidden", false, ""); configEnableCleanupCrew = config.Bind("Enemies", "Cleanup Crew", true, ""); Log.LogInfo((object)"[BerserkerOrbFix] Injected Hidden and Cleanup Crew config into BerserkerEnemies"); } } [HarmonyPatch(typeof(ModPatch), "DespawnPrefix")] internal static class DespawnTranspiler { [CompilerGenerated] private sealed class d__0 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable instructions; public IEnumerable <>3__instructions; private FieldInfo 5__2; private FieldInfo 5__3; private bool 5__4; private IEnumerator <>7__wrap4; CodeInstruction IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__2 = null; 5__3 = null; <>7__wrap4 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = AccessTools.Field(typeof(EnemyHealth), "health"); 5__3 = AccessTools.Field(typeof(EnemyHealth), "healthCurrent"); 5__4 = false; <>7__wrap4 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } if (<>7__wrap4.MoveNext()) { CodeInstruction current = <>7__wrap4.Current; if (!5__4 && current.opcode == OpCodes.Ldfld && (FieldInfo)current.operand == 5__2) { current.operand = 5__3; 5__4 = true; Plugin.Log.LogInfo((object)"[BerserkerOrbFix] Patched: EnemyHealth.health → EnemyHealth.healthCurrent"); } <>2__current = current; <>1__state = 1; return true; } <>m__Finally1(); <>7__wrap4 = null; if (!5__4) { Plugin.Log.LogWarning((object)"[BerserkerOrbFix] Could not find EnemyHealth.health field access to patch!"); } return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap4 != null) { <>7__wrap4.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__0 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__0(0); } d__.instructions = <>3__instructions; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [IteratorStateMachine(typeof(d__0))] [HarmonyTranspiler] private static IEnumerable Transpiler(IEnumerable instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(-2) { <>3__instructions = instructions }; } } [HarmonyPatch(typeof(EnemyValuable), "Start")] internal static class EnemyValuableExplosionFix { [HarmonyPostfix] private static void Postfix(EnemyValuable __instance) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance.enemyValuableExplosion != (Object)null) { return; } GameObject val = AssetManager.instance.enemyValuableBig; if ((Object)(object)val == (Object)null) { val = AssetManager.instance.enemyValuableMedium; } if ((Object)(object)val == (Object)null) { val = AssetManager.instance.enemyValuableSmall; } if (!((Object)(object)val == (Object)null)) { EnemyValuable component = val.GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.enemyValuableExplosion == (Object)null)) { GameObject val2 = Object.Instantiate(component.enemyValuableExplosion, ((Component)__instance).transform); val2.transform.localPosition = Vector3.zero; val2.SetActive(false); __instance.enemyValuableExplosion = val2; Plugin.Log.LogInfo((object)"[BerserkerOrbFix] Injected explosion into berserker orb"); } } } } [HarmonyPatch(typeof(ModPatch), "GetEnemyTypes")] internal static class MissingEnemiesFix { [HarmonyPostfix] private static void Postfix(List __result) { if (Plugin.configEnableHidden.Value && !__result.Contains("Hidden")) { __result.Add("Hidden"); } if (Plugin.configEnableCleanupCrew.Value && !__result.Contains("Cleanup Crew")) { __result.Add("Cleanup Crew"); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }