Decompiled source of DualGrab v1.0.0

OmniCurse.dll

Decompiled 2 weeks 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.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("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OmniCurse")]
[assembly: AssemblyTitle("OmniCurse")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.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]
	[Microsoft.CodeAnalysis.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]
	[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 OmniCurse
{
	[HarmonyPatch(typeof(PhysGrabber))]
	internal static class PassiveExtraGrabPatch
	{
		private static Rigidbody extraGrabbed;

		private static Transform extraTransform;

		private static Rigidbody mainGrabbed;

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void Update_Postfix(PhysGrabber __instance)
		{
			//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)
			//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_0051: 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_0058: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: 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_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: 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)
			mainGrabbed = __instance.grabbedObject;
			if ((Object)(object)mainGrabbed != (Object)null && (Object)(object)extraGrabbed == (Object)null)
			{
				Vector3 position = ((Component)__instance.playerCamera).transform.position;
				Vector3 forward = ((Component)__instance.playerCamera).transform.forward;
				Collider[] array = Physics.OverlapSphere(position + forward * 2f, 1f);
				Collider[] array2 = array;
				foreach (Collider val in array2)
				{
					Rigidbody attachedRigidbody = val.attachedRigidbody;
					if (!((Object)(object)attachedRigidbody != (Object)null) || !((Object)(object)attachedRigidbody != (Object)(object)mainGrabbed))
					{
						continue;
					}
					extraGrabbed = attachedRigidbody;
					extraTransform = ((Component)attachedRigidbody).transform;
					attachedRigidbody.useGravity = false;
					attachedRigidbody.isKinematic = false;
					attachedRigidbody.velocity = Vector3.zero;
					attachedRigidbody.angularVelocity = Vector3.zero;
					Collider[] components = ((Component)mainGrabbed).GetComponents<Collider>();
					foreach (Collider val2 in components)
					{
						Collider[] components2 = ((Component)attachedRigidbody).GetComponents<Collider>();
						foreach (Collider val3 in components2)
						{
							Physics.IgnoreCollision(val2, val3, true);
						}
					}
					OmniCurse.Logger.LogDebug((object)("[ExtraGrab] Grabbed secondary: " + ((Object)attachedRigidbody).name));
					break;
				}
			}
			if ((Object)(object)mainGrabbed == (Object)null && (Object)(object)extraGrabbed != (Object)null)
			{
				extraGrabbed.useGravity = true;
				extraGrabbed.velocity = Vector3.zero;
				extraGrabbed.angularVelocity = Vector3.zero;
				Rigidbody obj = mainGrabbed;
				Collider[] array3 = (Collider[])(((object)((obj != null) ? ((Component)obj).GetComponents<Collider>() : null)) ?? ((object)new Collider[0]));
				foreach (Collider val4 in array3)
				{
					Collider[] components3 = ((Component)extraGrabbed).GetComponents<Collider>();
					foreach (Collider val5 in components3)
					{
						Physics.IgnoreCollision(val4, val5, false);
					}
				}
				OmniCurse.Logger.LogDebug((object)("[ExtraGrab] Released secondary: " + ((Object)extraGrabbed).name));
				extraGrabbed = null;
				extraTransform = null;
			}
			if ((Object)(object)extraGrabbed != (Object)null && (Object)(object)extraTransform != (Object)null)
			{
				Vector3 val6 = ((Component)__instance.playerCamera).transform.right * 0.75f;
				Vector3 val7 = __instance.physGrabPoint.position + val6;
				Vector3 val8 = Vector3.Lerp(extraTransform.position, val7, Time.deltaTime * 10f);
				extraGrabbed.velocity = Vector3.zero;
				extraGrabbed.angularVelocity = Vector3.zero;
				extraGrabbed.MovePosition(val8);
			}
		}
	}
	[BepInPlugin("Omniscye.OmniCurse", "OmniCurse", "1.0")]
	public class OmniCurse : BaseUnityPlugin
	{
		internal static OmniCurse Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
		}
	}
}