Decompiled source of AbilityRoulette v1.0.1

AbilityRoulette.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BoplFixedMath;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AbilityRoulette")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AbilityRoulette")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3f76e7e0-a196-405d-a575-3ed39b373a2a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AbilityRoulette;

[BepInPlugin("com.ccheeses.abilityroulette", "AbilityRoulette", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Expected O, but got Unknown
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Expected O, but got Unknown
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Expected O, but got Unknown
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin AbilityRoulette is loaded!");
		Harmony val = new Harmony("com.ccheeses.abilityroulette");
		MethodInfo methodInfo = AccessTools.Method(typeof(Ability), "EnterAbility", (Type[])null, (Type[])null);
		MethodInfo methodInfo2 = AccessTools.Method(typeof(myPatches), "EnterAbility", (Type[])null, (Type[])null);
		val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo3 = AccessTools.Method(typeof(Teleport), "CastAbility", (Type[])null, (Type[])null);
		MethodInfo methodInfo4 = AccessTools.Method(typeof(myPatches), "CastAbility", (Type[])null, (Type[])null);
		val.Patch((MethodBase)methodInfo3, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo5 = AccessTools.Method(typeof(Invisibility), "CastInvisibility", (Type[])null, (Type[])null);
		MethodInfo methodInfo6 = AccessTools.Method(typeof(myPatches), "CastInvisibility", (Type[])null, (Type[])null);
		val.Patch((MethodBase)methodInfo5, new HarmonyMethod(methodInfo6), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo7 = AccessTools.Method(typeof(HookshotInstant), "FireHook", (Type[])null, (Type[])null);
		MethodInfo methodInfo8 = AccessTools.Method(typeof(myPatches), "FireHook", (Type[])null, (Type[])null);
		val.Patch((MethodBase)methodInfo7, new HarmonyMethod(methodInfo8), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}
}
public class myPatches
{
	[HarmonyPatch(typeof(Ability), "EnterAbility")]
	[HarmonyPostfix]
	public static void EnterAbility(Ability __instance, PlayerInfo playerInfo, Action<AbilityExitInfo> onExitAbility)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Expected O, but got Unknown
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		if (Updater.RandomInt(1, 100) != 1)
		{
			return;
		}
		Player player = PlayerHandler.Get().GetPlayer(playerInfo.playerId);
		if (player == null)
		{
			return;
		}
		Explosion val = new Explosion();
		Explosion[] array = Resources.FindObjectsOfTypeAll(typeof(Explosion)) as Explosion[];
		Explosion[] array2 = array;
		foreach (Explosion val2 in array2)
		{
			if (((Object)val2).name == "MineExplosion")
			{
				val = val2;
			}
		}
		Explosion val3 = FixTransform.InstantiateFixed<Explosion>(val, player.Position);
		((Component)val3).GetComponent<IPhysicsCollider>().Scale = Fix.One;
		val3.PlayerOwnerId = 256;
		AudioManager.Get().Play("explosion");
	}

	[HarmonyPatch(typeof(Teleport), "CastAbility")]
	[HarmonyPostfix]
	public static void CastAbility(Teleport __instance)
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		if (Updater.RandomInt(1, 100) != 1)
		{
			return;
		}
		InstantAbility value = Traverse.Create((object)__instance).Field("instantAbility").GetValue<InstantAbility>();
		Player player = PlayerHandler.Get().GetPlayer(value.GetPlayerId());
		if (player == null)
		{
			return;
		}
		Explosion val = new Explosion();
		Explosion[] array = Resources.FindObjectsOfTypeAll(typeof(Explosion)) as Explosion[];
		Explosion[] array2 = array;
		foreach (Explosion val2 in array2)
		{
			if (((Object)val2).name == "MineExplosion")
			{
				val = val2;
			}
		}
		Explosion val3 = FixTransform.InstantiateFixed<Explosion>(val, player.Position);
		((Component)val3).GetComponent<IPhysicsCollider>().Scale = Fix.One;
		val3.PlayerOwnerId = 256;
		AudioManager.Get().Play("explosion");
	}

	[HarmonyPatch(typeof(Invisibility), "CastInvisibility")]
	[HarmonyPostfix]
	public static void CastInvisibility(Invisibility __instance)
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		if (Updater.RandomInt(1, 100) != 1)
		{
			return;
		}
		InstantAbility value = Traverse.Create((object)__instance).Field("ia").GetValue<InstantAbility>();
		Player player = PlayerHandler.Get().GetPlayer(value.GetPlayerId());
		if (player == null)
		{
			return;
		}
		Explosion val = new Explosion();
		Explosion[] array = Resources.FindObjectsOfTypeAll(typeof(Explosion)) as Explosion[];
		Explosion[] array2 = array;
		foreach (Explosion val2 in array2)
		{
			if (((Object)val2).name == "MineExplosion")
			{
				val = val2;
			}
		}
		Explosion val3 = FixTransform.InstantiateFixed<Explosion>(val, player.Position);
		((Component)val3).GetComponent<IPhysicsCollider>().Scale = Fix.One;
		val3.PlayerOwnerId = 256;
		AudioManager.Get().Play("explosion");
	}

	[HarmonyPatch(typeof(HookshotInstant), "FireHook")]
	[HarmonyPostfix]
	public static void FireHook(HookshotInstant __instance)
	{
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Expected O, but got Unknown
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		if (Updater.RandomInt(1, 100) != 1)
		{
			return;
		}
		InstantAbility value = Traverse.Create((object)__instance).Field("instantAbility").GetValue<InstantAbility>();
		Player player = PlayerHandler.Get().GetPlayer(value.GetPlayerId());
		if (player == null)
		{
			using (StreamWriter streamWriter = new StreamWriter("C:/Users/B/Desktop/log.txt", append: true))
			{
				streamWriter.WriteLine("fail :(");
				return;
			}
		}
		Explosion val = new Explosion();
		Explosion[] array = Resources.FindObjectsOfTypeAll(typeof(Explosion)) as Explosion[];
		Explosion[] array2 = array;
		foreach (Explosion val2 in array2)
		{
			if (((Object)val2).name == "MineExplosion")
			{
				val = val2;
			}
		}
		Explosion val3 = FixTransform.InstantiateFixed<Explosion>(val, player.Position);
		((Component)val3).GetComponent<IPhysicsCollider>().Scale = Fix.One;
		val3.PlayerOwnerId = 256;
		AudioManager.Get().Play("explosion");
	}
}