Decompiled source of JustDropItems v1.0.0

JustDropItems.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using H1xl.Shared;
using HG;
using MonoMod.RuntimeDetour;
using Rewired;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Networking;
using RoR2.Orbs;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("JustDropItems")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+27ed5a0478ae60ad9f4f2b15195f19fdcd1348d4")]
[assembly: AssemblyProduct("JustDropItems")]
[assembly: AssemblyTitle("JustDropItems")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace H1xl.Shared
{
	internal static class Log
	{
		private static ManualLogSource source;

		private static readonly HashSet<string> logged = new HashSet<string>();

		internal static Func<bool> IsVerbose = null;

		internal static bool Verbose
		{
			get
			{
				if (IsVerbose != null)
				{
					return IsVerbose();
				}
				return false;
			}
		}

		internal static void Init(ManualLogSource logger)
		{
			source = logger;
		}

		internal static void Info(object message)
		{
			ManualLogSource obj = source;
			if (obj != null)
			{
				obj.LogInfo(message);
			}
		}

		internal static void Warn(object message)
		{
			ManualLogSource obj = source;
			if (obj != null)
			{
				obj.LogWarning(message);
			}
		}

		internal static void Error(object message)
		{
			ManualLogSource obj = source;
			if (obj != null)
			{
				obj.LogError(message);
			}
		}

		internal static void Debug(object message)
		{
			if (Verbose)
			{
				ManualLogSource obj = source;
				if (obj != null)
				{
					obj.LogInfo(message);
				}
			}
		}

		internal static bool ErrorOnce(string key, object message)
		{
			if (!logged.Add(key))
			{
				return false;
			}
			ManualLogSource obj = source;
			if (obj != null)
			{
				obj.LogError(message);
			}
			return true;
		}

		internal static bool WarnOnce(string key, object message)
		{
			if (!logged.Add(key))
			{
				return false;
			}
			ManualLogSource obj = source;
			if (obj != null)
			{
				obj.LogWarning(message);
			}
			return true;
		}
	}
	internal static class HookUtil
	{
		private static readonly List<Hook> hooks = new List<Hook>();

		internal static bool Add(GameMethod method, Type handlerType, string handler)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			MethodInfo methodInfo = method.Find();
			if (methodInfo == null)
			{
				Log.Warn($"{method} not found (game updated?). The feature using it is disabled.");
				return false;
			}
			MethodInfo method2 = handlerType.GetMethod(handler, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (method2 == null)
			{
				Log.Error($"Hook handler {handlerType.Name}.{handler} not found (mod bug). {method} is not hooked.");
				return false;
			}
			try
			{
				hooks.Add(new Hook((MethodBase)methodInfo, method2));
				return true;
			}
			catch (Exception arg)
			{
				Log.Error($"Failed to hook {method}: {arg}");
				return false;
			}
		}

		internal static void DisposeAll()
		{
			foreach (Hook hook in hooks)
			{
				hook.Dispose();
			}
			hooks.Clear();
		}
	}
	internal abstract class GameMember
	{
		internal const BindingFlags Any = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		internal readonly Type Type;

		internal readonly string Name;

		protected GameMember(Type type, string name)
		{
			Type = type;
			Name = name;
		}

		internal abstract MemberInfo FindMember();

		internal static Type Nested(Type outer, string name)
		{
			return outer.GetNestedType(name, BindingFlags.Public | BindingFlags.NonPublic);
		}

		public override string ToString()
		{
			return (Type?.Name ?? "<missing type>") + "." + Name;
		}
	}
	internal sealed class GameMethod : GameMember
	{
		internal readonly Type[] Args;

		internal GameMethod(Type type, string name, params Type[] args)
			: base(type, name)
		{
			Args = args;
		}

		internal MethodInfo Find()
		{
			try
			{
				return Type?.GetMethod(Name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Args, null);
			}
			catch (Exception)
			{
				return null;
			}
		}

		internal override MemberInfo FindMember()
		{
			return Find();
		}
	}
	internal sealed class GameField : GameMember
	{
		internal GameField(Type type, string name)
			: base(type, name)
		{
		}

		internal FieldInfo Find()
		{
			try
			{
				return Type?.GetField(Name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			}
			catch (Exception)
			{
				return null;
			}
		}

		internal override MemberInfo FindMember()
		{
			return Find();
		}
	}
	internal sealed class GameProperty : GameMember
	{
		internal GameProperty(Type type, string name)
			: base(type, name)
		{
		}

		internal PropertyInfo Find()
		{
			try
			{
				return Type?.GetProperty(Name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			}
			catch (Exception)
			{
				return null;
			}
		}

		internal override MemberInfo FindMember()
		{
			return Find();
		}
	}
	internal static class SharedGameMembers
	{
		internal static readonly GameField PickupTransferOrb_orbEffectPrefab = new GameField(typeof(PickupTransferOrb), "orbEffectPrefab");

		internal static readonly GameMethod DynamicBone_SetupParticles = new GameMethod(typeof(DynamicBone), "SetupParticles");

		internal static readonly GameMethod DynamicBone_InitTransforms = new GameMethod(typeof(DynamicBone), "InitTransforms");

		internal static readonly GameMethod DynamicBone_ResetParticlesPosition = new GameMethod(typeof(DynamicBone), "ResetParticlesPosition");

		internal static readonly GameMethod DynamicBone_UpdateDynamicBones = new GameMethod(typeof(DynamicBone), "UpdateDynamicBones", typeof(float));
	}
	internal static class RooPage
	{
		internal const string GUID = "com.rune580.riskofoptions";

		internal static void TryRegister(Action register)
		{
			if (!Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				return;
			}
			try
			{
				register();
			}
			catch (Exception ex)
			{
				Log.Error("Risk Of Options page failed: " + ex);
			}
		}
	}
	internal static class RooHelper
	{
		internal static void Page(string description, string pluginFolder)
		{
			ModSettingsManager.SetModDescription(description);
			Sprite val = LoadIcon(Path.Combine(pluginFolder, "icon.png"));
			if (Object.op_Implicit((Object)(object)val))
			{
				ModSettingsManager.SetModIcon(val);
			}
		}

		internal static void CheckBox(ConfigEntry<bool> entry, IsDisabledDelegate disabled = null)
		{
			//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_0012: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
			{
				checkIfDisabled = disabled
			}));
		}

		internal static void Choice(ConfigEntryBase entry, IsDisabledDelegate disabled = null)
		{
			//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_0012: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new ChoiceOption(entry, new ChoiceConfig
			{
				checkIfDisabled = disabled
			}));
		}

		internal static void Key(ConfigEntry<KeyboardShortcut> entry)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry));
		}

		internal static void IntSlider(ConfigEntry<int> entry, int min, int max, string format = "{0}", IsDisabledDelegate disabled = null)
		{
			//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_0028: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig
			{
				min = min,
				max = max,
				formatString = format,
				checkIfDisabled = disabled
			}));
		}

		internal static void Slider(ConfigEntry<float> entry, float min, float max, float step, string format, IsDisabledDelegate disabled = null)
		{
			//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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(entry, new StepSliderConfig
			{
				min = min,
				max = max,
				increment = step,
				FormatString = format,
				checkIfDisabled = disabled
			}));
		}

		internal static void Text(ConfigEntry<string> entry, IsDisabledDelegate disabled = null)
		{
			//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_0019: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(entry, new InputFieldConfig
			{
				submitOn = (SubmitEnum)6,
				checkIfDisabled = disabled
			}));
		}

		private static Sprite LoadIcon(string path)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if (!File.Exists(path))
			{
				return null;
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path)))
			{
				return null;
			}
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}
	}
	internal sealed class ItemFlightOrb : ItemTransferOrb
	{
		internal PickupIndex iconPickup = PickupIndex.none;

		internal Action<EffectData> decorate;

		internal Action<bool> deliver;

		internal bool done;

		public override void Begin()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_0062: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			GameObject val = (((PickupIndex)(ref iconPickup)).isValid ? ItemFlight.PickupOrbEffect : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				if ((int)base.itemIndex != -1)
				{
					((ItemTransferOrb)this).Begin();
				}
				else
				{
					((Orb)this).duration = base.travelDuration;
				}
				return;
			}
			((Orb)this).duration = base.travelDuration;
			if (Object.op_Implicit((Object)(object)((Orb)this).target) || Object.op_Implicit((Object)(object)base.orbEffectTargetObjectOverride))
			{
				EffectData val2 = new EffectData
				{
					origin = ((Orb)this).origin,
					genericFloat = ((Orb)this).duration,
					genericUInt = Util.IntToUintPlusOne(iconPickup.value)
				};
				if (Object.op_Implicit((Object)(object)base.orbEffectTargetObjectOverride))
				{
					val2.SetNetworkedObjectReference(((Component)base.orbEffectTargetObjectOverride).gameObject);
				}
				else
				{
					val2.SetHurtBoxReference(((Orb)this).target);
				}
				decorate?.Invoke(val2);
				EffectManager.SpawnEffect(val, val2, true);
			}
		}

		public override void OnArrival()
		{
			ItemFlight.Arrive(this, stageEnding: false);
		}
	}
	internal static class ItemFlight
	{
		private static readonly List<ItemFlightOrb> inFlight = new List<ItemFlightOrb>(64);

		private static readonly FieldInfo pickupOrbEffectField = SharedGameMembers.PickupTransferOrb_orbEffectPrefab.Find();

		private static GameObject pickupOrbEffect;

		internal static bool PickupOrbEffectFound => pickupOrbEffectField != null;

		internal static GameObject PickupOrbEffect
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)pickupOrbEffect) && pickupOrbEffectField != null)
				{
					object? value = pickupOrbEffectField.GetValue(null);
					pickupOrbEffect = (GameObject)((value is GameObject) ? value : null);
				}
				return pickupOrbEffect;
			}
		}

		internal static Vector3 DropPoint(CharacterBody body, Vector3 fallback)
		{
			//IL_000b: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)body))
			{
				return fallback;
			}
			return body.footPosition + Vector3.up * 1.5f;
		}

		internal static void Launch(ItemFlightOrb orb, CharacterMaster recipient, float travelTime, bool animate, Action<bool> deliver)
		{
			orb.deliver = deliver;
			if (!animate || !Object.op_Implicit((Object)(object)OrbManager.instance))
			{
				Arrive(orb, stageEnding: false);
				return;
			}
			((ItemTransferOrb)orb).travelDuration = travelTime;
			CharacterBody val = (Object.op_Implicit((Object)(object)recipient) ? recipient.GetBody() : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				if (Object.op_Implicit((Object)(object)val.mainHurtBox))
				{
					((Orb)orb).target = val.mainHurtBox;
				}
				else
				{
					((ItemTransferOrb)orb).orbEffectTargetObjectOverride = val.networkIdentity;
				}
			}
			inFlight.Add(orb);
			try
			{
				OrbManager.instance.AddOrb((Orb)(object)orb);
			}
			catch (Exception ex)
			{
				Log.Error("Item orb failed to start, delivering at once: " + ex);
				Arrive(orb, stageEnding: false);
			}
		}

		internal static void FlushAll()
		{
			if (inFlight.Count != 0)
			{
				ItemFlightOrb[] array = inFlight.ToArray();
				inFlight.Clear();
				for (int num = array.Length - 1; num >= 0; num--)
				{
					Arrive(array[num], stageEnding: true);
				}
			}
		}

		internal static void Arrive(ItemFlightOrb orb, bool stageEnding)
		{
			if (orb.done)
			{
				return;
			}
			orb.done = true;
			int num = inFlight.IndexOf(orb);
			if (num >= 0)
			{
				int index = inFlight.Count - 1;
				inFlight[num] = inFlight[index];
				inFlight.RemoveAt(index);
			}
			try
			{
				orb.deliver?.Invoke(stageEnding);
			}
			catch (Exception ex)
			{
				Log.Error("Item delivery failed: " + ex);
			}
		}
	}
}
namespace JustDropItems
{
	internal static class AmountPopup
	{
		private const float BarWidth = 200f;

		private const float Pad = 10f;

		private const float BarHeight = 14f;

		private const float Gap = 10f;

		private const float NumberSize = 20f;

		private const float BreakdownSize = 15f;

		private const float RowHeight = 24f;

		private const float IconGap = 8f;

		private const float CrossThickness = 2f;

		private static GameObject root;

		private static RectTransform rootRt;

		private static RectTransform barRt;

		private static Image background;

		private static Image frame;

		private static Image loadoutPanel;

		private static Color loadoutPanelColor;

		private static CanvasGroup panelGroup;

		private static readonly Image[] dim = (Image[])(object)new Image[4];

		private static readonly Image[] fill = (Image[])(object)new Image[4];

		private static readonly Image[] ticks = (Image[])(object)new Image[3];

		private static readonly RectTransform[] crosses = (RectTransform[])(object)new RectTransform[4];

		private static TextMeshProUGUI numbers;

		private static TextMeshProUGUI breakdown;

		private static object owner;

		private static bool styleLoaded;

		private static GameObject tooltipPanel;

		private static readonly Color panelColor = new Color(0.1f, 0.1f, 0.12f);

		private static readonly Color frameColor = new Color(0.55f, 0.55f, 0.6f);

		private static TMP_FontAsset font;

		private static Material fontMaterial;

		private static readonly Color crossColor = new Color(1f, 0.38f, 0.38f, 0.95f);

		private static readonly Color[] kindColors = (Color[])(object)new Color[4]
		{
			new Color(0.92f, 0.92f, 0.92f),
			new Color(0.62f, 0.85f, 1f),
			new Color(0.85f, 0.75f, 0.55f),
			new Color(0.45f, 0.45f, 0.45f)
		};

		private static RectTransform shownIcon;

		private static bool shownBar;

		private static StackModel shownModel;

		private static int shownAmount;

		private static int shownMax;

		private static string shownText;

		private static float shownScale;

		private static float shownOpacity;

		private static PopupSide shownSide;

		private static bool shownBreakdown;

		private static Language shownLanguage;

		private static readonly Vector3[] corners = (Vector3[])(object)new Vector3[4];

		private static readonly PopupSide[] order = new PopupSide[4]
		{
			PopupSide.Right,
			PopupSide.Below,
			PopupSide.Left,
			PopupSide.Above
		};

		internal static void Hide(object who)
		{
			if (Object.op_Implicit((Object)(object)root) && owner == who)
			{
				root.SetActive(false);
			}
		}

		private static bool Unchanged(object who, RectTransform icon, bool bar, StackModel m, int amount, int max, string text)
		{
			StackModel stackModel = shownModel;
			if (Object.op_Implicit((Object)(object)root) && root.activeSelf && owner == who && (Object)(object)shownIcon == (Object)(object)icon && shownBar == bar && stackModel.permanent == m.permanent && stackModel.ethereal == m.ethereal && stackModel.temporary == m.temporary && stackModel.shared == m.shared && stackModel.etherealAllowed == m.etherealAllowed && stackModel.temporaryAllowed == m.temporaryAllowed && stackModel.order == m.order && shownAmount == amount && shownMax == max && string.Equals(shownText, text) && shownScale == Settings.popupScale.Value && shownOpacity == Settings.popupOpacity.Value && shownSide == Settings.popupSide.Value && shownBreakdown == Settings.showBreakdown.Value && shownLanguage == Language.currentLanguage)
			{
				return true;
			}
			shownIcon = icon;
			shownBar = bar;
			shownModel = m;
			shownAmount = amount;
			shownMax = max;
			shownText = text;
			shownScale = Settings.popupScale.Value;
			shownOpacity = Settings.popupOpacity.Value;
			shownSide = Settings.popupSide.Value;
			shownBreakdown = Settings.showBreakdown.Value;
			shownLanguage = Language.currentLanguage;
			return false;
		}

		private static void Follow(RectTransform icon)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Position(icon, (RectTransform)((Transform)rootRt).parent, rootRt.sizeDelta * Settings.popupScale.Value);
		}

		internal static void ShowText(object who, RectTransform icon, string text)
		{
			if (Object.op_Implicit((Object)(object)icon))
			{
				if (Unchanged(who, icon, bar: false, default(StackModel), 0, 0, text))
				{
					Follow(icon);
					return;
				}
				RectTransform overlay = Open(who, icon, withBar: false);
				float width = 80f;
				float height = 20f;
				PlaceText(text, -10f, ref width, ref height);
				Finish(icon, overlay, width, height);
			}
		}

		private static RectTransform Open(object who, RectTransform icon, bool withBar)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = Overlay.For((Transform)(object)icon);
			Build((Transform)(object)obj);
			owner = who;
			root.SetActive(true);
			root.transform.SetAsLastSibling();
			ApplyBackground();
			((Component)barRt).gameObject.SetActive(withBar);
			((Component)numbers).gameObject.SetActive(withBar);
			float value = Settings.popupScale.Value;
			((Transform)rootRt).localScale = new Vector3(value, value, 1f);
			return obj;
		}

		private static void PlaceText(string text, float top, ref float width, ref float height)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			((Component)breakdown).gameObject.SetActive(!string.IsNullOrEmpty(text));
			if (!string.IsNullOrEmpty(text))
			{
				((TMP_Text)breakdown).text = text;
				Vector2 preferredValues = ((TMP_Text)breakdown).GetPreferredValues(text);
				width = Mathf.Max(width, Mathf.Ceil(preferredValues.x) + 2f + 20f);
				RectTransform rectTransform = ((TMP_Text)breakdown).rectTransform;
				rectTransform.anchoredPosition = new Vector2(0f, top);
				rectTransform.sizeDelta = new Vector2(-20f, Mathf.Ceil(preferredValues.y) + 2f);
				height += Mathf.Ceil(preferredValues.y) + 4f;
			}
		}

		private static void Finish(RectTransform icon, RectTransform overlay, float width, float height)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			rootRt.sizeDelta = new Vector2(width, height);
			Position(icon, overlay, new Vector2(width, height) * Settings.popupScale.Value);
		}

		internal static void Show(object who, RectTransform icon, StackModel model, int amount, int max, string extra = null)
		{
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: 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_01f3: 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_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)icon))
			{
				return;
			}
			if (Unchanged(who, icon, bar: true, model, amount, max, extra))
			{
				Follow(icon);
				return;
			}
			RectTransform overlay = Open(who, icon, withBar: true);
			model.Split(amount, out var p, out var e, out var t);
			bool flag = model.Movable > max;
			int[] array;
			if (flag)
			{
				model.Split(max, out var p2, out var e2, out var t2);
				array = new int[4] { p2, e2, t2, 0 };
			}
			else
			{
				array = new int[4] { model.permanent, model.ethereal, model.temporary, model.shared };
			}
			int[] array2 = new int[4] { p, e, t, 0 };
			int num = 0;
			int[] array3 = array;
			foreach (int num2 in array3)
			{
				num += num2;
			}
			num = Mathf.Max(1, num);
			float num3 = 0f;
			int j = 0;
			ItemKind[] array4 = model.Kinds();
			for (int k = 0; k < 4; k++)
			{
				int num4 = (int)((k < 3) ? array4[k] : ItemKind.Shared);
				float num5 = 200f * (float)array[num4] / (float)num;
				Place(((Graphic)dim[num4]).rectTransform, num3, num5);
				((Behaviour)dim[num4]).enabled = num5 > 0.01f;
				float num6 = 200f * (float)array2[num4] / (float)num;
				Place(((Graphic)fill[num4]).rectTransform, num3, num6);
				((Behaviour)fill[num4]).enabled = num6 > 0.01f;
				Color val = kindColors[num4];
				bool flag2 = model.Allowed((ItemKind)num4);
				((Graphic)dim[num4]).color = new Color(val.r * 0.35f, val.g * 0.35f, val.b * 0.35f, flag2 ? 1f : 0.6f);
				((Graphic)fill[num4]).color = val;
				Cross(crosses[num4], num3, num5, array[num4] > 0 && !flag2);
				num3 += num5;
				if (array[num4] > 0 && k < 3 && j < ticks.Length && num3 < 199.5f)
				{
					((Component)ticks[j]).gameObject.SetActive(true);
					Place(((Graphic)ticks[j]).rectTransform, num3 - 1f, 2f);
					j++;
				}
			}
			for (; j < ticks.Length; j++)
			{
				((Component)ticks[j]).gameObject.SetActive(false);
			}
			string arg = (flag ? (" <size=70%><color=#8C8C8C>" + Language.GetStringFormatted("JUSTDROP_OF_STACK", new object[1] { model.Total }) + "</color></size>") : string.Empty);
			((TMP_Text)numbers).text = $"{amount} / {max}{arg}";
			float num7 = Mathf.Ceil(((TMP_Text)numbers).GetPreferredValues($"{max} / {max}{arg}").x) + 2f;
			RectTransform rectTransform = ((TMP_Text)numbers).rectTransform;
			rectTransform.anchoredPosition = new Vector2(220f, -10f);
			rectTransform.sizeDelta = new Vector2(num7, 24f);
			float width = 220f + num7 + 10f;
			string text = ((Settings.showBreakdown.Value && (model.ethereal > 0 || model.temporary > 0)) ? Breakdown(model.Kinds(), p, e, t) : null);
			if (!string.IsNullOrEmpty(extra))
			{
				text = ((text == null) ? extra : (text + "\n" + extra));
			}
			float height = 44f;
			PlaceText(text, -36f, ref width, ref height);
			Finish(icon, overlay, width, height);
		}

		private static string Breakdown(ItemKind[] kinds, int p, int e, int t)
		{
			List<string> list = new List<string>(3);
			foreach (ItemKind itemKind in kinds)
			{
				int num = itemKind switch
				{
					ItemKind.Ethereal => e, 
					ItemKind.Permanent => p, 
					_ => t, 
				};
				if (num > 0)
				{
					list.Add(num + " " + Tokens.KindName(itemKind));
				}
			}
			return string.Join("  ·  ", list);
		}

		private static void Place(RectTransform rt, float x, float width)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			rt.anchoredPosition = new Vector2(x, 0f);
			rt.sizeDelta = new Vector2(Mathf.Max(0f, width), 0f);
		}

		private static void Cross(RectTransform cross, float x, float width, bool show)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			show = show && width > 0.5f;
			((Component)cross).gameObject.SetActive(show);
			if (show)
			{
				Place(cross, x, width);
				float num = Mathf.Sqrt(width * width + 196f);
				float num2 = Mathf.Atan2(14f, width) * 57.29578f;
				for (int i = 0; i < 2; i++)
				{
					RectTransform val = (RectTransform)((Transform)cross).GetChild(i);
					val.sizeDelta = new Vector2(num, 2f);
					((Transform)val).localRotation = Quaternion.Euler(0f, 0f, (i == 0) ? num2 : (0f - num2));
				}
			}
		}

		private static void ApplyBackground()
		{
			//IL_0017: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			float value = Settings.popupOpacity.Value;
			if (Object.op_Implicit((Object)(object)loadoutPanel))
			{
				Color color = loadoutPanelColor;
				color.a *= value;
				((Graphic)loadoutPanel).color = color;
			}
			if (Object.op_Implicit((Object)(object)panelGroup))
			{
				panelGroup.alpha = value;
				return;
			}
			((Graphic)background).color = new Color(panelColor.r, panelColor.g, panelColor.b, value);
			((Graphic)frame).color = new Color(frameColor.r, frameColor.g, frameColor.b, Mathf.Min(1f, value * 0.6f));
		}

		private static void Position(RectTransform icon, RectTransform canvas, Vector2 size)
		{
			//IL_0013: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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)
			//IL_00df: 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_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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			icon.GetWorldCorners(corners);
			Vector2 val = Overlay.ToLocal(canvas, (Transform)(object)icon, corners[0]);
			Vector2 val2 = Overlay.ToLocal(canvas, (Transform)(object)icon, corners[2]);
			Rect rect = canvas.rect;
			int num = Mathf.Max(0, Array.IndexOf(order, Settings.popupSide.Value));
			Vector2 mid = (val + val2) / 2f;
			for (int i = 0; i < 4; i++)
			{
				Rect rect2 = SideRect(order[(num + i) % 4], val, val2, mid, size);
				if (((Rect)(ref rect2)).xMin >= ((Rect)(ref rect)).xMin && ((Rect)(ref rect2)).xMax <= ((Rect)(ref rect)).xMax && ((Rect)(ref rect2)).yMin >= ((Rect)(ref rect)).yMin && ((Rect)(ref rect2)).yMax <= ((Rect)(ref rect)).yMax)
				{
					PlaceRect(rect2);
					return;
				}
			}
			Rect rect3 = SideRect(order[num], val, val2, mid, size);
			((Rect)(ref rect3)).x = Mathf.Clamp(((Rect)(ref rect3)).x, ((Rect)(ref rect)).xMin, Mathf.Max(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).xMax - size.x));
			((Rect)(ref rect3)).y = Mathf.Clamp(((Rect)(ref rect3)).y, ((Rect)(ref rect)).yMin, Mathf.Max(((Rect)(ref rect)).yMin, ((Rect)(ref rect)).yMax - size.y));
			PlaceRect(rect3);
		}

		private static Rect SideRect(PopupSide side, Vector2 min, Vector2 max, Vector2 mid, Vector2 size)
		{
			//IL_0017: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			return (Rect)(side switch
			{
				PopupSide.Right => new Rect(max.x + 8f, mid.y - size.y / 2f, size.x, size.y), 
				PopupSide.Below => new Rect(mid.x - size.x / 2f, min.y - 8f - size.y, size.x, size.y), 
				PopupSide.Left => new Rect(min.x - 8f - size.x, mid.y - size.y / 2f, size.x, size.y), 
				_ => new Rect(mid.x - size.x / 2f, max.y + 8f, size.x, size.y), 
			});
		}

		private static void PlaceRect(Rect rect)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			rootRt.pivot = Vector2.zero;
			((Transform)rootRt).localPosition = new Vector3(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 0f);
		}

		private static void LoadStyle()
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if (styleLoaded)
			{
				return;
			}
			styleLoaded = true;
			GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/UI/Tooltip");
			if (Object.op_Implicit((Object)(object)val))
			{
				if (Log.Verbose)
				{
					Log.Info("Tooltip prefab:\n" + Dump(val.transform, 0));
				}
				Canvas component = val.GetComponent<Canvas>();
				if (Object.op_Implicit((Object)(object)component))
				{
					Overlay.AddShaderChannels(component.additionalShaderChannels);
				}
				tooltipPanel = FindDescriptionPanel(val);
				TextMeshProUGUI componentInChildren = val.GetComponentInChildren<TextMeshProUGUI>(true);
				if (Object.op_Implicit((Object)(object)componentInChildren))
				{
					font = ((TMP_Text)componentInChildren).font;
					fontMaterial = ((TMP_Text)componentInChildren).fontSharedMaterial;
				}
			}
			kindColors[1] = StyleColor("cIsRental", kindColors[1]);
			kindColors[2] = StyleColor("cIsTemporary", kindColors[2]);
		}

		private static Color StyleColor(string style, Color fallback)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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)
			try
			{
				TMP_Style val = (Object.op_Implicit((Object)(object)TMP_Settings.defaultStyleSheet) ? TMP_Settings.defaultStyleSheet.GetStyle(style) : null);
				Match match = ((val != null) ? Regex.Match(val.styleOpeningDefinition, "#([0-9A-Fa-f]{6,8})") : Match.Empty);
				Color result = default(Color);
				if (match.Success && ColorUtility.TryParseHtmlString("#" + match.Groups[1].Value, ref result))
				{
					return result;
				}
			}
			catch (Exception ex)
			{
				Log.Debug("Style " + style + ": " + ex.Message);
			}
			return fallback;
		}

		private static void Build(Transform canvas)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: 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_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)root))
			{
				if ((Object)(object)root.transform.parent != (Object)(object)canvas)
				{
					root.transform.SetParent(canvas, false);
				}
				return;
			}
			LoadStyle();
			root = new GameObject("JustDropItemsAmount", new Type[2]
			{
				typeof(RectTransform),
				typeof(CanvasGroup)
			});
			root.transform.SetParent(canvas, false);
			root.layer = ((Component)canvas).gameObject.layer;
			CanvasGroup component = root.GetComponent<CanvasGroup>();
			component.blocksRaycasts = false;
			component.interactable = false;
			rootRt = (RectTransform)root.transform;
			RectTransform obj = rootRt;
			RectTransform obj2 = rootRt;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.5f);
			obj2.anchorMax = val;
			obj.anchorMin = val;
			if (!Object.op_Implicit((Object)(object)tooltipPanel) || !CopyPanel())
			{
				BuildPlainPanel();
			}
			barRt = NewRect("Bar", (Transform)(object)rootRt);
			RectTransform obj3 = barRt;
			RectTransform obj4 = barRt;
			((Vector2)(ref val))..ctor(0f, 1f);
			obj4.anchorMax = val;
			obj3.anchorMin = val;
			barRt.pivot = new Vector2(0f, 1f);
			barRt.anchoredPosition = new Vector2(10f, -15f);
			barRt.sizeDelta = new Vector2(200f, 14f);
			Image obj5 = NewImage("Back", (Transform)(object)barRt);
			((Graphic)obj5).color = new Color(0f, 0f, 0f, 0.6f);
			Stretch(((Graphic)obj5).rectTransform);
			for (int i = 0; i < 4; i++)
			{
				dim[i] = Segment("Kind" + i);
			}
			for (int j = 0; j < 4; j++)
			{
				fill[j] = Segment("Chosen" + j);
			}
			for (int k = 0; k < ticks.Length; k++)
			{
				ticks[k] = Segment("Border" + k);
				((Graphic)ticks[k]).color = new Color(1f, 1f, 1f, 0.9f);
			}
			Vector2 val2 = default(Vector2);
			for (int l = 0; l < 4; l++)
			{
				crosses[l] = SegmentRect("Forbidden" + l);
				for (int m = 0; m < 2; m++)
				{
					Image obj6 = NewImage("Line" + m, (Transform)(object)crosses[l]);
					((Graphic)obj6).color = crossColor;
					RectTransform rectTransform = ((Graphic)obj6).rectTransform;
					((Vector2)(ref val2))..ctor(0.5f, 0.5f);
					rectTransform.pivot = val2;
					val = (rectTransform.anchorMin = (rectTransform.anchorMax = val2));
					rectTransform.anchoredPosition = Vector2.zero;
				}
				((Component)crosses[l]).gameObject.SetActive(false);
			}
			numbers = NewText("Numbers", 20f, (FontStyles)1);
			RectTransform rectTransform2 = ((TMP_Text)numbers).rectTransform;
			((Vector2)(ref val))..ctor(0f, 1f);
			rectTransform2.anchorMax = val;
			rectTransform2.anchorMin = val;
			rectTransform2.pivot = new Vector2(0f, 1f);
			((TMP_Text)numbers).alignment = (TextAlignmentOptions)4097;
			((TMP_Text)numbers).enableWordWrapping = false;
			breakdown = NewText("Breakdown", 15f, (FontStyles)0);
			RectTransform rectTransform3 = ((TMP_Text)breakdown).rectTransform;
			rectTransform3.anchorMin = new Vector2(0f, 1f);
			rectTransform3.anchorMax = new Vector2(1f, 1f);
			rectTransform3.pivot = new Vector2(0.5f, 1f);
			((TMP_Text)breakdown).enableWordWrapping = false;
			AddHudFrame();
			root.SetActive(false);
		}

		private static void AddHudFrame()
		{
			//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_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/HUDSimple.prefab").WaitForCompletion();
				HUD val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponentInChildren<HUD>(true) : null);
				Transform obj = ((Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.itemInventoryDisplay)) ? ((Component)val2.itemInventoryDisplay).transform : null);
				StringBuilder stringBuilder = new StringBuilder("HUD frame candidates (item bar and its parents):");
				Image val3 = null;
				Transform val4 = obj;
				while (Object.op_Implicit((Object)(object)val4) && (Object)(object)val4 != (Object)(object)val.transform)
				{
					Image[] components = ((Component)val4).GetComponents<Image>();
					foreach (Image val5 in components)
					{
						bool flag = Object.op_Implicit((Object)(object)val5.sprite) && val5.sprite.border != Vector4.zero && ((Object)val5.sprite).name != "UISprite";
						stringBuilder.Append("\n  " + ((Object)val4).name + ": sprite " + (Object.op_Implicit((Object)(object)val5.sprite) ? ((Object)val5.sprite).name : "none") + " border " + (Object.op_Implicit((Object)(object)val5.sprite) ? ((object)val5.sprite.border/*cast due to .constrained prefix*/).ToString() : "-") + " " + $"{val5.type}, colour #{ColorUtility.ToHtmlStringRGBA(((Graphic)val5).color)}, ppu x{val5.pixelsPerUnitMultiplier}, " + "material " + ((Object.op_Implicit((Object)(object)((Graphic)val5).material) && (Object)(object)((Graphic)val5).material != (Object)(object)((Graphic)val5).defaultMaterial) ? ((Object)((Graphic)val5).material).name : "default"));
						if (flag && !Object.op_Implicit((Object)(object)val3))
						{
							val3 = val5;
							stringBuilder.Append("  <- used");
						}
					}
					for (int j = 0; j < val4.childCount; j++)
					{
						if (Object.op_Implicit((Object)(object)val3))
						{
							break;
						}
						Image component = ((Component)val4.GetChild(j)).GetComponent<Image>();
						if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.sprite) && !(component.sprite.border == Vector4.zero) && !(((Object)component.sprite).name == "UISprite"))
						{
							stringBuilder.Append($"\n  {((Object)val4).name}/{((Object)component).name}: sprite {((Object)component.sprite).name} border {component.sprite.border} {component.type}, " + "colour #" + ColorUtility.ToHtmlStringRGBA(((Graphic)component).color) + "  <- used");
							val3 = component;
						}
					}
					if (Object.op_Implicit((Object)(object)val3))
					{
						break;
					}
					val4 = val4.parent;
				}
				if (Log.Verbose)
				{
					Log.Info(stringBuilder.ToString());
				}
				if (!Object.op_Implicit((Object)(object)val3))
				{
					Log.Warn("HUD frame not found: the amount window has no frame.");
					return;
				}
				loadoutPanel = NewImage("HudFrame", (Transform)(object)rootRt);
				loadoutPanel.sprite = val3.sprite;
				loadoutPanel.type = (Type)(((int)val3.type == 0) ? 1 : ((int)val3.type));
				loadoutPanel.fillCenter = val3.fillCenter;
				loadoutPanel.pixelsPerUnitMultiplier = val3.pixelsPerUnitMultiplier;
				if (Object.op_Implicit((Object)(object)((Graphic)val3).material) && (Object)(object)((Graphic)val3).material != (Object)(object)((Graphic)val3).defaultMaterial)
				{
					((Graphic)loadoutPanel).material = ((Graphic)val3).material;
				}
				loadoutPanelColor = ((Graphic)val3).color;
				Stretch(((Graphic)loadoutPanel).rectTransform);
				((Component)loadoutPanel).transform.SetSiblingIndex(Object.op_Implicit((Object)(object)panelGroup) ? (((Component)panelGroup).transform.GetSiblingIndex() + 1) : 0);
			}
			catch (Exception ex)
			{
				Log.Warn("HUD frame: " + ex.Message);
			}
		}

		private static void StripToGraphics(GameObject copy)
		{
			TMP_Text[] componentsInChildren = copy.GetComponentsInChildren<TMP_Text>(true);
			foreach (TMP_Text val in componentsInChildren)
			{
				if (Object.op_Implicit((Object)(object)val) && (Object)(object)((Component)val).gameObject != (Object)(object)copy)
				{
					Object.DestroyImmediate((Object)(object)((Component)val).gameObject);
				}
			}
			MonoBehaviour[] componentsInChildren2 = copy.GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val2 in componentsInChildren2)
			{
				if (Object.op_Implicit((Object)(object)val2) && !(val2 is Graphic) && !(val2 is Mask) && !(val2 is RectMask2D))
				{
					Object.DestroyImmediate((Object)(object)val2);
				}
			}
			Graphic[] componentsInChildren3 = copy.GetComponentsInChildren<Graphic>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				componentsInChildren3[i].raycastTarget = false;
			}
		}

		private static void BuildPlainPanel()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			frame = NewImage("Frame", (Transform)(object)rootRt);
			Stretch(((Graphic)frame).rectTransform);
			((Graphic)frame).rectTransform.offsetMin = new Vector2(-1f, -1f);
			((Graphic)frame).rectTransform.offsetMax = new Vector2(1f, 1f);
			background = NewImage("Background", (Transform)(object)rootRt);
			Stretch(((Graphic)background).rectTransform);
		}

		private static GameObject FindDescriptionPanel(GameObject tooltip)
		{
			TooltipController componentInChildren = tooltip.GetComponentInChildren<TooltipController>(true);
			if (!Object.op_Implicit((Object)(object)componentInChildren) || !Object.op_Implicit((Object)(object)componentInChildren.bodyLabel))
			{
				return null;
			}
			Transform parent = ((TMP_Text)componentInChildren.bodyLabel).transform.parent;
			while (Object.op_Implicit((Object)(object)parent) && (Object)(object)parent != (Object)(object)tooltip.transform.parent)
			{
				Image component = ((Component)parent).GetComponent<Image>();
				if (Object.op_Implicit((Object)(object)component) && ((Behaviour)component).enabled)
				{
					if (Log.Verbose)
					{
						Log.Info("Popup panel: copying " + ((Object)parent).name);
					}
					return ((Component)parent).gameObject;
				}
				parent = parent.parent;
			}
			return null;
		}

		private static bool CopyPanel()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			TooltipController componentInParent = tooltipPanel.GetComponentInParent<TooltipController>(true);
			GameObject val2;
			if (Object.op_Implicit((Object)(object)componentInParent) && Object.op_Implicit((Object)(object)componentInParent.titleLabel) && ((TMP_Text)componentInParent.titleLabel).transform.IsChildOf(tooltipPanel.transform))
			{
				Image component = tooltipPanel.GetComponent<Image>();
				Image val = NewImage("GamePanel", (Transform)(object)rootRt);
				val.sprite = component.sprite;
				val.type = component.type;
				val.fillCenter = component.fillCenter;
				val.pixelsPerUnitMultiplier = component.pixelsPerUnitMultiplier;
				((Graphic)val).color = ((Graphic)component).color;
				if (Object.op_Implicit((Object)(object)((Graphic)component).material) && (Object)(object)((Graphic)component).material != (Object)(object)((Graphic)component).defaultMaterial)
				{
					((Graphic)val).material = ((Graphic)component).material;
				}
				val2 = ((Component)val).gameObject;
			}
			else
			{
				val2 = Object.Instantiate<GameObject>(tooltipPanel, (Transform)(object)rootRt, false);
				((Object)val2).name = "GamePanel";
				val2.SetActive(true);
				StripToGraphics(val2);
			}
			RectTransform val3 = (RectTransform)val2.transform;
			((Transform)val3).localScale = Vector3.one;
			((Transform)val3).localRotation = Quaternion.identity;
			val3.pivot = new Vector2(0.5f, 0.5f);
			Stretch(val3);
			val2.transform.SetAsFirstSibling();
			panelGroup = val2.GetComponent<CanvasGroup>() ?? val2.AddComponent<CanvasGroup>();
			panelGroup.blocksRaycasts = false;
			panelGroup.interactable = false;
			return true;
		}

		private static string Dump(Transform t, int depth)
		{
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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)
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append(' ', depth * 2).Append(((Object)t).name).Append(((Component)t).gameObject.activeSelf ? "" : " (off)");
			Component[] components = ((Component)t).GetComponents<Component>();
			foreach (Component val in components)
			{
				if (Object.op_Implicit((Object)(object)val) && !(val is Transform))
				{
					stringBuilder.Append(" [").Append(((object)val).GetType().Name);
					Image val2 = (Image)(object)((val is Image) ? val : null);
					if (val2 != null)
					{
						stringBuilder.Append(' ').Append(Object.op_Implicit((Object)(object)val2.sprite) ? ((Object)val2.sprite).name : "no sprite").Append(' ')
							.Append(val2.type)
							.Append(' ')
							.Append(ColorUtility.ToHtmlStringRGBA(((Graphic)val2).color))
							.Append((Object.op_Implicit((Object)(object)((Graphic)val2).material) && (Object)(object)((Graphic)val2).material != (Object)(object)((Graphic)val2).defaultMaterial) ? (" mat " + ((Object)((Graphic)val2).material).name) : "");
					}
					stringBuilder.Append(']');
				}
			}
			RectTransform val3 = (RectTransform)(object)((t is RectTransform) ? t : null);
			if (val3 != null)
			{
				stringBuilder.Append($" anchors {val3.anchorMin}-{val3.anchorMax} offsets {val3.offsetMin}/{val3.offsetMax}");
			}
			stringBuilder.Append('\n');
			for (int j = 0; j < t.childCount; j++)
			{
				stringBuilder.Append(Dump(t.GetChild(j), depth + 1));
			}
			return stringBuilder.ToString();
		}

		private static RectTransform SegmentRect(string name)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = NewRect(name, (Transform)(object)barRt);
			obj.anchorMin = new Vector2(0f, 0f);
			obj.anchorMax = new Vector2(0f, 1f);
			obj.pivot = new Vector2(0f, 0.5f);
			return obj;
		}

		private static Image Segment(string name)
		{
			Image obj = ((Component)SegmentRect(name)).gameObject.AddComponent<Image>();
			((Graphic)obj).raycastTarget = false;
			return obj;
		}

		private static RectTransform NewRect(string name, Transform parent)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) })
			{
				layer = ((Component)parent).gameObject.layer
			};
			val.transform.SetParent(parent, false);
			return (RectTransform)val.transform;
		}

		private static Image NewImage(string name, Transform parent)
		{
			Image obj = ((Component)NewRect(name, parent)).gameObject.AddComponent<Image>();
			((Graphic)obj).raycastTarget = false;
			return obj;
		}

		private static TextMeshProUGUI NewText(string name, float size, FontStyles style)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI val = ((Component)NewRect(name, (Transform)(object)rootRt)).gameObject.AddComponent<TextMeshProUGUI>();
			if (Object.op_Implicit((Object)(object)font))
			{
				((TMP_Text)val).font = font;
			}
			if (Object.op_Implicit((Object)(object)fontMaterial))
			{
				((TMP_Text)val).fontSharedMaterial = fontMaterial;
			}
			((TMP_Text)val).fontSize = size;
			((TMP_Text)val).fontStyle = style;
			((TMP_Text)val).alignment = (TextAlignmentOptions)514;
			((Graphic)val).raycastTarget = false;
			((TMP_Text)val).richText = true;
			return val;
		}

		private static void Stretch(RectTransform rt)
		{
			//IL_0001: 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_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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = Vector2.zero;
			rt.anchorMax = Vector2.one;
			Vector2 offsetMin = (rt.offsetMax = Vector2.zero);
			rt.offsetMin = offsetMin;
		}
	}
	public static class Api
	{
		public static void ItemGranted(CharacterMaster master, ItemIndex item, bool recycled, bool duplicated)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Recycling.OnGranted(master, item, recycled, duplicated);
		}
	}
	internal static class ChatCommands
	{
		internal static void OnSay(Action<ConCommandArgs> orig, ConCommandArgs args)
		{
			//IL_0001: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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)
			orig(args);
			if (!NetworkServer.active || !Settings.chatCommands.Value || !Object.op_Implicit((Object)(object)args.sender) || args.userArgs.Count < 1)
			{
				return;
			}
			string text = args.userArgs[0]?.Trim();
			if (string.IsNullOrEmpty(text) || text[0] != '/')
			{
				return;
			}
			string[] array = text.Substring(1).Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
			if (array.Length == 0)
			{
				return;
			}
			string text2 = array[0].ToLowerInvariant();
			try
			{
				Net.ChatContext = true;
				switch (text2)
				{
				case "drop":
				case "d":
					Drop(args.sender, array);
					break;
				case "give":
				case "g":
					Give(args.sender, array);
					break;
				}
			}
			catch (Exception message)
			{
				Log.Error(message);
			}
			finally
			{
				Net.ChatContext = false;
			}
		}

		private static void Drop(NetworkUser sender, string[] w)
		{
			//IL_0070: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Invalid comparison between Unknown and I4
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected I4, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected I4, but got Unknown
			if (w.Length < 2)
			{
				Help(sender);
				return;
			}
			int result;
			int requested = ((w.Length < 3 || !int.TryParse(w[2], NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) ? 1 : result);
			CharacterMaster master = sender.master;
			if (!Object.op_Implicit((Object)(object)master) || !Object.op_Implicit((Object)(object)master.inventory))
			{
				return;
			}
			if (IsEquipmentWord(w[1]))
			{
				Exchange.Drop(sender, master, Net.Target.Equipment, (int)master.inventory.currentEquipmentIndex, 1);
				return;
			}
			ItemIndex val = FindItem(master.inventory, w[1]);
			if ((int)val == -1)
			{
				Net.SendReject(sender, Tokens.Reject.NothingThere);
			}
			else
			{
				Exchange.Drop(sender, master, Net.Target.Item, (int)val, requested);
			}
		}

		private static void Give(NetworkUser sender, string[] w)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_009c: Invalid comparison between Unknown and I4
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected I4, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected I4, but got Unknown
			if (w.Length < 3)
			{
				Help(sender);
				return;
			}
			int result;
			int requested = ((w.Length < 4 || !int.TryParse(w[3], NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) ? 1 : result);
			CharacterMaster master = sender.master;
			if (!Object.op_Implicit((Object)(object)master) || !Object.op_Implicit((Object)(object)master.inventory))
			{
				return;
			}
			CharacterMaster val = FindPlayer(w[2]);
			if (!Object.op_Implicit((Object)(object)val))
			{
				Net.SendReject(sender, Tokens.Reject.NoTarget);
				return;
			}
			if (IsEquipmentWord(w[1]))
			{
				Exchange.Give(sender, master, Net.Target.Equipment, (int)master.inventory.currentEquipmentIndex, 1, val);
				return;
			}
			ItemIndex val2 = FindItem(master.inventory, w[1]);
			if ((int)val2 == -1)
			{
				Net.SendReject(sender, Tokens.Reject.NothingThere);
			}
			else
			{
				Exchange.Give(sender, master, Net.Target.Item, (int)val2, requested, val);
			}
		}

		private static void Help(NetworkUser sender)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = "<color=#AAE6F0>/drop {item} [amount]   /give {item} {player} [amount]   (\"equip\" = equipment)</color>"
			});
		}

		private static bool IsEquipmentWord(string s)
		{
			s = s.ToLowerInvariant();
			if (!(s == "e") && !(s == "equip"))
			{
				return s == "equipment";
			}
			return true;
		}

		private static ItemIndex FindItem(Inventory inv, string query)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			string text = Normalize(query);
			if (text.Length != 0)
			{
				List<ItemIndex> itemAcquisitionOrder = inv.itemAcquisitionOrder;
				for (int i = 0; i < 3; i++)
				{
					for (int num = itemAcquisitionOrder.Count - 1; num >= 0; num--)
					{
						ItemDef itemDef = ItemCatalog.GetItemDef(itemAcquisitionOrder[num]);
						if (Object.op_Implicit((Object)(object)itemDef) && inv.GetItemCountEffective(itemDef.itemIndex) > 0)
						{
							string[] array = new string[3]
							{
								Language.GetString(itemDef.nameToken),
								Language.GetString(itemDef.nameToken, "en"),
								((Object)itemDef).name
							};
							for (int j = 0; j < array.Length; j++)
							{
								string text2 = Normalize(array[j]);
								if (i switch
								{
									1 => text2.StartsWith(text), 
									0 => text2 == text, 
									_ => text2.Contains(text), 
								})
								{
									return itemDef.itemIndex;
								}
							}
						}
					}
				}
				return (ItemIndex)(-1);
			}
			return (ItemIndex)(-1);
		}

		private static CharacterMaster FindPlayer(string query)
		{
			string text = Normalize(query);
			if (text.Length == 0)
			{
				return null;
			}
			bool[] array = new bool[2] { true, false };
			foreach (bool flag in array)
			{
				foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
				{
					if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.master))
					{
						string text2 = Normalize(instance.GetDisplayName());
						if (flag ? (text2 == text) : text2.Contains(text))
						{
							return instance.master;
						}
					}
				}
			}
			return null;
		}

		private static string Normalize(string s)
		{
			return Settings.Normalize(s);
		}
	}
	internal static class Exchange
	{
		private struct PendingDroplet
		{
			public CreatePickupInfo info;

			public Vector3 position;

			public Vector3 velocity;

			public CharacterMaster owner;
		}

		private const float MinRequestInterval = 0.08f;

		private const int DropletsPerTick = 3;

		private static Rules rules;

		private static GameObject pickupPrefab;

		private static readonly Dictionary<NetworkUser, float> lastRequest = new Dictionary<NetworkUser, float>();

		private static readonly Queue<PendingDroplet> pending = new Queue<PendingDroplet>();

		private static readonly List<PendingDroplet> carried = new List<PendingDroplet>();

		private static Stage carriedFrom;

		internal static Rules CurrentRules => rules ?? (rules = Rules.FromConfig());

		internal static void Init()
		{
			Settings.RulesChanged += delegate
			{
				rules = null;
			};
		}

		internal static void CreatePickupPrefab()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/NetworkedObjects/GenericPickup");
			if (!Object.op_Implicit((Object)(object)val))
			{
				Log.Error("GenericPickup prefab not found: dropped items will use the vanilla prefab.");
				return;
			}
			GameObject val2 = new GameObject("JustDropItemsPrefabs");
			Object.DontDestroyOnLoad((Object)(object)val2);
			((Object)val2).hideFlags = (HideFlags)61;
			val2.SetActive(false);
			pickupPrefab = Object.Instantiate<GameObject>(val, val2.transform);
			((Object)pickupPrefab).name = "JustDropItemsPickup";
			pickupPrefab.AddComponent<DroppedPickup>();
		}

		internal static void Reset()
		{
			pending.Clear();
			carried.Clear();
			lastRequest.Clear();
			Recycling.Reset();
		}

		private static bool TooFast(NetworkUser sender)
		{
			float unscaledTime = Time.unscaledTime;
			if (lastRequest.TryGetValue(sender, out var value) && unscaledTime - value < 0.08f)
			{
				return true;
			}
			lastRequest[sender] = unscaledTime;
			return false;
		}

		private static bool IsPlayer(CharacterMaster m)
		{
			if (Object.op_Implicit((Object)(object)m) && Object.op_Implicit((Object)(object)m.inventory))
			{
				return Object.op_Implicit((Object)(object)m.playerCharacterMasterController);
			}
			return false;
		}

		private static bool IsAlive(CharacterMaster m)
		{
			CharacterBody val = (Object.op_Implicit((Object)(object)m) ? m.GetBody() : null);
			if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.healthComponent))
			{
				return val.healthComponent.alive;
			}
			return false;
		}

		private static Tokens.Reject CheckOwner(NetworkUser sender, CharacterMaster owner)
		{
			if (!IsPlayer(owner))
			{
				return Tokens.Reject.NothingThere;
			}
			if ((Object)(object)sender.master == (Object)(object)owner)
			{
				return Tokens.Reject.None;
			}
			switch (CurrentRules.takeFrom)
			{
			case TakeFromMode.Everyone:
				return Tokens.Reject.None;
			case TakeFromMode.HostAll:
				if (!((NetworkBehaviour)sender).isLocalPlayer)
				{
					return Tokens.Reject.NotYours;
				}
				return Tokens.Reject.None;
			default:
				return Tokens.Reject.NotYours;
			}
		}

		internal static string NameOf(CharacterMaster m)
		{
			if (!Object.op_Implicit((Object)(object)m) || !Object.op_Implicit((Object)(object)m.playerCharacterMasterController))
			{
				return string.Empty;
			}
			string displayName = m.playerCharacterMasterController.GetDisplayName();
			if (!string.IsNullOrWhiteSpace(displayName))
			{
				return displayName;
			}
			CharacterBody val = (Object.op_Implicit((Object)(object)m.bodyPrefab) ? m.bodyPrefab.GetComponent<CharacterBody>() : null);
			string text = (Object.op_Implicit((Object)(object)val) ? Language.GetString(val.baseNameToken, "en") : null);
			if (!string.IsNullOrWhiteSpace(text) && !(text == val.baseNameToken))
			{
				return text;
			}
			return "Player";
		}

		internal static string NetName(CharacterMaster m)
		{
			if (!Object.op_Implicit((Object)(object)m) || !Object.op_Implicit((Object)(object)m.playerCharacterMasterController))
			{
				return string.Empty;
			}
			string displayName = m.playerCharacterMasterController.GetDisplayName();
			if (!string.IsNullOrWhiteSpace(displayName))
			{
				return displayName;
			}
			CharacterBody val = (Object.op_Implicit((Object)(object)m.bodyPrefab) ? m.bodyPrefab.GetComponent<CharacterBody>() : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return "Player";
			}
			return "\u0001" + val.baseNameToken;
		}

		internal static string NameOf(NetworkUser user)
		{
			if (!Object.op_Implicit((Object)(object)user))
			{
				return string.Empty;
			}
			string text = NameOf(user.master);
			if (text.Length <= 0)
			{
				if (!string.IsNullOrWhiteSpace(user.userName))
				{
					return user.userName;
				}
				return "Player";
			}
			return text;
		}

		private static bool CheckStack(NetworkUser sender, CharacterMaster owner, int index, int requested, bool drop, KindOrder order, out ItemIndex item, out StackModel model, out int amount)
		{
			item = (ItemIndex)index;
			model = default(StackModel);
			amount = 0;
			if (!ItemCatalog.IsIndexValid(ref item))
			{
				Net.SendReject(sender, Tokens.Reject.NothingThere);
				return false;
			}
			Tokens.Reject reject = CurrentRules.CheckItem(item, drop);
			if (reject != Tokens.Reject.None)
			{
				Net.SendReject(sender, reject, Net.Target.Item, index);
				return false;
			}
			model = StackModel.Of(owner.inventory, item, CurrentRules, order);
			if (model.Total == 0)
			{
				Net.SendReject(sender, Tokens.Reject.NothingThere, Net.Target.Item, index);
				return false;
			}
			int movable = model.Movable;
			if (movable == 0)
			{
				bool flag = model.shared > 0 && model.permanent + model.ethereal + model.temporary == 0;
				Net.SendReject(sender, flag ? Tokens.Reject.SharedOnly : Tokens.Reject.NoCopies, Net.Target.Item, index);
				return false;
			}
			amount = Amount.ClampRequest(requested, movable, CurrentRules.maxPerAction);
			return true;
		}

		private static void TakeCopies(Inventory inv, ItemIndex item, int p, int e, int t, List<float> tempValues)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (p > 0)
			{
				inv.RemoveItemPermanent(item, p);
			}
			if (e > 0)
			{
				inv.RemoveItemRented(item, e);
			}
			if (t <= 0)
			{
				return;
			}
			float tempItemRawValue = inv.GetTempItemRawValue(item);
			float num = 0f;
			for (int i = 0; i < t; i++)
			{
				float num2 = Mathf.Min(1f, tempItemRawValue - num);
				if (num2 <= 0f)
				{
					break;
				}
				tempValues.Add(num2);
				num += num2;
			}
			if (num > 0f)
			{
				inv.RemoveItemTemp(item, num);
			}
		}

		internal static void Drop(NetworkUser sender, CharacterMaster owner, Net.Target target, int index, int requested, KindOrder order = KindOrder.PermanentEtherealTemporary)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			bool flag = target == Net.Target.AltEquipment;
			if (flag)
			{
				target = Net.Target.Equipment;
			}
			if (TooFast(sender))
			{
				Net.SendReject(sender, Tokens.Reject.TooFast);
				return;
			}
			if (!CurrentRules.allowDrop)
			{
				Net.SendReject(sender, Tokens.Reject.DropDisabled);
				return;
			}
			Tokens.Reject reject = CheckOwner(sender, owner);
			if (reject != Tokens.Reject.None)
			{
				Net.SendReject(sender, reject);
				return;
			}
			CharacterBody val = (IsAlive(owner) ? owner.GetBody() : ((Object.op_Implicit((Object)(object)sender.master) && IsAlive(sender.master)) ? sender.master.GetBody() : null));
			if (!Object.op_Implicit((Object)(object)val))
			{
				Net.SendReject(sender, Tokens.Reject.NeedsBody);
				return;
			}
			Vector3 corePosition = val.corePosition;
			Vector3 aim = (Object.op_Implicit((Object)(object)val.inputBank) ? val.inputBank.aimDirection : ((Component)val).transform.forward);
			aim.y = 0f;
			if (((Vector3)(ref aim)).sqrMagnitude < 0.01f)
			{
				aim = ((Component)val).transform.forward;
			}
			((Vector3)(ref aim)).Normalize();
			ItemIndex item;
			StackModel model;
			int amount;
			if (target == Net.Target.Equipment)
			{
				DropEquipment(sender, owner, index, corePosition, aim, flag);
			}
			else if (CheckStack(sender, owner, index, requested, drop: true, order, out item, out model, out amount))
			{
				model.Split(amount, out var p, out var e, out var t);
				int num = Recycling.TakeItemMarks(owner, item, model.Total, amount);
				int num2 = Recycling.TakePrinted(owner, item, model.Total, amount);
				List<float> list = new List<float>(t);
				TakeCopies(owner.inventory, item, p, e, t, list);
				t = list.Count;
				int num3 = QueueCopies(owner, item, p, e, list, num, num2, corePosition, aim);
				if (Log.Verbose)
				{
					Log.Info($"{NameOf(sender)} dropped {num3} {((Object)ItemCatalog.GetItemDef(item)).name} from {NameOf(owner)} " + $"(permanent {p}, ethereal {e}, temporary {t}, recycler marks {num}, printed {num2})");
				}
				if (Settings.announceDrops.Value)
				{
					Net.BroadcastNotice(Net.NoticeType.Dropped, NetName(sender.master), NetName(owner), string.Empty, Net.Target.Item, index, p, e, t);
				}
			}
		}

		private static int QueueCopies(CharacterMaster owner, ItemIndex item, int p, int e, List<float> temps, int marks, int printedMarks, Vector3 origin, Vector3 aim)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			PickupIndex val = PickupCatalog.FindPickupIndex(item);
			int num = p + e + temps.Count;
			UniquePickup val2 = default(UniquePickup);
			for (int i = 0; i < num; i++)
			{
				((UniquePickup)(ref val2))..ctor(val);
				val2.ignoreArtifactBasedPickupReplacements = true;
				UniquePickup pickup = val2;
				if (i >= p && i < p + e)
				{
					pickup.isRental = true;
				}
				else if (i >= p + e)
				{
					pickup.decayValue = temps[i - p - e];
				}
				Queue(owner, pickup, Recycling.FlagFor(i < marks), i < printedMarks, origin, Fan(aim, i, num));
			}
			return num;
		}

		private static void DropEquipment(NetworkUser sender, CharacterMaster owner, int index, Vector3 origin, Vector3 aim, bool alternate)
		{
			//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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			EquipmentIndex val = (EquipmentIndex)index;
			Tokens.Reject reject = CurrentRules.CheckEquipment(val);
			if (reject != Tokens.Reject.None)
			{
				Net.SendReject(sender, reject, Net.Target.Equipment, index);
				return;
			}
			if (!TakeEquipment(owner.inventory, val, alternate))
			{
				Net.SendReject(sender, Tokens.Reject.NothingThere, Net.Target.Equipment, index);
				return;
			}
			bool marked = Recycling.TakeEquipmentMark(owner, val);
			UniquePickup val2 = default(UniquePickup);
			((UniquePickup)(ref val2))..ctor(PickupCatalog.FindPickupIndex(val));
			val2.ignoreArtifactBasedPickupReplacements = true;
			UniquePickup pickup = val2;
			Queue(owner, pickup, Recycling.FlagFor(marked), printed: false, origin, Fan(aim, 0, 1));
			if (Log.Verbose)
			{
				Log.Info(NameOf(sender) + " dropped equipment " + ((Object)EquipmentCatalog.GetEquipmentDef(val)).name + " from " + NameOf(owner));
			}
			if (Settings.announceDrops.Value)
			{
				Net.BroadcastNotice(Net.NoticeType.Dropped, NetName(sender.master), NetName(owner), string.Empty, Net.Target.Equipment, index, 1, 0, 0);
			}
		}

		private static bool TakeEquipment(Inventory inv, EquipmentIndex equipment, bool alternate)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			if ((int)equipment == -1)
			{
				return false;
			}
			if (alternate)
			{
				EquipmentLocation val = ((inv.accessibleEquipmentSetCount > 1) ? inv.nextSetEquipmentLocation : inv.nextSlotEquipmentLocation);
				if (inv.IsEquipmentLocationInBounds(ref val) && inv.GetEquipmentIndex(ref val) == equipment)
				{
					inv.SetEquipmentIndex((EquipmentIndex)(-1), ref val);
					return true;
				}
			}
			if (inv.currentEquipmentIndex == equipment)
			{
				inv.SetEquipmentIndex((EquipmentIndex)(-1), true);
				return true;
			}
			for (uint num = 0u; num < inv.equipmentSlotCount; num++)
			{
				for (uint num2 = 0u; num2 < inv.equipmentSetCount; num2++)
				{
					EquipmentLocation val2 = new EquipmentLocation
					{
						slot = num,
						set = num2
					};
					if (inv.GetEquipmentIndex(ref val2) == equipment)
					{
						inv.SetEquipmentIndex((EquipmentIndex)(-1), ref val2);
						return true;
					}
				}
			}
			return false;
		}

		private static Vector3 Fan(Vector3 aim, int i, int n)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0057: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			float num = ((n <= 1) ? 0f : Mathf.Min(90f, 12f * (float)(n - 1)));
			return Quaternion.AngleAxis((n <= 1) ? 0f : ((0f - num) / 2f + num * (float)i / (float)(n - 1)), Vector3.up) * aim * 8f + Vector3.up * 15f;
		}

		private static void Queue(CharacterMaster owner, UniquePickup pickup, bool recycled, bool printed, Vector3 position, Vector3 velocity)
		{
			//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_000c: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			CreatePickupInfo val = new CreatePickupInfo
			{
				position = position,
				rotation = Quaternion.identity
			};
			((CreatePickupInfo)(ref val)).pickup = pickup;
			val.prefabOverride = pickupPrefab;
			val.recycled = recycled;
			val.duplicated = printed;
			CreatePickupInfo info = val;
			pending.Enqueue(new PendingDroplet
			{
				info = info,
				position = position,
				velocity = velocity,
				owner = owner
			});
		}

		internal static void Tick()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_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_00f0: 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_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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 3; i++)
			{
				if (pending.Count <= 0)
				{
					break;
				}
				PendingDroplet pendingDroplet = pending.Dequeue();
				try
				{
					PickupDropletController.CreatePickupDroplet(pendingDroplet.info, pendingDroplet.position, pendingDroplet.velocity);
				}
				catch (Exception message)
				{
					Log.Error(message);
				}
			}
			if (carried.Count == 0 || !Object.op_Implicit((Object)(object)Stage.instance) || (Object)(object)Stage.instance == (Object)(object)carriedFrom)
			{
				return;
			}
			for (int num = carried.Count - 1; num >= 0; num--)
			{
				PendingDroplet item = carried[num];
				if (!Object.op_Implicit((Object)(object)item.owner))
				{
					carried.RemoveAt(num);
				}
				else if (IsAlive(item.owner))
				{
					CharacterBody body = item.owner.GetBody();
					if (!Object.op_Implicit((Object)(object)body.currentVehicle))
					{
						carried.RemoveAt(num);
						item.position = (item.info.position = ItemFlight.DropPoint(body, body.footPosition));
						item.velocity = Vector3.up * 5f;
						pending.Enqueue(item);
					}
				}
			}
		}

		internal static void Give(NetworkUser sender, CharacterMaster owner, Net.Target target, int index, int requested, CharacterMaster recipient, KindOrder order = KindOrder.PermanentEtherealTemporary)
		{
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: 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_0276: 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_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			bool flag = target == Net.Target.AltEquipment;
			if (flag)
			{
				target = Net.Target.Equipment;
			}
			if (TooFast(sender))
			{
				Net.SendReject(sender, Tokens.Reject.TooFast);
				return;
			}
			if (!CurrentRules.allowGive)
			{
				Net.SendReject(sender, Tokens.Reject.GiveDisabled);
				return;
			}
			Tokens.Reject reject = CheckOwner(sender, owner);
			if (reject != Tokens.Reject.None)
			{
				Net.SendReject(sender, reject);
				return;
			}
			if (!IsPlayer(recipient) || !recipient.playerCharacterMasterController.isConnected)
			{
				Net.SendReject(sender, Tokens.Reject.NoTarget);
				return;
			}
			if ((Object)(object)recipient == (Object)(object)owner)
			{
				Net.SendReject(sender, Tokens.Reject.TargetSelf);
				return;
			}
			if (!IsAlive(recipient) && !CurrentRules.allowGiveToDead)
			{
				Net.SendReject(sender, Tokens.Reject.TargetDead);
				return;
			}
			bool flag2 = IsAlive(owner);
			if (!flag2 && !CurrentRules.allowGiveWhileDead)
			{
				Net.SendReject(sender, Tokens.Reject.DeadGiver);
				return;
			}
			Vector3 val = (flag2 ? owner.GetBody().corePosition : owner.deathFootPosition);
			if (target == Net.Target.Equipment)
			{
				GiveEquipment(sender, owner, index, recipient, val, flag);
			}
			else
			{
				if (!CheckStack(sender, owner, index, requested, drop: false, order, out var item, out var model, out var amount))
				{
					return;
				}
				model.Split(amount, out var p, out var e, out var t);
				int marks = Recycling.TakeItemMarks(owner, item, model.Total, amount);
				int printedMarks = Recycling.TakePrinted(owner, item, model.Total, amount);
				List<float> temps = new List<float>(t);
				TakeCopies(owner.inventory, item, p, e, t, temps);
				t = temps.Count;
				float tempSum = 0f;
				foreach (float item2 in temps)
				{
					tempSum += item2;
				}
				Vector3 seen = LastSeen(recipient, val);
				Launch(val, recipient, PickupCatalog.FindPickupIndex(item), item, delegate
				{
					//IL_005b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0093: Unknown result type (might be due to invalid IL or missing references)
					//IL_00aa: 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_003e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0043: Unknown result type (might be due to invalid IL or missing references)
					//IL_0048: Unknown result type (might be due to invalid IL or missing references)
					if (Left(recipient))
					{
						QueueCopies(owner, item, p, e, temps, marks, printedMarks, LastSeen(recipient, seen), Vector3.forward);
					}
					else
					{
						Grant(recipient, item, p, e, tempSum, temps.Count, Settings.notify.Value);
						Recycling.AddItemMarks(recipient, item, marks);
						Recycling.AddPrinted(recipient, item, printedMarks);
					}
				});
				if (Log.Verbose)
				{
					Log.Info($"{NameOf(sender)} gave {p + e + t} {((Object)ItemCatalog.GetItemDef(item)).name} from {NameOf(owner)} to {NameOf(recipient)} " + $"(permanent {p}, ethereal {e}, temporary {t}, recycler marks {marks}, printed {printedMarks})");
				}
				if (Settings.announceGives.Value)
				{
					Net.BroadcastNotice(Net.NoticeType.Gave, NetName(sender.master), NetName(owner), NetName(recipient), Net.Target.Item, index, p, e, t);
				}
			}
		}

		private static bool Left(CharacterMaster m)
		{
			if (Object.op_Implicit((Object)(object)m) && Object.op_Implicit((Object)(object)m.inventory) && Object.op_Implicit((Object)(object)m.playerCharacterMasterController))
			{
				return !m.playerCharacterMasterController.isConnected;
			}
			return true;
		}

		private static Vector3 LastSeen(CharacterMaster m, Vector3 fallback)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return ItemFlight.DropPoint(Object.op_Implicit((Object)(object)m) ? m.GetBody() : null, fallback);
		}

		private static void Grant(CharacterMaster to, ItemIndex item, int p, int e, float temp, int tempCopies, bool notify)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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)
			//IL_003a: Expected O, but got Unknown
			//IL_006c: 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)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			ItemTransferOrb.DefaultOnArrivalBehavior(new ItemTransferOrb
			{
				inventoryToGrantTo = to.inventory,
				itemIndex = item,
				stack = p,
				rentalStack = e,
				tempStack = temp,
				isPickup = false
			});
			if (notify)
			{
				bool flag = tempCopies > p && tempCopies > e;
				CharacterBody body = to.GetBody();
				if (Object.op_Implicit((Object)(object)body))
				{
					body.OnPickup((PickupClass)(flag ? 2 : 3));
				}
				UniquePickup val = default(UniquePickup);
				((UniquePickup)(ref val))..ctor(PickupCatalog.FindPickupIndex(item));
				val.decayValue = (flag ? 1f : 0f);
				val.isRental = e > p && e > tempCopies;
				GenericPickupController.SendPickupMessage(to, val, p + e + tempCopies);
			}
		}

		private static void GiveEquipment(NetworkUser sender, CharacterMaster owner, int index, CharacterMaster recipient, Vector3 origin, bool alternate)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Invalid comparison between Unknown and I4
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			EquipmentIndex equipment = (EquipmentIndex)index;
			Tokens.Reject reject = CurrentRules.CheckEquipment(equipment);
			if (reject != Tokens.Reject.None)
			{
				Net.SendReject(sender, reject, Net.Target.Equipment, index);
				return;
			}
			if ((int)recipient.inventory.currentEquipmentIndex != -1)
			{
				Net.SendReject(sender, Tokens.Reject.TargetEquipmentFull, Net.Target.Equipment, index, NetName(recipient));
				return;
			}
			if (!TakeEquipment(owner.inventory, equipment, alternate))
			{
				Net.SendReject(sender, Tokens.Reject.NothingThere, Net.Target.Equipment, index);
				return;
			}
			bool marked = Recycling.TakeEquipmentMark(owner, equipment);
			PickupIndex pickupIndex = PickupCatalog.FindPickupIndex(equipment);
			Vector3 seen = LastSeen(recipient, origin);
			Launch(origin, recipient, pickupIndex, (ItemIndex)(-1), delegate
			{
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Invalid comparison between Unknown and I4
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: 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)
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				UniquePickup pickup = default(UniquePickup);
				if (Left(recipient))
				{
					CharacterMaster owner2 = owner;
					((UniquePickup)(ref pickup))..ctor(pickupIndex);
					pickup.ignoreArtifactBasedPickupReplacements = true;
					Queue(owner2, pickup, Recycling.FlagFor(marked), printed: false, LastSeen(recipient, seen), Vector3.up * 5f);
				}
				else
				{
					CharacterMaster val = recipient;
					if ((int)val.inventory.currentEquipmentIndex == -1)
					{
						val.inventory.SetEquipmentIndex(equipment, false);
						if (marked)
						{
							Recycling.MarkEq