Decompiled source of AntiDrone v1.0.0

plugins/AntiDrone.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Configgy;
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: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("AntiDrone")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AntiDrone")]
[assembly: AssemblyTitle("AntiDrone")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("antidrone.cay.ultrakill", "AntiDrone", "1.0.0")]
public class AntiDrone : BaseUnityPlugin
{
	public static AntiDrone Instance;

	private ConfigBuilder configBuilder;

	[Configgable("General", "Enable", 0, null)]
	public static bool modEnabled = true;

	private void Awake()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		Instance = this;
		configBuilder = new ConfigBuilder("antidrone.cay.ultrakill", "AntiDrone");
		configBuilder.BuildAll();
		Harmony val = new Harmony("antidrone.cay.ultrakill");
		val.PatchAll();
		LogInfo("[AntiDrone] i hate these damn drones (loaded)");
	}

	public static void LogInfo(string msg)
	{
		((BaseUnityPlugin)Instance).Logger.LogInfo((object)msg);
	}
}
[HarmonyPatch(typeof(Drone), "Awake")]
public class DroneAwakePatch
{
	[CompilerGenerated]
	private sealed class <DelayedDeath>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Drone drone;

		private MethodInfo <deathMethod>5__1;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <DelayedDeath>d__1(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<deathMethod>5__1 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(0.1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<deathMethod>5__1 = AccessTools.Method(((object)drone).GetType(), "Death", new Type[1] { typeof(bool) }, (Type[])null);
				if (<deathMethod>5__1 != null)
				{
					<deathMethod>5__1.Invoke(drone, new object[1] { true });
				}
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private static void Postfix(Drone __instance)
	{
		if (AntiDrone.modEnabled)
		{
			((MonoBehaviour)__instance).StartCoroutine(DelayedDeath(__instance));
		}
	}

	[IteratorStateMachine(typeof(<DelayedDeath>d__1))]
	private static IEnumerator DelayedDeath(Drone drone)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedDeath>d__1(0)
		{
			drone = drone
		};
	}
}
[HarmonyPatch(typeof(LeaderboardController), "SubmitCyberGrindScore")]
internal class PatchCyberGrindScore
{
	private static bool Prefix()
	{
		return !AntiDrone.modEnabled;
	}
}
[HarmonyPatch(typeof(LeaderboardController), "SubmitLevelScore")]
internal class PatchLevelScore
{
	private static bool Prefix()
	{
		return !AntiDrone.modEnabled;
	}
}