Decompiled source of ResourceStashWithdrawal v1.3.0

VMods.ResourceStashWithdrawal.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils;
using Bloodstone.API;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.CastleBuilding;
using ProjectM.Network;
using ProjectM.Scripting;
using ProjectM.Shared;
using ProjectM.UI;
using StunShared.UI;
using Stunlock.Core;
using Stunlock.Localization;
using TMPro;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Entities;
using UnityEngine;
using UnityEngine.EventSystems;
using VMods.Shared;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("VMods.ResourceStashWithdrawal")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Allows a player to withdraw required resources from their stash when clicking a recipe at a work or refinement station")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0+15ef3da5b4c8389e967e8ee73634b79c7fd66d91")]
[assembly: AssemblyProduct("VMods.ResourceStashWithdrawal")]
[assembly: AssemblyTitle("VMods.ResourceStashWithdrawal")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsUnmanagedAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace VMods.Shared
{
	public static class Utils
	{
		private struct FakeNull
		{
			public int value;

			public bool has_value;
		}

		private static ComponentType[] _containerComponents;

		public static World CurrentWorld => VWorld.Game;

		public static ManualLogSource Logger { get; private set; }

		public static string PluginName { get; private set; }

		private static ComponentType[] ContainerComponents
		{
			get
			{
				//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_0025: 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_0036: 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_0047: 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 (_containerComponents == null)
				{
					_containerComponents = (ComponentType[])(object)new ComponentType[4]
					{
						ComponentType.ReadOnly(Il2CppType.Of<Team>()),
						ComponentType.ReadOnly(Il2CppType.Of<CastleHeartConnection>()),
						ComponentType.ReadOnly(Il2CppType.Of<InventoryBuffer>()),
						ComponentType.ReadOnly(Il2CppType.Of<NameableInteractable>())
					};
				}
				return _containerComponents;
			}
		}

		public static void Initialize(ManualLogSource logger, string pluginName)
		{
			Logger = logger;
			PluginName = pluginName;
		}

		public static void Deinitialize()
		{
			Logger = null;
		}

		public static NativeArray<Entity> GetStashEntities(EntityManager entityManager)
		{
			//IL_0007: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery(ContainerComponents);
			return ((EntityQuery)(ref val)).ToEntityArray((Allocator)2);
		}

		public static IEnumerable<Entity> GetAlliedStashes(EntityManager entityManager, Entity character)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			ComponentDataFromEntity<Team> getTeam = ((EntityManager)(ref entityManager)).GetComponentDataFromEntity<Team>(false);
			Enumerator<Entity> enumerator = GetStashEntities(entityManager).GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				if (((EntityManager)(ref entityManager)).HasComponent<Team>(current) && ((EntityManager)(ref entityManager)).HasComponent<Team>(character))
				{
					Team val = getTeam[current];
					Team val2 = getTeam[character];
					if (Team.IsAllies(val, val2))
					{
						yield return current;
					}
				}
			}
		}

		public static int GetStashItemCount(EntityManager entityManager, Entity character, PrefabGUID itemGUID, StoredBlood? storedBlood = null)
		{
			//IL_0004: 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_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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0072: 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_0082: 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)
			int num = 0;
			int num2 = 0;
			DynamicBuffer<InventoryBuffer> val = default(DynamicBuffer<InventoryBuffer>);
			StoredBlood val3 = default(StoredBlood);
			foreach (Entity alliedStash in GetAlliedStashes(entityManager, character))
			{
				((EntityManager)(ref entityManager)).TryGetBuffer<InventoryBuffer>(alliedStash, ref val);
				for (int i = 0; i < val.Length; i++)
				{
					InventoryBuffer val2 = val[i];
					if (!(val2.ItemType == itemGUID))
					{
						continue;
					}
					if (storedBlood.HasValue)
					{
						((EntityManager)(ref entityManager)).TryGetComponentData<StoredBlood>(val2.ItemEntity._Entity, ref val3);
						if (storedBlood.Value.BloodType != val3.BloodType || storedBlood.Value.BloodQuality != val3.BloodQuality)
						{
							continue;
						}
					}
					num += val2.Amount;
				}
				num2++;
			}
			if (num2 != 0)
			{
				return num;
			}
			return -1;
		}

		public static string GetItemName(PrefabGUID itemGUID, GameDataSystem gameDataSystem = null, EntityManager? entityManager = null, PrefabLookupMap? prefabLookupMap = null)
		{
			//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_0015: 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_00b4: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//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_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)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			if (itemGUID == PrefabGUID.Empty)
			{
				return string.Empty;
			}
			EntityManager valueOrDefault = entityManager.GetValueOrDefault();
			if (!entityManager.HasValue)
			{
				valueOrDefault = CurrentWorld.EntityManager;
				entityManager = valueOrDefault;
			}
			if (gameDataSystem == null)
			{
				gameDataSystem = CurrentWorld.GetExistingSystem<GameDataSystem>();
			}
			PrefabLookupMap valueOrDefault2 = prefabLookupMap.GetValueOrDefault();
			if (!prefabLookupMap.HasValue)
			{
				valueOrDefault2 = ((PrefabCollectionSystem_Base)CurrentWorld.GetExistingSystem<PrefabCollectionSystem>()).PrefabLookupMap;
				prefabLookupMap = valueOrDefault2;
			}
			try
			{
				AssetGuid val = GameplayHelper.TryGetItemName(gameDataSystem, entityManager.Value, prefabLookupMap.Value, itemGUID);
				if (Localization.HasKey(val))
				{
					return Localization.Get(val, true);
				}
			}
			catch (Exception)
			{
			}
			return $"[{itemGUID}]";
		}

		public static void SendMessage(Entity userEntity, string message, ServerChatMessageType messageType)
		{
			//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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_004a: 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_0056: 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_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_006c: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00ac: 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_00e7: 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)
			if (VWorld.IsServer)
			{
				EntityManager entityManager = VWorld.Server.EntityManager;
				User val = default(User);
				((EntityManager)(ref entityManager)).TryGetComponentData<User>(userEntity, ref val);
				int index = val.Index;
				NetworkId fromUser = default(NetworkId);
				((EntityManager)(ref entityManager)).TryGetComponentData<NetworkId>(userEntity, ref fromUser);
				Entity val2 = ((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[3]
				{
					ComponentType.ReadOnly<NetworkEventType>(),
					ComponentType.ReadOnly<SendEventToUser>(),
					ComponentType.ReadOnly<ChatMessageServerEvent>()
				});
				ChatMessageServerEvent val3 = default(ChatMessageServerEvent);
				val3.MessageText = FixedString512.op_Implicit(message);
				val3.MessageType = messageType;
				val3.FromUser = fromUser;
				val3.TimeUTC = DateTime.Now.ToFileTimeUtc();
				ChatMessageServerEvent val4 = val3;
				val2.WithComponentDataVmodAOT<SendEventToUser>((VModsVExtensionsOverride.ActionRefVmod<SendEventToUser>)delegate(ref SendEventToUser us)
				{
					us.UserIndex = index;
				});
				val2.WithComponentDataVmodAOT<NetworkEventType>((VModsVExtensionsOverride.ActionRefVmod<NetworkEventType>)delegate(ref NetworkEventType ev)
				{
					ev.EventId = NetworkEvents.EventId_ChatMessageServerEvent;
					ev.IsAdminEvent = false;
					ev.IsDebugEvent = false;
				});
				((EntityManager)(ref entityManager)).SetComponentData<ChatMessageServerEvent>(val2, val4);
			}
		}

		public static bool TryGetPrefabGUIDForItemName(GameDataSystem gameDataSystem, LocalizationKey itemName, out PrefabGUID prefabGUID)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return TryGetPrefabGUIDForItemName(gameDataSystem, Localization.Get(itemName, true), out prefabGUID);
		}

		public static bool TryGetPrefabGUIDForItemName(GameDataSystem gameDataSystem, string itemName, out PrefabGUID prefabGUID)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Enumerator<PrefabGUID, ItemData> enumerator = gameDataSystem.ItemHashLookupMap.GetEnumerator();
			while (enumerator.MoveNext())
			{
				KeyValue<PrefabGUID, ItemData> current = enumerator.Current;
				if (Localization.Get(gameDataSystem.ManagedDataRegistry.GetOrDefault<ManagedItemData>(current.Key, (ManagedItemData)null).Name, false) == itemName)
				{
					prefabGUID = current.Key;
					return true;
				}
			}
			prefabGUID = PrefabGUID.Empty;
			return false;
		}

		public static bool TryGiveItem(EntityManager entityManager, NativeHashMap<PrefabGUID, ItemData>? itemDataMap, Entity recipient, PrefabGUID itemType, int amount, out int remainingitems, bool dropRemainder = false)
		{
			//IL_0002: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_005a: 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_0062: 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_0020: 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)
			NativeHashMap<PrefabGUID, ItemData> valueOrDefault = itemDataMap.GetValueOrDefault();
			if (!itemDataMap.HasValue)
			{
				valueOrDefault = CurrentWorld.GetExistingSystem<GameDataSystem>().ItemHashLookupMap;
				itemDataMap = valueOrDefault;
			}
			AddItemResponse val = InventoryUtilitiesServer.TryAddItem(AddItemSettings.Create(entityManager, itemDataMap.Value, false, default(Entity), default(Nullable_Unboxed<int>), false, false, dropRemainder, default(Nullable_Unboxed<int>)), recipient, itemType, amount);
			remainingitems = val.RemainingAmount;
			return ((AddItemResponse)(ref val)).Success;
		}

		public static void ApplyBuff(Entity user, Entity character, PrefabGUID buffGUID)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0019: Unknown result type (might be due to invalid IL or missing references)
			FromCharacter fromCharacter = default(FromCharacter);
			fromCharacter.User = user;
			fromCharacter.Character = character;
			ApplyBuff(fromCharacter, buffGUID);
		}

		public static void ApplyBuff(FromCharacter fromCharacter, PrefabGUID buffGUID)
		{
			//IL_000c: 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_0015: 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_001b: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			DebugEventsSystem existingSystem = VWorld.Server.GetExistingSystem<DebugEventsSystem>();
			ApplyBuffDebugEvent val = new ApplyBuffDebugEvent
			{
				BuffPrefabGUID = buffGUID
			};
			existingSystem.ApplyBuff(fromCharacter, val);
		}

		public static void RemoveBuff(FromCharacter fromCharacter, PrefabGUID buffGUID)
		{
			//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)
			RemoveBuff(fromCharacter.Character, buffGUID);
		}

		public static void RemoveBuff(Entity charEntity, PrefabGUID buffGUID, EntityManager? entityManager = null)
		{
			//IL_0002: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_001e: 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_003b: 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_0047: 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)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			EntityManager value = entityManager.GetValueOrDefault();
			if (!entityManager.HasValue)
			{
				value = CurrentWorld.EntityManager;
				entityManager = value;
			}
			if (BuffUtility.HasBuff(entityManager.Value, charEntity, buffGUID))
			{
				Entity val = default(Entity);
				BuffUtility.TryGetBuff(entityManager.Value, charEntity, buffGUID, ref val);
				value = entityManager.Value;
				((EntityManager)(ref value)).AddComponent<DestroyTag>(val);
			}
		}

		public static string GetCharacterName(ulong platformId, EntityManager? entityManager = null)
		{
			//IL_0002: 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_002b: 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_003b: 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)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0056: 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_001b: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_006c: 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)
			EntityManager value = entityManager.GetValueOrDefault();
			if (!entityManager.HasValue)
			{
				value = CurrentWorld.EntityManager;
				entityManager = value;
			}
			value = entityManager.Value;
			EntityQuery val = ((EntityManager)(ref value)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
			Enumerator<Entity> enumerator = ((EntityQuery)(ref val)).ToEntityArray((Allocator)2).GetEnumerator();
			User val2 = default(User);
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				value = entityManager.Value;
				((EntityManager)(ref value)).TryGetComponentData<User>(current, ref val2);
				if (val2.PlatformId == platformId)
				{
					return ((object)(FixedString64)(ref val2.CharacterName)).ToString();
				}
			}
			return null;
		}

		public static AdminLevel GetAdminLevel(Entity userEntity, EntityManager? entityManager = null)
		{
			//IL_0002: 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_002b: 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_0016: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			EntityManager value = entityManager.GetValueOrDefault();
			if (!entityManager.HasValue)
			{
				value = CurrentWorld.EntityManager;
				entityManager = value;
			}
			value = entityManager.Value;
			AdminUser val = default(AdminUser);
			if (((EntityManager)(ref value)).TryGetComponentData<AdminUser>(userEntity, ref val))
			{
				return val.Level;
			}
			return (AdminLevel)0;
		}

		public static void LogAllComponentTypes(Entity entity, EntityManager? entityManager = null)
		{
			//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_0010: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0024: 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_002c: 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_005c: 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_0066: 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_006e: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			if (entity == Entity.Null)
			{
				return;
			}
			EntityManager value = entityManager.GetValueOrDefault();
			if (!entityManager.HasValue)
			{
				value = CurrentWorld.EntityManager;
				entityManager = value;
			}
			ManualLogSource logger = Logger;
			bool flag = default(bool);
			BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(3, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("---");
			}
			logger.LogMessage(val);
			value = entityManager.Value;
			Enumerator<ComponentType> enumerator = ((EntityManager)(ref value)).GetComponentTypes(entity, (Allocator)2).GetEnumerator();
			while (enumerator.MoveNext())
			{
				ComponentType current = enumerator.Current;
				ManualLogSource logger2 = Logger;
				val = new BepInExMessageLogInterpolatedStringHandler(30, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Component Type: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ComponentType>(current);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (Shared? ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(((ComponentType)(ref current)).IsSharedComponent);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") | ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((ComponentType)(ref current)).GetManagedType().FullName);
				}
				logger2.LogMessage(val);
			}
			ManualLogSource logger3 = Logger;
			val = new BepInExMessageLogInterpolatedStringHandler(3, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("---");
			}
			logger3.LogMessage(val);
		}

		public static void LogAllComponentTypes(EntityQuery entityQuery)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0049: Expected O, but got Unknown
			//IL_0058: 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: Expected O, but got Unknown
			Il2CppStructArray<ComponentType> queryTypes = ((EntityQuery)(ref entityQuery)).GetQueryTypes();
			ManualLogSource logger = Logger;
			bool flag = default(bool);
			BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(3, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("---");
			}
			logger.LogMessage(val);
			foreach (ComponentType item in (Il2CppArrayBase<ComponentType>)(object)queryTypes)
			{
				ManualLogSource logger2 = Logger;
				val = new BepInExMessageLogInterpolatedStringHandler(22, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Query Component Type: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ComponentType>(item);
				}
				logger2.LogMessage(val);
			}
			ManualLogSource logger3 = Logger;
			val = new BepInExMessageLogInterpolatedStringHandler(3, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("---");
			}
			logger3.LogMessage(val);
		}
	}
	public static class VModsVExtensionsOverride
	{
		public delegate void ActionRefVmod<T>(ref T item);

		public static void WithComponentDataVmod<T>(this Entity entity, ActionRefVmod<T> action) where T : struct
		{
			//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_000d: 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_0028: 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)
			EntityManager entityManager = VWorld.Game.EntityManager;
			T item = default(T);
			((EntityManager)(ref entityManager)).TryGetComponentData<T>(entity, ref item);
			action(ref item);
			entityManager = VWorld.Game.EntityManager;
			((EntityManager)(ref entityManager)).SetComponentData<T>(entity, item);
		}

		public static void WithComponentDataVmodAOT<T>(this Entity entity, ActionRefVmod<T> action) where T : unmanaged
		{
			//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_001e: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			T item = VWorld.Game.EntityManager.GetComponentDataAOT<T>(entity);
			action(ref item);
			EntityManager entityManager = VWorld.Game.EntityManager;
			((EntityManager)(ref entityManager)).SetComponentData<T>(entity, item);
		}

		private static Type GetType<T>()
		{
			return Il2CppType.Of<T>();
		}

		public unsafe static T GetComponentDataAOT<T>(this EntityManager entityManager, Entity entity) where T : unmanaged
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			int typeIndex = TypeManager.GetTypeIndex(GetType<T>());
			T* componentDataRawRW = (T*)((EntityManager)(ref entityManager)).GetComponentDataRawRW(entity, typeIndex);
			return *componentDataRawRW;
		}
	}
}
namespace VMods.ResourceStashWithdrawal
{
	public static class ResourceStashWithdrawalConfig
	{
		public static ConfigEntry<bool> ResourceStashWithdrawalEnabled { get; private set; }

		public static void Initialize(ConfigFile config)
		{
			ResourceStashWithdrawalEnabled = config.Bind<bool>("Server", "ResourceStashWithdrawalEnabled", true, "Enabled/disable the resource stash withdrawal system.");
		}
	}
	[HarmonyPatch]
	public class UIClickHook
	{
		private static DateTime _lastResourceRequest = DateTime.UtcNow;

		public static void Reset()
		{
			//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)
			_lastResourceRequest = DateTime.UtcNow;
		}

		[HarmonyPatch(typeof(GridSelectionEntry), "OnPointerClick")]
		[HarmonyPostfix]
		public static void OnPointerClick(GridSelectionEntry __instance, PointerEventData eventData)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			//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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_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_00d8: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: 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_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0600: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			//IL_061b: Unknown result type (might be due to invalid IL or missing references)
			//IL_048e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0621: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_0635: Unknown result type (might be due to invalid IL or missing references)
			//IL_063a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_064b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_054f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			UITooltipHook.OnPointerEnter(__instance, eventData);
			if (!VWorld.IsClient || (int)eventData.button != 2)
			{
				return;
			}
			DateTime utcNow = DateTime.UtcNow;
			TimeSpan val = ((DateTime)(ref utcNow)).Subtract(_lastResourceRequest);
			if (((TimeSpan)(ref val)).TotalSeconds <= 0.20000000298023224)
			{
				return;
			}
			_lastResourceRequest = DateTime.UtcNow;
			bool withdrawFullAmount = Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305);
			World client = VWorld.Client;
			EntityManager entityManager = client.EntityManager;
			GameDataSystem gameDataSystem = client.GetExistingSystem<GameDataSystem>();
			_ = gameDataSystem.ItemHashLookupMap;
			PrefabCollectionSystem existingSystem = client.GetExistingSystem<PrefabCollectionSystem>();
			PrefabLookupMap prefabLookupMap = ((PrefabCollectionSystem_Base)existingSystem).PrefabLookupMap;
			Entity userCharEntity = Entity.Null;
			EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
			Enumerator<Entity> enumerator = ((EntityQuery)(ref val2)).ToEntityArray((Allocator)2).GetEnumerator();
			User val3 = default(User);
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				((EntityManager)(ref entityManager)).TryGetComponentData<User>(current, ref val3);
				userCharEntity = val3.LocalCharacter._Entity;
			}
			RefinementstationRecipeEntry component = ((Component)__instance).GetComponent<RefinementstationRecipeEntry>();
			RefinementstationRecipeItem component2 = ((Component)__instance).GetComponent<RefinementstationRecipeItem>();
			WorkstationRecipeGridSelectionEntry component3 = ((Component)__instance).GetComponent<WorkstationRecipeGridSelectionEntry>();
			BuildMenu_StructureEntry component4 = ((Component)__instance).GetComponent<BuildMenu_StructureEntry>();
			if ((Object)(object)component != (Object)null)
			{
				RefinementstationSubMenu componentInParent = ((Component)__instance).GetComponentInParent<RefinementstationSubMenu>();
				UnitSpawnerstationSubMenu componentInParent2 = ((Component)__instance).GetComponentInParent<UnitSpawnerstationSubMenu>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					Data val4 = componentInParent.RecipesSelectionGroup.Entries._items[((UIEntry)component).EntryIndex];
					Enumerator<RecipeRequirementBuffer> enumerator2 = val4.Requirements.GetEnumerator();
					while (enumerator2.MoveNext())
					{
						RecipeRequirementBuffer current2 = enumerator2.Current;
						SendWithdrawRequest(componentInParent.InputInventorySelectionGroup, componentInParent.OutputInventorySelectionGroup, val4, current2);
					}
				}
				else
				{
					if (!((Object)(object)componentInParent2 != (Object)null))
					{
						return;
					}
					Data val5 = componentInParent2.RecipesSelectionGroup.Entries._items[((UIEntry)component).EntryIndex];
					Enumerator<RecipeRequirementBuffer> enumerator2 = val5.Requirements.GetEnumerator();
					while (enumerator2.MoveNext())
					{
						RecipeRequirementBuffer current3 = enumerator2.Current;
						SendWithdrawRequest(componentInParent2.InputInventorySelectionGroup, componentInParent2.OutputInventorySelectionGroup, val5, current3);
					}
				}
				UITooltipHook.OnPointerEnter(__instance, eventData);
			}
			else if ((Object)(object)component2 != (Object)null)
			{
				component = ((Component)component2).GetComponentInParent<RefinementstationRecipeEntry>();
				RefinementstationSubMenu componentInParent3 = ((Component)__instance).GetComponentInParent<RefinementstationSubMenu>();
				UnitSpawnerstationSubMenu componentInParent4 = ((Component)__instance).GetComponentInParent<UnitSpawnerstationSubMenu>();
				if ((Object)(object)componentInParent3 != (Object)null)
				{
					Data val6 = componentInParent3.RecipesSelectionGroup.Entries._items[((UIEntry)component).EntryIndex];
					Enumerator<RecipeRequirementBuffer> enumerator2 = val6.Requirements.GetEnumerator();
					while (enumerator2.MoveNext())
					{
						RecipeRequirementBuffer current4 = enumerator2.Current;
						if (current4.Guid == component2.Guid)
						{
							SendWithdrawRequest(componentInParent3.InputInventorySelectionGroup, componentInParent3.OutputInventorySelectionGroup, val6, current4);
							UITooltipHook.OnPointerEnter(__instance, eventData);
							return;
						}
					}
					Enumerator<RecipeOutputBuffer> enumerator3 = val6.OutputItems.GetEnumerator();
					while (enumerator3.MoveNext())
					{
						RecipeOutputBuffer current5 = enumerator3.Current;
						if (current5.Guid == component2.Guid)
						{
							int amount = current5.Amount;
							ResourceStashWithdrawalRequest request = default(ResourceStashWithdrawalRequest);
							request.ItemGUIDHash = current5.Guid.GuidHash;
							request.Amount = amount;
							ResourceStashWithDrawalRequester.StartTask(request);
							UITooltipHook.OnPointerEnter(__instance, eventData);
							break;
						}
					}
				}
				else
				{
					if (!((Object)(object)componentInParent4 != (Object)null))
					{
						return;
					}
					Data val7 = componentInParent4.RecipesSelectionGroup.Entries._items[((UIEntry)component).EntryIndex];
					Enumerator<RecipeRequirementBuffer> enumerator2 = val7.Requirements.GetEnumerator();
					while (enumerator2.MoveNext())
					{
						RecipeRequirementBuffer current6 = enumerator2.Current;
						if (current6.Guid == component2.Guid)
						{
							SendWithdrawRequest(componentInParent4.InputInventorySelectionGroup, componentInParent4.OutputInventorySelectionGroup, val7, current6);
							UITooltipHook.OnPointerEnter(__instance, eventData);
							break;
						}
					}
				}
			}
			else if ((Object)(object)component3 != (Object)null)
			{
				WorkstationSubMenu componentInParent5 = ((Component)__instance).GetComponentInParent<WorkstationSubMenu>();
				if ((Object)(object)componentInParent5 == (Object)null)
				{
					return;
				}
				float num = 1f;
				Il2CppArrayBase<Data> items = componentInParent5.BonusesSelectionGroup.Entries._items;
				int num2 = items.Count - 1;
				Data val8 = items[num2];
				if (val8.Unlocked)
				{
					num = 1f - val8.Value / 100f;
				}
				Data val9 = componentInParent5.RecipesGridSelectionGroup.Entries._items[((UIEntry)component3).EntryIndex];
				if (!gameDataSystem.RecipeHashLookupMap.ContainsKey(val9.EntryId))
				{
					return;
				}
				RecipeData val10 = gameDataSystem.RecipeHashLookupMap[val9.EntryId];
				DynamicBuffer<RecipeRequirementBuffer> val11 = default(DynamicBuffer<RecipeRequirementBuffer>);
				if (!((EntityManager)(ref entityManager)).TryGetBuffer<RecipeRequirementBuffer>(val10.Entity, ref val11))
				{
					return;
				}
				Enumerator<RecipeRequirementBuffer> enumerator2 = val11.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					RecipeRequirementBuffer current7 = enumerator2.Current;
					int num3 = (int)Math.Ceiling((double)((float)current7.Amount * num));
					PrefabGUID guid = current7.Guid;
					if (!withdrawFullAmount)
					{
						foreach (Data item in componentInParent5.ItemOutputGridSelectionGroup.Entries._items)
						{
							if (item.EntryId == guid)
							{
								num3 -= item.Stacks;
							}
						}
						num3 -= InventoryUtilities.GetItemAmount(entityManager, userCharEntity, guid, default(Nullable_Unboxed<int>));
					}
					if (num3 > 0)
					{
						ResourceStashWithdrawalRequest request = default(ResourceStashWithdrawalRequest);
						request.ItemGUIDHash = guid.GuidHash;
						request.Amount = num3;
						ResourceStashWithDrawalRequester.StartTask(request);
					}
				}
				UITooltipHook.OnPointerEnter(__instance, eventData);
			}
			else
			{
				if (!((Object)(object)component4 != (Object)null) || !gameDataSystem.BlueprintHashLookupMap.ContainsKey(component4.PrefabGuid))
				{
					return;
				}
				BlueprintData val12 = gameDataSystem.BlueprintHashLookupMap[component4.PrefabGuid];
				DynamicBuffer<BlueprintRequirementBuffer> val13 = default(DynamicBuffer<BlueprintRequirementBuffer>);
				if (!((EntityManager)(ref entityManager)).TryGetBuffer<BlueprintRequirementBuffer>(val12.Entity, ref val13))
				{
					return;
				}
				new List<PrefabGUID>();
				Enumerator<BlueprintRequirementBuffer> enumerator5 = val13.GetEnumerator();
				while (enumerator5.MoveNext())
				{
					BlueprintRequirementBuffer current9 = enumerator5.Current;
					int num4 = (int)Math.Ceiling((double)current9.Amount);
					PrefabGUID prefabGUID = current9.PrefabGUID;
					if (num4 > 0)
					{
						ResourceStashWithdrawalRequest request = default(ResourceStashWithdrawalRequest);
						request.ItemGUIDHash = prefabGUID.GuidHash;
						request.Amount = num4;
						ResourceStashWithDrawalRequester.StartTask(request);
					}
				}
				UITooltipHook.OnPointerEnter(__instance, eventData);
			}
			void SendWithdrawRequest(GridSelectionGroup<ItemGridSelectionEntry, Data> inputInventorySelectionGroup, GridSelectionGroup<ItemGridSelectionEntry, Data> outputInventorySelectionGroup, Data recipe, RecipeRequirementBuffer requirement)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0228: Unknown result type (might be due to invalid IL or missing references)
				//IL_0229: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0043: 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_009a: Expected O, but got Unknown
				//IL_0129: 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_012f: 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_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0203: Unknown result type (might be due to invalid IL or missing references)
				//IL_0204: Unknown result type (might be due to invalid IL or missing references)
				//IL_020b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0211: Unknown result type (might be due to invalid IL or missing references)
				//IL_0148: Unknown result type (might be due to invalid IL or missing references)
				//IL_014f: Expected O, but got Unknown
				//IL_0162: 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_017c: Unknown result type (might be due to invalid IL or missing references)
				//IL_019e: Unknown result type (might be due to invalid IL or missing references)
				//IL_019f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
				int num5 = (int)Math.Ceiling((double)((float)requirement.Amount * recipe.ResourceMultiplier));
				if (!withdrawFullAmount)
				{
					foreach (Data item2 in inputInventorySelectionGroup.Entries._items)
					{
						if (item2.EntryId == requirement.Guid)
						{
							num5 -= item2.Stacks;
						}
					}
					bool flag = default(bool);
					foreach (Data item3 in outputInventorySelectionGroup.Entries._items)
					{
						ManualLogSource logger = Utils.Logger;
						BepInExMessageLogInterpolatedStringHandler val14 = new BepInExMessageLogInterpolatedStringHandler(26, 3, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val14).AppendLiteral("Output Station Item: ");
							((BepInExLogInterpolatedStringHandler)val14).AppendFormatted<int>(item3.Stacks);
							((BepInExLogInterpolatedStringHandler)val14).AppendLiteral("x ");
							((BepInExLogInterpolatedStringHandler)val14).AppendFormatted<string>(Utils.GetItemName(item3.EntryId, gameDataSystem, entityManager, prefabLookupMap));
							((BepInExLogInterpolatedStringHandler)val14).AppendLiteral(" (");
							((BepInExLogInterpolatedStringHandler)val14).AppendFormatted<int>(item3.EntryId.GuidHash);
							((BepInExLogInterpolatedStringHandler)val14).AppendLiteral(")");
						}
						logger.LogMessage(val14);
						if (item3.EntryId == requirement.Guid)
						{
							ManualLogSource logger2 = Utils.Logger;
							val14 = new BepInExMessageLogInterpolatedStringHandler(25, 2, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val14).AppendLiteral("Output Station Item: ");
								((BepInExLogInterpolatedStringHandler)val14).AppendFormatted<string>(Utils.GetItemName(item3.EntryId, gameDataSystem, entityManager, prefabLookupMap));
								((BepInExLogInterpolatedStringHandler)val14).AppendLiteral(" == ");
								((BepInExLogInterpolatedStringHandler)val14).AppendFormatted<string>(Utils.GetItemName(requirement.Guid, gameDataSystem, entityManager, prefabLookupMap));
							}
							logger2.LogMessage(val14);
							num5 -= item3.Stacks;
						}
					}
					num5 -= InventoryUtilities.GetItemAmount(entityManager, userCharEntity, requirement.Guid, default(Nullable_Unboxed<int>));
				}
				if (num5 > 0)
				{
					ResourceStashWithdrawalRequest request2 = default(ResourceStashWithdrawalRequest);
					request2.ItemGUIDHash = requirement.Guid.GuidHash;
					request2.Amount = num5;
					ResourceStashWithDrawalRequester.StartTask(request2);
				}
			}
		}
	}
	[HarmonyPatch]
	public class UITooltipHook
	{
		private static readonly Dictionary<int, (DateTime creationTime, int? stashCount, List<int> requiredItemStashCount, List<int> repairItemStashCount)> _tooltipInfo = new Dictionary<int, (DateTime, int?, List<int>, List<int>)>();

		[HarmonyPatch(typeof(GridSelectionEntry), "OnPointerEnter")]
		[HarmonyPostfix]
		public static void OnPointerEnter(GridSelectionEntry __instance, PointerEventData eventData)
		{
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: 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_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: 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_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0669: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0676: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_0608: Unknown result type (might be due to invalid IL or missing references)
			//IL_060d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0612: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Unknown result type (might be due to invalid IL or missing references)
			//IL_061c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_045c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: 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)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0633: Unknown result type (might be due to invalid IL or missing references)
			//IL_0638: Unknown result type (might be due to invalid IL or missing references)
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_063e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0643: Unknown result type (might be due to invalid IL or missing references)
			//IL_0647: Unknown result type (might be due to invalid IL or missing references)
			//IL_0649: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
			if (!VWorld.IsClient)
			{
				return;
			}
			RefinementstationRecipeEntry val = default(RefinementstationRecipeEntry);
			bool num = ((Component)__instance).TryGetComponent<RefinementstationRecipeEntry>(ref val);
			RefinementstationRecipeItem val2 = default(RefinementstationRecipeItem);
			bool flag = ((Component)__instance).TryGetComponent<RefinementstationRecipeItem>(ref val2);
			ItemGridSelectionEntry val3 = default(ItemGridSelectionEntry);
			bool flag2 = ((Component)__instance).TryGetComponent<ItemGridSelectionEntry>(ref val3);
			WorkstationRecipeGridSelectionEntry val4 = default(WorkstationRecipeGridSelectionEntry);
			bool flag3 = ((Component)__instance).TryGetComponent<WorkstationRecipeGridSelectionEntry>(ref val4);
			ResearchEntry val5 = default(ResearchEntry);
			bool flag4 = ((Component)__instance).TryGetComponent<ResearchEntry>(ref val5);
			BuildMenu_StructureEntry val6 = default(BuildMenu_StructureEntry);
			bool flag5 = ((Component)__instance).TryGetComponent<BuildMenu_StructureEntry>(ref val6);
			if (!num && !flag && !flag2 && !flag3 && !flag4 && !flag5)
			{
				return;
			}
			RefinementstationSubMenu componentInParent = ((Component)__instance).GetComponentInParent<RefinementstationSubMenu>();
			UnitSpawnerstationSubMenu componentInParent2 = ((Component)__instance).GetComponentInParent<UnitSpawnerstationSubMenu>();
			WorkstationSubMenu componentInParent3 = ((Component)__instance).GetComponentInParent<WorkstationSubMenu>();
			ResearchstationSubMenu componentInParent4 = ((Component)__instance).GetComponentInParent<ResearchstationSubMenu>();
			InventorySubMenu componentInParent5 = ((Component)__instance).GetComponentInParent<InventorySubMenu>();
			BuildMenu componentInParent6 = ((Component)__instance).GetComponentInParent<BuildMenu>();
			ServantInventorySubMenu componentInParent7 = ((Component)__instance).GetComponentInParent<ServantInventorySubMenu>();
			SalvagestationSubMenu componentInParent8 = ((Component)__instance).GetComponentInParent<SalvagestationSubMenu>();
			FakeTooltip val7 = null;
			if ((Object)(object)componentInParent != (Object)null)
			{
				val7 = componentInParent.FakeTooltip;
			}
			else if ((Object)(object)componentInParent2 != (Object)null)
			{
				val7 = componentInParent2.FakeTooltip;
			}
			else if ((Object)(object)componentInParent3 != (Object)null)
			{
				val7 = componentInParent3.FakeTooltip;
			}
			else if ((Object)(object)componentInParent4 != (Object)null)
			{
				val7 = componentInParent4.FakeTooltip;
			}
			else if ((Object)(object)componentInParent5 != (Object)null)
			{
				val7 = componentInParent5.FakeTooltip;
			}
			else if ((Object)(object)componentInParent6 != (Object)null)
			{
				val7 = componentInParent6.FakeTooltip;
			}
			else if ((Object)(object)componentInParent7 != (Object)null)
			{
				val7 = componentInParent7.FakeTooltip;
			}
			else if ((Object)(object)componentInParent8 != (Object)null)
			{
				val7 = componentInParent8.FakeTooltip;
			}
			if ((Object)(object)val7 == (Object)null)
			{
				return;
			}
			World client = VWorld.Client;
			if (client.Systems.Count == 0)
			{
				return;
			}
			EntityManager entityManager = client.EntityManager;
			GameDataSystem existingSystem = client.GetExistingSystem<GameDataSystem>();
			ClientScriptMapper existingSystem2 = client.GetExistingSystem<ClientScriptMapper>();
			if (existingSystem2 != null)
			{
				_ = existingSystem2._ClientGameManager;
			}
			Entity val8 = Entity.Null;
			EntityQuery val9 = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
			Enumerator<Entity> enumerator = ((EntityQuery)(ref val9)).ToEntityArray((Allocator)2).GetEnumerator();
			User val10 = default(User);
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				((EntityManager)(ref entityManager)).TryGetComponentData<User>(current, ref val10);
				val8 = val10.LocalCharacter._Entity;
			}
			Entity character = val8;
			PrefabGUID? val11 = null;
			StoredBlood? storedBlood = null;
			List<PrefabGUID> list = null;
			List<PrefabGUID> list2 = null;
			if ((Object)(object)val != (Object)null)
			{
				Data val12;
				if ((Object)(object)componentInParent != (Object)null)
				{
					val12 = componentInParent.RecipesSelectionGroup.Entries._items[((UIEntry)val).EntryIndex];
				}
				else
				{
					if (!((Object)(object)componentInParent2 != (Object)null))
					{
						return;
					}
					val12 = componentInParent2.RecipesSelectionGroup.Entries._items[((UIEntry)val).EntryIndex];
				}
				list = new List<PrefabGUID>();
				Enumerator<RecipeRequirementBuffer> enumerator2 = val12.Requirements.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					RecipeRequirementBuffer current2 = enumerator2.Current;
					list.Add(current2.Guid);
				}
				val11 = val12.OutputItems[0].Guid;
			}
			else if ((Object)(object)val2 != (Object)null)
			{
				val11 = val2.Guid;
			}
			else if ((Object)(object)val3 != (Object)null)
			{
				if (val3.EntryId == PrefabGUID.Empty)
				{
					return;
				}
				val11 = val3.EntryId;
				if ((Object)(object)componentInParent5 != (Object)null && val3.SyncedEntity != Entity.Null)
				{
					Durability val13 = default(Durability);
					if (((EntityManager)(ref entityManager)).TryGetComponentData<Durability>(val3.SyncedEntity, ref val13))
					{
						PrefabLookupMap prefabLookupMap = ((PrefabCollectionSystem_Base)client.GetExistingSystem<PrefabCollectionSystem>()).PrefabLookupMap;
						list2 = new List<PrefabGUID>();
						Enumerator<ItemRepairBuffer> enumerator3 = ((Durability)(ref val13)).GetRepairCost(prefabLookupMap, entityManager).GetEnumerator();
						while (enumerator3.MoveNext())
						{
							ItemRepairBuffer current3 = enumerator3.Current;
							list2.Add(current3.Guid);
						}
					}
					StoredBlood value = default(StoredBlood);
					if (((EntityManager)(ref entityManager)).TryGetComponentData<StoredBlood>(val3.SyncedEntity, ref value))
					{
						storedBlood = value;
					}
				}
			}
			else if ((Object)(object)val4 != (Object)null)
			{
				Data val14;
				if ((Object)(object)componentInParent3 != (Object)null)
				{
					val14 = componentInParent3.RecipesGridSelectionGroup.Entries._items[((UIEntry)val4).EntryIndex];
				}
				else
				{
					if (!((Object)(object)componentInParent5 != (Object)null))
					{
						return;
					}
					val14 = componentInParent5.RecipesGridSelectionGroup.Entries._items[((UIEntry)val4).EntryIndex];
				}
				if (existingSystem.RecipeHashLookupMap.ContainsKey(val14.EntryId))
				{
					RecipeData val15 = existingSystem.RecipeHashLookupMap[val14.EntryId];
					DynamicBuffer<RecipeRequirementBuffer> val16 = default(DynamicBuffer<RecipeRequirementBuffer>);
					if (((EntityManager)(ref entityManager)).TryGetBuffer<RecipeRequirementBuffer>(val15.Entity, ref val16))
					{
						list = new List<PrefabGUID>();
						Enumerator<RecipeRequirementBuffer> enumerator2 = val16.GetEnumerator();
						while (enumerator2.MoveNext())
						{
							RecipeRequirementBuffer current4 = enumerator2.Current;
							list.Add(current4.Guid);
						}
					}
					DynamicBuffer<RecipeOutputBuffer> val17 = default(DynamicBuffer<RecipeOutputBuffer>);
					if (((EntityManager)(ref entityManager)).TryGetBuffer<RecipeOutputBuffer>(val15.Entity, ref val17))
					{
						val11 = val17[0].Guid;
					}
				}
			}
			else if ((Object)(object)val5 != (Object)null)
			{
				Enumerator<ResearchGroupEntry> enumerator4 = componentInParent4.ResearchCategories.GetEnumerator();
				while (enumerator4.MoveNext())
				{
					ResearchGroupEntry current5 = enumerator4.Current;
					if (current5.ResearchGridSelectionGroup.Entries._items.Count <= ((UIEntry)val5).EntryIndex || !(current5.ResearchGridSelectionGroup.Entries._items[((UIEntry)val5).EntryIndex].EntryId == val5.EntryId))
					{
						continue;
					}
					Data obj = current5.ResearchGridSelectionGroup.Entries._items[((UIEntry)val5).EntryIndex];
					list = new List<PrefabGUID>();
					Enumerator<CostData> enumerator5 = obj.Requirements.GetEnumerator();
					while (enumerator5.MoveNext())
					{
						CostData current6 = enumerator5.Current;
						if (Utils.TryGetPrefabGUIDForItemName(existingSystem, current6.ItemName, out var prefabGUID))
						{
							list.Add(prefabGUID);
						}
					}
					break;
				}
			}
			else
			{
				if (!((Object)(object)val6 != (Object)null))
				{
					return;
				}
				if (existingSystem.BlueprintHashLookupMap.ContainsKey(val6.PrefabGuid))
				{
					BlueprintData val18 = existingSystem.BlueprintHashLookupMap[val6.PrefabGuid];
					DynamicBuffer<BlueprintRequirementBuffer> val19 = default(DynamicBuffer<BlueprintRequirementBuffer>);
					if (((EntityManager)(ref entityManager)).TryGetBuffer<BlueprintRequirementBuffer>(val18.Entity, ref val19))
					{
						list = new List<PrefabGUID>();
						Enumerator<BlueprintRequirementBuffer> enumerator6 = val19.GetEnumerator();
						while (enumerator6.MoveNext())
						{
							BlueprintRequirementBuffer current7 = enumerator6.Current;
							list.Add(current7.PrefabGUID);
						}
					}
				}
			}
			int? item = ((!val11.HasValue) ? null : new int?(Utils.GetStashItemCount(entityManager, character, val11.Value, storedBlood)));
			List<int> list3 = list?.Select((PrefabGUID x) => Utils.GetStashItemCount(entityManager, character, x)).ToList();
			List<int> list4 = list2?.Select((PrefabGUID x) => Utils.GetStashItemCount(entityManager, character, x)).ToList();
			if ((!item.HasValue || item.Value != -1) && (list3 == null || !list3.Contains(-1)) && (list4 == null || !list4.Contains(-1)))
			{
				int instanceID = ((Object)val7).GetInstanceID();
				(DateTime, int?, List<int>, List<int>) value2;
				bool num2 = _tooltipInfo.TryGetValue(instanceID, out value2);
				_tooltipInfo[instanceID] = (DateTime.UtcNow, item, list3, list4);
				if (num2 || DateTime.UtcNow.Subtract(value2.Item1).TotalSeconds >= 0.20000000298023224)
				{
					MonoBehaviourExtensions.StartCoroutine((MonoBehaviour)(object)__instance, UpdateTooltip(val7));
				}
			}
		}

		private static IEnumerator UpdateTooltip(FakeTooltip tooltip)
		{
			int id = ((Object)tooltip).GetInstanceID();
			DateTime lastUpdateTime = DateTime.MinValue;
			(DateTime, int?, List<int>, List<int>) value;
			while (_tooltipInfo.TryGetValue(id, out value) && (lastUpdateTime != value.Item1 || (!AllTextsContainStashInfo() && DateTime.UtcNow.Subtract(lastUpdateTime).TotalSeconds < 10.0)))
			{
				yield return null;
				if ((Object)(object)tooltip == (Object)null || (Object)(object)tooltip.SubText == (Object)null || (Object)(object)tooltip.SubText.Text == (Object)null || !_tooltipInfo.ContainsKey(id))
				{
					break;
				}
				int? num;
				List<int> list;
				List<int> list2;
				(lastUpdateTime, num, list, list2) = _tooltipInfo[id];
				if (num.HasValue)
				{
					((TMP_Text)tooltip.SubText.Text).SetText($"{tooltip.SubText._LocalizedString.Text} <size=14><color=white>(Stash: <color=yellow>{num.Value}</color>)</color></size>", true);
				}
				if (list != null)
				{
					for (int i = 0; i < list.Count; i++)
					{
						WorkstationRequirementEntry val = tooltip.RecipeRequiredItems.RequiredItemsList._items[i];
						((TMP_Text)val.Name.Text).SetText($"{val.Name._LocalizedString.Text} <size=12><color=white>(Stash: <color=yellow>{list[i]}</color>)</color></size>", true);
					}
				}
				if (list2 != null)
				{
					for (int j = 0; j < list2.Count; j++)
					{
						WorkstationRequirementEntry val2 = tooltip.ItemRepairCost.RepairCostList._items[j];
						((TMP_Text)val2.Name.Text).SetText($"{val2.Name._LocalizedString.Text} <size=12><color=white>(Stash: <color=yellow>{list2[j]}</color>)</color></size>", true);
					}
				}
				float endTime = Time.realtimeSinceStartup + 0.2f;
				while (endTime > Time.realtimeSinceStartup && _tooltipInfo.TryGetValue(id, out value) && lastUpdateTime == value.Item1 && AllTextsContainStashInfo())
				{
					yield return null;
				}
			}
			_tooltipInfo.Remove(id);
			bool AllTextsContainStashInfo()
			{
				if ((Object)(object)tooltip == (Object)null || (Object)(object)tooltip.SubText == (Object)null || (Object)(object)tooltip.SubText.Text == (Object)null || !((Behaviour)tooltip).isActiveAndEnabled)
				{
					return true;
				}
				string value2 = "</size>";
				if (!((TMP_Text)tooltip.SubText.Text).text.EndsWith(value2))
				{
					return false;
				}
				return true;
			}
		}
	}
	[BepInPlugin("VMods.ResourceStashWithdrawal", "VMods.ResourceStashWithdrawal", "1.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[Reloadable]
	public class Plugin : BasePlugin, IRunOnInitialized
	{
		private Harmony _hooks;

		public sealed override void Load()
		{
			Utils.Initialize(((BasePlugin)this).Log, "VMods.ResourceStashWithdrawal");
			ResourceStashWithdrawalConfig.Initialize(((BasePlugin)this).Config);
		}

		public void OnGameInitialized()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			if (VWorld.IsClient)
			{
				UIClickHook.Reset();
			}
			ResourceStashWithdrawalSystem.Initialize();
			_hooks = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("VMods.ResourceStashWithdrawal");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (v");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.3.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") is loaded!");
			}
			log.LogInfo(val);
		}

		public sealed override bool Unload()
		{
			Harmony hooks = _hooks;
			if (hooks != null)
			{
				hooks.UnpatchSelf();
			}
			ResourceStashWithdrawalSystem.Deinitialize();
			((BasePlugin)this).Config.Clear();
			Utils.Deinitialize();
			return true;
		}
	}
	public struct ResourceStashWithdrawalRequest
	{
		public int ItemGUIDHash;

		public int Amount;
	}
	public class ResourceStashWithDrawalRequester
	{
		private static Queue<ResourceStashWithdrawalRequest> requests = new Queue<ResourceStashWithdrawalRequest>();

		private static bool running = false;

		private static int fps = 30;

		private static int frameDelay = 1000 / fps;

		public static void StartTask(ResourceStashWithdrawalRequest request)
		{
			lock (requests)
			{
				requests.Enqueue(request);
				if (!running)
				{
					running = true;
					RunActionsAsync();
				}
			}
		}

		private static async void RunActionsAsync()
		{
			while (requests.Count > 0)
			{
				ResourceStashWithdrawalRequest resourceStashWithdrawalRequest;
				lock (requests)
				{
					resourceStashWithdrawalRequest = requests.Dequeue();
				}
				VNetwork.SendToServerStruct<ResourceStashWithdrawalRequest>(resourceStashWithdrawalRequest);
				await Task.Delay(frameDelay);
			}
			running = false;
		}
	}
	public static class ResourceStashWithdrawalSystem
	{
		public static void Initialize()
		{
			VNetworkRegistry.RegisterServerboundStruct<ResourceStashWithdrawalRequest>((Action<FromCharacter, ResourceStashWithdrawalRequest>)OnResourceStashWithdrawalRequest);
		}

		public static void Deinitialize()
		{
			VNetworkRegistry.UnregisterStruct<ResourceStashWithdrawalRequest>();
		}

		private static void OnResourceStashWithdrawalRequest(FromCharacter fromCharacter, ResourceStashWithdrawalRequest request)
		{
			//IL_0007: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_003f: 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)
			//IL_0041: 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_0052: 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_0068: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_018a: 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_0196: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_00d7: 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_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			if (!VWorld.IsServer || fromCharacter.Character == Entity.Null)
			{
				return;
			}
			World server = VWorld.Server;
			GameDataSystem existingSystem = server.GetExistingSystem<GameDataSystem>();
			NativeHashMap<PrefabGUID, ItemData> itemHashLookupMap = existingSystem.ItemHashLookupMap;
			PrefabLookupMap prefabLookupMap = ((PrefabCollectionSystem_Base)server.GetExistingSystem<PrefabCollectionSystem>()).PrefabLookupMap;
			EntityManager entityManager = server.EntityManager;
			Entity val = default(Entity);
			if (!InventoryUtilities.TryGetInventoryEntity(entityManager, fromCharacter.Character, ref val, 0) || val == Entity.Null)
			{
				return;
			}
			int num = request.Amount;
			DynamicBuffer<InventoryBuffer> val2 = default(DynamicBuffer<InventoryBuffer>);
			foreach (Entity alliedStash in Utils.GetAlliedStashes(entityManager, fromCharacter.Character))
			{
				((EntityManager)(ref entityManager)).TryGetBuffer<InventoryBuffer>(alliedStash, ref val2);
				for (int i = 0; i < val2.Length; i++)
				{
					InventoryBuffer val3 = val2[i];
					if (val3.ItemType.GuidHash == request.ItemGUIDHash)
					{
						int num2 = Math.Min(num, val3.Amount);
						if (!Utils.TryGiveItem(entityManager, itemHashLookupMap, val, val3.ItemType, num2, out var remainingitems))
						{
							return;
						}
						num2 -= remainingitems;
						if (!InventoryUtilitiesServer.TryRemoveItem(entityManager, alliedStash, val3.ItemType, num2))
						{
							InventoryUtilitiesServer.TryRemoveItem(entityManager, val, val3.ItemType, num2);
							return;
						}
						InventoryUtilitiesServer.CreateInventoryChangedEvent(entityManager, fromCharacter.Character, val3.ItemType, val3.Amount, (InventoryChangedEventType)2);
						num -= num2;
						if (num <= 0)
						{
							break;
						}
					}
				}
				if (num <= 0)
				{
					break;
				}
			}
			if (num > 0)
			{
				string itemName = Utils.GetItemName(new PrefabGUID(request.ItemGUIDHash), existingSystem, entityManager, prefabLookupMap);
				if (num == request.Amount)
				{
					Utils.SendMessage(fromCharacter.User, "Couldn't find any " + itemName + " in the stash(es).", (ServerChatMessageType)6);
					return;
				}
				Utils.SendMessage(fromCharacter.User, $"Couldn't find all {itemName} in the stash(es). {num} {((num == 1) ? "is" : "are")} missing.", (ServerChatMessageType)6);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "VMods.ResourceStashWithdrawal";

		public const string PLUGIN_NAME = "VMods.ResourceStashWithdrawal";

		public const string PLUGIN_VERSION = "1.3.0";
	}
}