Decompiled source of DvDCursor v1.0.0

DvDCrosshair.dll

Decompiled 2 hours ago
using System;
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.Configuration;
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("DvDCrosshair")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DvDLogo")]
[assembly: AssemblyTitle("DvDCrosshair")]
[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 DvDLogo
{
	[BepInPlugin("DvDCrosshair", "DvDLogo", "1.0.0")]
	public class DvDLogo : BaseUnityPlugin
	{
		internal static DvDLogo instance;

		public static GameObject CrosshairMover = null;

		public static Vector3 Velocity = Vector3.zero;

		public static Vector3 ScreenPosition = Vector3.forward;

		public static Vector2 CrosshairSize = Vector2.zero;

		public static float SavedSpeed = 0f;

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

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

		internal static Harmony? Harmony { get; set; }

		public static ConfigEntry<float> Speed { get; set; }

		public static ConfigEntry<float> BoundScale { get; set; }

		public static ConfigFile BepInExConfig()
		{
			return ((BaseUnityPlugin)instance).Config;
		}

		private void Awake()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			Speed = BepInExConfig().Bind<float>("General", "Speed", 125f, new ConfigDescription("how fast you want the torment", (AcceptableValueBase)null, Array.Empty<object>()));
			BoundScale = BepInExConfig().Bind<float>("General", "BoundScale", 6f, new ConfigDescription("how many multiples of the crosshair from the screen edges does it bounce", (AcceptableValueBase)null, Array.Empty<object>()));
			Logger.LogInfo((object)"DvDCrosshair 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("DvDCrosshair");
			}
			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 = "DvDCrosshair";

		public const string PLUGIN_NAME = "DvDLogo";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace DvDLogo.Patches
{
	public sealed class Configstuff
	{
		private static Configstuff instance;

		public ConfigEntry<float> Speed { get; set; }

		public ConfigEntry<float> BoundScale { get; set; }

		public static Configstuff Instance
		{
			get
			{
				if (instance == null)
				{
					instance = new Configstuff();
				}
				return instance;
			}
		}

		public void Setup()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			Speed = DvDLogo.BepInExConfig().Bind<float>("General", "speed", 125f, new ConfigDescription("how fast you want the torment", (AcceptableValueBase)null, Array.Empty<object>()));
			BoundScale = DvDLogo.BepInExConfig().Bind<float>("General", "boundscale", 6f, new ConfigDescription("how many multiples of the crosshair from the screen edges does it bounce", (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
	[HarmonyPatch(typeof(CameraFrustumTargeter))]
	public class CrosshairMover
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void DvDCrosshair(CameraFrustumTargeter __instance)
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)(object)DvDLogo.CrosshairMover != (Object)null) & ((Behaviour)__instance).enabled)
			{
				if (DvDLogo.Speed.Value != DvDLogo.SavedSpeed)
				{
					float num = Random.Range(25f, 65f);
					DvDLogo.Velocity = Vector2.op_Implicit(new Vector2(Mathf.Cos(num * (MathF.PI / 180f)), Mathf.Sin(num * (MathF.PI / 180f))) * DvDLogo.Speed.Value);
					DvDLogo.SavedSpeed = DvDLogo.Speed.Value;
				}
				PropertyInfo propertyInfo = AccessTools.Property(typeof(CameraFrustumTargeter), "CurrentTarget");
				PropertyInfo propertyInfo2 = AccessTools.Property(typeof(CameraFrustumTargeter), "IsAutoAimed");
				propertyInfo.SetValue(__instance, DvDLogo.CrosshairMover.GetComponent<Collider>());
				propertyInfo2.SetValue(__instance, true);
				DvDLogo.ScreenPosition += DvDLogo.Velocity * Time.deltaTime;
				if (DvDLogo.ScreenPosition.x - DvDLogo.CrosshairSize.x * DvDLogo.BoundScale.Value <= 0f)
				{
					DvDLogo.ScreenPosition.x = DvDLogo.CrosshairSize.x * DvDLogo.BoundScale.Value;
					DvDLogo.Velocity.x = Mathf.Abs(DvDLogo.Velocity.x);
				}
				else if (DvDLogo.ScreenPosition.x + DvDLogo.CrosshairSize.x * DvDLogo.BoundScale.Value >= (float)Screen.width)
				{
					DvDLogo.ScreenPosition.x = (float)Screen.width - DvDLogo.CrosshairSize.x * DvDLogo.BoundScale.Value;
					DvDLogo.Velocity.x = 0f - Mathf.Abs(DvDLogo.Velocity.x);
				}
				if (DvDLogo.ScreenPosition.y - DvDLogo.CrosshairSize.y * DvDLogo.BoundScale.Value <= 0f)
				{
					DvDLogo.ScreenPosition.y = DvDLogo.CrosshairSize.y * DvDLogo.BoundScale.Value;
					DvDLogo.Velocity.y = Mathf.Abs(DvDLogo.Velocity.y);
				}
				else if (DvDLogo.ScreenPosition.y + DvDLogo.CrosshairSize.y * DvDLogo.BoundScale.Value >= (float)Screen.height)
				{
					DvDLogo.ScreenPosition.y = (float)Screen.height - DvDLogo.CrosshairSize.y * DvDLogo.BoundScale.Value;
					DvDLogo.Velocity.y = 0f - Mathf.Abs(DvDLogo.Velocity.y);
				}
				DvDLogo.CrosshairMover.transform.position = Camera.main.ScreenToWorldPoint(DvDLogo.ScreenPosition);
			}
		}
	}
	[HarmonyPatch(typeof(CanvasController))]
	public class GameStart
	{
		[HarmonyPatch("OnEnable")]
		[HarmonyPrefix]
		private static void CrosshairStart(CanvasController __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_007d: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)DvDLogo.CrosshairMover != (Object)null)
			{
				Object.Destroy((Object)(object)DvDLogo.CrosshairMover);
			}
			DvDLogo.CrosshairMover = new GameObject("mover");
			DvDLogo.CrosshairMover.transform.localScale = Vector3.zero;
			DvDLogo.CrosshairMover.transform.parent = ((Component)__instance).transform;
			float num = Random.Range(25f, 65f);
			DvDLogo.Velocity = Vector2.op_Implicit(new Vector2(Mathf.Cos(num * (MathF.PI / 180f)), Mathf.Sin(num * (MathF.PI / 180f))) * DvDLogo.Speed.Value);
			DvDLogo.CrosshairSize = ((Component)__instance.crosshair).GetComponent<RectTransform>().sizeDelta;
			((Collider)DvDLogo.CrosshairMover.AddComponent<BoxCollider>()).isTrigger = true;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}