using System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using Dawn; using HarmonyLib; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace FacilityMeltdownBridge; [BepInPlugin("tyler.facilitymeltdownbridge", "FacilityMeltdown Bridge", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "tyler.facilitymeltdownbridge"; public const string PluginName = "FacilityMeltdown Bridge"; public const string PluginVersion = "1.1.0"; private void Awake() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown Harmony val = new Harmony("tyler.facilitymeltdownbridge"); try { val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} v{1} loaded.", "FacilityMeltdown Bridge", "1.1.0")); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)string.Format("{0} failed to apply patches: {1}", "FacilityMeltdown Bridge", arg)); } } } [HarmonyPatch] internal static class HandleEnemiesSpawnableEnemyGuardPatch { [HarmonyTargetMethod] private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("FacilityMeltdown.MeltdownSequence.Behaviours.MeltdownHandler"); if (type == null) { Debug.LogWarning((object)"[FacilityMeltdownBridge] Could not find MeltdownHandler type. Patch not applied."); return null; } Type type2 = AccessTools.Inner(type, "<>c__DisplayClass20_0"); if (type2 == null) { Debug.LogWarning((object)"[FacilityMeltdownBridge] Could not find MeltdownHandler's <>c__DisplayClass20_0 closure type (may have shifted with an update). Patch not applied."); return null; } MethodInfo methodInfo = AccessTools.Method(type2, "b__0", (Type[])null, (Type[])null); if (methodInfo == null) { Debug.LogWarning((object)"[FacilityMeltdownBridge] Could not find the HandleEnemies eligibility lambda. Patch not applied."); return null; } Debug.Log((object)"[FacilityMeltdownBridge] Successfully hooked HandleEnemies' enemy-eligibility lambda."); return methodInfo; } [HarmonyPrefix] private static bool Prefix(SpawnableEnemyWithRarity __0, ref bool __result) { if ((Object)(object)__0.enemyType == (Object)null) { __result = false; return false; } DawnEnemyInfo dawnInfo = EnemyTypeExtensions.GetDawnInfo(__0.enemyType); if (dawnInfo == null) { Debug.LogWarning((object)$"[FacilityMeltdownBridge] {((Object)__0.enemyType).name} has no DawnEnemyInfo - excluding it from the meltdown spawn pool instead of crashing."); __result = false; return false; } return true; } } [HarmonyPatch] internal static class HandleEnemiesVentGuardPatch { [HarmonyTargetMethod] private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("FacilityMeltdown.MeltdownSequence.Behaviours.MeltdownHandler"); if (type == null) { return null; } Type type2 = AccessTools.Inner(type, "<>c"); if (type2 == null) { return null; } return AccessTools.Method(type2, "b__20_1", (Type[])null, (Type[])null); } [HarmonyPrefix] private static bool Prefix(EnemyVent __0, ref bool __result) { if ((Object)(object)__0 == (Object)null) { Debug.LogWarning((object)"[FacilityMeltdownBridge] Null EnemyVent encountered in HandleEnemies filter - treating as ineligible instead of crashing."); __result = false; return false; } return true; } }