Decompiled source of BetterEscapeSequence v0.1.1

BetterEscapeSequence.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.0")]
[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 Prototype
{
	[BepInPlugin("prototype.escape.sequence", "BetterEscapeSequence", "0.1.1")]
	public class BetterEscapeSequence : BaseUnityPlugin
	{
		public const string version = "0.1.1";

		public const string identifier = "prototype.escape.sequence";

		private static AsyncOperationHandle<DirectorCardCategorySelection> handle;

		private void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			Harmony instance = null;
			handle = Addressables.LoadAssetAsync<DirectorCardCategorySelection>((object)"RoR2/DLC1/voidstage/dccsVoidStageMonsters.asset");
			Stage.onStageStartGlobal += OnStageStartGlobal;
			SceneCatalog.onMostRecentSceneDefChanged += delegate(SceneDef stage)
			{
				Harmony obj = instance;
				if (obj != null)
				{
					obj.UnpatchSelf();
				}
				if (NetworkServer.active)
				{
					string cachedName = stage.cachedName;
					if ((cachedName == "moon" || cachedName == "moon2") ? true : false)
					{
						instance = Harmony.CreateAndPatchAll(((object)this).GetType(), (string)null);
					}
				}
			};
		}

		[HarmonyPatch(typeof(CombatDirector), "Awake")]
		[HarmonyPrefix]
		private static void Awake(CombatDirector __instance)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			string name = ((Object)__instance).name;
			if (!(name == "VoidReaverDirector"))
			{
				if (!(name == "LunarMonsterDirector"))
				{
					return;
				}
				__instance.creditMultiplier = 0.6f;
			}
			else
			{
				__instance.monsterCards = Object.Instantiate<DirectorCardCategorySelection>(handle.WaitForCompletion());
				for (int i = 0; i < __instance.monsterCards.categories.Length; i++)
				{
					ref Category reference = ref __instance.monsterCards.categories[i];
					DirectorCard[] cards = reference.cards;
					foreach (DirectorCard obj in cards)
					{
						obj.spawnCard = Object.Instantiate<SpawnCard>(obj.spawnCard);
						obj.spawnCard.eliteRules = (EliteRules)1;
					}
					Run instance = Run.instance;
					if (instance == null || instance.loopClearCount > 1)
					{
						continue;
					}
					string name2 = reference.name;
					if (!(name2 == "Champions"))
					{
						if (name2 == "Minibosses")
						{
							reference.selectionWeight = 0.5f;
						}
					}
					else
					{
						reference.selectionWeight = 0f;
					}
				}
				__instance.creditMultiplier = 0.8f;
			}
			__instance.spawnDistanceMultiplier /= 0.5f;
			__instance.minSpawnRange = float.PositiveInfinity;
		}

		[HarmonyPatch(typeof(HoldoutZoneController), "IsPointInChargingRadius", new Type[]
		{
			typeof(HoldoutZoneController),
			typeof(Vector3),
			typeof(float),
			typeof(Vector3)
		})]
		[HarmonyPrefix]
		private static bool IsPointInChargingRadius(ref bool __result, HoldoutZoneController holdoutZoneController, Vector3 origin, Vector3 point)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			HoldoutZoneShape val = (HoldoutZoneShape)1;
			if (holdoutZoneController.holdoutZoneShape != val)
			{
				return true;
			}
			__result = point.y > origin.y - 10f && point.y < origin.y + 100f;
			return __result;
		}

		private void OnStageStartGlobal(Stage stage)
		{
			GameObject[] array = Object.FindObjectsOfType<GameObject>();
			foreach (GameObject val in array)
			{
				if (((Object)val).name.StartsWith("Deadmando") || ((Object)val).name == "HOLDER: Meteors")
				{
					val.SetActive(false);
				}
			}
		}

		[HarmonyPatch(typeof(FrogController), "Pet")]
		[HarmonyPrefix]
		private static void LowerCost(FrogController __instance)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			__instance.maxPets = 1;
			if (__instance.petCount > __instance.maxPets)
			{
				((Behaviour)__instance.purchaseInteraction).enabled = false;
				PortalSpawner portalSpawner = __instance.portalSpawner;
				portalSpawner.spawnMessageToken = "PORTAL_VOID_OPEN";
				portalSpawner.portalSpawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/DLC1/PortalVoid/iscVoidPortal.asset").WaitForCompletion();
				GameObject val = GameObject.Find("/DeepVoidPortal(Clone)");
				if (Object.op_Implicit((Object)(object)val))
				{
					val.SetActive(false);
					portalSpawner.NetworkwillSpawn = true;
				}
			}
		}
	}
}