Decompiled source of DropGuide v1.0.0

DropGuide.dll

Decompiled a week ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("DropGuide")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Simply draws a line under the object you grab.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Drop Guide")]
[assembly: AssemblyTitle("DropGuide")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace DropGuide;

[BepInPlugin("DropGuide", "Drop Guide", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(PhysGrabber))]
	public class PhysGrabberPatch
	{
		private static GameObject dropLineObject;

		private static LineRenderer dropLineRenderer;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void StartPostfix(PhysGrabber __instance)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.isLocal)
			{
				dropLineObject = new GameObject("DropLine");
				dropLineRenderer = dropLineObject.AddComponent<LineRenderer>();
				((Renderer)dropLineRenderer).material = new Material(Shader.Find("Sprites/Default"));
				dropLineRenderer.startWidth = 0.02f;
				dropLineRenderer.endWidth = 0.02f;
				dropLineRenderer.positionCount = 2;
				dropLineRenderer.useWorldSpace = true;
				dropLineRenderer.startColor = Color.white;
				dropLineRenderer.endColor = Color.white;
				dropLineObject.SetActive(false);
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void UpdatePostfix(PhysGrabber __instance)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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)
			if (__instance.isLocal && !((Object)(object)dropLineRenderer == (Object)null))
			{
				if (__instance.grabbed && (Object)(object)__instance.grabbedObjectTransform != (Object)null)
				{
					Vector3 top;
					Vector3 dropPosition = GetDropPosition(__instance, out top);
					dropLineObject.SetActive(true);
					dropLineRenderer.SetPosition(0, top);
					dropLineRenderer.SetPosition(1, dropPosition);
				}
				else
				{
					dropLineObject.SetActive(false);
				}
			}
		}

		private static Vector3 GetDropPosition(PhysGrabber instance, out Vector3 top)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			FieldInfo fieldInfo = AccessTools.Field(typeof(PhysGrabber), "grabbedPhysGrabObjectCollider");
			Collider val = (Collider)fieldInfo.GetValue(instance);
			Vector3 val2;
			if (!((Object)(object)val != (Object)null))
			{
				val2 = instance.grabbedObjectTransform.position;
			}
			else
			{
				Bounds bounds = val.bounds;
				val2 = ((Bounds)(ref bounds)).center;
			}
			top = val2;
			FieldInfo fieldInfo2 = AccessTools.Field(typeof(PhysGrabber), "mask");
			LayerMask val3 = (LayerMask)fieldInfo2.GetValue(instance);
			RaycastHit[] array = Physics.RaycastAll(top, Vector3.down, 100f, LayerMask.op_Implicit(val3));
			RaycastHit[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val4 = array2[i];
				if ((Object)(object)((RaycastHit)(ref val4)).collider != (Object)(object)val)
				{
					return ((RaycastHit)(ref val4)).point;
				}
			}
			return top + Vector3.down * 5f;
		}
	}

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("Drop Guide");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Drop Guide Plugin Loaded!");
	}
}
public static class MyPluginInfo
{
	public const string PLUGIN_GUID = "DropGuide";

	public const string PLUGIN_NAME = "Drop Guide";

	public const string PLUGIN_VERSION = "1.0.0";
}