Decompiled source of ULTRAKILL MUSTNT LIVE v0.5.0

UKML.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UKML")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My take on the currently unreleased ULTRAKILL Must Die difficulty")]
[assembly: AssemblyFileVersion("0.5.0.0")]
[assembly: AssemblyInformationalVersion("0.5.0+ea6cdecc62868df8fa7676f87d8027e4231baa74")]
[assembly: AssemblyProduct("UKML")]
[assembly: AssemblyTitle("UKML")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.5.0.0")]
[module: UnverifiableCode]
[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 UKML
{
	[BepInPlugin("wacfeld.ukml", "ULTRAKILL Mustn't Live", "0.5.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "wacfeld.ukml";

		public const string PLUGIN_NAME = "ULTRAKILL Mustn't Live";

		public const string PLUGIN_VERSION = "0.5.0";

		private readonly Harmony harmony = new Harmony("wacfeld.ukml");

		private static bool addressableInit;

		public static GameObject shockwave;

		public static GameObject explosion;

		public ManualLogSource Log => ((BaseUnityPlugin)this).Logger;

		public static T LoadObject<T>(string path)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			if (!addressableInit)
			{
				Addressables.InitializeAsync().WaitForCompletion();
				addressableInit = true;
			}
			return Addressables.LoadAssetAsync<T>((object)path).WaitForCompletion();
		}

		private void LoadAll()
		{
			shockwave = LoadObject<GameObject>("Assets/Prefabs/Attacks and Projectiles/PhysicalShockwave.prefab");
			explosion = LoadObject<GameObject>("Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion.prefab");
			Console.WriteLine("loaded assets!");
		}

		private void Awake()
		{
			harmony.PatchAll();
			LoadAll();
			Log.LogInfo((object)"Loaded ULTRAKILL Mustn't Live v0.5.0");
		}
	}
	[HarmonyPatch(typeof(NewMovement))]
	[HarmonyPatch("GetHurt")]
	internal class PatchGetHurt
	{
		private static void Prefix(ref float hardDamageMultiplier)
		{
			hardDamageMultiplier = 0.5f;
		}
	}
	[HarmonyPatch(typeof(SpiderBody))]
	[HarmonyPatch("Start")]
	internal class PatchMauriceStart
	{
		private static void Postfix(ref float ___coolDownMultiplier, ref int ___maxBurst, ref EnemyIdentifier ___eid)
		{
			___coolDownMultiplier = 500f;
			___maxBurst = 5;
		}
	}
	[HarmonyPatch(typeof(SpiderBody))]
	[HarmonyPatch("Update")]
	internal class PatchMauriceUpdate
	{
		private static void Postfix(SpiderBody __instance, EnemyIdentifier ___eid, ref int ___beamsAmount, ref float ___beamProbability)
		{
			if (___eid.beenGasolined)
			{
				__instance.Enrage();
			}
			if (__instance.isEnraged)
			{
				___beamsAmount = 2;
				___beamProbability = 1f;
			}
		}
	}
	[HarmonyPatch(typeof(SpiderBody))]
	[HarmonyPatch("BeamChargeEnd")]
	internal class PatchMauriceBeamChargeEnd
	{
		public static Dictionary<int, bool> beamParryable = new Dictionary<int, bool>();

		private static void Prefix(SpiderBody __instance)
		{
			int instanceID = ((Object)__instance).GetInstanceID();
			if (!beamParryable.ContainsKey(instanceID))
			{
				beamParryable.Add(instanceID, value: false);
			}
			beamParryable[instanceID] = !beamParryable[instanceID];
			if (beamParryable[instanceID])
			{
				__instance.spark = MonoSingleton<DefaultReferenceManager>.Instance.parryableFlash;
			}
			else
			{
				__instance.spark = MonoSingleton<DefaultReferenceManager>.Instance.unparryableFlash;
			}
		}

		private static void Postfix(SpiderBody __instance, ref bool ___parryable, Vector3 ___predictedPlayerPos, EnemyIdentifier ___eid)
		{
			int instanceID = ((Object)__instance).GetInstanceID();
			if (!beamParryable[instanceID])
			{
				___parryable = false;
			}
			if (((MonoBehaviour)__instance).IsInvoking("BeamFire"))
			{
				((MonoBehaviour)__instance).CancelInvoke("BeamFire");
				((MonoBehaviour)__instance).Invoke("BeamFire", 0.25f / ___eid.totalSpeedModifier);
			}
		}
	}
	[HarmonyPatch(typeof(Explosion))]
	[HarmonyPatch("Start")]
	internal class PatchExplosion
	{
		private static void Postfix(Explosion __instance)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.enemy)
			{
				__instance.canHit = (AffectedSubjects)1;
			}
		}
	}
	[HarmonyPatch(typeof(ContinuousBeam))]
	[HarmonyPatch("Update")]
	internal class PatchSchismBeam
	{
		private static void Postfix(ContinuousBeam __instance)
		{
			if (__instance.enemy)
			{
				__instance.canHitEnemy = false;
			}
			else
			{
				__instance.canHitEnemy = true;
			}
		}
	}
	[HarmonyPatch(typeof(Projectile))]
	[HarmonyPatch("Start")]
	internal class PatchProjectileStart
	{
		private static void Postfix(Projectile __instance, ref float ___speed, ref float ___turningSpeedMultiplier)
		{
			___speed *= 2f;
			___turningSpeedMultiplier *= 2f;
		}
	}
	[HarmonyPatch(typeof(Projectile))]
	[HarmonyPatch("Collided")]
	internal class PatchCollided
	{
		private static void Prefix(Projectile __instance, ref bool ___active, Collider other)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			if (___active && (((Component)other).gameObject.CompareTag("Head") || ((Component)other).gameObject.CompareTag("Body") || ((Component)other).gameObject.CompareTag("Limb") || ((Component)other).gameObject.CompareTag("EndLimb")) && !((Component)other).gameObject.CompareTag("Armor"))
			{
				EnemyIdentifierIdentifier componentInParent = ((Component)other).gameObject.GetComponentInParent<EnemyIdentifierIdentifier>();
				EnemyIdentifier val = null;
				if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.eid != (Object)null)
				{
					val = componentInParent.eid;
				}
				if ((Object)(object)val != (Object)null)
				{
					__instance.safeEnemyType = val.enemyType;
				}
			}
		}
	}
	[HarmonyPatch(typeof(StatueBoss))]
	[HarmonyPatch("OrbSpawn")]
	internal class PatchCerbThrow
	{
		public static Dictionary<int, int> orbBounces = new Dictionary<int, int>();

		private static bool Prefix(StatueBoss __instance, Light ___orbLight, Vector3 ___projectedPlayerPos, EnemyIdentifier ___eid, ref bool ___orbGrowing, ParticleSystem ___part)
		{
			//IL_0012: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(AddressablesExtensions.ToAsset(__instance.orbProjectile), new Vector3(((Component)___orbLight).transform.position.x, ((Component)__instance).transform.position.y + 3.5f, ((Component)___orbLight).transform.position.z), Quaternion.identity);
			val.transform.LookAt(___projectedPlayerPos);
			val.GetComponent<Rigidbody>().AddForce(val.transform.forward * 20000f);
			Projectile val2 = default(Projectile);
			if (val.TryGetComponent<Projectile>(ref val2))
			{
				int instanceID = ((Object)val2).GetInstanceID();
				orbBounces.Add(instanceID, 0);
				val2.target = ___eid.target;
			}
			___orbGrowing = false;
			___orbLight.range = 0f;
			___part.Play();
			return false;
		}
	}
	[HarmonyPatch(typeof(Projectile))]
	[HarmonyPatch("FixedUpdate")]
	internal class PatchCerbProj
	{
		private static bool Prefix(Projectile __instance, Rigidbody ___rb, Vector3 ___origScale, AudioSource ___aud, ref float ___radius)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Invalid comparison between Unknown and I4
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.parried || __instance.boosted)
			{
				return true;
			}
			int instanceID = ((Object)__instance).GetInstanceID();
			if (!PatchCerbThrow.orbBounces.ContainsKey(instanceID))
			{
				return true;
			}
			if (PatchCerbThrow.orbBounces[instanceID] >= 5)
			{
				return true;
			}
			if (!__instance.hittingPlayer && !__instance.undeflectable && !__instance.decorative && __instance.speed != 0f && (int)__instance.homingType == 0)
			{
				___rb.velocity = ((Component)__instance).transform.forward * __instance.speed;
			}
			if (__instance.decorative && ((Component)__instance).transform.localScale.x < ___origScale.x)
			{
				___aud.pitch = ((Component)__instance).transform.localScale.x / ___origScale.x * 2.8f;
				((Component)__instance).transform.localScale = Vector3.Slerp(((Component)__instance).transform.localScale, ___origScale, Time.deltaTime * __instance.speed);
			}
			Vector3 velocity = ___rb.velocity;
			Vector3 normalized = ((Vector3)(ref velocity)).normalized;
			velocity = ___rb.velocity;
			RaycastHit[] array = ___rb.SweepTestAll(normalized, ((Vector3)(ref velocity)).magnitude * Time.fixedDeltaTime, (QueryTriggerInteraction)1);
			if (array == null || array.Length == 0)
			{
				return false;
			}
			Array.Sort(array, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance));
			for (int i = 0; i < array.Length; i++)
			{
				GameObject gameObject = ((Component)((RaycastHit)(ref array[i])).transform).gameObject;
				if ((gameObject.layer == 10 || gameObject.layer == 11) && (gameObject.gameObject.CompareTag("Head") || gameObject.gameObject.CompareTag("Body") || gameObject.gameObject.CompareTag("Limb") || gameObject.gameObject.CompareTag("EndLimb") || gameObject.gameObject.CompareTag("Enemy")))
				{
					return false;
				}
				if (LayerMaskDefaults.IsMatchingLayer(gameObject.layer, (LMD)1) || gameObject.layer == 26 || gameObject.CompareTag("Armor"))
				{
					Vector3 normal = ((RaycastHit)(ref array[i])).normal;
					velocity = ___rb.velocity;
					Vector3 val = Vector3.Reflect(((Vector3)(ref velocity)).normalized, ((RaycastHit)(ref array[i])).normal);
					velocity = ___rb.velocity;
					___rb.velocity = val * ((Vector3)(ref velocity)).magnitude;
					PatchCerbThrow.orbBounces[instanceID]++;
					GameObject val2 = Object.Instantiate<GameObject>(Plugin.shockwave, ((Component)___rb).transform.position, Quaternion.identity);
					PhysicalShockwave component = val2.GetComponent<PhysicalShockwave>();
					component.damage = 25;
					component.speed = 75f;
					component.maxSize = 100f;
					component.enemy = true;
					component.enemyType = (EnemyType)0;
					((Component)component).transform.rotation = Quaternion.FromToRotation(((Component)component).transform.rotation * Vector3.up, normal);
					Explosion[] componentsInChildren = Object.Instantiate<GameObject>(Plugin.explosion, ((Component)___rb).transform.position, Quaternion.identity).GetComponentsInChildren<Explosion>();
					Explosion[] array2 = componentsInChildren;
					foreach (Explosion val3 in array2)
					{
						val3.maxSize *= 1.5f;
						val3.damage = Mathf.RoundToInt(__instance.damage);
						val3.enemy = true;
						val3.canHit = (AffectedSubjects)1;
						val3.enemyDamageMultiplier = 0f;
					}
					MonoSingleton<StainVoxelManager>.Instance.TryIgniteAt(((Component)__instance).transform.position, 3);
					break;
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Projectile))]
	[HarmonyPatch("Start")]
	internal class PatchCerbOrbStart
	{
		private static void Postfix(Projectile __instance)
		{
			int instanceID = ((Object)__instance).GetInstanceID();
			if (PatchCerbThrow.orbBounces.ContainsKey(instanceID))
			{
				__instance.ignoreExplosions = true;
			}
		}
	}
	[HarmonyPatch(typeof(Explosion))]
	[HarmonyPatch("Collide")]
	internal class PatchExplosionOrb
	{
		private static bool Prefix(Collider other, Explosion __instance)
		{
			if (!__instance.enemy)
			{
				return true;
			}
			Projectile component = ((Component)other).GetComponent<Projectile>();
			if ((Object)(object)component != (Object)null)
			{
				int instanceID = ((Object)component).GetInstanceID();
				if (PatchCerbThrow.orbBounces.ContainsKey(instanceID))
				{
					return false;
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(StatueBoss))]
	[HarmonyPatch("Update")]
	internal class PatchCerbEnrage
	{
		private static void Postfix(StatueBoss __instance)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			if (__instance.enraged)
			{
				return;
			}
			int instanceID = ((Object)__instance).GetInstanceID();
			StatueBoss[] array = (StatueBoss[])(object)Resources.FindObjectsOfTypeAll(typeof(StatueBoss));
			StatueBoss[] array2 = array;
			foreach (StatueBoss val in array2)
			{
				int instanceID2 = ((Object)val).GetInstanceID();
				if (instanceID2 != instanceID)
				{
					FieldInfo field = typeof(StatueBoss).GetField("st", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
					Statue val2 = (Statue)field.GetValue(val);
					if ((Object)(object)val2 != (Object)null && val2.health < val2.originalHealth / 2f)
					{
						__instance.EnrageDelayed();
						break;
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(StatueBoss))]
	[HarmonyPatch("StompHit")]
	internal class PatchCerbStomp
	{
		private static void Postfix(GameObject ___currentStompWave, AssetReference ___stompWave, StatueBoss __instance, EnemyIdentifier ___eid)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			___currentStompWave = Object.Instantiate<GameObject>(AddressablesExtensions.ToAsset(___stompWave), ((Component)__instance).transform.position, Quaternion.identity);
			PhysicalShockwave component = ___currentStompWave.GetComponent<PhysicalShockwave>();
			((Component)component).transform.rotation = ((Component)__instance).transform.rotation;
			((Component)component).transform.Rotate(Vector3.forward * 90f, (Space)1);
			component.damage = 25;
			component.speed = 75f;
			AudioSource val = default(AudioSource);
			if (((Component)component).TryGetComponent<AudioSource>(ref val))
			{
				((Behaviour)val).enabled = false;
			}
			component.damage = Mathf.RoundToInt((float)component.damage * ___eid.totalDamageModifier);
			component.maxSize = 100f;
			component.enemy = true;
			component.enemyType = (EnemyType)0;
		}
	}
	[HarmonyPatch(typeof(StatueBoss))]
	[HarmonyPatch("Tackle")]
	internal class PatchTackle
	{
		private static void Postfix(StatueBoss __instance, ref int ___extraTackles)
		{
			if (__instance.enraged)
			{
				___extraTackles++;
			}
		}
	}
	[HarmonyPatch(typeof(StatueBoss))]
	[HarmonyPatch("Dash")]
	internal class PatchDash
	{
		private static void Postfix(GameObject ___currentStompWave, AssetReference ___stompWave, StatueBoss __instance, EnemyIdentifier ___eid, ref int ___extraTackles)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			float num = 45f;
			num = ((!__instance.enraged) ? ((___extraTackles == 1) ? 45f : 135f) : ((___extraTackles != 0) ? ((___extraTackles == 2) ? 45f : 135f) : 0f));
			___currentStompWave = Object.Instantiate<GameObject>(AddressablesExtensions.ToAsset(___stompWave), ((Component)__instance).transform.position, Quaternion.identity);
			PhysicalShockwave component = ___currentStompWave.GetComponent<PhysicalShockwave>();
			((Component)component).transform.rotation = ((Component)__instance).transform.rotation;
			((Component)component).transform.Rotate(Vector3.forward * num, (Space)1);
			component.damage = 25;
			component.speed = 75f;
			component.damage = Mathf.RoundToInt((float)component.damage * ___eid.totalDamageModifier);
			component.maxSize = 100f;
			component.enemy = true;
			component.enemyType = (EnemyType)0;
		}
	}
	[HarmonyPatch(typeof(StatueBoss))]
	[HarmonyPatch("StopDash")]
	internal class PatchStopDash
	{
		private static void Postfix(StatueBoss __instance, ref float ___realSpeedModifier)
		{
			if (((MonoBehaviour)__instance).IsInvoking("DelayedTackle"))
			{
				((MonoBehaviour)__instance).CancelInvoke("DelayedTackle");
				float num = 0.25f;
				if (!__instance.enraged && Random.value > 0.75f)
				{
					num += 0.5f;
				}
				((MonoBehaviour)__instance).Invoke("DelayedTackle", num / ___realSpeedModifier);
			}
		}
	}
	[HarmonyPatch(typeof(StatueBoss))]
	[HarmonyPatch("Update")]
	internal class PatchCerbCooldown
	{
		private static void Postfix(StatueBoss __instance)
		{
			int num = ((!__instance.enraged) ? 1 : 3);
			for (int i = 0; i < num; i++)
			{
				if (__instance.attackCheckCooldown > 0f)
				{
					__instance.attackCheckCooldown = Mathf.MoveTowards(__instance.attackCheckCooldown, 0f, Time.deltaTime);
				}
			}
		}
	}
	[HarmonyPatch(typeof(StatueBoss))]
	[HarmonyPatch("SetSpeed")]
	internal class PatchCerbAnim
	{
		private static void Postfix(StatueBoss __instance, Animator ___anim)
		{
			if (__instance.enraged)
			{
				___anim.speed *= 1.5f;
			}
			else
			{
				___anim.speed *= 1.2f;
			}
		}
	}
	[HarmonyPatch(typeof(Guttertank))]
	[HarmonyPatch("PunchStop")]
	internal class PatchGTEnrage
	{
		public static HashSet<int> enraged = new HashSet<int>();

		public static Dictionary<int, GameObject> effects = new Dictionary<int, GameObject>();

		private static void Postfix(Guttertank __instance, ref bool ___punchHit, Machine ___mach)
		{
			if (!___punchHit)
			{
				int instanceID = ((Object)__instance).GetInstanceID();
				if (!enraged.Contains(instanceID))
				{
					enraged.Add(instanceID);
					Console.WriteLine("enraging!");
					GameObject value = Object.Instantiate<GameObject>(MonoSingleton<DefaultReferenceManager>.Instance.enrageEffect, ___mach.chest.transform);
					effects.Add(instanceID, value);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Guttertank))]
	[HarmonyPatch("Death")]
	internal class PatchGTUnenrage
	{
		private static void Postfix(Guttertank __instance)
		{
			int instanceID = ((Object)__instance).GetInstanceID();
			if (PatchGTEnrage.effects.ContainsKey(instanceID))
			{
				Console.WriteLine("destroying enrage effect");
				Object.Destroy((Object)(object)PatchGTEnrage.effects[instanceID]);
				PatchGTEnrage.effects.Remove(instanceID);
			}
			if (PatchGTEnrage.enraged.Contains(instanceID))
			{
				PatchGTEnrage.enraged.Remove(instanceID);
			}
		}
	}
	[HarmonyPatch(typeof(Guttertank))]
	[HarmonyPatch("FireRocket")]
	internal class PatchGTFire
	{
		public static Dictionary<int, GameObject> enragedRocketEffects = new Dictionary<int, GameObject>();

		private static bool Prefix(Guttertank __instance, Vector3 ___overrideTargetPosition, EnemyIdentifier ___eid, ref int ___difficulty, ref float ___shootCooldown)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			Object.Instantiate<GameObject>(__instance.rocketParticle, __instance.shootPoint.position, Quaternion.LookRotation(___overrideTargetPosition - __instance.shootPoint.position));
			Grenade val = Object.Instantiate<Grenade>(__instance.rocket, MonoSingleton<WeaponCharges>.Instance.rocketFrozen ? (__instance.shootPoint.position + __instance.shootPoint.forward * 2.5f) : __instance.shootPoint.position, Quaternion.LookRotation(___overrideTargetPosition - __instance.shootPoint.position));
			val.proximityTarget = ___eid.target;
			val.ignoreEnemyType.Add(___eid.enemyType);
			val.originEnemy = ___eid;
			if (___eid.totalDamageModifier != 1f)
			{
				val.totalDamageMultiplier = ___eid.totalDamageModifier;
			}
			if (___difficulty == 1)
			{
				val.rocketSpeed *= 0.8f;
			}
			else if (___difficulty == 0)
			{
				val.rocketSpeed *= 0.6f;
			}
			___shootCooldown = Random.Range(1.25f, 1.75f) - ((___difficulty >= 4) ? 0.5f : 0f);
			int instanceID = ((Object)__instance).GetInstanceID();
			if (PatchGTEnrage.enraged.Contains(instanceID))
			{
				Console.WriteLine("enraging rocket");
				GameObject val2 = Object.Instantiate<GameObject>(MonoSingleton<DefaultReferenceManager>.Instance.enrageEffect, ((Component)val.rb).transform);
				AudioSource component = val2.GetComponent<AudioSource>();
				component.pitch = 3f;
				int instanceID2 = ((Object)val).GetInstanceID();
				if (!enragedRocketEffects.ContainsKey(instanceID2))
				{
					enragedRocketEffects.Add(instanceID2, val2);
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Grenade))]
	[HarmonyPatch("Explode")]
	internal class PatchRocketExplode
	{
		private static void Postfix(Grenade __instance)
		{
			int instanceID = ((Object)__instance).GetInstanceID();
			if (PatchGTFire.enragedRocketEffects.ContainsKey(instanceID))
			{
				Object.Destroy((Object)(object)PatchGTFire.enragedRocketEffects[instanceID]);
				PatchGTFire.enragedRocketEffects.Remove(instanceID);
			}
		}
	}
	[HarmonyPatch(typeof(Grenade))]
	[HarmonyPatch("ProximityExplosion")]
	internal class PatchRocketProxExplode
	{
		private static bool Prefix(Grenade __instance, ref bool ___exploded)
		{
			int instanceID = ((Object)__instance).GetInstanceID();
			if (!PatchGTFire.enragedRocketEffects.ContainsKey(instanceID))
			{
				return true;
			}
			if (___exploded)
			{
				return false;
			}
			EnragedExplosion(__instance, ref ___exploded);
			return false;
		}

		public static void EnragedExplosion(Grenade __instance, ref bool ___exploded)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			float num = 5f;
			___exploded = true;
			int num2 = Mathf.RoundToInt(3f * num);
			MonoSingleton<StainVoxelManager>.Instance.TryIgniteAt(((Component)__instance).transform.position, num2);
			GameObject val = Object.Instantiate<GameObject>(__instance.explosion, ((Component)__instance).transform.position, Quaternion.identity);
			Explosion[] componentsInChildren = val.GetComponentsInChildren<Explosion>();
			Explosion[] array = componentsInChildren;
			foreach (Explosion val2 in array)
			{
				val2.sourceWeapon = __instance.sourceWeapon;
				val2.hitterWeapon = __instance.hitterWeapon;
				val2.isFup = false;
				if (__instance.enemy)
				{
					val2.enemy = true;
				}
				if (__instance.ignoreEnemyType.Count > 0)
				{
					val2.toIgnore = __instance.ignoreEnemyType;
				}
				val2.maxSize *= 1.5f * num;
				val2.speed *= 3f;
				if (__instance.totalDamageMultiplier != 1f)
				{
					val2.damage = (int)((float)val2.damage * __instance.totalDamageMultiplier);
				}
				if (Object.op_Implicit((Object)(object)__instance.originEnemy))
				{
					val2.originEnemy = __instance.originEnemy;
				}
				if (val2.damage != 0)
				{
					val2.rocketExplosion = true;
				}
				else
				{
					Object.Destroy((Object)(object)val2);
				}
			}
			Object.Destroy((Object)(object)((Component)__instance).gameObject);
			int instanceID = ((Object)__instance).GetInstanceID();
			if (PatchGTFire.enragedRocketEffects.ContainsKey(instanceID))
			{
				Object.Destroy((Object)(object)PatchGTFire.enragedRocketEffects[instanceID]);
				PatchGTFire.enragedRocketEffects.Remove(instanceID);
			}
		}
	}
	[HarmonyPatch(typeof(Grenade))]
	[HarmonyPatch("Collision")]
	internal class PatchEnragedRocketCollision
	{
		private static bool Prefix(Collider other, Grenade __instance, ref bool ___exploded, ref bool ___enemy, CapsuleCollider ___col, Rigidbody ___rb, ref bool ___hasBeenRidden)
		{
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_045c: Invalid comparison between Unknown and I4
			int instanceID = ((Object)__instance).GetInstanceID();
			if (!PatchGTFire.enragedRocketEffects.ContainsKey(instanceID))
			{
				return true;
			}
			if (___exploded || (!___enemy && ((Component)other).CompareTag("Player")) || ((Component)other).gameObject.layer == 14 || ((Component)other).gameObject.layer == 20)
			{
				return false;
			}
			bool flag = false;
			EnemyIdentifierIdentifier val = default(EnemyIdentifierIdentifier);
			if ((((Component)other).gameObject.layer == 11 || ((Component)other).gameObject.layer == 10) && (Object.op_Implicit((Object)(object)other.attachedRigidbody) ? ((Component)other.attachedRigidbody).TryGetComponent<EnemyIdentifierIdentifier>(ref val) : ((Component)other).TryGetComponent<EnemyIdentifierIdentifier>(ref val)) && Object.op_Implicit((Object)(object)val.eid))
			{
				if ((int)val.eid.enemyType == 4 && !val.eid.isGasolined)
				{
					flag = true;
				}
				else
				{
					if (__instance.ignoreEnemyType.Count > 0 && __instance.ignoreEnemyType.Contains(val.eid.enemyType))
					{
						return false;
					}
					if (val.eid.dead)
					{
						Physics.IgnoreCollision((Collider)(object)___col, other, true);
						return false;
					}
				}
			}
			if (!flag && ((Component)other).gameObject.CompareTag("Armor"))
			{
				flag = true;
			}
			if (flag)
			{
				___rb.constraints = (RigidbodyConstraints)0;
				RaycastHit val2 = default(RaycastHit);
				if (Physics.Raycast(((Component)__instance).transform.position - ((Component)__instance).transform.forward, ((Component)__instance).transform.forward, ref val2, float.PositiveInfinity, LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)3))))
				{
					Vector3 velocity = ___rb.velocity;
					___rb.velocity = Vector3.zero;
					Vector3 val3 = Vector3.Reflect(((Vector3)(ref velocity)).normalized, ((RaycastHit)(ref val2)).normal);
					___rb.AddForce(((Vector3)(ref val3)).normalized * ((Vector3)(ref velocity)).magnitude * 2f, (ForceMode)2);
					Transform transform = ((Component)__instance).transform;
					val3 = Vector3.Reflect(((Vector3)(ref velocity)).normalized, ((RaycastHit)(ref val2)).normal);
					transform.forward = ((Vector3)(ref val3)).normalized;
					Vector2 insideUnitCircle = Random.insideUnitCircle;
					___rb.AddTorque(Vector2.op_Implicit(((Vector2)(ref insideUnitCircle)).normalized * (float)Random.Range(0, 250)));
				}
				Object.Instantiate<GameObject>(MonoSingleton<DefaultReferenceManager>.Instance.ineffectiveSound, ((Component)__instance).transform.position, Quaternion.identity).GetComponent<AudioSource>().volume = 0.75f;
				return false;
			}
			bool flag2 = false;
			bool flag3 = false;
			bool flag4 = false;
			if (__instance.rocket)
			{
				if (((Component)other).gameObject.layer == 10 || ((Component)other).gameObject.layer == 11)
				{
					EnemyIdentifierIdentifier component = ((Component)other).GetComponent<EnemyIdentifierIdentifier>();
					if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.eid))
					{
						if (__instance.levelledUp)
						{
							flag4 = true;
						}
						else if (!component.eid.dead && !component.eid.flying && ((Object.op_Implicit((Object)(object)component.eid.gce) && !component.eid.gce.onGround) || TimeSince.op_Implicit(component.eid.timeSinceSpawned) <= 0.15f))
						{
							flag4 = true;
						}
						if (component.eid.stuckMagnets.Count > 0)
						{
							foreach (Magnet stuckMagnet in component.eid.stuckMagnets)
							{
								if (!((Object)(object)stuckMagnet == (Object)null))
								{
									stuckMagnet.DamageMagnet((float)((!flag4) ? 1 : 2));
								}
							}
						}
						if ((Object)(object)component.eid == (Object)(object)__instance.originEnemy && !component.eid.blessed)
						{
							if (___hasBeenRidden && !__instance.frozen && (int)__instance.originEnemy.enemyType == 34)
							{
								__instance.originEnemy.Explode(true);
								MonoSingleton<StyleHUD>.Instance.AddPoints(300, "ultrakill.roundtrip", (GameObject)null, component.eid, -1, "", "");
							}
							else
							{
								MonoSingleton<StyleHUD>.Instance.AddPoints(100, "ultrakill.rocketreturn", (GameObject)null, component.eid, -1, "", "");
							}
						}
					}
					MonoSingleton<TimeController>.Instance.HitStop(0.05f);
				}
				else if (!___enemy || !((Component)other).gameObject.CompareTag("Player"))
				{
					flag2 = true;
				}
			}
			else if (!LayerMaskDefaults.IsMatchingLayer(((Component)other).gameObject.layer, (LMD)1))
			{
				MonoSingleton<TimeController>.Instance.HitStop(0.05f);
			}
			PatchRocketProxExplode.EnragedExplosion(__instance, ref ___exploded);
			return false;
		}
	}
	[HarmonyPatch]
	internal class PatchLandmine
	{
		public static HashSet<int> parriedByPlayer = new HashSet<int>();

		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(Landmine), "Explode", new Type[1] { typeof(bool) }, (Type[])null);
		}

		private static bool Prefix(bool super, Landmine __instance, ref bool ___exploded, GameObject ___superExplosion, GameObject ___explosion)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!___exploded)
			{
				___exploded = true;
				Explosion[] componentsInChildren = Object.Instantiate<GameObject>(super ? ___superExplosion : ___explosion, ((Component)__instance).transform.position, Quaternion.identity).GetComponentsInChildren<Explosion>();
				int instanceID = ((Object)__instance).GetInstanceID();
				bool enemy = !parriedByPlayer.Contains(instanceID);
				Explosion[] array = componentsInChildren;
				foreach (Explosion val in array)
				{
					val.enemy = enemy;
				}
				Object.Destroy((Object)(object)((Component)__instance).gameObject);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Landmine))]
	[HarmonyPatch("Parry")]
	internal class PatchLandmineParry
	{
		private static void Postfix(Landmine __instance, GameObject ___parryZone, ref Vector3 ___movementDirection)
		{
			int instanceID = ((Object)__instance).GetInstanceID();
			if (!PatchLandmine.parriedByPlayer.Contains(instanceID))
			{
				PatchLandmine.parriedByPlayer.Add(instanceID);
			}
			___parryZone.SetActive(true);
		}
	}
	[HarmonyPatch(typeof(Guttertank))]
	[HarmonyPatch("Update")]
	internal class PatchGTUpdate
	{
		public static Dictionary<int, bool> punchParryable = new Dictionary<int, bool>();

		public static HashSet<int> punchedMines = new HashSet<int>();

		private static bool Prefix(Guttertank __instance, ref bool ___dead, EnemyIdentifier ___eid, ref bool ___inAction, ref bool ___overrideTarget, ref Vector3 ___overrideTargetPosition, ref bool ___trackInAction, ref bool ___moveForward, ref float ___lineOfSightTimer, ref float ___shootCooldown, ref float ___mineCooldown, ref int ___difficulty, ref float ___punchCooldown, Animator ___anim, NavMeshAgent ___nma, ref bool ___lookAtTarget, ref bool ___punching, SwingCheck2 ___sc, ref bool ___punchHit, Machine ___mach, Collider ___col)
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			if (___dead || ___eid.target == null)
			{
				return false;
			}
			if (___inAction)
			{
				Vector3 val = ___eid.target.headPosition;
				if (___overrideTarget)
				{
					val = ___overrideTargetPosition;
				}
				if (___trackInAction | ___moveForward)
				{
					((Component)__instance).transform.rotation = Quaternion.RotateTowards(((Component)__instance).transform.rotation, Quaternion.LookRotation(new Vector3(val.x, ((Component)__instance).transform.position.y, val.z) - ((Component)__instance).transform.position), (float)(___trackInAction ? 360 : 90) * Time.deltaTime);
				}
			}
			else
			{
				RaycastHit val2 = default(RaycastHit);
				bool flag = !Physics.Raycast(((Component)__instance).transform.position + Vector3.up, ___eid.target.headPosition - (((Component)__instance).transform.position + Vector3.up), ref val2, Vector3.Distance(___eid.target.position, ((Component)__instance).transform.position + Vector3.up), LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)1)));
				___lineOfSightTimer = Mathf.MoveTowards(___lineOfSightTimer, (float)(flag ? 1 : 0), Time.deltaTime * ___eid.totalSpeedModifier);
				if (___shootCooldown > 0f)
				{
					___shootCooldown = Mathf.MoveTowards(___shootCooldown, 0f, Time.deltaTime * ___eid.totalSpeedModifier);
				}
				if (___mineCooldown > 0f)
				{
					___mineCooldown = Mathf.MoveTowards(___mineCooldown, 0f, Time.deltaTime * ((___lineOfSightTimer >= 0.5f) ? 0.5f : 1f) * ___eid.totalSpeedModifier);
				}
				if (___lineOfSightTimer >= 0.5f)
				{
					if (___difficulty <= 1 && Vector3.Distance(((Component)__instance).transform.position, ___eid.target.position) > 10f && Vector3.Distance(((Component)__instance).transform.position, ___eid.target.PredictTargetPosition(0.5f, false)) > 10f)
					{
						___punchCooldown = ((___difficulty == 1) ? 1 : 2);
					}
					if (___punchCooldown <= 0f && (Vector3.Distance(((Component)__instance).transform.position, ___eid.target.position) < 10f || Vector3.Distance(((Component)__instance).transform.position, ___eid.target.PredictTargetPosition(0.5f, false)) < 10f))
					{
						MethodInfo method = typeof(Guttertank).GetMethod("Punch", BindingFlags.Instance | BindingFlags.NonPublic);
						method.Invoke(__instance, null);
					}
					else if (___shootCooldown <= 0f && Vector3.Distance(((Component)__instance).transform.position, ___eid.target.PredictTargetPosition(1f, false)) > 15f)
					{
						if (MonoSingleton<WeaponCharges>.Instance.rocketFrozen)
						{
							MinePunch(__instance, ref ___inAction, ___nma, ref ___trackInAction, ref ___lookAtTarget, ref ___punching, ref ___shootCooldown, ref ___difficulty, ___anim, ___sc, ref ___punchHit, ___mach, ref ___overrideTargetPosition, ___eid, ref ___overrideTarget, ___col);
						}
						else
						{
							MethodInfo method2 = typeof(Guttertank).GetMethod("PrepRocket", BindingFlags.Instance | BindingFlags.NonPublic);
							method2.Invoke(__instance, null);
						}
					}
				}
				if (!___inAction && ___mineCooldown <= 0f && !MonoSingleton<WeaponCharges>.Instance.rocketFrozen)
				{
					MethodInfo method3 = typeof(Guttertank).GetMethod("CheckMines", BindingFlags.Instance | BindingFlags.NonPublic);
					if ((bool)method3.Invoke(__instance, null))
					{
						MethodInfo method4 = typeof(Guttertank).GetMethod("PrepMine", BindingFlags.Instance | BindingFlags.NonPublic);
						method4.Invoke(__instance, null);
					}
					else
					{
						___mineCooldown = 0.5f;
					}
				}
			}
			___punchCooldown = Mathf.MoveTowards(___punchCooldown, 0f, Time.deltaTime * ___eid.totalSpeedModifier);
			Vector3 velocity = ___nma.velocity;
			___anim.SetBool("Walking", ((Vector3)(ref velocity)).magnitude > 2.5f);
			return false;
		}

		private static void MinePunch(Guttertank __instance, ref bool ___inAction, NavMeshAgent ___nma, ref bool ___trackInAction, ref bool ___lookAtTarget, ref bool ___punching, ref float ___shootCooldown, ref int ___difficulty, Animator ___anim, SwingCheck2 ___sc, ref bool ___punchHit, Machine ___mach, ref Vector3 ___overrideTargetPosition, EnemyIdentifier ___eid, ref bool ___overrideTarget, Collider ___col)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			Console.WriteLine("mine punch!");
			___anim.Play("Punch", 0, 0f);
			Object.Instantiate<AudioSource>(__instance.punchPrepSound, ((Component)__instance).transform);
			Transform transform = Object.Instantiate<GameObject>(MonoSingleton<DefaultReferenceManager>.Instance.parryableFlash, ((Component)___sc).transform.position + ((Component)__instance).transform.forward, ((Component)__instance).transform.rotation).transform;
			transform.localScale *= 5f;
			___inAction = true;
			((Behaviour)___nma).enabled = false;
			___trackInAction = true;
			___lookAtTarget = true;
			___punching = true;
			___punchHit = true;
			int instanceID = ((Object)__instance).GetInstanceID();
			if (!punchParryable.ContainsKey(instanceID))
			{
				punchParryable.Add(instanceID, value: true);
			}
			else
			{
				punchParryable[instanceID] = true;
			}
			___mach.parryable = true;
			___shootCooldown = 0.25f;
			PredictTargetMine(__instance, ___eid, ref ___overrideTarget, ref ___difficulty, ref ___overrideTargetPosition, ___col, ___mach);
		}

		private static void PredictTargetMine(Guttertank __instance, EnemyIdentifier ___eid, ref bool ___overrideTarget, ref int ___difficulty, ref Vector3 ___overrideTargetPosition, Collider ___col, Machine ___mach)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			if (___eid.target == null)
			{
				return;
			}
			___overrideTarget = true;
			float num = 250f;
			Vector3 minePos = PatchGTPunchParryable.GetMinePos(___mach, ref ___overrideTargetPosition);
			___overrideTargetPosition = ___eid.target.PredictTargetPosition(0.5f + Vector3.Distance(minePos, ___eid.target.headPosition) / num, false);
			if (Physics.Raycast(___eid.target.position, Vector3.down, 15f, LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)1))))
			{
				___overrideTargetPosition = new Vector3(___overrideTargetPosition.x, ___eid.target.headPosition.y, ___overrideTargetPosition.z);
			}
			bool flag = false;
			RaycastHit val = default(RaycastHit);
			Breakable val2 = default(Breakable);
			if (Physics.Raycast(__instance.aimBone.position, ___overrideTargetPosition - __instance.aimBone.position, ref val, Vector3.Distance(___overrideTargetPosition, __instance.aimBone.position), LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)2))) && (!((Component)((RaycastHit)(ref val)).transform).TryGetComponent<Breakable>(ref val2) || !val2.playerOnly))
			{
				flag = true;
				___overrideTargetPosition = ___eid.target.headPosition;
			}
			if (!flag && ___overrideTargetPosition != ___eid.target.headPosition)
			{
				Vector3 headPosition = ___eid.target.headPosition;
				Vector3 val3 = ___overrideTargetPosition - ___eid.target.headPosition;
				if (___col.Raycast(new Ray(headPosition, ((Vector3)(ref val3)).normalized), ref val, Vector3.Distance(___eid.target.headPosition, ___overrideTargetPosition)))
				{
					___overrideTargetPosition = ___eid.target.headPosition;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Landmine))]
	[HarmonyPatch("Start")]
	internal class PatchLandmineStart
	{
		private static void Postfix(Landmine __instance, Rigidbody ___rb, ref bool ___activated, GameObject ___parryZone, ref bool ___parried, ref Vector3 ___movementDirection)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			int instanceID = ((Object)__instance).GetInstanceID();
			if (PatchGTUpdate.punchedMines.Contains(instanceID))
			{
				PatchGTUpdate.punchedMines.Remove(instanceID);
				___rb.isKinematic = false;
				___rb.useGravity = true;
				___activated = true;
				___parryZone.SetActive(true);
				___parried = true;
				___movementDirection = ((Component)__instance).transform.forward;
				___rb.useGravity = true;
				__instance.SetColor(new Color(0f, 1f, 1f));
				((MonoBehaviour)__instance).Invoke("Explode", 3f);
			}
		}
	}
	[HarmonyPatch(typeof(Guttertank))]
	[HarmonyPatch("PunchActive")]
	internal class PatchGTPunchParryable
	{
		public static Vector3 GetMinePos(Machine ___mach, ref Vector3 ___overrideTargetPosition)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ___mach.chest.transform.position;
			Vector3 val = ___overrideTargetPosition - position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			return position + normalized * 10f;
		}

		private static void Postfix(Guttertank __instance, SwingCheck2 ___sc, ref bool ___moveForward, ref bool ___trackInAction, ref Vector3 ___overrideTargetPosition, EnemyIdentifier ___eid, Machine ___mach)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			Console.WriteLine("punch active!");
			int instanceID = ((Object)__instance).GetInstanceID();
			if (PatchGTUpdate.punchParryable.ContainsKey(instanceID) && PatchGTUpdate.punchParryable[instanceID])
			{
				Vector3 minePos = GetMinePos(___mach, ref ___overrideTargetPosition);
				Landmine val = Object.Instantiate<Landmine>(__instance.landmine, minePos, Quaternion.LookRotation(___overrideTargetPosition - minePos));
				Landmine val2 = default(Landmine);
				if (((Component)val).TryGetComponent<Landmine>(ref val2))
				{
					val2.originEnemy = ___eid;
					int instanceID2 = ((Object)val2).GetInstanceID();
					PatchGTUpdate.punchedMines.Add(instanceID2);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Guttertank))]
	[HarmonyPatch("PunchStop")]
	internal class PatchGTPunchStopParryable
	{
		private static void Postfix(Guttertank __instance, Machine ___mach)
		{
			int instanceID = ((Object)__instance).GetInstanceID();
			if (PatchGTUpdate.punchParryable.ContainsKey(instanceID))
			{
				PatchGTUpdate.punchParryable[instanceID] = false;
				___mach.parryable = false;
			}
		}
	}
	[HarmonyPatch(typeof(Guttertank))]
	[HarmonyPatch("GotParried")]
	internal class PatchGTParried
	{
		private static bool Prefix(Guttertank __instance, Machine ___mach)
		{
			int instanceID = ((Object)__instance).GetInstanceID();
			if (PatchGTUpdate.punchParryable.ContainsKey(instanceID) && PatchGTUpdate.punchParryable[instanceID])
			{
				___mach.parryable = false;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Landmine))]
	[HarmonyPatch("OnCollisionEnter")]
	internal class PatchMineCollide
	{
		private static bool Prefix(Landmine __instance, ref bool ___parried, ref bool ___exploded, Collision collision)
		{
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Invalid comparison between Unknown and I4
			if (!___parried | ___exploded)
			{
				return false;
			}
			int instanceID = ((Object)__instance).GetInstanceID();
			if ((Object)(object)collision.gameObject == (Object)(object)((Component)MonoSingleton<NewMovement>.Instance).gameObject && PatchLandmine.parriedByPlayer.Contains(instanceID))
			{
				return false;
			}
			EnemyIdentifier val = null;
			EnemyIdentifierIdentifier val2 = null;
			ParryHelper val3 = default(ParryHelper);
			if (collision.gameObject.layer == 26 && collision.gameObject.TryGetComponent<ParryHelper>(ref val3) && Object.op_Implicit((Object)(object)val3.target))
			{
				((Component)val3.target).TryGetComponent<EnemyIdentifier>(ref val);
			}
			if (Object.op_Implicit((Object)(object)val) || (collision.gameObject.TryGetComponent<EnemyIdentifierIdentifier>(ref val2) && Object.op_Implicit((Object)(object)val2.eid)) || collision.gameObject.TryGetComponent<EnemyIdentifier>(ref val))
			{
				if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.eid))
				{
					val = val2.eid;
				}
				if (!val.dead)
				{
					if ((Object)(object)val == (Object)(object)__instance.originEnemy)
					{
						MonoSingleton<StyleHUD>.Instance.AddPoints(150, "ultrakill.landyours", (GameObject)null, val, -1, "", "");
					}
					else
					{
						MonoSingleton<StyleHUD>.Instance.AddPoints(75, "ultrakill.serve", (GameObject)null, val, -1, "", "");
					}
					Gutterman val4 = default(Gutterman);
					if ((int)val.enemyType == 33 && ((Component)val).TryGetComponent<Gutterman>(ref val4) && val4.hasShield)
					{
						val4.ShieldBreak(true, false);
					}
				}
			}
			MethodInfo method = typeof(Landmine).GetMethod("Explode", BindingFlags.Instance | BindingFlags.NonPublic, Type.DefaultBinder, new Type[1] { typeof(bool) }, null);
			method.Invoke(__instance, new object[1] { true });
			return false;
		}
	}
}