Decompiled source of StrongerMultidrag v1.0.0

BepInEx/plugins/StrongerMultiDrag.dll

Decompiled 3 months 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 HarmonyLib;
using Microsoft.CodeAnalysis;
using ScheduleOne;
using ScheduleOne.PlayerTasks;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StrongerMultiDrag")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Makes it so you won't drop items while multi-dragging")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StrongerMultiDrag")]
[assembly: AssemblyTitle("StrongerMultiDrag")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace StrongerMultiDrag
{
	internal class Patches
	{
		[HarmonyPatch(typeof(Task), "FixedUpdate")]
		[HarmonyPrefix]
		public static bool Pre_TaskFixedUpdate(Task __instance)
		{
			//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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: 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_0177: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			__instance.UpdateDraggablePhysics();
			if (__instance.ClickDetectionEnabled && __instance.multiDraggingEnabled && (Object)(object)__instance.multiGrabProjectionPlane != (Object)null && GameInput.GetButton((ButtonCode)1) && (Object)(object)__instance.draggable == (Object)null)
			{
				__instance.isMultiDragging = true;
				Vector3 multiDragOrigin = __instance.GetMultiDragOrigin();
				Collider[] array = Physics.OverlapSphere(multiDragOrigin, __instance.MultiGrabRadius, LayerMask.GetMask(new string[1] { "Task" }));
				for (int i = 0; i < array.Length; i++)
				{
					Draggable componentInParent = ((Component)array[i]).GetComponentInParent<Draggable>();
					if ((Object)(object)componentInParent != (Object)null && ((Clickable)componentInParent).ClickableEnabled && componentInParent.CanBeMultiDragged && !__instance.multiDragTargets.Contains(componentInParent) && __instance.multiDragTargets.Count < Plugin.instance.MaxDraggedItems.Value)
					{
						__instance.multiDragTargets.Add(componentInParent);
						((Clickable)componentInParent).StartClick(default(RaycastHit));
						componentInParent.Rb.useGravity = false;
					}
				}
				foreach (Draggable multiDragTarget in __instance.multiDragTargets)
				{
					Vector3 val = (multiDragOrigin - ((Component)multiDragTarget).transform.position) * 10f * multiDragTarget.DragForceMultiplier * 1.25f;
					multiDragTarget.Rb.AddForce(val, (ForceMode)5);
				}
				return false;
			}
			__instance.isMultiDragging = false;
			Draggable[] array2 = __instance.multiDragTargets.ToArray();
			foreach (Draggable val2 in array2)
			{
				__instance.multiDragTargets.Remove(val2);
				((Clickable)val2).EndClick();
				val2.Rb.useGravity = true;
			}
			return false;
		}
	}
	[BepInPlugin("StrongerMultiDrag", "StrongerMultiDrag", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin instance;

		public ConfigEntry<int> MaxDraggedItems;

		private void Awake()
		{
			instance = this;
			MaxDraggedItems = ((BaseUnityPlugin)this).Config.Bind<int>("Features", "Max Dragged Items", 7, "How many items can be dragged at once");
			Harmony.CreateAndPatchAll(typeof(Patches), (string)null);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "StrongerMultiDrag";

		public const string PLUGIN_NAME = "StrongerMultiDrag";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}