Decompiled source of NoForcedDropMod v1.0.0

NoForcedDropMod.dll

Decompiled a year ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("NoForcedDropMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NoForcedDropMod")]
[assembly: AssemblyTitle("NoForcedDropMod")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 NoForcedDropMod
{
	[BepInPlugin("com.seuusername.noforceddrop", "No Forced Drop Mod", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("com.seuusername.noforceddrop").PatchAll();
		}
	}
	[HarmonyPatch(typeof(PhysGrabber), "DropHeldObject")]
	public class DropHeldObject_Patch
	{
		private static bool Prefix(object __instance)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			Type type = __instance.GetType();
			FieldInfo fieldInfo = AccessTools.Field(type, "field_Public_GameObject_0");
			FieldInfo fieldInfo2 = AccessTools.Field(type, "field_Public_GameObject_1");
			FieldInfo fieldInfo3 = AccessTools.Field(type, "field_Public_Player_0");
			GameObject val = (GameObject)fieldInfo.GetValue(__instance);
			GameObject val2 = (GameObject)fieldInfo2.GetValue(__instance);
			object value = fieldInfo3.GetValue(__instance);
			if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)val2 || value == null)
			{
				return true;
			}
			object value2 = AccessTools.Field(value.GetType(), "field_Internal_Inventory_0").GetValue(value);
			if (value2 == null)
			{
				return true;
			}
			if (!(AccessTools.Field(value2.GetType(), "field_Public_List_1_GameObject_").GetValue(value2) is List<GameObject> list))
			{
				return true;
			}
			list.Add(val);
			val.SetActive(false);
			return false;
		}
	}
}