Decompiled source of UltrakillOvercharged v0.1.0

UltraKillOvercharged.dll

Decompiled 7 hours 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;

[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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("UltraKillOvercharged")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OverchargedUltrakill")]
[assembly: AssemblyTitle("UltraKillOvercharged")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 OverchargedUltrakill
{
	[BepInPlugin("UltraKillOvercharged", "OverchargedUltrakill", "1.0.0")]
	public class OverchargedUltrakill : BaseUnityPlugin
	{
		public static GameObject CrosshairMover = null;

		public static Vector3 Velocity = Vector3.zero;

		public static Vector3 ScreenPosition = Vector3.forward;

		public static Vector3 CamOffset = new Vector3((float)Screen.width * 0.5f, (float)Screen.height * 0.5f, 0f);

		public static Vector2 CrosshairSize = Vector2.zero;

		public static bool Enabled = false;

		public static float BoundScale = 6f;

		public static OverchargedUltrakill Instance { get; private set; } = null;

		internal static ManualLogSource Logger { get; private set; } = null;

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			Logger.LogInfo((object)"UltraKillOvercharged v1.0.0 has loaded!");
		}

		internal static void Patch()
		{
			//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_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("UltraKillOvercharged");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "UltraKillOvercharged";

		public const string PLUGIN_NAME = "OverchargedUltrakill";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace OverchargedUltrakill.Patches
{
	[HarmonyPatch(typeof(TimeController))]
	public class SetFlash
	{
		[HarmonyPatch("OnEnable")]
		[HarmonyPostfix]
		private static void FlashSet(TimeController __instance)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			if ((Object)(GameObject)typeof(TimeController).GetField("parryFlash", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(MonoSingleton<TimeController>.Instance) != (Object)null)
			{
				MonoSingleton<FlashBang>.Instance.SetFlash((GameObject)typeof(TimeController).GetField("parryFlash", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance));
			}
		}
	}
	[HarmonyPatch(typeof(Drone))]
	public class DroneFlash
	{
		[HarmonyPatch("Shoot")]
		[HarmonyPrefix]
		private static void Flash(Drone __instance)
		{
			MonoSingleton<FlashBang>.Instance.Flash();
		}
	}
	public class FlashBang : MonoSingleton<FlashBang>
	{
		private GameObject flashobject;

		private List<GameObject> flash = new List<GameObject>();

		private int flashlevel = 0;

		public void SetFlash(GameObject parryflash)
		{
			flashobject = parryflash;
		}

		private void StopFlash()
		{
			GameObject val = flash[flashlevel];
			flash.Remove(flash[flashlevel]);
			Object.Destroy((Object)(object)val);
			flashlevel--;
			if (flashlevel < 0)
			{
				((MonoBehaviour)this).CancelInvoke();
			}
		}

		public void Flash()
		{
			flash.Add(Object.Instantiate<GameObject>(flashobject, flashobject.transform.parent));
			flash.Add(Object.Instantiate<GameObject>(flashobject, flashobject.transform.parent));
			flash.Add(Object.Instantiate<GameObject>(flashobject, flashobject.transform.parent));
			flash.Add(Object.Instantiate<GameObject>(flashobject, flashobject.transform.parent));
			flash.Add(Object.Instantiate<GameObject>(flashobject, flashobject.transform.parent));
			flash[flash.Count - 1].SetActive(true);
			flash[flash.Count - 2].SetActive(true);
			flash[flash.Count - 3].SetActive(true);
			flash[flash.Count - 4].SetActive(true);
			flash[flash.Count - 5].SetActive(true);
			((MonoBehaviour)this).InvokeRepeating("StopFlash", 0.2f, 0.05f);
			flashlevel = flash.Count - 1;
		}
	}
	[HarmonyPatch(typeof(NewMovement))]
	public class Jump
	{
		[HarmonyPatch("Jump")]
		[HarmonyPrefix]
		private static bool CancelJump(NewMovement __instance)
		{
			__instance.boostCharge = Mathf.Max(__instance.boostCharge - 90f, 0f);
			if (__instance.boostCharge <= 1f)
			{
				Object.Instantiate<GameObject>(__instance.staminaFailSound);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(CameraFrustumTargeter))]
	public class CrosshairMover
	{
		[HarmonyPatch("OnEnable")]
		[HarmonyPostfix]
		private static void EnableCrosshair(CameraFrustumTargeter __instance)
		{
			OverchargedUltrakill.Enabled = true;
		}

		[HarmonyPatch("OnDisable")]
		[HarmonyPostfix]
		private static void DisableCrosshair(CameraFrustumTargeter __instance)
		{
			OverchargedUltrakill.Enabled = false;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void DvDCrosshair(CameraFrustumTargeter __instance)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)(object)OverchargedUltrakill.CrosshairMover != (Object)null) & OverchargedUltrakill.Enabled)
			{
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor((0f - MonoSingleton<CameraController>.Instance.rotationY) * ((float)Screen.width / 2.5f), (0f - MonoSingleton<CameraController>.Instance.rotationX) * ((float)Screen.height / 2.5f), 0f);
				OverchargedUltrakill.Velocity = OverchargedUltrakill.CamOffset - val;
				OverchargedUltrakill.CamOffset = val;
				PropertyInfo propertyInfo = AccessTools.Property(typeof(CameraFrustumTargeter), "CurrentTarget");
				PropertyInfo propertyInfo2 = AccessTools.Property(typeof(CameraFrustumTargeter), "IsAutoAimed");
				propertyInfo.SetValue(__instance, OverchargedUltrakill.CrosshairMover.GetComponent<Collider>());
				propertyInfo2.SetValue(__instance, true);
				OverchargedUltrakill.ScreenPosition += OverchargedUltrakill.Velocity * Time.deltaTime;
				if ((double)OverchargedUltrakill.ScreenPosition.x - (double)OverchargedUltrakill.CrosshairSize.x * 1.666666667 * (double)OverchargedUltrakill.BoundScale <= 0.0)
				{
					OverchargedUltrakill.ScreenPosition.x = OverchargedUltrakill.CrosshairSize.x * 1.6666666f * OverchargedUltrakill.BoundScale;
					OverchargedUltrakill.Velocity.x = Mathf.Abs(OverchargedUltrakill.Velocity.x);
				}
				else if (OverchargedUltrakill.ScreenPosition.x + OverchargedUltrakill.CrosshairSize.x * 1.6666666f * OverchargedUltrakill.BoundScale >= (float)Screen.width)
				{
					OverchargedUltrakill.ScreenPosition.x = (float)Screen.width - OverchargedUltrakill.CrosshairSize.x * 1.6666666f * OverchargedUltrakill.BoundScale;
					OverchargedUltrakill.Velocity.x = 0f - Mathf.Abs(OverchargedUltrakill.Velocity.x);
				}
				if (OverchargedUltrakill.ScreenPosition.y - OverchargedUltrakill.CrosshairSize.y * OverchargedUltrakill.BoundScale <= 0f)
				{
					OverchargedUltrakill.ScreenPosition.y = OverchargedUltrakill.CrosshairSize.y * OverchargedUltrakill.BoundScale;
					OverchargedUltrakill.Velocity.y = Mathf.Abs(OverchargedUltrakill.Velocity.y);
				}
				else if (OverchargedUltrakill.ScreenPosition.y + OverchargedUltrakill.CrosshairSize.y * OverchargedUltrakill.BoundScale >= (float)Screen.height)
				{
					OverchargedUltrakill.ScreenPosition.y = (float)Screen.height - OverchargedUltrakill.CrosshairSize.y * OverchargedUltrakill.BoundScale;
					OverchargedUltrakill.Velocity.y = 0f - Mathf.Abs(OverchargedUltrakill.Velocity.y);
				}
				OverchargedUltrakill.CrosshairMover.transform.position = Camera.main.ScreenToWorldPoint(OverchargedUltrakill.ScreenPosition);
			}
		}
	}
	[HarmonyPatch(typeof(Crosshair))]
	public class Realism
	{
		[HarmonyPatch("OnEnable")]
		[HarmonyPrefix]
		private static void CrosshairStart(Crosshair __instance)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0034: 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)
			if ((Object)(object)OverchargedUltrakill.CrosshairMover != (Object)null)
			{
				Object.Destroy((Object)(object)OverchargedUltrakill.CrosshairMover);
			}
			OverchargedUltrakill.CrosshairMover = new GameObject("mover");
			OverchargedUltrakill.CrosshairMover.transform.localScale = Vector3.zero;
			OverchargedUltrakill.CrosshairMover.transform.parent = ((Component)__instance).transform.parent;
			OverchargedUltrakill.CrosshairSize = ((Component)__instance).GetComponent<RectTransform>().sizeDelta;
			((Collider)OverchargedUltrakill.CrosshairMover.AddComponent<BoxCollider>()).isTrigger = true;
		}

		[HarmonyPatch("OnDisable")]
		[HarmonyPrefix]
		private static void CrosshairDisable(Crosshair __instance)
		{
			Object.Destroy((Object)(object)OverchargedUltrakill.CrosshairMover);
			OverchargedUltrakill.CrosshairMover = null;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}