Decompiled source of BetterEscapeSequence v0.1.0

BetterEscapeSequence.dll

Decompiled 4 months 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 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 = "")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
namespace Prototype;

[BepInPlugin("prototype.escape.sequence", "BetterEscapeSequence", "0.1.0")]
public class BetterEscapeSequence : BaseUnityPlugin
{
	public const string version = "0.1.0";

	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 && stage.baseSceneName == "moon2")
			{
				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);
			}
		}
	}
}