Decompiled source of VikingVault v0.1.2

VikingVault.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using MyMods.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Splatform;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[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("VikingVault")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: AssemblyInformationalVersion("0.1.2+901b84ab23f2f10926b13865f9b40bb283490874")]
[assembly: AssemblyProduct("VikingVault")]
[assembly: AssemblyTitle("VikingVault")]
[assembly: AssemblyVersion("0.1.2.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 MyMods.Web
{
	public static class WebNav
	{
		public sealed class Link
		{
			public readonly string Id;

			public readonly string Label;

			public readonly int Port;

			public string Url => "http://127.0.0.1:" + Port + "/";

			public Link(string id, string label, int port)
			{
				Id = id;
				Label = label;
				Port = port;
			}
		}

		public static readonly Link[] Links = new Link[13]
		{
			new Link("monsters", "Monsters", 8777),
			new Link("searoute", "SeaRoute", 8778),
			new Link("longboat", "Harpoon Longboat", 8779),
			new Link("tradewind", "TradeWind", 8780),
			new Link("safeharbor", "Safe Harbor", 8781),
			new Link("hub", "DFG Hub", 8782),
			new Link("vault", "Viking Vault", 8783),
			new Link("qolvault", "QoL Vault Buttons", 8784),
			new Link("qolinventory", "QoL Inventory Buttons", 8785),
			new Link("cacophony", "Cacophony", 8787),
			new Link("ominous", "Ominous", 8788),
			new Link("pebble", "Pebble", 8789),
			new Link("trolls", "Trolls", 8790)
		};

		public const string Style = "nav.top{position:sticky;top:0;z-index:20;font-family:Segoe UI,Arial,sans-serif;background:#0d1219;border-bottom:1px solid #2b3b4c;padding:6px 14px;display:flex;align-items:center;gap:6px;flex-wrap:wrap}\nnav.top .brand{color:#7f8fa0;font-size:11px;text-transform:uppercase;letter-spacing:.6px;margin-right:8px}\nnav.top a{color:#9fc3dd;text-decoration:none;font-size:13px;padding:4px 9px;border-radius:5px}\nnav.top a:hover{background:#1a2530}\nnav.top a.here{background:#3a2b4c;border:1px solid #55406b;color:#efe0ff}\n";

		public static string Html(string currentId)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("<nav class='top'><span class='brand'>MyMods</span>");
			Link[] links = Links;
			foreach (Link link in links)
			{
				stringBuilder.Append("<a class='");
				if (link.Id == currentId)
				{
					stringBuilder.Append("here");
				}
				stringBuilder.Append("' href='").Append(link.Url).Append("'>")
					.Append(link.Label)
					.Append("</a>");
			}
			stringBuilder.Append("</nav>");
			return stringBuilder.ToString();
		}

		public static Link Find(string id)
		{
			Link[] links = Links;
			foreach (Link link in links)
			{
				if (link.Id == id)
				{
					return link;
				}
			}
			return null;
		}
	}
}
namespace VikingVault
{
	public static class ObjLoader
	{
		public static GameObject Load(string objPath, Shader shader, Material templateMaterial = null)
		{
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04da: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: 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)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ef: Expected O, but got Unknown
			//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_060e: 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_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: 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_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0691: Unknown result type (might be due to invalid IL or missing references)
			//IL_0698: Expected O, but got Unknown
			//IL_06a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: 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_03d7: 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_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: 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_0393: 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_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_077d: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07be: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d7: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(objPath) || !File.Exists(objPath))
			{
				Logger.LogWarning((object)("Viking Vault: OBJ file not found: " + objPath));
				return null;
			}
			Logger.LogInfo((object)("Viking Vault: loading OBJ model: " + objPath));
			string directoryName = Path.GetDirectoryName(objPath);
			string[] array;
			try
			{
				array = File.ReadAllLines(objPath);
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Viking Vault: could not read OBJ file: " + ex.Message));
				return null;
			}
			List<Vector3> list = new List<Vector3>();
			List<Vector2> list2 = new List<Vector2>();
			List<Vector3> list3 = new List<Vector3>();
			List<Vector3> list4 = new List<Vector3>();
			List<Vector2> list5 = new List<Vector2>();
			List<Vector3> list6 = new List<Vector3>();
			List<int> list7 = new List<int>();
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			string mtlLib = null;
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim();
				if (text.Length < 2 || text[0] == '#')
				{
					continue;
				}
				if (text.StartsWith("v ") || text.StartsWith("v\t"))
				{
					string[] array2 = text.Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
					if (array2.Length >= 4)
					{
						float num = float.Parse(array2[1], CultureInfo.InvariantCulture);
						float num2 = float.Parse(array2[2], CultureInfo.InvariantCulture);
						float num3 = float.Parse(array2[3], CultureInfo.InvariantCulture);
						list.Add(new Vector3(0f - num, num2, num3));
					}
				}
				else if (text.StartsWith("vt ") || text.StartsWith("vt\t"))
				{
					string[] array3 = text.Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
					if (array3.Length >= 3)
					{
						float num4 = float.Parse(array3[1], CultureInfo.InvariantCulture);
						float num5 = float.Parse(array3[2], CultureInfo.InvariantCulture);
						list2.Add(new Vector2(num4, num5));
					}
				}
				else if (text.StartsWith("vn ") || text.StartsWith("vn\t"))
				{
					string[] array4 = text.Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
					if (array4.Length >= 4)
					{
						float num6 = float.Parse(array4[1], CultureInfo.InvariantCulture);
						float num7 = float.Parse(array4[2], CultureInfo.InvariantCulture);
						float num8 = float.Parse(array4[3], CultureInfo.InvariantCulture);
						list3.Add(new Vector3(0f - num6, num7, num8));
					}
				}
				else if (text.StartsWith("mtllib ", StringComparison.OrdinalIgnoreCase))
				{
					mtlLib = text.Substring(7).Trim();
				}
				else
				{
					if (!text.StartsWith("f ") && !text.StartsWith("f\t"))
					{
						continue;
					}
					string[] array5 = text.Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
					if (array5.Length < 4)
					{
						continue;
					}
					int[] array6 = new int[array5.Length - 1];
					for (int j = 1; j < array5.Length; j++)
					{
						string text2 = array5[j];
						if (!dictionary.TryGetValue(text2, out var value))
						{
							string[] array7 = text2.Split('/');
							int num9 = int.Parse(array7[0]);
							if (num9 < 0)
							{
								num9 = list.Count + num9 + 1;
							}
							Vector3 item = list[num9 - 1];
							Vector2 item2 = Vector2.zero;
							if (array7.Length > 1 && !string.IsNullOrEmpty(array7[1]))
							{
								int num10 = int.Parse(array7[1]);
								if (num10 < 0)
								{
									num10 = list2.Count + num10 + 1;
								}
								item2 = list2[num10 - 1];
							}
							Vector3 item3 = Vector3.up;
							if (array7.Length > 2 && !string.IsNullOrEmpty(array7[2]))
							{
								int num11 = int.Parse(array7[2]);
								if (num11 < 0)
								{
									num11 = list3.Count + num11 + 1;
								}
								item3 = list3[num11 - 1];
								item3 = ((!(((Vector3)(ref item3)).sqrMagnitude > 0.0001f)) ? Vector3.up : ((Vector3)(ref item3)).normalized);
							}
							value = list4.Count;
							list4.Add(item);
							list5.Add(item2);
							list6.Add(item3);
							dictionary[text2] = value;
						}
						array6[j - 1] = value;
					}
					for (int k = 1; k < array6.Length - 1; k++)
					{
						int num12 = array6[0];
						int num13 = array6[k];
						int num14 = array6[k + 1];
						if (num12 != num13 && num12 != num14 && num13 != num14)
						{
							Vector3 val = list4[num12];
							Vector3 val2 = list4[num13];
							Vector3 val3 = list4[num14];
							Vector3 val4 = Vector3.Cross(val2 - val, val3 - val);
							if (!(((Vector3)(ref val4)).sqrMagnitude < 1E-10f))
							{
								list7.Add(num12);
								list7.Add(num13);
								list7.Add(num14);
							}
						}
					}
				}
			}
			if (list4.Count == 0 || list7.Count == 0)
			{
				Logger.LogWarning((object)"Viking Vault: OBJ file contained no valid geometry.");
				return null;
			}
			Mesh val5 = new Mesh();
			((Object)val5).name = Path.GetFileNameWithoutExtension(objPath);
			val5.indexFormat = (IndexFormat)1;
			val5.SetVertices(list4);
			val5.SetTriangles(list7, 0);
			if (list5.Count == list4.Count)
			{
				val5.SetUVs(0, list5);
			}
			if (list3.Count > 0 && list6.Count == list4.Count)
			{
				val5.SetNormals(list6);
			}
			else
			{
				val5.RecalculateNormals();
			}
			Color[] array8 = (Color[])(object)new Color[list4.Count];
			for (int l = 0; l < array8.Length; l++)
			{
				array8[l] = Color.white;
			}
			val5.colors = array8;
			Vector4[] array9 = (Vector4[])(object)new Vector4[list4.Count];
			for (int m = 0; m < array9.Length; m++)
			{
				array9[m] = new Vector4(1f, 0f, 0f, 1f);
			}
			val5.tangents = array9;
			val5.RecalculateBounds();
			Texture2D val6 = ResolveTexture(directoryName, mtlLib, Path.GetFileNameWithoutExtension(objPath));
			GameObject val7 = new GameObject("VikingVaultModel");
			GameObject val8 = new GameObject(((Object)val5).name);
			val8.transform.SetParent(val7.transform, false);
			val8.AddComponent<MeshFilter>().sharedMesh = val5;
			MeshRenderer obj = val8.AddComponent<MeshRenderer>();
			Shader val9 = shader;
			if ((Object)(object)val9 == (Object)null || ((Object)val9).name == "Hidden/InternalErrorShader")
			{
				val9 = Shader.Find("Custom/Creature");
			}
			if ((Object)(object)val9 == (Object)null)
			{
				val9 = Shader.Find("Standard");
			}
			if ((Object)(object)val9 == (Object)null)
			{
				val9 = Shader.Find("Unlit/Texture");
			}
			Material val10 = new Material(((Object)(object)val9 != (Object)null) ? val9 : Shader.Find("Hidden/InternalErrorShader"));
			((Object)val10).name = "VaultMaterial";
			val10.color = Color.white;
			if (val10.HasProperty("_Color"))
			{
				val10.SetColor("_Color", Color.white);
			}
			if (val10.HasProperty("_Glossiness"))
			{
				val10.SetFloat("_Glossiness", 0.35f);
			}
			if (val10.HasProperty("_Metallic"))
			{
				val10.SetFloat("_Metallic", 0.15f);
			}
			if (val10.HasProperty("_Mode"))
			{
				val10.SetFloat("_Mode", 0f);
			}
			val10.DisableKeyword("_ALPHATEST_ON");
			val10.DisableKeyword("_ALPHABLEND_ON");
			val10.DisableKeyword("_ALPHAPREMULTIPLY_ON");
			val10.renderQueue = 2000;
			if ((Object)(object)val6 != (Object)null)
			{
				val10.mainTexture = (Texture)(object)val6;
				val10.mainTextureScale = Vector2.one;
				val10.mainTextureOffset = Vector2.zero;
			}
			if (val10.HasProperty("_Cull"))
			{
				val10.SetInt("_Cull", 0);
			}
			val10.doubleSidedGI = true;
			((Renderer)obj).sharedMaterial = val10;
			BoxCollider obj2 = val8.AddComponent<BoxCollider>();
			Bounds bounds = val5.bounds;
			obj2.size = ((Bounds)(ref bounds)).size;
			bounds = val5.bounds;
			obj2.center = ((Bounds)(ref bounds)).center;
			Logger.LogInfo((object)("Viking Vault: OBJ loaded successfully - " + list4.Count + " vertices, " + list7.Count / 3 + " triangles."));
			return val7;
		}

		private static Texture2D ResolveTexture(string dir, string mtlLib, string baseName)
		{
			string[] array = (string.IsNullOrEmpty(mtlLib) ? new string[2]
			{
				baseName + ".mtl",
				"vault.mtl"
			} : new string[3]
			{
				mtlLib,
				baseName + ".mtl",
				"vault.mtl"
			});
			foreach (string path in array)
			{
				string path2 = Path.Combine(dir, path);
				if (!File.Exists(path2))
				{
					continue;
				}
				try
				{
					string[] array2 = File.ReadAllLines(path2);
					for (int j = 0; j < array2.Length; j++)
					{
						string text = array2[j].Trim();
						if (text.StartsWith("map_Kd ", StringComparison.OrdinalIgnoreCase))
						{
							string path3 = text.Substring(7).Trim();
							string path4 = Path.Combine(dir, path3);
							if (File.Exists(path4))
							{
								return LoadTextureFromFile(path4);
							}
						}
					}
				}
				catch
				{
				}
			}
			array = new string[16]
			{
				baseName + ".jpg",
				baseName + ".png",
				"vault.jpg",
				"vault.png",
				baseName + "_basecolor.jpg",
				baseName + "_basecolor.png",
				baseName + "_diffuse.jpg",
				baseName + "_diffuse.png",
				baseName + "_albedo.jpg",
				baseName + "_albedo.png",
				"basecolor.jpg",
				"basecolor.png",
				"diffuse.jpg",
				"diffuse.png",
				"texture.jpg",
				"texture.png"
			};
			foreach (string path5 in array)
			{
				string path6 = Path.Combine(dir, path5);
				if (File.Exists(path6))
				{
					return LoadTextureFromFile(path6);
				}
			}
			try
			{
				array = Directory.GetFiles(dir, "*.*");
				foreach (string path7 in array)
				{
					string text2 = Path.GetExtension(path7).ToLowerInvariant();
					if (!(text2 != ".png") || !(text2 != ".jpg") || !(text2 != ".jpeg"))
					{
						string text3 = Path.GetFileNameWithoutExtension(path7).ToLowerInvariant();
						if (!text3.Contains("(2)") && !text3.Contains("(3)") && !text3.Contains("(4)") && !text3.Contains("roughness") && !text3.Contains("normal") && !text3.Contains("metallic") && !text3.Contains("bump") && !text3.Contains("spec") && !text3.Contains("_rm"))
						{
							return LoadTextureFromFile(path7);
						}
					}
				}
			}
			catch
			{
			}
			return null;
		}

		private static Texture2D LoadTextureFromFile(string path)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			try
			{
				byte[] array = File.ReadAllBytes(path);
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				if (ImageConversion.LoadImage(val, array))
				{
					((Object)val).name = Path.GetFileNameWithoutExtension(path);
					((Texture)val).wrapMode = (TextureWrapMode)0;
					((Texture)val).filterMode = (FilterMode)1;
					Logger.LogInfo((object)("Viking Vault: loaded texture: " + path + " (" + ((Texture)val).width + "x" + ((Texture)val).height + ")"));
					return val;
				}
				Object.Destroy((Object)(object)val);
			}
			catch (Exception ex)
			{
				Logger.LogWarning((object)("Viking Vault: failed to load texture " + path + ": " + ex.Message));
			}
			return null;
		}
	}
	public class VaultController : MonoBehaviour, Hoverable, Interactable, TextReceiver
	{
		private Container m_container;

		private ZNetView m_nview;

		private static readonly FieldInfo s_invWidthField = typeof(Inventory).GetField("m_width", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly MethodInfo s_containerSaveMethod = typeof(Container).GetMethod("Save", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		public const int TierScheme = 2;

		public static readonly int[] TierWidths = new int[6] { 8, 10, 10, 12, 12, 12 };

		public static readonly int[] TierHeights = new int[6] { 8, 8, 10, 10, 12, 14 };

		public static readonly string[] TierNames = new string[6] { "Timber Vault (64 slots)", "Ironclad Strongroom (80 slots)", "Blackmetal Dragon Hoard (100 slots)", "Marble Sepulchre (120 slots)", "Eitr Crypt (144 slots)", "Flametal Reliquary (168 slots)" };

		public static int MaxTier => TierWidths.Length;

		public Container Container
		{
			get
			{
				if ((Object)(object)m_container == (Object)null)
				{
					m_container = ((Component)this).GetComponent<Container>();
				}
				return m_container;
			}
		}

		public Inventory VaultInventory
		{
			get
			{
				Container container = Container;
				if (!((Object)(object)container != (Object)null))
				{
					return null;
				}
				return container.GetInventory();
			}
		}

		public ZNetView NetView
		{
			get
			{
				if ((Object)(object)m_nview == (Object)null)
				{
					m_nview = ((Component)this).GetComponent<ZNetView>();
				}
				return m_nview;
			}
		}

		public string VaultId
		{
			get
			{
				ZNetView netView = NetView;
				if ((Object)(object)netView != (Object)null && netView.GetZDO() != null)
				{
					return ((object)Unsafe.As<ZDOID, ZDOID>(ref netView.GetZDO().m_uid)/*cast due to .constrained prefix*/).ToString();
				}
				return null;
			}
		}

		public string VaultName
		{
			get
			{
				ZNetView netView = NetView;
				if ((Object)(object)netView != (Object)null && netView.GetZDO() != null)
				{
					string text = netView.GetZDO().GetString("vikingvault_name", "");
					if (!string.IsNullOrEmpty(text))
					{
						return text;
					}
				}
				return "Viking Vault";
			}
		}

		public int Tier
		{
			get
			{
				ZNetView netView = NetView;
				if ((Object)(object)netView != (Object)null && netView.GetZDO() != null)
				{
					return Mathf.Clamp(netView.GetZDO().GetInt("vikingvault_tier", 1), 1, MaxTier);
				}
				return 1;
			}
		}

		public bool IsPinned
		{
			get
			{
				ZNetView netView = NetView;
				if ((Object)(object)netView != (Object)null && netView.GetZDO() != null)
				{
					return netView.GetZDO().GetBool("vikingvault_pinned", false);
				}
				return false;
			}
		}

		public string BiomeName
		{
			get
			{
				//IL_0012: 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)
				try
				{
					if (WorldGenerator.instance != null)
					{
						return ((object)WorldGenerator.instance.GetBiome(((Component)this).transform.position)/*cast due to .constrained prefix*/).ToString();
					}
				}
				catch
				{
				}
				return "Unknown";
			}
		}

		public bool CanMutate()
		{
			Container container = Container;
			if ((Object)(object)container == (Object)null)
			{
				return false;
			}
			try
			{
				return container.IsOwner();
			}
			catch
			{
				return false;
			}
		}

		public void Open()
		{
			if (((Behaviour)this).enabled && (Object)(object)VaultGUI.Instance != (Object)null)
			{
				VaultGUI.Instance.Open(this);
			}
		}

		public void SetVaultName(string newName)
		{
			string text = ((newName != null) ? newName.Trim() : "");
			if (string.IsNullOrEmpty(text))
			{
				text = "Viking Vault";
			}
			ZNetView netView = NetView;
			if ((Object)(object)netView != (Object)null && netView.GetZDO() != null)
			{
				netView.GetZDO().Set("vikingvault_name", text);
			}
			if (IsPinned)
			{
				UpdateMapPin(true);
			}
			VaultStore.Instance.RegisterOrUpdate(this);
		}

		public void SetPinned(bool pinned)
		{
			ZNetView netView = NetView;
			if ((Object)(object)netView != (Object)null && netView.GetZDO() != null)
			{
				netView.GetZDO().Set("vikingvault_pinned", pinned);
			}
			UpdateMapPin(pinned);
			VaultStore.Instance.RegisterOrUpdate(this);
		}

		public void UpdateMapPin(bool? forceState = null)
		{
			//IL_0033: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Minimap.instance == (Object)null))
			{
				bool num = forceState ?? IsPinned;
				Minimap.instance.RemovePin(((Component)this).transform.position, 1.5f);
				if (num)
				{
					long num2 = (((Object)(object)Player.m_localPlayer != (Object)null) ? Player.m_localPlayer.GetPlayerID() : 0);
					Minimap.instance.AddPin(((Component)this).transform.position, (PinType)3, VaultName, true, false, num2, default(PlatformUserID));
				}
			}
		}

		private void MigrateTierScheme()
		{
			ZNetView netView = NetView;
			if (!((Object)(object)netView == (Object)null) && netView.GetZDO() != null)
			{
				ZDO zDO = netView.GetZDO();
				if (zDO.GetInt("vikingvault_tier_scheme", 0) < 2)
				{
					int num = zDO.GetInt("vikingvault_tier", 1);
					int num2 = ((num <= 2) ? 1 : (num - 1));
					zDO.Set("vikingvault_tier", Mathf.Clamp(num2, 1, MaxTier));
					zDO.Set("vikingvault_tier_scheme", 2);
				}
			}
		}

		public void SyncDimensionsFromTier()
		{
			MigrateTierScheme();
			int tier = Tier;
			int num = TierWidths[tier - 1];
			int height = TierHeights[tier - 1];
			Container container = Container;
			if ((Object)(object)container != (Object)null)
			{
				container.m_width = num;
				container.m_height = height;
				Inventory inventory = container.GetInventory();
				if (inventory != null)
				{
					s_invWidthField?.SetValue(inventory, num);
					inventory.SetHeight(height);
				}
			}
		}

		public void ApplyUpgradeTier(int nextTier)
		{
			nextTier = Mathf.Clamp(nextTier, 1, MaxTier);
			ZNetView netView = NetView;
			if ((Object)(object)netView != (Object)null && netView.GetZDO() != null)
			{
				netView.GetZDO().Set("vikingvault_tier", nextTier);
			}
			SyncDimensionsFromTier();
			if ((Object)(object)Container != (Object)null)
			{
				s_containerSaveMethod?.Invoke(Container, null);
			}
			VaultStore.Instance.RegisterOrUpdate(this);
		}

		public void StartRename()
		{
			if ((Object)(object)TextInput.instance != (Object)null)
			{
				TextInput.instance.RequestText((TextReceiver)(object)this, "Name your Viking Vault", 25);
			}
		}

		public string GetText()
		{
			return VaultName;
		}

		public void SetText(string text)
		{
			SetVaultName(text);
		}

		public string GetHoverText()
		{
			return VaultName + "\n[<color=yellow>E</color>] Access vault contents";
		}

		public string GetHoverName()
		{
			return VaultName;
		}

		public float GetHoverOffset()
		{
			return 0.5f;
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			if (hold)
			{
				return false;
			}
			Open();
			return true;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}

		private void Start()
		{
			m_nview = ((Component)this).GetComponent<ZNetView>();
			SyncDimensionsFromTier();
			VaultStore.Instance.RegisterOrUpdate(this);
		}

		private void Awake()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			m_container = ((Component)this).GetComponent<Container>();
			m_nview = ((Component)this).GetComponent<ZNetView>();
			Transform val = ((Component)this).transform.Find("VaultModel");
			if ((Object)(object)val != (Object)null)
			{
				foreach (Transform item in ((Component)this).transform)
				{
					Transform val2 = item;
					if ((Object)(object)val2 != (Object)(object)val)
					{
						Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Renderer>(true);
						for (int i = 0; i < componentsInChildren.Length; i++)
						{
							componentsInChildren[i].enabled = false;
						}
						MeshFilter[] componentsInChildren2 = ((Component)val2).GetComponentsInChildren<MeshFilter>(true);
						for (int j = 0; j < componentsInChildren2.Length; j++)
						{
							componentsInChildren2[j].sharedMesh = null;
						}
						Collider[] componentsInChildren3 = ((Component)val2).GetComponentsInChildren<Collider>(true);
						for (int k = 0; k < componentsInChildren3.Length; k++)
						{
							componentsInChildren3[k].enabled = false;
						}
					}
				}
				BoxCollider componentInChildren = ((Component)val).GetComponentInChildren<BoxCollider>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					((Collider)componentInChildren).enabled = true;
					((Component)componentInChildren).gameObject.layer = ((Component)this).gameObject.layer;
				}
			}
			WearNTear component = ((Component)this).GetComponent<WearNTear>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_new = null;
				component.m_worn = null;
				component.m_broken = null;
				component.m_wet = null;
				component.m_snow = null;
				component.m_snowWorn = null;
				component.m_snowBroken = null;
				component.m_noRoofWear = true;
				component.m_noSupportWear = true;
			}
			if ((Object)(object)m_container != (Object)null)
			{
				m_container.m_open = null;
				m_container.m_closed = null;
			}
		}

		private void OnDestroy()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (IsPinned && (Object)(object)Minimap.instance != (Object)null)
			{
				Minimap.instance.RemovePin(((Component)this).transform.position, 1.5f);
			}
			if (!string.IsNullOrEmpty(VaultId))
			{
				VaultStore.Instance.RemoveVault(VaultId);
			}
		}
	}
	public class VaultGUI : MonoBehaviour
	{
		public static VaultGUI Instance;

		private bool open;

		private bool busy;

		private bool canMutate;

		private VaultController vault;

		private VaultRecord viewingRecord;

		private VaultTab tab;

		private int selectedSlot = -1;

		private int scrollRow;

		private int visibleRows = 1;

		private string status = "";

		private float refreshTimer;

		private static bool s_isFullscreen = false;

		private bool renaming;

		private string renameInput = "";

		private float lastClickTime;

		private int lastClickedSlot = -1;

		private List<VaultUtil.TypeEntry> sideItems = new List<VaultUtil.TypeEntry>();

		private List<VaultUtil.TypeEntry> playerItems = new List<VaultUtil.TypeEntry>();

		private Vector2 sideScroll;

		private Vector2 playerScroll;

		private Vector2 vaultTabScroll;

		private Texture2D whiteTex;

		private static readonly Color ColBackdrop = new Color(0f, 0f, 0f, 0.76f);

		private static readonly Color ColWindowBg = new Color(0.08f, 0.1f, 0.14f, 0.98f);

		private static readonly Color ColWindowBorder = new Color(0.74f, 0.58f, 0.28f, 1f);

		private static readonly Color ColWindowBorderInner = new Color(0.18f, 0.23f, 0.32f, 0.85f);

		private static readonly Color ColCardBg = new Color(0.09f, 0.11f, 0.16f, 0.96f);

		private static readonly Color ColCardBorder = new Color(0.22f, 0.28f, 0.38f, 0.85f);

		private static readonly Color ColCardHeaderBg = new Color(0.12f, 0.16f, 0.22f, 1f);

		private static readonly Color ColSlotEmptyBg = new Color(0.06f, 0.08f, 0.11f, 0.95f);

		private static readonly Color ColSlotEmptyBorder = new Color(0.14f, 0.18f, 0.24f, 0.7f);

		private static readonly Color ColSlotItemBg = new Color(0.11f, 0.14f, 0.2f, 0.95f);

		private static readonly Color ColSlotItemBorder = new Color(0.24f, 0.32f, 0.44f, 0.85f);

		private static readonly Color ColSlotHoverBorder = new Color(0.38f, 0.72f, 1f, 1f);

		private static readonly Color ColSlotSelectedBg = new Color(0.26f, 0.2f, 0.08f, 0.98f);

		private static readonly Color ColSlotSelectedBorder = new Color(1f, 0.82f, 0.28f, 1f);

		private static readonly Color ColGoldText = new Color(1f, 0.84f, 0.38f, 1f);

		private static readonly Color ColWhiteText = new Color(0.92f, 0.95f, 0.98f, 1f);

		private static readonly Color ColMutedText = new Color(0.6f, 0.66f, 0.75f, 1f);

		private static readonly Color ColCyanText = new Color(0.4f, 0.8f, 1f, 1f);

		private static readonly Color ColGreenText = new Color(0.38f, 0.88f, 0.48f, 1f);

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

		private static readonly Dictionary<string, GUIStyle> styleCache = new Dictionary<string, GUIStyle>();

		public static bool IsOpen
		{
			get
			{
				if ((Object)(object)Instance != (Object)null)
				{
					return Instance.open;
				}
				return false;
			}
		}

		public bool IsViewingRemote => viewingRecord != null;

		public Inventory CurrentInventory
		{
			get
			{
				if (!IsViewingRemote || viewingRecord == null)
				{
					if (!((Object)(object)vault != (Object)null))
					{
						return null;
					}
					return vault.VaultInventory;
				}
				return viewingRecord.GetCachedInventory();
			}
		}

		private void Awake()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			whiteTex = new Texture2D(1, 1);
			whiteTex.SetPixel(0, 0, Color.white);
			whiteTex.Apply();
		}

		private void OnDestroy()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		public void Open(VaultController target)
		{
			vault = target;
			viewingRecord = null;
			renaming = false;
			open = true;
			busy = false;
			canMutate = false;
			tab = VaultTab.All;
			selectedSlot = -1;
			scrollRow = 0;
			status = "";
			refreshTimer = 0f;
			lastClickTime = 0f;
			lastClickedSlot = -1;
			RefreshData();
			((MonoBehaviour)this).StartCoroutine(CoEnsureOwned());
			if ((Object)(object)vault != (Object)null)
			{
				VaultStore.Instance.RegisterOrUpdate(vault);
			}
		}

		public void Close()
		{
			open = false;
			Cursor.visible = false;
			Cursor.lockState = (CursorLockMode)1;
			vault = null;
			viewingRecord = null;
			renaming = false;
		}

		private void Update()
		{
			if (!open)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead())
			{
				Close();
				return;
			}
			if (!IsViewingRemote && ((Object)(object)vault == (Object)null || (Object)(object)vault.Container == (Object)null))
			{
				Close();
				return;
			}
			if (Input.GetKeyDown((KeyCode)27))
			{
				Close();
				return;
			}
			refreshTimer -= Time.deltaTime;
			if (refreshTimer <= 0f)
			{
				refreshTimer = 1.5f;
				if (!IsViewingRemote)
				{
					RefreshData();
				}
			}
		}

		private IEnumerator CoEnsureOwned()
		{
			Container val = (((Object)(object)vault != (Object)null) ? vault.Container : null);
			if ((Object)(object)val != (Object)null)
			{
				ZNetView component = ((Component)val).GetComponent<ZNetView>();
				if ((Object)(object)component != (Object)null && !component.IsOwner())
				{
					component.ClaimOwnership();
				}
			}
			yield return null;
			yield return null;
			yield return null;
			canMutate = !IsViewingRemote && (Object)(object)vault != (Object)null && vault.CanMutate();
			if (open && !canMutate && !IsViewingRemote)
			{
				status = "Read-only: you do not own this vault.";
			}
		}

		private void ReturnToLocal()
		{
			viewingRecord = null;
			canMutate = (Object)(object)vault != (Object)null && vault.CanMutate();
			status = (((Object)(object)vault != (Object)null) ? ("Switched back to " + vault.VaultName + ".") : "");
			selectedSlot = -1;
			scrollRow = 0;
			renaming = false;
			RefreshData();
		}

		private void SelectRemoteVault(VaultRecord rec)
		{
			viewingRecord = rec;
			canMutate = false;
			renaming = false;
			status = "Viewing remote vault: " + rec.Name + " (" + rec.Biome + ").";
			selectedSlot = -1;
			scrollRow = 0;
			RefreshData();
		}

		private void RefreshData()
		{
			Player localPlayer = Player.m_localPlayer;
			Inventory currentInventory = CurrentInventory;
			sideItems.Clear();
			playerItems.Clear();
			if (currentInventory != null)
			{
				sideItems = VaultUtil.Aggregate(currentInventory.GetAllItems(), tab);
			}
			if ((Object)(object)localPlayer != (Object)null && ((Humanoid)localPlayer).GetInventory() != null)
			{
				playerItems = VaultUtil.Aggregate(((Humanoid)localPlayer).GetInventory().GetAllItems(), tab);
			}
			ClampSelection();
		}

		private void ClampSelection()
		{
			Inventory currentInventory = CurrentInventory;
			if (selectedSlot >= 0 && currentInventory != null)
			{
				int num = currentInventory.GetWidth() * currentInventory.GetHeight();
				if (selectedSlot >= num)
				{
					selectedSlot = -1;
				}
				else
				{
					int width = currentInventory.GetWidth();
					int num2 = selectedSlot % width;
					int num3 = selectedSlot / width;
					if (currentInventory.GetItemAt(num2, num3) == null)
					{
						selectedSlot = -1;
					}
				}
			}
			int num4 = ((currentInventory == null) ? 1 : currentInventory.GetHeight());
			int num5 = Mathf.Max(0, num4 - Mathf.Max(1, visibleRows));
			scrollRow = Mathf.Clamp(scrollRow, 0, num5);
		}

		private void DrawRect(Rect r, Color c)
		{
			//IL_0000: 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: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)whiteTex);
			GUI.color = Color.white;
		}

		private void DrawBorder(Rect r, Color c, float thickness = 1f)
		{
			//IL_0000: 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_0044: 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_00a6: 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)
			GUI.color = c;
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, thickness), (Texture)(object)whiteTex);
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - thickness, ((Rect)(ref r)).width, thickness), (Texture)(object)whiteTex);
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + thickness, thickness, ((Rect)(ref r)).height - thickness * 2f), (Texture)(object)whiteTex);
			GUI.DrawTexture(new Rect(((Rect)(ref r)).xMax - thickness, ((Rect)(ref r)).y + thickness, thickness, ((Rect)(ref r)).height - thickness * 2f), (Texture)(object)whiteTex);
			GUI.color = Color.white;
		}

		private void DrawBox(Rect r, Color bg, Color border, float thickness = 1f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			DrawRect(r, bg);
			if (thickness > 0f && border.a > 0.01f)
			{
				DrawBorder(r, border, thickness);
			}
		}

		private void DrawCard(Rect r, string title, string badge = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//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_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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			DrawBox(r, ColCardBg, ColCardBorder);
			Rect r2 = default(Rect);
			((Rect)(ref r2))..ctor(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 28f);
			DrawBox(r2, ColCardHeaderBg, ColCardBorder);
			GUI.Label(new Rect(((Rect)(ref r2)).x + 10f, ((Rect)(ref r2)).y + 4f, ((Rect)(ref r2)).width - 20f, 20f), title, GetTextStyle(12, bold: true, (TextAnchor)3, ColGoldText));
			if (!string.IsNullOrEmpty(badge))
			{
				GUI.Label(new Rect(((Rect)(ref r2)).xMax - 110f, ((Rect)(ref r2)).y + 4f, 100f, 20f), badge, GetTextStyle(11, bold: true, (TextAnchor)5, ColCyanText));
			}
		}

		private bool CustomButton(Rect r, string text, Color bg, Color hoverBg, Color textColor, int fontSize = 12, bool bold = true, Color? border = null)
		{
			//IL_0007: 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_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_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_006a: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0059: 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)
			bool flag = ((Rect)(ref r)).Contains(Event.current.mousePosition);
			Color bg2 = (flag ? hoverBg : bg);
			Color border2 = (Color)(((??)border) ?? (flag ? new Color(0.4f, 0.75f, 1f, 0.9f) : new Color(0.24f, 0.3f, 0.4f, 0.85f)));
			DrawBox(r, bg2, border2);
			GUI.Label(r, text, GetTextStyle(fontSize, bold, (TextAnchor)4, textColor));
			return GUI.Button(r, GUIContent.none, GUIStyle.none);
		}

		private static GUIStyle GetTextStyle(int fontSize, bool bold, TextAnchor anchor, Color color)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected I4, but got Unknown
			//IL_002b: 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_0047: 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_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_008c: 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_009a: 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_00a8: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			string key = $"{fontSize}_{(bold ? 1 : 0)}_{(int)anchor}_{color.r:F2}_{color.g:F2}_{color.b:F2}_{color.a:F2}";
			if (!styleCache.TryGetValue(key, out var value))
			{
				value = new GUIStyle(GUI.skin.label)
				{
					fontSize = fontSize,
					fontStyle = (FontStyle)(bold ? 1 : 0),
					alignment = anchor,
					clipping = (TextClipping)1
				};
				value.normal.textColor = color;
				value.hover.textColor = color;
				value.active.textColor = color;
				styleCache[key] = value;
			}
			return value;
		}

		private void DrawMaximizeIcon(Rect r, bool isMaximized, Color c)
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_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_01d8: 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_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: 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_0071: 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)
			//IL_009d: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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)
			float num = ((Rect)(ref r)).x + ((Rect)(ref r)).width * 0.5f;
			float num2 = ((Rect)(ref r)).y + ((Rect)(ref r)).height * 0.5f;
			if (!isMaximized)
			{
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(num - 5.5f, num2 - 4.5f, 11f, 9f);
				DrawRect(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, 2f), c);
				DrawRect(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).yMax - 1f, ((Rect)(ref val)).width, 1f), c);
				DrawRect(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + 1f, 1f, ((Rect)(ref val)).height - 2f), c);
				DrawRect(new Rect(((Rect)(ref val)).xMax - 1f, ((Rect)(ref val)).y + 1f, 1f, ((Rect)(ref val)).height - 2f), c);
			}
			else
			{
				DrawRect(new Rect(num - 2.5f, num2 - 5.5f, 8f, 1.5f), c);
				DrawRect(new Rect(num + 4.5f, num2 - 5.5f, 1f, 6f), c);
				DrawRect(new Rect(num + 2f, num2 + 0.5f, 3.5f, 1f), c);
				DrawRect(new Rect(num - 2.5f, num2 - 5.5f, 1f, 2.5f), c);
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(num - 5.5f, num2 - 2.5f, 8f, 7f);
				DrawRect(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, ((Rect)(ref val2)).width, 1.5f), c);
				DrawRect(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).yMax - 1f, ((Rect)(ref val2)).width, 1f), c);
				DrawRect(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, 1f, ((Rect)(ref val2)).height), c);
				DrawRect(new Rect(((Rect)(ref val2)).xMax - 1f, ((Rect)(ref val2)).y, 1f, ((Rect)(ref val2)).height), c);
			}
		}

		private void OnGUI()
		{
			//IL_002c: 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_00be: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: 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_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: 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)
			if (open)
			{
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)0;
				DrawRect(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), ColBackdrop);
				float num;
				float num2;
				if (s_isFullscreen)
				{
					num = (float)Screen.width - 24f;
					num2 = (float)Screen.height - 24f;
				}
				else
				{
					float num3 = 680f;
					float num4 = (float)Screen.width - 32f;
					float num5 = (float)Screen.height - 32f;
					num = Mathf.Min(1140f, num4);
					num2 = Mathf.Min(num3, num5);
				}
				Rect r = default(Rect);
				((Rect)(ref r))..ctor(((float)Screen.width - num) * 0.5f, ((float)Screen.height - num2) * 0.5f, num, num2);
				DrawBox(r, ColWindowBg, ColWindowBorder, 2f);
				DrawBorder(Shrink(r, 3f), ColWindowBorderInner);
				float num6 = ((Rect)(ref r)).y + 8f;
				List<VaultRecord> vaultsForCurrentWorld = VaultStore.Instance.GetVaultsForCurrentWorld();
				if (vaultsForCurrentWorld != null && vaultsForCurrentWorld.Count > 1)
				{
					Rect rect = default(Rect);
					((Rect)(ref rect))..ctor(((Rect)(ref r)).x + 12f, num6, ((Rect)(ref r)).width - 24f, 26f);
					DrawVaultNetworkRibbon(rect, vaultsForCurrentWorld);
					num6 += 30f;
				}
				Rect rect2 = default(Rect);
				((Rect)(ref rect2))..ctor(((Rect)(ref r)).x + 12f, num6, ((Rect)(ref r)).width - 24f, 40f);
				DrawMainHeader(rect2);
				num6 += 44f;
				if (IsViewingRemote && viewingRecord != null)
				{
					Rect rect3 = default(Rect);
					((Rect)(ref rect3))..ctor(((Rect)(ref r)).x + 12f, num6, ((Rect)(ref r)).width - 24f, 26f);
					DrawRemoteBanner(rect3);
					num6 += 30f;
				}
				float num7 = 118f;
				float num8 = ((Rect)(ref r)).yMax - num7 - 8f;
				float num9 = Mathf.Max(260f, num8 - num6);
				float num10 = 10f;
				float num11 = (s_isFullscreen ? Mathf.Clamp(((Rect)(ref r)).width * 0.48f, 540f, 740f) : Mathf.Clamp(((Rect)(ref r)).width * 0.48f, 500f, 560f));
				float num12 = (((Rect)(ref r)).width - 24f - num11 - num10 * 2f) * 0.5f;
				Rect playerArea = default(Rect);
				((Rect)(ref playerArea))..ctor(((Rect)(ref r)).x + 12f, num6, num12, num9);
				Rect gridArea = default(Rect);
				((Rect)(ref gridArea))..ctor(((Rect)(ref playerArea)).xMax + num10, num6, num11, num9);
				Rect sideArea = default(Rect);
				((Rect)(ref sideArea))..ctor(((Rect)(ref gridArea)).xMax + num10, num6, num12, num9);
				DrawPlayerCard(playerArea);
				DrawGridCard(gridArea);
				DrawSummaryCard(sideArea);
				Rect footerArea = default(Rect);
				((Rect)(ref footerArea))..ctor(((Rect)(ref r)).x + 12f, ((Rect)(ref r)).yMax - num7 - 4f, ((Rect)(ref r)).width - 24f, num7);
				DrawFooter(footerArea);
			}
		}

		private void DrawVaultNetworkRibbon(Rect rect, List<VaultRecord> vaults)
		{
			//IL_0001: 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_002f: 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_0070: 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_00bd: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: 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_0296: Unknown result type (might be due to invalid IL or missing references)
			DrawBox(rect, new Color(0.06f, 0.08f, 0.12f, 0.95f), new Color(0.2f, 0.25f, 0.35f, 0.8f));
			GUI.Label(new Rect(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y + 4f, 70f, 18f), "VAULTS:", GetTextStyle(11, bold: true, (TextAnchor)3, ColGoldText));
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref rect)).x + 80f, ((Rect)(ref rect)).y + 2f, ((Rect)(ref rect)).width - 86f, ((Rect)(ref rect)).height - 4f);
			vaultTabScroll = GUI.BeginScrollView(val, vaultTabScroll, new Rect(0f, 0f, (float)vaults.Count * 170f, 22f), GUIStyle.none, GUIStyle.none);
			Rect r = default(Rect);
			for (int i = 0; i < vaults.Count; i++)
			{
				VaultRecord vaultRecord = vaults[i];
				bool flag = (Object)(object)vault != (Object)null && string.Equals(vault.VaultId, vaultRecord.Id, StringComparison.OrdinalIgnoreCase);
				bool flag2 = (flag && !IsViewingRemote) || (IsViewingRemote && viewingRecord != null && string.Equals(viewingRecord.Id, vaultRecord.Id, StringComparison.OrdinalIgnoreCase));
				((Rect)(ref r))..ctor((float)i * 170f, 1f, 164f, 20f);
				Color val2 = ((!flag2) ? (flag ? new Color(0.22f, 0.2f, 0.12f, 0.9f) : new Color(0.1f, 0.13f, 0.18f, 0.9f)) : (flag ? new Color(0.18f, 0.4f, 0.22f, 1f) : new Color(0.15f, 0.35f, 0.55f, 1f)));
				Color hoverBg = (Color)(flag2 ? val2 : new Color(0.2f, 0.28f, 0.38f, 1f));
				Color textColor = (Color)(flag2 ? ColGoldText : (flag ? new Color(0.9f, 0.85f, 0.5f, 1f) : ColWhiteText));
				string text = (flag ? "★ " : "• ") + vaultRecord.Name;
				if (text.Length > 20)
				{
					text = text.Substring(0, 18) + "..";
				}
				if (CustomButton(r, text, val2, hoverBg, textColor, 11, flag2))
				{
					if (flag)
					{
						ReturnToLocal();
					}
					else
					{
						SelectRemoteVault(vaultRecord);
					}
				}
			}
			GUI.EndScrollView();
		}

		private void DrawMainHeader(Rect rect)
		{
			//IL_0001: 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_002f: 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_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: 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_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_053f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: 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_012a: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ca: 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_060c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: 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_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_0611: 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_047a: 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_062e: 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_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: 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_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0691: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0696: Unknown result type (might be due to invalid IL or missing references)
			//IL_0699: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_068a: 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_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: 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_04c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0752: Unknown result type (might be due to invalid IL or missing references)
			//IL_0757: Unknown result type (might be due to invalid IL or missing references)
			//IL_077f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0795: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07db: Unknown result type (might be due to invalid IL or missing references)
			//IL_074b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0744: Unknown result type (might be due to invalid IL or missing references)
			DrawBox(rect, new Color(0.1f, 0.13f, 0.18f, 0.95f), new Color(0.25f, 0.32f, 0.44f, 0.85f));
			float num = ((Rect)(ref rect)).x + 10f;
			if (!renaming)
			{
				string text = (IsViewingRemote ? viewingRecord.Name : (((Object)(object)vault != (Object)null) ? vault.VaultName : "Viking Vault"));
				GUI.Label(new Rect(num, ((Rect)(ref rect)).y + 4f, 160f, 32f), text, GetTextStyle(14, bold: true, (TextAnchor)3, ColGoldText));
				num += 165f;
				if (!IsViewingRemote && canMutate && (Object)(object)vault != (Object)null)
				{
					Rect r = default(Rect);
					((Rect)(ref r))..ctor(num, ((Rect)(ref rect)).y + 8f, 60f, 24f);
					if (CustomButton(r, "Rename", new Color(0.15f, 0.18f, 0.24f, 1f), new Color(0.24f, 0.3f, 0.42f, 1f), ColWhiteText, 11, bold: false))
					{
						renaming = true;
						renameInput = vault.VaultName;
					}
					num += 66f;
					Rect r2 = default(Rect);
					((Rect)(ref r2))..ctor(num, ((Rect)(ref rect)).y + 8f, 68f, 24f);
					Color bg = (vault.IsPinned ? new Color(0.42f, 0.32f, 0.12f, 1f) : new Color(0.15f, 0.18f, 0.24f, 1f));
					Color textColor = (vault.IsPinned ? ColGoldText : ColMutedText);
					if (CustomButton(r2, vault.IsPinned ? "★ Pinned" : "☆ Pin", bg, new Color(0.32f, 0.26f, 0.16f, 1f), textColor, 11, vault.IsPinned))
					{
						vault.SetPinned(!vault.IsPinned);
					}
					num += 74f;
				}
			}
			else
			{
				renameInput = GUI.TextField(new Rect(num, ((Rect)(ref rect)).y + 8f, 140f, 24f), renameInput, 25);
				num += 146f;
				if (CustomButton(new Rect(num, ((Rect)(ref rect)).y + 8f, 48f, 24f), "Save", new Color(0.14f, 0.38f, 0.2f, 1f), new Color(0.2f, 0.5f, 0.28f, 1f), ColWhiteText, 11))
				{
					if ((Object)(object)vault != (Object)null)
					{
						vault.SetVaultName(renameInput);
					}
					renaming = false;
					RefreshData();
				}
				num += 54f;
				if (CustomButton(new Rect(num, ((Rect)(ref rect)).y + 8f, 54f, 24f), "Cancel", new Color(0.22f, 0.16f, 0.16f, 1f), new Color(0.32f, 0.2f, 0.2f, 1f), ColWhiteText, 11, bold: false))
				{
					renaming = false;
				}
				num += 60f;
			}
			num += 10f;
			float num2 = 68f;
			Rect r3 = default(Rect);
			for (int i = 0; i < VaultUtil.TabLabels.Length; i++)
			{
				VaultTab vaultTab = (VaultTab)i;
				bool flag = tab == vaultTab;
				((Rect)(ref r3))..ctor(num + (float)i * (num2 + 4f), ((Rect)(ref rect)).y + 8f, num2, 24f);
				Color val = (flag ? new Color(0.28f, 0.22f, 0.1f, 1f) : new Color(0.12f, 0.15f, 0.2f, 0.9f));
				Color hoverBg = (Color)(flag ? val : new Color(0.18f, 0.24f, 0.34f, 1f));
				Color textColor2 = (flag ? ColGoldText : ColMutedText);
				Color value = (Color)(flag ? ColGoldText : new Color(0.2f, 0.25f, 0.35f, 0.8f));
				if (CustomButton(r3, VaultUtil.TabLabels[i], val, hoverBg, textColor2, 11, flag, value))
				{
					tab = vaultTab;
					selectedSlot = -1;
					status = "";
					RefreshData();
				}
			}
			float num3 = ((Rect)(ref rect)).xMax - 10f;
			Rect r4 = default(Rect);
			((Rect)(ref r4))..ctor(num3 - 30f, ((Rect)(ref rect)).y + 8f, 30f, 24f);
			if (CustomButton(r4, "✕", new Color(0.35f, 0.12f, 0.12f, 1f), new Color(0.65f, 0.18f, 0.18f, 1f), Color.white, 13))
			{
				Close();
			}
			num3 -= 36f;
			Rect r5 = default(Rect);
			((Rect)(ref r5))..ctor(num3 - 30f, ((Rect)(ref rect)).y + 8f, 30f, 24f);
			bool flag2 = ((Rect)(ref r5)).Contains(Event.current.mousePosition);
			Color bg2 = (s_isFullscreen ? new Color(0.26f, 0.2f, 0.1f, 1f) : new Color(0.14f, 0.18f, 0.25f, 1f));
			Color hoverBg2 = (s_isFullscreen ? new Color(0.38f, 0.3f, 0.14f, 1f) : new Color(0.22f, 0.28f, 0.38f, 1f));
			Color value2 = (Color)(s_isFullscreen ? ColGoldText : (flag2 ? new Color(0.4f, 0.75f, 1f, 0.9f) : new Color(0.24f, 0.3f, 0.4f, 0.85f)));
			if (CustomButton(r5, "", bg2, hoverBg2, ColWhiteText, 11, bold: true, value2))
			{
				s_isFullscreen = !s_isFullscreen;
			}
			DrawMaximizeIcon(r5, s_isFullscreen, flag2 ? ColGoldText : (s_isFullscreen ? ColGoldText : ColWhiteText));
			num3 -= 38f;
			Inventory currentInventory = CurrentInventory;
			if (currentInventory != null)
			{
				int num4 = currentInventory.NrOfItems();
				int num5 = currentInventory.GetWidth() * currentInventory.GetHeight();
				float num6 = (float)num4 / (float)Mathf.Max(1, num5);
				Color color = ((num6 > 0.9f) ? ColRedText : ((num6 > 0.75f) ? ColGoldText : ColGreenText));
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(num3 - 110f, ((Rect)(ref rect)).y + 8f, 105f, 24f);
				DrawBox(val2, new Color(0.06f, 0.08f, 0.12f, 0.9f), new Color(0.2f, 0.25f, 0.35f, 0.8f));
				GUI.Label(val2, $"{num4} / {num5} Slots", GetTextStyle(11, bold: true, (TextAnchor)4, color));
			}
		}

		private void DrawRemoteBanner(Rect rect)
		{
			//IL_0001: 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_002f: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			DrawBox(rect, new Color(0.08f, 0.18f, 0.26f, 0.95f), new Color(0.22f, 0.5f, 0.75f, 0.85f));
			GUI.Label(new Rect(((Rect)(ref rect)).x + 10f, ((Rect)(ref rect)).y + 3f, ((Rect)(ref rect)).width - 180f, 20f), $"<b>REMOTE SNAPSHOT:</b> {viewingRecord.Name} ({viewingRecord.Biome} — Tier {viewingRecord.Tier}, {viewingRecord.Width}x{viewingRecord.Height} slots) • <i>Read-Only</i>", GetTextStyle(11, bold: false, (TextAnchor)3, ColCyanText));
			Rect r = default(Rect);
			((Rect)(ref r))..ctor(((Rect)(ref rect)).xMax - 165f, ((Rect)(ref rect)).y + 3f, 155f, 20f);
			if (CustomButton(r, "↩ Return to Local Vault", new Color(0.14f, 0.4f, 0.22f, 1f), new Color(0.2f, 0.55f, 0.3f, 1f), ColWhiteText, 11))
			{
				ReturnToLocal();
			}
		}

		private void DrawGridCard(Rect gridArea)
		{
			//IL_00c5: 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_018f: Invalid comparison between Unknown and I4
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: 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_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: 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_0590: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Expected O, but got Unknown
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: 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_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_052e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_057f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0584: Unknown result type (might be due to invalid IL or missing references)
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			Inventory currentInventory = CurrentInventory;
			int num = ((currentInventory == null) ? 1 : currentInventory.GetWidth());
			int num2 = ((currentInventory == null) ? 1 : currentInventory.GetHeight());
			string badge = (((Object)(object)vault != (Object)null) ? $"Tier {vault.Tier} • {num}×{num2} ({num * num2} Slots)" : ((viewingRecord != null) ? $"Tier {viewingRecord.Tier} • {num}×{num2} ({num * num2} Slots)" : ""));
			DrawCard(gridArea, "VAULT HOARD", badge);
			float num3 = 32f;
			float num4 = ((Rect)(ref gridArea)).width - 16f;
			float num5 = ((Rect)(ref gridArea)).height - num3 - 12f;
			float num6 = 4f;
			float num7 = Mathf.Floor((num4 - (float)(num - 1) * num6) / (float)num);
			float num8 = (s_isFullscreen ? 66f : 54f);
			num7 = Mathf.Clamp(num7, 38f, num8);
			float num9 = num7 + num6;
			visibleRows = Mathf.Max(1, (int)(num5 / num9));
			visibleRows = Mathf.Min(visibleRows, num2);
			int num10 = Mathf.Max(0, num2 - visibleRows);
			scrollRow = Mathf.Clamp(scrollRow, 0, num10);
			if ((int)Event.current.type == 6 && ((Rect)(ref gridArea)).Contains(Event.current.mousePosition))
			{
				scrollRow += ((Event.current.delta.y > 0f) ? 1 : (-1));
				scrollRow = Mathf.Clamp(scrollRow, 0, num10);
				Event.current.Use();
			}
			float num11 = (float)num * num7 + (float)(num - 1) * num6;
			float num12 = (float)visibleRows * num7 + (float)(visibleRows - 1) * num6;
			float num13 = ((Rect)(ref gridArea)).x + (((Rect)(ref gridArea)).width - num11) * 0.5f;
			float num14 = ((Rect)(ref gridArea)).y + num3 + (num5 - num12) * 0.5f;
			if (num2 > visibleRows)
			{
				Rect val = new Rect(((Rect)(ref gridArea)).xMax - 140f, ((Rect)(ref gridArea)).y + 4f, 130f, 20f);
				string text = $"Rows {scrollRow + 1}-{scrollRow + visibleRows} / {num2}";
				GUI.Label(val, text, GetTextStyle(10, bold: false, (TextAnchor)5, ColMutedText));
			}
			Rect r = default(Rect);
			Rect val4 = default(Rect);
			Rect r2 = default(Rect);
			for (int i = scrollRow; i < scrollRow + visibleRows && i < num2; i++)
			{
				for (int j = 0; j < num; j++)
				{
					((Rect)(ref r))..ctor(num13 + (float)j * num9, num14 + (float)(i - scrollRow) * num9, num7, num7);
					int num15 = i * num + j;
					ItemData val2 = ((currentInventory != null) ? currentInventory.GetItemAt(j, i) : null);
					bool flag = ((Rect)(ref r)).Contains(Event.current.mousePosition);
					if (num15 == selectedSlot)
					{
						DrawBox(r, ColSlotSelectedBg, ColSlotSelectedBorder, 2f);
					}
					else if (flag)
					{
						DrawBox(r, new Color(0.18f, 0.24f, 0.35f, 0.95f), ColSlotHoverBorder, 1.5f);
					}
					else if (val2 != null)
					{
						DrawBox(r, ColSlotItemBg, ColSlotItemBorder);
					}
					else
					{
						DrawBox(r, ColSlotEmptyBg, ColSlotEmptyBorder);
					}
					if (val2 != null)
					{
						DrawIcon(Shrink(r, 3f), VaultUtil.Icon(val2.GetIcon()), whiteTex);
						if (val2.m_stack > 1)
						{
							string text2 = val2.m_stack.ToString();
							GUIStyle textStyle = GetTextStyle(10, bold: true, (TextAnchor)4, Color.white);
							Vector2 val3 = textStyle.CalcSize(new GUIContent(text2));
							((Rect)(ref val4))..ctor(((Rect)(ref r)).xMax - val3.x - 5f, ((Rect)(ref r)).yMax - val3.y - 2f, val3.x + 4f, val3.y + 1f);
							DrawBox(val4, new Color(0.04f, 0.06f, 0.1f, 0.9f), new Color(0.2f, 0.26f, 0.36f, 0.8f));
							GUI.Label(val4, text2, textStyle);
						}
						if (val2.m_shared != null && val2.m_shared.m_useDurability && val2.m_durability < val2.GetMaxDurability())
						{
							float num16 = Mathf.Clamp01(val2.GetDurabilityPercentage());
							((Rect)(ref r2))..ctor(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).yMax - 3f, ((Rect)(ref r)).width - 4f, 2f);
							DrawRect(r2, new Color(0f, 0f, 0f, 0.8f));
							Color c = ((num16 > 0.5f) ? ColGreenText : ((num16 > 0.25f) ? ColGoldText : ColRedText));
							DrawRect(new Rect(((Rect)(ref r2)).x, ((Rect)(ref r2)).y, ((Rect)(ref r2)).width * num16, ((Rect)(ref r2)).height), c);
						}
					}
					if ((int)Event.current.type == 0 && ((Rect)(ref r)).Contains(Event.current.mousePosition))
					{
						OnCellClick(num15, Event.current.button);
						Event.current.Use();
					}
				}
			}
		}

		private void OnCellClick(int index, int button)
		{
			if (busy)
			{
				return;
			}
			ItemData itemAt = GetItemAt(index);
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			switch (button)
			{
			case 0:
				if (selectedSlot == index && realtimeSinceStartup - lastClickTime < 0.35f && itemAt != null && !IsViewingRemote && canMutate)
				{
					TryTake(itemAt, itemAt.m_stack);
				}
				else
				{
					selectedSlot = index;
					if (itemAt == null)
					{
						status = "Empty slot selected.";
					}
					else
					{
						status = VaultUtil.Localize(itemAt.m_shared.m_name) + " x" + itemAt.m_stack + (IsViewingRemote ? " (Remote: View Only)" : "");
					}
				}
				lastClickTime = realtimeSinceStartup;
				lastClickedSlot = index;
				break;
			case 1:
				selectedSlot = index;
				if (itemAt != null)
				{
					if (IsViewingRemote)
					{
						status = "Remote vault is read-only.";
					}
					else if (!canMutate)
					{
						status = "Read-only: not your vault.";
					}
					else
					{
						TryTake(itemAt, 1);
					}
				}
				break;
			}
		}

		private ItemData GetItemAt(int index)
		{
			Inventory currentInventory = CurrentInventory;
			if (currentInventory == null || index < 0)
			{
				return null;
			}
			int width = currentInventory.GetWidth();
			return currentInventory.GetItemAt(index % width, index / width);
		}

		private void DrawPlayerCard(Rect playerArea)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00dd: 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_006e: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			DrawCard(playerArea, "PLAYER PACK", $"({playerItems.Count})");
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref playerArea)).x + 4f, ((Rect)(ref playerArea)).y + 32f, ((Rect)(ref playerArea)).width - 8f, ((Rect)(ref playerArea)).height - 36f);
			if (playerItems.Count == 0)
			{
				GUI.Label(val, "No items matching filter.", GetTextStyle(11, bold: false, (TextAnchor)4, ColMutedText));
				return;
			}
			Color backgroundColor = GUI.backgroundColor;
			GUI.backgroundColor = new Color(0.2f, 0.25f, 0.35f, 0.8f);
			playerScroll = GUI.BeginScrollView(val, playerScroll, new Rect(0f, 0f, ((Rect)(ref val)).width - 16f, (float)playerItems.Count * 36f));
			Rect r = default(Rect);
			Rect r2 = default(Rect);
			Rect r3 = default(Rect);
			for (int i = 0; i < playerItems.Count; i++)
			{
				VaultUtil.TypeEntry typeEntry = playerItems[i];
				((Rect)(ref r))..ctor(0f, (float)i * 36f, ((Rect)(ref val)).width - 16f, 32f);
				bool flag = ((Rect)(ref r)).Contains(Event.current.mousePosition + playerScroll);
				DrawBox(r, flag ? new Color(0.14f, 0.18f, 0.25f, 0.95f) : new Color(0.1f, 0.12f, 0.17f, 0.9f), flag ? new Color(0.3f, 0.4f, 0.55f, 0.8f) : new Color(0.16f, 0.2f, 0.28f, 0.7f));
				DrawIcon(new Rect(((Rect)(ref r)).x + 4f, ((Rect)(ref r)).y + 4f, 24f, 24f), VaultUtil.Icon(typeEntry.IconSprite), whiteTex);
				string text = typeEntry.DisplayName;
				if (text.Length > 16)
				{
					text = text.Substring(0, 14) + "..";
				}
				GUI.Label(new Rect(((Rect)(ref r)).x + 32f, ((Rect)(ref r)).y + 1f, ((Rect)(ref r)).width - 110f, 16f), text, GetTextStyle(11, bold: true, (TextAnchor)3, ColWhiteText));
				GUI.Label(new Rect(((Rect)(ref r)).x + 32f, ((Rect)(ref r)).y + 16f, 70f, 14f), $"x{typeEntry.Count}", GetTextStyle(10, bold: false, (TextAnchor)3, ColCyanText));
				if (!IsViewingRemote && canMutate)
				{
					((Rect)(ref r2))..ctor(((Rect)(ref r)).xMax - 66f, ((Rect)(ref r)).y + 4f, 28f, 24f);
					if (CustomButton(r2, "+1", new Color(0.12f, 0.32f, 0.18f, 1f), new Color(0.18f, 0.45f, 0.25f, 1f), ColWhiteText, 10))
					{
						TryDepositOne(typeEntry.NameKey);
					}
					((Rect)(ref r3))..ctor(((Rect)(ref r)).xMax - 34f, ((Rect)(ref r)).y + 4f, 32f, 24f);
					if (CustomButton(r3, "+All", new Color(0.14f, 0.38f, 0.22f, 1f), new Color(0.2f, 0.52f, 0.3f, 1f), ColWhiteText, 10))
					{
						TryDepositAllOfType(typeEntry.NameKey);
					}
				}
			}
			GUI.EndScrollView();
			GUI.backgroundColor = backgroundColor;
		}

		private void DrawSummaryCard(Rect sideArea)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00dd: 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_006e: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: 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_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			DrawCard(sideArea, "STORED TYPES", $"({sideItems.Count})");
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref sideArea)).x + 4f, ((Rect)(ref sideArea)).y + 32f, ((Rect)(ref sideArea)).width - 8f, ((Rect)(ref sideArea)).height - 36f);
			if (sideItems.Count == 0)
			{
				GUI.Label(val, "No items stored.", GetTextStyle(11, bold: false, (TextAnchor)4, ColMutedText));
				return;
			}
			Color backgroundColor = GUI.backgroundColor;
			GUI.backgroundColor = new Color(0.2f, 0.25f, 0.35f, 0.8f);
			sideScroll = GUI.BeginScrollView(val, sideScroll, new Rect(0f, 0f, ((Rect)(ref val)).width - 16f, (float)sideItems.Count * 36f));
			Rect r = default(Rect);
			Rect r2 = default(Rect);
			Rect r3 = default(Rect);
			for (int i = 0; i < sideItems.Count; i++)
			{
				VaultUtil.TypeEntry typeEntry = sideItems[i];
				((Rect)(ref r))..ctor(0f, (float)i * 36f, ((Rect)(ref val)).width - 16f, 32f);
				bool flag = ((Rect)(ref r)).Contains(Event.current.mousePosition + sideScroll);
				DrawBox(r, flag ? new Color(0.14f, 0.18f, 0.25f, 0.95f) : new Color(0.1f, 0.12f, 0.17f, 0.9f), flag ? new Color(0.3f, 0.4f, 0.55f, 0.8f) : new Color(0.16f, 0.2f, 0.28f, 0.7f));
				DrawIcon(new Rect(((Rect)(ref r)).x + 4f, ((Rect)(ref r)).y + 4f, 24f, 24f), VaultUtil.Icon(typeEntry.IconSprite), whiteTex);
				string text = typeEntry.DisplayName;
				if (text.Length > 16)
				{
					text = text.Substring(0, 14) + "..";
				}
				GUI.Label(new Rect(((Rect)(ref r)).x + 32f, ((Rect)(ref r)).y + 1f, ((Rect)(ref r)).width - 120f, 16f), text, GetTextStyle(11, bold: true, (TextAnchor)3, ColWhiteText));
				GUI.Label(new Rect(((Rect)(ref r)).x + 32f, ((Rect)(ref r)).y + 16f, 90f, 14f), $"{typeEntry.Count} ({typeEntry.Slots}s)", GetTextStyle(10, bold: false, (TextAnchor)3, ColGoldText));
				((Rect)(ref r2))..ctor(((Rect)(ref r)).xMax - 78f, ((Rect)(ref r)).y + 4f, 36f, 24f);
				if (CustomButton(r2, "Find", new Color(0.14f, 0.2f, 0.3f, 1f), new Color(0.2f, 0.3f, 0.45f, 1f), ColCyanText, 10, bold: false))
				{
					LocateType(typeEntry.NameKey);
				}
				if (!IsViewingRemote && canMutate)
				{
					((Rect)(ref r3))..ctor(((Rect)(ref r)).xMax - 38f, ((Rect)(ref r)).y + 4f, 36f, 24f);
					if (CustomButton(r3, "Take", new Color(0.32f, 0.2f, 0.12f, 1f), new Color(0.48f, 0.28f, 0.16f, 1f), ColGoldText, 10))
					{
						TryTakeAllOfType(typeEntry.NameKey);
					}
				}
			}
			GUI.EndScrollView();
			GUI.backgroundColor = backgroundColor;
		}

		private void LocateType(string nameKey)
		{
			Inventory currentInventory = CurrentInventory;
			if (currentInventory == null)
			{
				return;
			}
			int width = currentInventory.GetWidth();
			int height = currentInventory.GetHeight();
			for (int i = 0; i < height; i++)
			{
				for (int j = 0; j < width; j++)
				{
					ItemData itemAt = currentInventory.GetItemAt(j, i);
					if (itemAt != null && itemAt.m_shared != null && itemAt.m_shared.m_name == nameKey)
					{
						int num = (selectedSlot = i * width + j);
						int num2 = Mathf.Max(0, height - Mathf.Max(1, visibleRows));
						scrollRow = Mathf.Clamp(i, 0, num2);
						status = VaultUtil.Localize(nameKey) + " located at slot " + (num + 1) + ".";
						return;
					}
				}
			}
		}

		private void DrawFooter(Rect footerArea)
		{
			//IL_0082: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			float num = 92f;
			float num2 = ((Rect)(ref footerArea)).width * 0.48f;
			float num3 = ((Rect)(ref footerArea)).width - num2 - 10f;
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(((Rect)(ref footerArea)).x, ((Rect)(ref footerArea)).y, num2, num);
			Rect rect2 = default(Rect);
			((Rect)(ref rect2))..ctor(((Rect)(ref rect)).xMax + 10f, ((Rect)(ref footerArea)).y, num3, num);
			Rect rect3 = default(Rect);
			((Rect)(ref rect3))..ctor(((Rect)(ref footerArea)).x, ((Rect)(ref footerArea)).y + num + 4f, ((Rect)(ref footerArea)).width, 22f);
			DrawSelectedItemCard(rect);
			DrawCapacityForgeCard(rect2);
			DrawStatusBar(rect3);
		}

		private void DrawSelectedItemCard(Rect rect)
		{
			//IL_0001: 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_0059: 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_006d: 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_00cf: 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_013d: 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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: 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_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: 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_035d: 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_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			DrawCard(rect, "SELECTED ITEM");
			ItemData val = ((selectedSlot >= 0) ? GetItemAt(selectedSlot) : null);
			if (val != null)
			{
				Rect r = default(Rect);
				((Rect)(ref r))..ctor(((Rect)(ref rect)).x + 10f, ((Rect)(ref rect)).y + 34f, 48f, 48f);
				DrawBox(r, ColSlotItemBg, ColWindowBorder);
				DrawIcon(Shrink(r, 4f), VaultUtil.Icon(val.GetIcon()), whiteTex);
				float num = ((Rect)(ref r)).xMax + 10f;
				string text = VaultUtil.Localize(val.m_shared.m_name);
				GUI.Label(new Rect(num, ((Rect)(ref rect)).y + 32f, ((Rect)(ref rect)).width - num - 140f, 18f), text, GetTextStyle(13, bold: true, (TextAnchor)3, ColGoldText));
				string text2 = $"Stack: {val.m_stack} / {val.m_shared.m_maxStackSize}  •  Weight: {val.GetWeight(-1):0.#}";
				GUI.Label(new Rect(num, ((Rect)(ref rect)).y + 50f, ((Rect)(ref rect)).width - num - 140f, 16f), text2, GetTextStyle(10, bold: false, (TextAnchor)3, ColMutedText));
				string text3 = $"Slot {selectedSlot + 1}  •  {val.m_shared.m_itemType}";
				GUI.Label(new Rect(num, ((Rect)(ref rect)).y + 66f, ((Rect)(ref rect)).width - num - 140f, 16f), text3, GetTextStyle(10, bold: false, (TextAnchor)3, ColCyanText));
				if (!IsViewingRemote && canMutate)
				{
					float num2 = 60f;
					Rect r2 = default(Rect);
					((Rect)(ref r2))..ctor(((Rect)(ref rect)).xMax - 130f, ((Rect)(ref rect)).y + 36f, num2, 22f);
					if (CustomButton(r2, "Take 1", new Color(0.18f, 0.24f, 0.35f, 1f), new Color(0.25f, 0.35f, 0.5f, 1f), ColWhiteText, 11, bold: false))
					{
						TryTake(val, 1);
					}
					Rect r3 = default(Rect);
					((Rect)(ref r3))..ctor(((Rect)(ref rect)).xMax - 66f, ((Rect)(ref rect)).y + 36f, num2, 22f);
					if (CustomButton(r3, "Take All", new Color(0.35f, 0.22f, 0.12f, 1f), new Color(0.5f, 0.32f, 0.16f, 1f), ColGoldText, 11))
					{
						TryTake(val, val.m_stack);
					}
				}
				else if (IsViewingRemote)
				{
					Rect val2 = default(Rect);
					((Rect)(ref val2))..ctor(((Rect)(ref rect)).xMax - 130f, ((Rect)(ref rect)).y + 42f, 120f, 22f);
					DrawBox(val2, new Color(0.1f, 0.15f, 0.22f, 0.9f), new Color(0.2f, 0.35f, 0.5f, 0.8f));
					GUI.Label(val2, "Remote View", GetTextStyle(10, bold: false, (TextAnchor)4, ColCyanText));
				}
			}
			else
			{
				string text4 = ((selectedSlot >= 0) ? $"Slot {selectedSlot + 1} is empty." : "Click any slot to inspect or withdraw. Right-click to take 1.");
				GUI.Label(new Rect(((Rect)(ref rect)).x + 12f, ((Rect)(ref rect)).y + 42f, ((Rect)(ref rect)).width - 24f, 24f), text4, GetTextStyle(11, bold: false, (TextAnchor)3, ColMutedText));
			}
		}

		private void DrawCapacityForgeCard(Rect rect)
		{
			//IL_0017: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_050e: Unknown result type (might be due to invalid IL or missing references)
			//IL_051c: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Unknown result type (might be due to invalid IL or missing references)
			//IL_056b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: 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_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: 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_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: 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_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Expected O, but got Unknown
			//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_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: 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)
			//IL_02dc: 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)
			if (IsViewingRemote || (Object)(object)vault == (Object)null)
			{
				DrawCard(rect, "CAPACITY FORGE", "Remote Snapshot");
				GUI.Label(new Rect(((Rect)(ref rect)).x + 12f, ((Rect)(ref rect)).y + 42f, ((Rect)(ref rect)).width - 24f, 24f), "Upgrades must be forged at the physical vault.", GetTextStyle(11, bold: false, (TextAnchor)3, ColMutedText));
				return;
			}
			int tier = vault.Tier;
			string text = VaultController.TierNames[tier - 1];
			int num = VaultController.TierWidths[tier - 1] * VaultController.TierHeights[tier - 1];
			DrawCard(rect, "CAPACITY FORGE", $"Tier {tier} ({num} Slots)");
			if (tier < VaultController.MaxTier)
			{
				int num2 = tier + 1;
				string arg = VaultController.TierNames[num2 - 1];
				int num3 = VaultController.TierWidths[num2 - 1] * VaultController.TierHeights[num2 - 1];
				Player localPlayer = Player.m_localPlayer;
				Inventory val = (((Object)(object)localPlayer != (Object)null) ? ((Humanoid)localPlayer).GetInventory() : null);
				string missingReason;
				bool flag = VaultUtil.CanAffordTier(val, num2, out missingReason);
				List<VaultUtil.UpgradeRequirement> tierRequirements = VaultUtil.GetTierRequirements(num2);
				float num4 = ((Rect)(ref rect)).x + 12f;
				GUI.Label(new Rect(num4, ((Rect)(ref rect)).y + 30f, 220f, 16f), $"Tier {num2}: {arg} ({num3} Slots)", GetTextStyle(11, bold: true, (TextAnchor)3, ColGoldText));
				num4 = ((Rect)(ref rect)).x + 12f;
				Rect val3 = default(Rect);
				for (int i = 0; i < tierRequirements.Count; i++)
				{
					VaultUtil.UpgradeRequirement upgradeRequirement = tierRequirements[i];
					int num5 = VaultUtil.CountItem(val, upgradeRequirement.PrefabName);
					bool flag2 = num5 >= upgradeRequirement.Amount;
					string text2 = string.Format("{0} {1}: {2}/{3}", flag2 ? "✓" : "✗", upgradeRequirement.DisplayName, num5, upgradeRequirement.Amount);
					Color bg = (flag2 ? new Color(0.1f, 0.26f, 0.16f, 0.9f) : new Color(0.28f, 0.12f, 0.12f, 0.9f));
					Color border = (flag2 ? new Color(0.2f, 0.5f, 0.28f, 0.8f) : new Color(0.55f, 0.2f, 0.2f, 0.8f));
					Color color = (flag2 ? ColGreenText : ColRedText);
					GUIStyle textStyle = GetTextStyle(10, bold: true, (TextAnchor)4, color);
					Vector2 val2 = textStyle.CalcSize(new GUIContent(text2));
					((Rect)(ref val3))..ctor(num4, ((Rect)(ref rect)).y + 54f, val2.x + 10f, 20f);
					DrawBox(val3, bg, border);
					GUI.Label(val3, text2, textStyle);
					num4 += val2.x + 16f;
				}
				Rect r = default(Rect);
				((Rect)(ref r))..ctor(((Rect)(ref rect)).xMax - 180f, ((Rect)(ref rect)).y + 36f, 170f, 38f);
				if (flag)
				{
					if (CustomButton(r, $"▲ Forge Tier {num2}\n({num3} Slots)", new Color(0