Decompiled source of DropItem v2.1.6

dropitem.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dolso;
using Dolso.RiskofOptions;
using DropInMultiplayer;
using HG.GeneralSerializer;
using HG.Reflection;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using Rewired.Integration.UnityUI;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Networking;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.UI;

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyInformationalVersion("1.0.0+3d95356edc8ff3f3f44f1f42a86f908fb6766daf")]
[assembly: AssemblyProduct("dropitem")]
[assembly: AssemblyTitle("dropitem")]
[assembly: AssemblyCompany("dropitem")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Dolso
{
	internal static class log
	{
		private static ManualLogSource logger;

		internal static void start(ManualLogSource logSource)
		{
			logger = logSource;
		}

		internal static void start(string name)
		{
			logger = Logger.CreateLogSource(name);
		}

		internal static void debug(object data)
		{
			logger.LogDebug(data);
		}

		internal static void info(object data)
		{
			logger.LogInfo(data);
		}

		internal static void message(object data)
		{
			logger.LogMessage(data);
		}

		internal static void warning(object data)
		{
			logger.LogWarning(data);
		}

		internal static void error(object data)
		{
			logger.LogError(data);
		}

		internal static void fatal(object data)
		{
			logger.LogFatal(data);
		}

		internal static void LogError(this ILCursor c, object data)
		{
			logger.LogError((object)string.Format($"ILCursor failure, skipping: {data}\n{c}"));
		}

		internal static void LogErrorCaller(this ILCursor c, object data, [CallerMemberName] string callerName = "")
		{
			logger.LogError((object)string.Format($"ILCursor failure in {callerName}, skipping: {data}\n{c}"));
		}
	}
	internal static class HookManager
	{
		internal delegate bool ConfigEnabled<T>(ConfigEntry<T> configEntry);

		internal const BindingFlags allFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		private static ILHookConfig ilHookConfig = new ILHookConfig
		{
			ManualApply = true
		};

		private static HookConfig onHookConfig = new HookConfig
		{
			ManualApply = true
		};

		internal static void Hook(Type typeFrom, string methodFrom, Manipulator ilHook)
		{
			HookInternal(GetMethod(typeFrom, methodFrom), ilHook);
		}

		internal static void Hook(MethodBase methodFrom, Manipulator ilHook)
		{
			HookInternal(methodFrom, ilHook);
		}

		internal static void Hook(Delegate from, Manipulator ilHook)
		{
			HookInternal(from.Method, ilHook);
		}

		internal static void Hook<T>(Expression<Action<T>> from, Manipulator ilHook)
		{
			HookInternal(((MethodCallExpression)from.Body).Method, ilHook);
		}

		internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook)
		{
			HookInternal(GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target);
		}

		internal static void Hook(MethodBase methodFrom, MethodInfo onHook)
		{
			HookInternal(methodFrom, onHook, null);
		}

		internal static void Hook(MethodBase methodFrom, Delegate onHook)
		{
			HookInternal(methodFrom, onHook.Method, onHook.Target);
		}

		internal static void Hook(Delegate from, Delegate onHook)
		{
			HookInternal(from.Method, onHook.Method, onHook.Target);
		}

		internal static void Hook<T>(Expression<Action<T>> from, Delegate onHook)
		{
			HookInternal(((MethodCallExpression)from.Body).Method, onHook.Method, onHook.Target);
		}

		internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook, object instance)
		{
			HookInternal(GetMethod(typeFrom, methodFrom), onHook.Method, instance);
		}

		internal static void Hook(MethodBase methodFrom, MethodInfo onHook, object target)
		{
			HookInternal(methodFrom, onHook, target);
		}

		private static void HookInternal(MethodBase methodFrom, Manipulator ilHook)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (methodFrom == null)
			{
				log.error("null MethodFrom for hook: " + ((Delegate)(object)ilHook).Method.Name);
				return;
			}
			try
			{
				new ILHook(methodFrom, ilHook, ref ilHookConfig).Apply();
			}
			catch (Exception ex)
			{
				log.error($"Failed to apply ILHook: {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
			}
		}

		private static void HookInternal(MethodBase methodFrom, MethodInfo onHook, object target)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (methodFrom == null)
			{
				log.error("null methodFrom for hook: " + onHook.Name);
				return;
			}
			try
			{
				new Hook(methodFrom, onHook, target, ref onHookConfig).Apply();
			}
			catch (Exception ex)
			{
				log.error($"Failed to apply onHook: {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Name}\n{ex}");
			}
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Manipulator ilHook)
		{
			configEntry.AddHookConfig(enabled, GetMethod(typeFrom, methodFrom), ilHook);
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Manipulator ilHook)
		{
			configEntry.AddHookConfig(enabled, methodFrom, ilHook);
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Delegate onHook)
		{
			configEntry.AddHookConfig(enabled, GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target);
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Delegate onHook)
		{
			configEntry.AddHookConfig(enabled, methodFrom, onHook.Method, onHook.Target);
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Manipulator ilHook)
		{
			configEntry.AddHookConfig<bool>(BoolConfigEnabled, GetMethod(typeFrom, methodFrom), ilHook);
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Manipulator ilHook)
		{
			configEntry.AddHookConfig<bool>(BoolConfigEnabled, methodFrom, ilHook);
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Delegate onHook)
		{
			configEntry.AddHookConfig<bool>(BoolConfigEnabled, GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target);
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Delegate onHook)
		{
			configEntry.AddHookConfig<bool>(BoolConfigEnabled, methodFrom, onHook.Method, onHook.Target);
		}

		private static bool BoolConfigEnabled(ConfigEntry<bool> configEntry)
		{
			return configEntry.Value;
		}

		private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Manipulator ilHook)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			if (methodFrom == null)
			{
				log.error("null MethodFrom for hook: " + ((Delegate)(object)ilHook).Method.Name);
				return;
			}
			try
			{
				configEntry.AddHookConfig(enabled, (IDetour)new ILHook(methodFrom, ilHook, ref ilHookConfig));
			}
			catch (Exception ex)
			{
				log.error($"Failed to ilHook {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
			}
		}

		private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, MethodInfo onHook, object target)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			if (methodFrom == null)
			{
				log.error("null MethodFrom for hook: " + onHook.Name);
				return;
			}
			try
			{
				configEntry.AddHookConfig(enabled, (IDetour)new Hook(methodFrom, onHook, target, ref onHookConfig));
			}
			catch (Exception ex)
			{
				log.error($"Failed to onHook {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Name}\n{ex}");
			}
		}

		private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, IDetour detour)
		{
			configEntry.SettingChanged += delegate(object sender, EventArgs args)
			{
				UpdateHook(detour, enabled(sender as ConfigEntry<T>));
			};
			if (enabled(configEntry))
			{
				detour.Apply();
			}
		}

		private static void UpdateHook(IDetour hook, bool enabled)
		{
			if (enabled)
			{
				if (!hook.IsApplied)
				{
					hook.Apply();
				}
			}
			else if (hook.IsApplied)
			{
				hook.Undo();
			}
		}

		internal static void PriorityFirst()
		{
			ilHookConfig.Before = new string[1] { "*" };
			onHookConfig.Before = new string[1] { "*" };
		}

		internal static void PriorityLast()
		{
			ilHookConfig.After = new string[1] { "*" };
			onHookConfig.After = new string[1] { "*" };
		}

		internal static void PriorityNormal()
		{
			ilHookConfig.Before = null;
			onHookConfig.Before = null;
			ilHookConfig.After = null;
			onHookConfig.After = null;
		}

		internal static IDetour ManualDetour(Type typeFrom, string methodFrom, Delegate onHook)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			try
			{
				return (IDetour)new Hook((MethodBase)GetMethod(typeFrom, methodFrom), onHook, ref onHookConfig);
			}
			catch (Exception ex)
			{
				log.error($"Failed to make onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex}");
			}
			return null;
		}

		internal static MethodInfo GetMethod(Type typeFrom, string methodFrom)
		{
			if (typeFrom == null || methodFrom == null)
			{
				return null;
			}
			IEnumerable<MethodInfo> source = from predicate in typeFrom.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
				where predicate.Name == methodFrom
				select predicate;
			if (source.Count() == 1)
			{
				return source.First();
			}
			if (source.Count() == 0)
			{
				log.error($"Failed to find method: {typeFrom}.{methodFrom}");
			}
			if (source.Count() > 1)
			{
				log.error($"{source.Count()} ambiguous matches found for: {typeFrom}.{methodFrom}");
			}
			return null;
		}
	}
	internal static class Utilities
	{
		private static GameObject _prefabParent;

		internal static GameObject CreatePrefab(GameObject gameObject)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)_prefabParent))
			{
				_prefabParent = new GameObject("DolsoPrefabs");
				Object.DontDestroyOnLoad((Object)(object)_prefabParent);
				((Object)_prefabParent).hideFlags = (HideFlags)61;
				_prefabParent.SetActive(false);
			}
			return Object.Instantiate<GameObject>(gameObject, _prefabParent.transform);
		}

		internal static GameObject CreatePrefab(GameObject gameObject, string name)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)_prefabParent))
			{
				_prefabParent = new GameObject("DolsoPrefabs");
				Object.DontDestroyOnLoad((Object)(object)_prefabParent);
				((Object)_prefabParent).hideFlags = (HideFlags)61;
				_prefabParent.SetActive(false);
			}
			GameObject obj = Object.Instantiate<GameObject>(gameObject, _prefabParent.transform);
			((Object)obj).name = name;
			return obj;
		}

		internal static MethodInfo MakeGenericMethod<T>(this Type type, string methodName, params Type[] parameters)
		{
			return type.GetMethod(methodName, parameters).MakeGenericMethod(typeof(T));
		}

		internal static MethodInfo MakeGenericGetComponentG<T>() where T : Component
		{
			return typeof(GameObject).GetMethod("GetComponent", Type.EmptyTypes).MakeGenericMethod(typeof(T));
		}

		internal static MethodInfo MakeGenericGetComponentC<T>() where T : Component
		{
			return typeof(Component).GetMethod("GetComponent", Type.EmptyTypes).MakeGenericMethod(typeof(T));
		}

		internal static AssetBundle LoadAssetBundle(string bundlePathName)
		{
			AssetBundle result = null;
			try
			{
				result = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), bundlePathName));
			}
			catch (Exception ex)
			{
				log.error("Failed to load assetbundle\n" + ex);
			}
			return result;
		}

		internal static Obj GetAddressable<Obj>(string addressable) where Obj : Object
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<Obj>((object)addressable).WaitForCompletion();
		}

		internal static GameObject GetAddressable(string addressable)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<GameObject>((object)addressable).WaitForCompletion();
		}

		internal static void GetAddressable<Obj>(string addressable, Action<Obj> callback) where Obj : Object
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<Obj> val = Addressables.LoadAssetAsync<Obj>((object)addressable);
			val.Completed += delegate(AsyncOperationHandle<Obj> a)
			{
				callback(a.Result);
			};
		}

		internal static void GetAddressable(string addressable, Action<GameObject> callback)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
			val.Completed += delegate(AsyncOperationHandle<GameObject> a)
			{
				callback(a.Result);
			};
		}

		internal static void AddressableAddComp<Comp>(string addressable) where Comp : Component
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
			val.Completed += delegate(AsyncOperationHandle<GameObject> a)
			{
				a.Result.AddComponent<Comp>();
			};
		}

		internal static void AddressableAddComp<Comp>(string addressable, Action<Comp> callback) where Comp : Component
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
			val.Completed += delegate(AsyncOperationHandle<GameObject> a)
			{
				callback(a.Result.AddComponent<Comp>());
			};
		}

		internal static void AddressableAddCompSingle<Comp>(string addressable) where Comp : Component
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
			val.Completed += delegate(AsyncOperationHandle<GameObject> a)
			{
				if (!Object.op_Implicit((Object)(object)a.Result.GetComponent<Comp>()))
				{
					a.Result.AddComponent<Comp>();
				}
			};
		}

		internal static void SetStateConfigIndex(this EntityStateConfiguration stateConfig, string fieldName, string newValue)
		{
			ref SerializedField[] serializedFields = ref stateConfig.serializedFieldsCollection.serializedFields;
			for (int i = 0; i < serializedFields.Length; i++)
			{
				if (serializedFields[i].fieldName == fieldName)
				{
					serializedFields[i].fieldValue.stringValue = newValue;
					return;
				}
			}
			log.error("failed to find " + fieldName + " for " + ((Object)stateConfig).name);
		}

		internal static void SetStateConfigIndex(this EntityStateConfiguration stateConfig, string fieldName, Object newValue)
		{
			ref SerializedField[] serializedFields = ref stateConfig.serializedFieldsCollection.serializedFields;
			for (int i = 0; i < serializedFields.Length; i++)
			{
				if (serializedFields[i].fieldName == fieldName)
				{
					serializedFields[i].fieldValue.objectValue = newValue;
					return;
				}
			}
			log.error("failed to find " + fieldName + " for " + ((Object)stateConfig).name);
		}

		internal static bool IsKeyDown(this ConfigEntry<KeyboardShortcut> key)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = key.Value;
			if (!Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
			{
				return false;
			}
			value = key.Value;
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref value)).Modifiers)
			{
				if (!Input.GetKey(modifier))
				{
					return false;
				}
			}
			return true;
		}

		internal static bool IsKeyJustPressed(this ConfigEntry<KeyboardShortcut> key)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = key.Value;
			if (!Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey))
			{
				return false;
			}
			value = key.Value;
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref value)).Modifiers)
			{
				if (!Input.GetKey(modifier))
				{
					return false;
				}
			}
			return true;
		}

		internal static bool ContainsString(string source, string value)
		{
			return CultureInfo.InvariantCulture.CompareInfo.IndexOf(source, value, CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols) >= 0;
		}
	}
}
namespace Dolso.RiskofOptions
{
	internal static class RiskofOptions
	{
		internal const string rooGuid = "com.rune580.riskofoptions";

		internal static bool enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

		internal static void SetSprite(Sprite sprite)
		{
			ModSettingsManager.SetModIcon(sprite);
		}

		internal static void SetSpriteDefaultIcon()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//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)
			DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
			string path = ((!(directoryInfo.Name == "plugins")) ? directoryInfo.FullName : directoryInfo.Parent.FullName);
			Texture2D val = new Texture2D(256, 256);
			if (ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(path, "icon.png"))))
			{
				ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)));
			}
			else
			{
				log.error("Failed to load icon.png");
			}
		}

		internal static void AddBool(ConfigEntry<bool> entry)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
			{
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddBool(ConfigEntry<bool> entry, string categoryName, string name)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
			{
				category = categoryName,
				name = name,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddBool(ConfigEntry<bool> entry, string categoryName)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
			{
				category = categoryName,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddEnum<T>(ConfigEntry<T> entry) where T : Enum
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)entry, new ChoiceConfig
			{
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddColor(ConfigEntry<Color> entry)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new ColorOption(entry, new ColorOptionConfig
			{
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddKey(ConfigEntry<KeyboardShortcut> entry)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry, new KeyBindConfig
			{
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddFloat(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}")
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig
			{
				min = min,
				max = max,
				formatString = format,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault(format)
			}));
		}

		internal static void AddFloat(ConfigEntry<float> entry, string categoryName, float min, float max, string format = "{0:f2}")
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig
			{
				min = min,
				max = max,
				formatString = format,
				category = categoryName,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault(format)
			}));
		}

		internal static void AddFloatField(ConfigEntry<float> entry, float min = float.MinValue, float max = float.MaxValue, string format = "{0:f2}")
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			FloatFieldConfig val = new FloatFieldConfig();
			((NumericFieldConfig<float>)val).Min = min;
			((NumericFieldConfig<float>)val).Max = max;
			((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault(format);
			ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(entry, val));
		}

		internal static void AddInt(ConfigEntry<int> entry, int min = int.MinValue, int max = int.MaxValue)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			IntFieldConfig val = new IntFieldConfig();
			((NumericFieldConfig<int>)val).Min = min;
			((NumericFieldConfig<int>)val).Max = max;
			((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault();
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(entry, val));
		}

		internal static void AddIntSlider(ConfigEntry<int> entry, int min, int max)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig
			{
				min = min,
				max = max,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddIntSlider(ConfigEntry<int> entry, string categoryName, int min, int max)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig
			{
				min = min,
				max = max,
				category = categoryName,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddString(ConfigEntry<string> entry)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(entry, new InputFieldConfig
			{
				submitOn = (SubmitEnum)6,
				lineType = (LineType)0,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddOption(ConfigEntry<bool> entry)
		{
			AddBool(entry);
		}

		internal static void AddOption(ConfigEntry<bool> entry, string categoryName, string name)
		{
			AddBool(entry, categoryName, name);
		}

		internal static void AddOption(ConfigEntry<bool> entry, string categoryName)
		{
			AddBool(entry, categoryName);
		}

		internal static void AddOption<T>(ConfigEntry<T> entry) where T : Enum
		{
			AddEnum<T>(entry);
		}

		internal static void AddOption(ConfigEntry<Color> entry)
		{
			AddColor(entry);
		}

		internal static void AddOption(ConfigEntry<KeyboardShortcut> entry)
		{
			AddKey(entry);
		}

		internal static void AddOption(ConfigEntry<int> entry)
		{
			AddInt(entry);
		}

		internal static void AddOption(ConfigEntry<string> entry)
		{
			AddString(entry);
		}

		private static string DescWithDefault(this ConfigEntryBase entry)
		{
			return $"{entry.Description.Description}\n[Default: {entry.DefaultValue}]";
		}

		private static string DescWithDefault(this ConfigEntryBase entry, string format)
		{
			return string.Format("{1}\n[Default: " + format + "]", entry.DefaultValue, entry.Description.Description);
		}
	}
}
namespace Dropitem
{
	internal static class ChatCommands
	{
		internal class Command
		{
			internal Func<NetworkUser, string[], string> method;

			internal string helpText;

			internal byte minArgs;

			internal Command(Func<NetworkUser, string[], string> method, byte minArgs, string helpText)
			{
				this.method = method;
				this.minArgs = minArgs;
				this.helpText = helpText;
			}
		}

		internal static Dictionary<string, Command> chatCommands;

		static ChatCommands()
		{
			Command value = new Command(Drop.Drop_item, 1, "<color=#AAE6F0>/d itemname playername\nItems with spaces need to be typed without them:\nScrap, Green -> scrapgre</color>");
			Command value2 = new Command(Give.Give_Item, 2, "<color=#AAE6F0>/block playername\nPrevents the targeted player from dropping items</color>");
			Command value3 = new Command(Users.Block_User, 1, "<color=#AAE6F0>/g itemname playername\nWill transfer items from sender's inventory into playername's inventory</color>");
			Command value4 = new Command(Users.Lock_Inventory, 0, "<color=#AAE6F0>/lock 0 or 1\n Prevents other players from accessing your inventory</color>");
			chatCommands = new Dictionary<string, Command>
			{
				["d"] = value,
				["drop"] = value,
				["dropitem"] = value,
				["g"] = value2,
				["give"] = value2,
				["giveitem"] = value2,
				["b"] = value3,
				["block"] = value3,
				["blockuser"] = value3,
				["ub"] = value3,
				["unblock"] = value3,
				["unblockuser"] = value3,
				["lock"] = value4,
				["lockinventory"] = value4
			};
		}
	}
	internal static class Config
	{
		private static ConfigFile configFile;

		internal static ConfigEntry<bool> lockInventory;

		internal static ConfigEntry<bool> voidToggle;

		internal static ConfigEntry<InputButton> dropButton;

		internal static ConfigEntry<KeyboardShortcut> dropSingleButton;

		internal static void DoConfig(ConfigFile bepConfigFile)
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			configFile = bepConfigFile;
			lockInventory = configFile.Bind<bool>("", "Lock Inventory", false, "Prevent other players from dropping items from your inventory");
			voidToggle = configFile.Bind<bool>("", "Allow Void Drops", false, "Allow dropping of void corrupted items");
			dropButton = configFile.Bind<InputButton>("", "Drop button", (InputButton)0, "Mouse button to drop the currently hovered item");
			dropSingleButton = configFile.Bind<KeyboardShortcut>("", "Drop single key", new KeyboardShortcut((KeyCode)323, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Key to drop a single of the currently hovered item");
			if (RiskofOptions.enabled)
			{
				DoRiskofOptions();
			}
		}

		private static void DoRiskofOptions()
		{
			RiskofOptions.SetSpriteDefaultIcon();
			RiskofOptions.AddOption(voidToggle);
			RiskofOptions.AddOption(lockInventory);
			RiskofOptions.AddOption<InputButton>(dropButton);
			RiskofOptions.AddOption(dropSingleButton);
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void ReloadConfig(ConCommandArgs args)
		{
			configFile.Reload();
			Debug.Log((object)"DropItem config reloaded");
		}

		internal static KeyCode ToKey(this InputButton button)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected I4, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			return (KeyCode)((int)button switch
			{
				0 => 323, 
				1 => 324, 
				2 => 325, 
				_ => 324, 
			});
		}
	}
	internal class DragItem : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler, IInitializePotentialDragHandler, IPointerClickHandler
	{
		public enum ItemType : byte
		{
			None,
			Item,
			Equipment
		}

		public ItemType type;

		private static GameObject draggedIcon;

		private static RectTransform m_DraggingPlane;

		public static bool InvalidButton(PointerEventData eventData)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			if (eventData.button == Config.dropButton.Value)
			{
				return Main.singlePressed > 0;
			}
			return true;
		}

		public void OnBeginDrag(PointerEventData eventData)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			if (!InvalidButton(eventData))
			{
				if (Object.op_Implicit((Object)(object)draggedIcon))
				{
					Object.Destroy((Object)(object)draggedIcon);
				}
				draggedIcon = new GameObject("dragged icon");
				draggedIcon.transform.SetParent(Main.hud.mainContainer.transform);
				draggedIcon.transform.SetAsLastSibling();
				RawImage val = draggedIcon.AddComponent<RawImage>();
				if (type == ItemType.Item)
				{
					val.texture = ((Component)this).GetComponent<RawImage>().texture;
				}
				if (type == ItemType.Equipment)
				{
					val.texture = ((Component)this).GetComponent<EquipmentIcon>().iconImage.texture;
				}
				((Graphic)val).raycastTarget = false;
				((Graphic)val).color = new Color(1f, 1f, 1f, 0.6f);
				RectTransform component = draggedIcon.GetComponent<RectTransform>();
				((Transform)component).localScale = ((Transform)component).localScale / 128f;
				Transform transform = ((Component)Main.hud.canvas).transform;
				m_DraggingPlane = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			}
		}

		public void OnDrag(PointerEventData data)
		{
			//IL_001e: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)draggedIcon))
			{
				RectTransform component = draggedIcon.GetComponent<RectTransform>();
				Vector3 position = default(Vector3);
				if (RectTransformUtility.ScreenPointToWorldPointInRectangle(m_DraggingPlane, data.position, data.pressEventCamera, ref position))
				{
					((Transform)component).position = position;
					((Transform)component).rotation = ((Transform)m_DraggingPlane).rotation;
				}
			}
		}

		public void OnEndDrag(PointerEventData eventData)
		{
			if (Object.op_Implicit((Object)(object)draggedIcon))
			{
				Object.Destroy((Object)(object)draggedIcon);
			}
		}

		public void OnInitializePotentialDrag(PointerEventData eventData)
		{
			eventData.useDragThreshold = false;
		}

		public void OnPointerClick(PointerEventData eventData)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			if (!InvalidButton(eventData) && GetPlayerAndItem(out var player, out var args))
			{
				if ((Object)(object)player.networkUser != (Object)(object)LocalUserManager.GetFirstLocalUser().currentNetworkUser)
				{
					args.Add(NetworkUser.readOnlyInstancesList.IndexOf(player.networkUser).ToString());
				}
				Console.instance.RunCmd(new CmdSender(LocalUserManager.GetFirstLocalUser().currentNetworkUser), "dropitem", args);
			}
		}

		public bool GetPlayerAndItem(out PlayerCharacterMasterController player, out List<string> args)
		{
			switch (type)
			{
			case ItemType.Item:
				return FromItem(out player, out args);
			case ItemType.Equipment:
				return FromEquip(out player, out args);
			default:
				log.warning("unknown type of clicked object");
				player = null;
				args = null;
				return false;
			}
		}

		private bool FromItem(out PlayerCharacterMasterController player, out List<string> args)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			args = new List<string> { StringParsers.ReformatString(Language.GetString(ItemCatalog.GetItemDef(((Component)this).GetComponent<ItemIcon>().itemIndex).nameToken)) };
			ItemInventoryDisplay componentInParent = ((Component)this).GetComponentInParent<ItemInventoryDisplay>();
			object obj;
			if (componentInParent == null)
			{
				obj = null;
			}
			else
			{
				Inventory inventory = componentInParent.inventory;
				if (inventory == null)
				{
					obj = null;
				}
				else
				{
					CharacterMaster component = ((Component)inventory).GetComponent<CharacterMaster>();
					obj = ((component != null) ? component.playerCharacterMasterController : null);
				}
			}
			player = (PlayerCharacterMasterController)obj;
			if (!Object.op_Implicit((Object)(object)player))
			{
				log.warning("null player");
				return false;
			}
			return true;
		}

		private bool FromEquip(out PlayerCharacterMasterController player, out List<string> args)
		{
			args = new List<string> { "e" };
			Inventory targetInventory = ((Component)this).GetComponent<EquipmentIcon>().targetInventory;
			CharacterMaster val = ((targetInventory != null) ? ((Component)targetInventory).GetComponent<CharacterMaster>() : null);
			player = ((val != null) ? val.playerCharacterMasterController : null);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)player))
			{
				log.warning("null master");
				return false;
			}
			return true;
		}
	}
	internal static class Drop
	{
		public const string green = "<color=#96EBAA>";

		public const string player = "<color=#AAE6F0>";

		public const string error = "<color=#FF8282>";

		public const string bold = "<color=#ff4646>";

		private static bool isNegative;

		public static string Drop_item(NetworkUser sender, string[] args)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Invalid comparison between Unknown and I4
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Invalid comparison between Unknown and I4
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Invalid comparison between Unknown and I4
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Invalid comparison between Unknown and I4
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Invalid comparison between Unknown and I4
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Invalid comparison between Unknown and I4
			//IL_02b3: 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_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Invalid comparison between Unknown and I4
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Invalid comparison between Unknown and I4
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Invalid comparison between Unknown and I4
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0460: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			NetworkUserId id = sender.id;
			if (Users.blockedUserIds.Contains(id))
			{
				return "<color=#FF8282>You are blocked from dropping items</color>";
			}
			NetworkUser val = sender;
			Inventory val2 = (((Object)(object)sender != (Object)null) ? sender.master.inventory : null);
			if (args.Length >= 2)
			{
				val = StringParsers.GetNetUserFromString(args[1]);
				if ((Object)(object)val == (Object)null)
				{
					return "<color=#FF8282>Could not find specified </color>player<color=#FF8282> '<color=#ff4646>" + args[1] + "</color>'</color>";
				}
				val2 = (((Object)(object)val == (Object)null) ? val2 : val.master.inventory);
			}
			if ((Object)(object)val2 == (Object)null)
			{
				return "<color=#ff4646>ERROR: null inventory</color>";
			}
			CharacterBody currentBody = sender.GetCurrentBody();
			Transform val3 = ((currentBody != null) ? currentBody.coreTransform : null);
			if ((Object)(object)val3 == (Object)null)
			{
				return "<color=#FF8282>Must be alive to drop items</color>";
			}
			Vector3 velocity = sender.GetCurrentBody().inputBank.aimDirection;
			velocity.y = 0f;
			velocity = ((Vector3)(ref velocity)).normalized * 8f + Vector3.up * 15f;
			string text = "<color=#AAE6F0>" + val.masterController.GetDisplayName() + "</color>";
			string text2 = "<color=#AAE6F0>" + sender.masterController.GetDisplayName() + "</color>";
			if ((Object)(object)val != (Object)(object)sender && Users.lockedUserIds.Contains(val.id))
			{
				return "<color=#FF8282>" + text + " has their inventory locked</color>";
			}
			EquipmentIndex val4 = (EquipmentIndex)(-1);
			ItemIndex val5 = (ItemIndex)(-1);
			if (args[0].Equals("all", StringComparison.InvariantCultureIgnoreCase))
			{
				new GameObject("DropAll").AddComponent<DropAll>().Assign(val, sender, val3);
				if ((Object)(object)val == (Object)(object)sender)
				{
					return "<color=#96EBAA>Dropping all items from </color>" + text;
				}
				return "<color=#96EBAA>" + text2 + " is dropping all items from </color>" + text;
			}
			if (args[0].Equals("e", StringComparison.InvariantCultureIgnoreCase) || args[0].Equals("equip", StringComparison.InvariantCultureIgnoreCase) || args[0].Equals("equipment", StringComparison.InvariantCultureIgnoreCase))
			{
				val4 = val2.GetEquipmentIndex();
				if ((int)val4 == -1)
				{
					return "<color=#FF8282>Target does not have an </color><color=#ff7d00>equipment</color>";
				}
			}
			else
			{
				val5 = StringParsers.FindItemInInventroy(args[0], val2);
			}
			PickupIndex val6;
			string text3;
			if ((int)val5 == -1)
			{
				if ((int)val4 == -1)
				{
					val4 = val2.GetEquipmentIndex();
					if ((int)val4 == -1 || !Utilities.ContainsString(StringParsers.ReformatString(Language.GetString(EquipmentCatalog.GetEquipmentDef(val4).nameToken)), StringParsers.ReformatString(args[0])))
					{
						return "<color=#FF8282>Could not find item '<color=#ff4646>" + args[0] + "</color>' in " + text + "<color=#AAE6F0>'s</color> inventory</color>";
					}
				}
				val6 = PickupCatalog.FindPickupIndex(val4);
				text3 = Util.GenerateColoredString(Language.GetString(EquipmentCatalog.GetEquipmentDef(val4).nameToken), Color32.op_Implicit(PickupCatalog.GetPickupDef(val6).baseColor));
				if (val4 != val2.GetEquipmentIndex())
				{
					return "<color=#FF8282>Target does not have </color><color=#ff4646>" + text3 + "</color>";
				}
				MakePickupDroplets(val6, val3.position, velocity);
				val2.SetEquipmentIndex((EquipmentIndex)(-1));
				if ((Object)(object)val == (Object)(object)sender)
				{
					return "<color=#96EBAA>Dropped " + text3 + " from </color>" + text;
				}
				return "<color=#96EBAA>" + text2 + " is dropping " + text3 + " from </color>" + text;
			}
			ItemDef itemDef = ItemCatalog.GetItemDef(val5);
			val6 = PickupCatalog.FindPickupIndex(val5);
			text3 = Util.GenerateColoredString(Language.GetString(itemDef.nameToken), Color32.op_Implicit(PickupCatalog.GetPickupDef(val6).baseColor));
			if ((!Config.voidToggle.Value && ((int)itemDef.tier == 6 || (int)itemDef.tier == 7 || (int)itemDef.tier == 8 || (int)itemDef.tier == 9)) || (Object)(object)itemDef == (Object)(object)Items.CaptainDefenseMatrix || ((int)itemDef.tier == 5 && (Object)(object)itemDef != (Object)(object)Items.ExtraLifeConsumed && (Object)(object)itemDef != (Object)(object)Items.ExtraLifeVoidConsumed && (Object)(object)itemDef != (Object)(object)Items.FragileDamageBonusConsumed && (Object)(object)itemDef != (Object)(object)Items.HealingPotionConsumed && (Object)(object)itemDef != (Object)(object)Items.RegeneratingScrapConsumed))
			{
				return text3 + "<color=#FF8282> is not dropable</color>";
			}
			int num = Math.Min(val2.GetItemCount(val5), 20);
			if (args.Length > 2 && int.TryParse(args[2], out var result))
			{
				num = Math.Min(num, result);
			}
			if (num == 0)
			{
				return "<color=#FF8282>Target does not have </color>" + text3;
			}
			if (num > 1)
			{
				text3 += Util.GenerateColoredString("s", Color32.op_Implicit(PickupCatalog.GetPickupDef(val6).baseColor));
			}
			MakePickupDroplets(val6, val3.position, velocity, num);
			val2.RemoveItem(val5, num);
			if ((Object)(object)val == (Object)(object)sender)
			{
				return string.Format("{0}{1} dropped {2} {3}</color>", "<color=#96EBAA>", text, num, text3);
			}
			return string.Format("{0}{1} is dropping {2} {3} from </color>{4}", "<color=#96EBAA>", text2, num, text3, text);
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCDIDropItem(ConCommandArgs args)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			if (((ConCommandArgs)(ref args)).Count == 0)
			{
				Debug.LogError((object)"Requires at least 1 argument: dropitem {itemname} ({PlayerID:self}|{Playername})");
				return;
			}
			if ((Object)(object)args.sender == (Object)null && ((ConCommandArgs)(ref args)).Count < 2)
			{
				Debug.LogError((object)"Command must be fully qualified on dedicated servers.");
				return;
			}
			if (((ConCommandArgs)(ref args))[0].ToUpperInvariant() == "HELP")
			{
				Debug.Log((object)"<color=#AAE6F0>/d itemname playername\nItems with spaces need to be typed without them:\nScrap, Green -> scrapg</color>");
				return;
			}
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = Drop_item(args.sender, args.userArgs.ToArray())
			});
		}

		internal static void MakePickupDroplets(PickupIndex pickupIndex, Vector3 position, Vector3 velocity, int amount = 1)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			CreatePickupInfo val = default(CreatePickupInfo);
			val.position = position;
			val.artifactFlag = (PickupArtifactFlag)2;
			((CreatePickupInfo)(ref val)).pickupIndex = pickupIndex;
			val.prefabOverride = Main.pickupPrefab;
			CreatePickupInfo val2 = val;
			for (int i = 0; i < amount; i++)
			{
				val2.rotation = Quaternion.Euler(0f, 180f * (float)i / (float)amount + DoIsNegative(), 0f);
				PickupDropletController.CreatePickupDroplet(val2, position, velocity * (1f + (float)i / 60f));
			}
		}

		private static float DoIsNegative()
		{
			isNegative = !isNegative;
			return isNegative ? 180 : 0;
		}
	}
	internal class DropAll : MonoBehaviour
	{
		private const float period = 0.2f;

		private NetworkUser target;

		private Transform targetTransform;

		private NetworkUser sender;

		private Inventory inventory;

		private List<ItemIndex> items;

		private float timer = 0.2f - Time.fixedDeltaTime;

		private Vector3 currentDirection;

		private Quaternion rotation;

		public void Assign(NetworkUser target, NetworkUser sender, Transform transform)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			this.target = target;
			this.sender = sender;
			targetTransform = transform;
			inventory = target.master.inventory;
			items = inventory.itemAcquisitionOrder;
			int num = items.Count + inventory.GetEquipmentSlotCount();
			if (num <= 0)
			{
				log.warning("Empty inventory");
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else
			{
				currentDirection = Quaternion.AngleAxis((float)Random.Range(0, 360), Vector3.up) * (Vector3.up * 15f + Vector3.forward * 8f * (0.8f + (float)num / 80f));
				rotation = Quaternion.AngleAxis(360f / (float)num, Vector3.up);
			}
		}

		private void FixedUpdate()
		{
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Invalid comparison between Unknown and I4
			//IL_01ab: 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)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Invalid comparison between Unknown and I4
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			NetworkUser obj = target;
			if (obj != null)
			{
				CharacterMaster master = obj.master;
				if (((master != null) ? new bool?(master.hasBody) : null).GetValueOrDefault())
				{
					NetworkUser obj2 = sender;
					if (obj2 != null)
					{
						CharacterMaster master2 = obj2.master;
						if (((master2 != null) ? new bool?(master2.hasBody) : null).GetValueOrDefault() && Object.op_Implicit((Object)(object)inventory))
						{
							timer += Time.fixedDeltaTime;
							if (!(timer >= 0.2f))
							{
								return;
							}
							timer -= 0.2f;
							for (int num = items.Count - 1; num >= -1; num--)
							{
								if (num == -1)
								{
									for (uint num2 = 0u; num2 < inventory.GetEquipmentSlotCount(); num2++)
									{
										EquipmentIndex equipmentIndex = inventory.GetEquipment(num2).equipmentIndex;
										if ((int)equipmentIndex != -1)
										{
											Drop.MakePickupDroplets(PickupCatalog.FindPickupIndex(equipmentIndex), targetTransform.position, currentDirection);
											inventory.SetEquipmentIndexForSlot((EquipmentIndex)(-1), num2);
											currentDirection = rotation * currentDirection;
											return;
										}
									}
									log.info("Drop all complete");
									Object.Destroy((Object)(object)((Component)this).gameObject);
									break;
								}
								ItemDef itemDef = ItemCatalog.GetItemDef(items[num]);
								if ((int)itemDef.tier != 5 && !((Object)(object)itemDef == (Object)(object)Items.CaptainDefenseMatrix))
								{
									int num3 = inventory.GetItemCount(items[num]);
									if (num3 > 15)
									{
										num3 = 15;
									}
									timer -= (float)num3 * 0.02f;
									Drop.MakePickupDroplets(PickupCatalog.FindPickupIndex(items[num]), targetTransform.position, currentDirection, num3);
									inventory.RemoveItem(items[num], num3);
									if (inventory.GetItemCount(itemDef) == 0)
									{
										currentDirection = rotation * currentDirection;
									}
									break;
								}
							}
							return;
						}
					}
				}
			}
			log.warning("Lost body, aborting drop all");
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
	internal class DropNetworkComponent : NetworkBehaviour
	{
		private static int kCmdCmdLockInventory;

		private void Start()
		{
			if (Config.lockInventory.Value && Util.HasEffectiveAuthority(((NetworkBehaviour)this).netIdentity))
			{
				CallCmdLockInventory(enable: true);
			}
		}

		[Command]
		public void CmdLockInventory(bool enable)
		{
			Debug.Log((object)Users.Lock_Inventory(((Component)this).GetComponent<NetworkUser>(), enable));
		}

		private void UNetVersion()
		{
		}

		protected static void InvokeCmdCmdLockInventory(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"Command CmdLockInventory called on client.");
			}
			else
			{
				((DropNetworkComponent)(object)obj).CmdLockInventory(reader.ReadBoolean());
			}
		}

		public void CallCmdLockInventory(bool enable)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"Command function CmdLockInventory called on server.");
				return;
			}
			if (((NetworkBehaviour)this).isServer)
			{
				CmdLockInventory(enable);
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)5);
			val.WritePackedUInt32((uint)kCmdCmdLockInventory);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			val.Write(enable);
			((NetworkBehaviour)this).SendCommandInternal(val, 0, "CmdLockInventory");
		}

		static DropNetworkComponent()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			kCmdCmdLockInventory = -1225425357;
			NetworkBehaviour.RegisterCommandDelegate(typeof(DropNetworkComponent), kCmdCmdLockInventory, new CmdDelegate(InvokeCmdCmdLockInventory));
			NetworkCRC.RegisterBehaviour("DropNetworkComponent", 0);
		}

		public override bool OnSerialize(NetworkWriter writer, bool forceAll)
		{
			bool result = default(bool);
			return result;
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
		}
	}
	internal static class Give
	{
		public const string green = "<color=#96EBAA>";

		public const string player = "<color=#AAE6F0>";

		public const string error = "<color=#FF8282>";

		public const string bold = "<color=#ff4646>";

		public static string Give_Item(NetworkUser sender, string[] args)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Invalid comparison between Unknown and I4
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Invalid comparison between Unknown and I4
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: 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_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Invalid comparison between Unknown and I4
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: 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_02a9: Invalid comparison between Unknown and I4
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Invalid comparison between Unknown and I4
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Invalid comparison between Unknown and I4
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			NetworkUserId id = sender.id;
			if (Users.blockedUserIds.Contains(id))
			{
				return "<color=#FF8282>You are blocked from dropping items</color>";
			}
			Inventory val = (((Object)(object)sender != (Object)null) ? sender.master.inventory : null);
			NetworkUser netUserFromString = StringParsers.GetNetUserFromString(args[1]);
			if ((Object)(object)netUserFromString == (Object)null)
			{
				return "<color=#FF8282>Could not find specified </color>player<color=#FF8282> '<color=#ff4646>" + args[1] + "</color>'</color>";
			}
			Inventory val2 = (((Object)(object)netUserFromString != (Object)null) ? netUserFromString.master.inventory : null);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2))
			{
				return "<color=#ff4646>ERROR: null inventory</color>";
			}
			if ((Object)(object)val == (Object)(object)val2)
			{
				return "<color=#FF8282>Target can not be the sender</color>";
			}
			string text = "<color=#AAE6F0>" + netUserFromString.masterController.GetDisplayName() + "</color>";
			string text2 = "<color=#AAE6F0>" + sender.masterController.GetDisplayName() + "</color>";
			if (Users.lockedUserIds.Contains(netUserFromString.id))
			{
				return "<color=#FF8282>" + text + " has their inventory locked, failed to give item</color>";
			}
			EquipmentIndex val3 = (EquipmentIndex)(-1);
			ItemIndex val4 = (ItemIndex)(-1);
			if (args[0].ToLower() == "e" || args[0].ToLower() == "equip" || args[0].ToLower() == "equipment")
			{
				val3 = val.GetEquipmentIndex();
				if ((int)val3 == -1)
				{
					return "<color=#FF8282>Sender does not have an </color><color=#ff7d00>equipment</color>";
				}
			}
			else
			{
				val4 = StringParsers.FindItemInInventroy(args[0], val);
			}
			PickupIndex val5;
			string text3;
			if ((int)val4 == -1)
			{
				if ((int)val3 == -1)
				{
					val3 = val.GetEquipmentIndex();
					if ((int)val3 == -1 || !StringParsers.ReformatString(Language.GetString(EquipmentCatalog.GetEquipmentDef(val3).nameToken)).Contains(StringParsers.ReformatString(args[0])))
					{
						return "<color=#FF8282>Could not find item '<color=#ff4646>" + args[0] + "</color>' in " + text2 + "<color=#AAE6F0>'s</color> inventory</color>";
					}
				}
				if ((int)val2.GetEquipmentIndex() != -1)
				{
					return "<color=#FF8282>Target already has an equipment</color>";
				}
				val5 = PickupCatalog.FindPickupIndex(val3);
				text3 = Util.GenerateColoredString(Language.GetString(EquipmentCatalog.GetEquipmentDef(val3).nameToken), Color32.op_Implicit(PickupCatalog.GetPickupDef(val5).baseColor));
				if (val3 != val.GetEquipmentIndex())
				{
					return "<color=#FF8282>Sender does not have </color><color=#ff4646>" + text3 + "</color>";
				}
				val2.SetEquipmentIndex(val3);
				val.SetEquipmentIndex((EquipmentIndex)(-1));
				return "<color=#96EBAA>" + text2 + " gave " + text3 + " to </color>" + text;
			}
			ItemDef itemDef = ItemCatalog.GetItemDef(val4);
			val5 = PickupCatalog.FindPickupIndex(val4);
			text3 = Util.GenerateColoredString(Language.GetString(itemDef.nameToken), Color32.op_Implicit(PickupCatalog.GetPickupDef(val5).baseColor));
			if ((Object)(object)itemDef == (Object)(object)Items.CaptainDefenseMatrix || ((int)itemDef.tier == 5 && (Object)(object)itemDef != (Object)(object)Items.ExtraLifeConsumed && (Object)(object)itemDef != (Object)(object)Items.ExtraLifeVoidConsumed && (Object)(object)itemDef != (Object)(object)Items.FragileDamageBonusConsumed && (Object)(object)itemDef != (Object)(object)Items.HealingPotionConsumed && (Object)(object)itemDef != (Object)(object)Items.RegeneratingScrapConsumed))
			{
				return text3 + "<color=#FF8282> is not dropable</color>";
			}
			int num = val.GetItemCount(val4);
			if (num == 0)
			{
				return "<color=#FF8282>Sender does not have </color>" + text3;
			}
			if (num > 1)
			{
				text3 += Util.GenerateColoredString("s", Color32.op_Implicit(PickupCatalog.GetPickupDef(val5).baseColor));
			}
			if (num > 30)
			{
				num = 30;
			}
			val2.GiveItem(val4, num);
			val.RemoveItem(val4, num);
			return string.Format("{0}{1} gave {2} {3} to </color>{4}", "<color=#96EBAA>", text2, num, text3, text);
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCGiveItem(ConCommandArgs args)
		{
			//IL_0015: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			if (((ConCommandArgs)(ref args)).Count < 2)
			{
				Debug.LogError((object)"Requires at least 2 arguments: giveitem {Itemname} {{Playername}");
				return;
			}
			if ((Object)(object)args.sender == (Object)null)
			{
				Debug.LogError((object)"Command cannot be used by dedicated servers.");
				return;
			}
			string[] args2 = new string[2]
			{
				((ConCommandArgs)(ref args))[0],
				((ConCommandArgs)(ref args))[1]
			};
			if (((ConCommandArgs)(ref args))[0].ToUpperInvariant() == "HELP")
			{
				Debug.Log((object)"<color=#AAE6F0>/g itemname playername\nWill transfer items from sender's inventory into playername's inventory");
				return;
			}
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = Give_Item(args.sender, args2)
			});
		}
	}
	internal static class Hooks
	{
		private delegate GenericPickupController FuncCreatePickup<T1>(in T1 a1);

		internal static void DoSetup()
		{
			HookManager.Hook(typeof(Chat), "CCSay", (Delegate)new Action<Action<ConCommandArgs>, ConCommandArgs>(On_Chat_CCSay_CheckForCommands));
			HookManager.Hook(typeof(GenericPickupController), "CreatePickup", (Delegate)new <>F{00000008}<FuncCreatePickup<CreatePickupInfo>, CreatePickupInfo, GenericPickupController>(On_GenericPickupController_CreatePickup_DetectDropped));
			HookManager.Hook(typeof(HUD), "Awake", (Delegate)new Action<Action<HUD>, HUD>(On_HUD_Awake_GetHUD));
			HookManager.Hook(typeof(NetworkManagerSystem), "Init", (Delegate)new Action<Action<NetworkManagerSystem, NetworkManagerConfiguration>, NetworkManagerSystem, NetworkManagerConfiguration>(On_NetworkManagerSystem_Init_AddComponent));
			HookManager.Hook(typeof(ItemIcon), "ItemClicked", (Delegate)new Action<Action<ItemIcon>, ItemIcon>(On_ItemIcon_ItemClicked_BlockDropKey));
			HookManager.Hook(typeof(MPInputModule), "GetMousePointerEventData", (Delegate)new Func<Func<MPInputModule, int, int, MouseState>, MPInputModule, int, int, MouseState>(On_MPInputModule_GetMousePointerEventData_CheckResetKey));
			if (Chainloader.PluginInfos.ContainsKey("com.niwith.DropInMultiplayer"))
			{
				try
				{
					DoDropInMultiplayerHook();
				}
				catch (Exception ex)
				{
					log.error("Failed DropInMultiplayer chat compatibility\n" + ex);
				}
			}
		}

		private static void On_Chat_CCSay_CheckForCommands(Action<ConCommandArgs> orig, ConCommandArgs args)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			orig(args);
			string text = args.userArgs.FirstOrDefault();
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance) || string.IsNullOrWhiteSpace(text) || !text.StartsWith("/"))
			{
				return;
			}
			string[] source = text.Split(new char[1] { ' ' });
			string key = source.FirstOrDefault().Substring(1).ToLower();
			string[] array = source.Skip(1).ToArray();
			if (ChatCommands.chatCommands.TryGetValue(key, out var value))
			{
				string text2 = ((array.Length >= value.minArgs && (array.Length == 0 || (!(array[0] == "") && !array[0].Equals("h", StringComparison.InvariantCultureIgnoreCase) && !array[0].Equals("help", StringComparison.InvariantCultureIgnoreCase)))) ? value.method(args.sender, array) : value.helpText);
				if (text2 == null)
				{
					text2 = "<color=#ff4646>ERROR: null output</color>";
				}
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = text2
				});
			}
		}

		private static GenericPickupController On_GenericPickupController_CreatePickup_DetectDropped(FuncCreatePickup<CreatePickupInfo> orig, ref CreatePickupInfo createPickupInfo)
		{
			if ((Object)(object)createPickupInfo.prefabOverride == (Object)(object)Main.pickupPrefab)
			{
				createPickupInfo.prefabOverride = GenericPickupController.pickupPrefab;
				GenericPickupController obj = orig(in createPickupInfo);
				obj.NetworkRecycled = true;
				return obj;
			}
			return orig(in createPickupInfo);
		}

		private static void On_HUD_Awake_GetHUD(Action<HUD> orig, HUD self)
		{
			Main.hud = self;
			orig(self);
		}

		private static void On_NetworkManagerSystem_Init_AddComponent(Action<NetworkManagerSystem, NetworkManagerConfiguration> orig, NetworkManagerSystem self, NetworkManagerConfiguration config)
		{
			config.PlayerPrefab.AddComponent<DropNetworkComponent>();
			orig(self, config);
		}

		private static void On_ItemIcon_ItemClicked_BlockDropKey(Action<ItemIcon> orig, ItemIcon self)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			KeyCode val = Config.dropButton.Value.ToKey();
			if (!Input.GetKey(val) && !Input.GetKeyUp(val) && !Config.dropSingleButton.IsKeyDown() && Main.singlePressed == 0)
			{
				orig(self);
			}
		}

		private static MouseState On_MPInputModule_GetMousePointerEventData_CheckResetKey(Func<MPInputModule, int, int, MouseState> orig, MPInputModule self, int playerid, int mouseIndex)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			MouseState val = orig(self, playerid, mouseIndex);
			if (val != null && Config.dropSingleButton.IsKeyJustPressed())
			{
				RaycastResult pointerCurrentRaycast = ((PointerEventData)val.GetButtonState(0).eventData.buttonData).pointerCurrentRaycast;
				ExecuteEvents.GetEventChain(((RaycastResult)(ref pointerCurrentRaycast)).gameObject, (IList<Transform>)ExecuteEvents.s_InternalTransformList);
				foreach (Transform s_InternalTransform in ExecuteEvents.s_InternalTransformList)
				{
					DragItem component = ((Component)s_InternalTransform).gameObject.GetComponent<DragItem>();
					if (Object.op_Implicit((Object)(object)component) && component.GetPlayerAndItem(out var player, out var args))
					{
						args.Add(NetworkUser.readOnlyInstancesList.IndexOf(player.networkUser).ToString());
						args.Add("1");
						Console.instance.RunCmd(new CmdSender(LocalUserManager.GetFirstLocalUser().currentNetworkUser), "dropitem", args);
					}
				}
			}
			return val;
		}

		private static void DoDropInMultiplayerHook()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			HookManager.Hook(typeof(DropInMultiplayer), "Console_RunCmd", new Manipulator(IL_DropInMultiplayer_Console_RunCmd_FixNullAndMute));
		}

		private static void IL_DropInMultiplayer_Console_RunCmd_FixNullAndMute(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext(new Func<Instruction, bool>[2]
			{
				(Instruction a) => ILPatternMatchingExt.MatchLdstr(a, "Unable to find command, try /help"),
				(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, typeof(DropInMultiplayer), "SendChatMessage")
			}))
			{
				val.Emit(OpCodes.Ret);
			}
			else
			{
				log.warning("Failed DropInMultiplayer chat compatibility");
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("dolso.dropitem", "Dropitem", "2.1.6")]
	public class Main : BaseUnityPlugin
	{
		internal const string dropinguid = "com.niwith.DropInMultiplayer";

		internal static HUD hud;

		internal static GameObject pickupPrefab;

		internal static int singlePressed;

		private void Awake()
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00d9: Expected O, but got Unknown
			log.start(((BaseUnityPlugin)this).Logger);
			Config.DoConfig(((BaseUnityPlugin)this).Config);
			Hooks.DoSetup();
			Utilities.GetAddressable("RoR2/Base/UI/ScoreboardStrip.prefab", delegate(GameObject scoreboard)
			{
				scoreboard.AddComponent<ScoreboardDrop>();
				((Component)scoreboard.GetComponentInChildren<EquipmentIcon>()).gameObject.AddComponent<DragItem>().type = DragItem.ItemType.Equipment;
			});
			Utilities.GetAddressable("RoR2/Base/UI/HUDSimple.prefab", delegate(GameObject hudSimple)
			{
				Transform obj = hudSimple.transform.Find("MainContainer/MainUIArea/SpringCanvas/TopCenterCluster/ItemInventoryDisplayRoot/ItemInventoryDisplay");
				GameObject val2 = ((obj != null) ? ((Component)obj).gameObject : null);
				if (Object.op_Implicit((Object)(object)val2))
				{
					val2.AddComponent<ScoreboardDrop>();
				}
				else
				{
					log.error("failed to find ItemInventoryDisplay");
				}
				EquipmentIcon[] componentsInChildren = hudSimple.GetComponentsInChildren<EquipmentIcon>();
				foreach (EquipmentIcon val3 in componentsInChildren)
				{
					if (((Object)val3).name == "EquipmentSlot")
					{
						((Component)val3).gameObject.AddComponent<DragItem>().type = DragItem.ItemType.Equipment;
					}
				}
			});
			Utilities.AddressableAddComp<DragItem>("RoR2/Base/UI/ItemIcon.prefab", (Action<DragItem>)delegate(DragItem a)
			{
				a.type = DragItem.ItemType.Item;
			});
			Utilities.AddressableAddComp<DragItem>("RoR2/Base/UI/ItemIconScoreboard_InGame.prefab", (Action<DragItem>)delegate(DragItem a)
			{
				a.type = DragItem.ItemType.Item;
			});
			GameObject val = new GameObject();
			pickupPrefab = Utilities.CreatePrefab(val, "DropItemPickup");
			Object.Destroy((Object)val);
		}

		private void Update()
		{
			if (Config.dropSingleButton.IsKeyDown())
			{
				singlePressed = 2;
			}
			else if (singlePressed > 0)
			{
				singlePressed--;
			}
		}
	}
	internal class ScoreboardDrop : MonoBehaviour, IDropHandler, IEventSystemHandler
	{
		public void OnDrop(PointerEventData eventData)
		{
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			if (DragItem.InvalidButton(eventData))
			{
				return;
			}
			object obj;
			if (eventData == null)
			{
				obj = null;
			}
			else
			{
				GameObject pointerDrag = eventData.pointerDrag;
				obj = ((pointerDrag != null) ? pointerDrag.GetComponent<DragItem>() : null);
			}
			DragItem dragItem = (DragItem)obj;
			if (!Object.op_Implicit((Object)(object)dragItem))
			{
				log.warning("Dragged object does not have DragItem component");
			}
			else
			{
				if (!dragItem.GetPlayerAndItem(out var player, out var args))
				{
					return;
				}
				PlayerCharacterMasterController val = ((Component)this).GetComponent<ScoreboardStrip>()?.userPlayerCharacterMasterController;
				if (!Object.op_Implicit((Object)(object)val))
				{
					ItemInventoryDisplay component = ((Component)this).GetComponent<ItemInventoryDisplay>();
					object obj2;
					if (component == null)
					{
						obj2 = null;
					}
					else
					{
						Inventory inventory = component.inventory;
						obj2 = ((inventory != null) ? ((Component)inventory).GetComponent<CharacterMaster>().playerCharacterMasterController : null);
					}
					val = (PlayerCharacterMasterController)obj2;
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					log.warning("null target player");
					return;
				}
				string text;
				if ((Object)(object)player != (Object)(object)val)
				{
					if ((Object)(object)player.networkUser != (Object)(object)LocalUserManager.GetFirstLocalUser().currentNetworkUser)
					{
						Chat.AddMessage((ChatMessageBase)new SimpleChatMessage
						{
							baseToken = "<color=#FF8282>Can only give items from your inventory</color>"
						});
						return;
					}
					text = "giveitem";
					args.Add(NetworkUser.readOnlyInstancesList.IndexOf(val.networkUser).ToString());
				}
				else
				{
					text = "dropitem";
					if ((Object)(object)player.networkUser != (Object)(object)LocalUserManager.GetFirstLocalUser().currentNetworkUser)
					{
						args.Add(NetworkUser.readOnlyInstancesList.IndexOf(player.networkUser).ToString());
					}
				}
				Console.instance.RunCmd(new CmdSender(LocalUserManager.GetFirstLocalUser().currentNetworkUser), text, args);
			}
		}
	}
	internal static class StringParsers
	{
		internal static ItemIndex FindItemInInventroy(string input, Inventory inventory)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			List<ItemIndex> itemAcquisitionOrder = inventory.itemAcquisitionOrder;
			if (!itemAcquisitionOrder.Any())
			{
				return (ItemIndex)(-1);
			}
			input = ReformatString(input);
			if (int.TryParse(input, out var result))
			{
				if (result > itemAcquisitionOrder.Count || result < 0)
				{
					return (ItemIndex)(-1);
				}
				if (result == 0)
				{
					return itemAcquisitionOrder[itemAcquisitionOrder.Count - 1];
				}
				return itemAcquisitionOrder[itemAcquisitionOrder.Count - result];
			}
			for (int num = itemAcquisitionOrder.Count - 1; num >= 0; num--)
			{
				ItemDef itemDef = ItemCatalog.GetItemDef(itemAcquisitionOrder[num]);
				if (Utilities.ContainsString(ReformatString(Language.GetString(itemDef.nameToken)), input))
				{
					return itemDef.itemIndex;
				}
			}
			if (Language.currentLanguageName != "en")
			{
				for (int num2 = itemAcquisitionOrder.Count - 1; num2 >= 0; num2--)
				{
					ItemDef itemDef2 = ItemCatalog.GetItemDef(itemAcquisitionOrder[num2]);
					if (Utilities.ContainsString(ReformatString(Language.GetString(itemDef2.nameToken, "en")), input))
					{
						return itemDef2.itemIndex;
					}
				}
			}
			return (ItemIndex)(-1);
		}

		public static EquipmentIndex GetEquipFromPartial(string name)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			name = ReformatString(name);
			EquipmentDef[] equipmentDefs = EquipmentCatalog.equipmentDefs;
			foreach (EquipmentDef val in equipmentDefs)
			{
				if (Utilities.ContainsString(ReformatString(Language.GetString(val.nameToken)), name))
				{
					return val.equipmentIndex;
				}
			}
			return (EquipmentIndex)(-1);
		}

		internal static NetworkUser GetNetUserFromString(string name)
		{
			if (int.TryParse(name, out var result) && result < NetworkUser.readOnlyInstancesList.Count && result >= 0)
			{
				return NetworkUser.readOnlyInstancesList[result];
			}
			name = ReformatString(name);
			foreach (NetworkUser readOnlyInstances in NetworkUser.readOnlyInstancesList)
			{
				if (ReformatString(readOnlyInstances.userName).StartsWith(name, StringComparison.InvariantCultureIgnoreCase))
				{
					return readOnlyInstances;
				}
			}
			foreach (NetworkUser readOnlyInstances2 in NetworkUser.readOnlyInstancesList)
			{
				if (Utilities.ContainsString(ReformatString(readOnlyInstances2.userName), name))
				{
					return readOnlyInstances2;
				}
			}
			return null;
		}

		internal static string ReformatString(string input)
		{
			return Regex.Replace(input, "[ '_.,-]", string.Empty);
		}
	}
	internal static class Users
	{
		internal static List<NetworkUserId> lockedUserIds = new List<NetworkUserId>();

		public static List<NetworkUserId> blockedUserIds = new List<NetworkUserId>();

		public static string Lock_Inventory(NetworkUser user, string[] args)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			bool shouldLock = ((args.Length == 0) ? (!lockedUserIds.Contains(user.id)) : (args[0] != "0"));
			return Lock_Inventory(user, shouldLock);
		}

		public static string Lock_Inventory(NetworkUser user, bool shouldLock)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			NetworkUserId id = user.id;
			string text = "<color=#AAE6F0>" + user.userName + "</color>";
			if (shouldLock)
			{
				if (!lockedUserIds.Contains(id))
				{
					lockedUserIds.Add(id);
					return "<color=#96EBAA>Locking " + text + "'s inventory</color>";
				}
				return "<color=#FF8282>Locked list already contains " + text + ", do '/lock 0' to unlock</color>";
			}
			if (lockedUserIds.Contains(id))
			{
				lockedUserIds.Remove(id);
				return "<color=#96EBAA>Unlocking " + text + "'s inventory</color>";
			}
			return "<color=#FF8282>Locked list does not contain " + text + ", do '/lock 1' to lock</color>";
		}

		public static string Block_User(NetworkUser sender, string[] args)
		{
			//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_0058: 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)
			if ((Object)(object)LocalUserManager.GetFirstLocalUser().currentNetworkUser != (Object)(object)sender)
			{
				return "<color=#FF8282>Sender is not host</color>";
			}
			NetworkUser netUserFromString = StringParsers.GetNetUserFromString(args[0]);
			if ((Object)(object)netUserFromString == (Object)null)
			{
				return "<color=#FF8282>Could not find specified </color>player<color=#FF8282> '<color=#ff4646>" + args[0] + "</color>'</color>";
			}
			if ((Object)(object)netUserFromString == (Object)(object)sender)
			{
				return "<color=#FF8282>Can not block self</color>";
			}
			NetworkUserId id = netUserFromString.id;
			if (blockedUserIds.Remove(id))
			{
				return "<color=#96EBAA>Unblocked <color=#AAE6F0>" + netUserFromString.masterController.GetDisplayName() + "</color></color>";
			}
			blockedUserIds.Add(id);
			return "<color=#96EBAA>Blocked <color=#AAE6F0>" + netUserFromString.masterController.GetDisplayName() + "</color></color>";
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCDIBlockUser(ConCommandArgs args)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (((ConCommandArgs)(ref args)).Count == 0)
			{
				Debug.LogError((object)"Requires at least 1 argument: blockuser {Playername}");
				return;
			}
			Debug.Log((object)Block_User(args.sender, new string[1] { ((ConCommandArgs)(ref args))[0] }));
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCLockInventory(ConCommandArgs args)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if (((ConCommandArgs)(ref args)).Count > 0)
			{
				Config.lockInventory.Value = ((ConCommandArgs)(ref args))[0] != "0";
			}
			else
			{
				Config.lockInventory.Value = !Config.lockInventory.Value;
			}
			Debug.Log((object)("Set Lock Inventory to: " + Config.lockInventory.Value));
			if (Object.op_Implicit((Object)(object)args.sender))
			{
				((Component)args.sender).GetComponent<DropNetworkComponent>().CallCmdLockInventory(Config.lockInventory.Value);
			}
		}
	}
}