Decompiled source of XRayVision v2.2.3

XRayVision.dll

Decompiled 6 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using ServerSync;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using XRayVision.Utilities;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: Guid("52A07436-6260-495C-8DD0-138AF8D44323")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyProduct("XRayVision")]
[assembly: AssemblyCompany("Azumatt")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("XRayVision")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyFileVersion("2.2.3")]
[assembly: AssemblyConfiguration("")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.2.3.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<55a6475b-61ed-4ddb-b902-1b51e81324b8>Embedded]
	internal sealed class <55a6475b-61ed-4ddb-b902-1b51e81324b8>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[<55a6475b-61ed-4ddb-b902-1b51e81324b8>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <e42f466c-a03d-41ed-b958-4dbecb2066d7>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <e42f466c-a03d-41ed-b958-4dbecb2066d7>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <e42f466c-a03d-41ed-b958-4dbecb2066d7>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[<55a6475b-61ed-4ddb-b902-1b51e81324b8>Embedded]
	[CompilerGenerated]
	internal sealed class <f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace XRayVision
{
	[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
	[BepInPlugin("Azumatt.XRayVision", "XRayVision", "2.2.3")]
	[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(0)]
	public class XRayVisionPlugin : BaseUnityPlugin
	{
		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(0)]
		public enum Toggle
		{
			Off,
			On
		}

		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(0)]
		private class ConfigurationManagerAttributes
		{
			public int? Order;

			[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(2)]
			public string Category;
		}

		[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(0)]
		private class AcceptableShortcuts : AcceptableValueBase
		{
			public AcceptableShortcuts()
				: base(typeof(KeyboardShortcut))
			{
			}

			public override object Clamp(object value)
			{
				return value;
			}

			public override bool IsValid(object value)
			{
				return true;
			}

			public override string ToDescriptionString()
			{
				return "# Acceptable values: " + string.Join(", ", UnityInput.Current.SupportedKeyCodes);
			}
		}

		public const string ModVersion = "2.2.3";

		public const string ModName = "XRayVision";

		internal const string Author = "Azumatt";

		internal const string ModGuid = "Azumatt.XRayVision";

		private static string ConfigFileName = "Azumatt.XRayVision.cfg";

		private static string ConfigFileFullPath;

		internal static bool IsAdmin;

		internal static bool IsModerator;

		internal static string ModeratorPermsConfigPath;

		internal const string ModbypassFileName = "XRayVision_ModeratorList.yml";

		internal static SortedDictionary<string, ModeratorPerms> ModeratorConfigs;

		internal static string ConnectionError;

		internal static XRayVisionPlugin instance;

		internal static GameObject RootObject;

		[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(2)]
		internal static Harmony _harmony;

		internal static readonly ManualLogSource XRayLogger;

		internal static readonly ConfigSync configSync;

		internal static CustomSyncedValue<string> ModeratorPermsConfigData;

		protected internal static string ID;

		public static GameObject BorrowedTooltip;

		public static GameObject ToolTipGameObject;

		public static XRayProps PropertiesText;

		public static string CleanCopy;

		private static ConfigEntry<Toggle> _serverConfigLocked;

		internal static ConfigEntry<Toggle> ToggleTooltip;

		public static ConfigEntry<KeyboardShortcut> DisableVisuals;

		public static ConfigEntry<KeyboardShortcut> CopyHotkey;

		internal static ConfigEntry<Color> PrefabNameColor;

		internal static ConfigEntry<Color> ModSourceColor;

		internal static ConfigEntry<Color> PieceNameColor;

		internal static ConfigEntry<Color> CreatedColor;

		internal static ConfigEntry<Color> CreatorIDColor;

		internal static ConfigEntry<Color> CreatorNameColor;

		internal static ConfigEntry<Color> CreatorSteamInfoColor;

		internal static ConfigEntry<Color> OwnerColor;

		internal static ConfigEntry<string> LeftSeperator;

		internal static ConfigEntry<string> RightSeperator;

		internal static ConfigEntry<Vector2> ToolTipPosition;

		internal static ConfigEntry<int> ToolTipTextSize;

		internal static ConfigEntry<int> ToolTipTitleSize;

		internal static ConfigEntry<Color> ToolTipBkgColor;

		private void Awake()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Expected O, but got Unknown
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Expected O, but got Unknown
			//IL_0217: 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_0246: Expected O, but got Unknown
			//IL_026a: 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_0299: Expected O, but got Unknown
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Expected O, but got Unknown
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Expected O, but got Unknown
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Expected O, but got Unknown
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Expected O, but got Unknown
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Expected O, but got Unknown
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Expected O, but got Unknown
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Expected O, but got Unknown
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ff: Expected O, but got Unknown
			//IL_053a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Expected O, but got Unknown
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_058b: Expected O, but got Unknown
			//IL_065a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0664: Expected O, but got Unknown
			//IL_0674: Unknown result type (might be due to invalid IL or missing references)
			//IL_067e: Expected O, but got Unknown
			instance = this;
			_serverConfigLocked = config("General", "Force Server Config", Toggle.On, new ConfigDescription("If on, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "1 - General",
					Order = 4
				}
			}));
			configSync?.AddLockingConfigEntry<Toggle>(_serverConfigLocked);
			ToggleTooltip = config("General", "Toggle Tooltip", Toggle.On, new ConfigDescription("If on, the tooltip will be visible when you hover over an item and the tooltip is toggled to show content. If off, the tooltip will be hidden until you hold down your Disable XRayVision Keyboard shortcut.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "1 - General",
					Order = 3
				}
			}), synchronizedSetting: false);
			DisableVisuals = config<KeyboardShortcut>("General", "Disable XRayVision", new KeyboardShortcut((KeyCode)103, Array.Empty<KeyCode>()), new ConfigDescription("Custom shortcut to enable or disable the tooltip. Depending on the configuration, the tooltip will be hidden or visible when you hold down or press this key.", (AcceptableValueBase)(object)new AcceptableShortcuts(), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "1 - General",
					Order = 2
				}
			}), synchronizedSetting: false);
			CopyHotkey = config<KeyboardShortcut>("General", "Copy Information Shortcut", new KeyboardShortcut((KeyCode)104, Array.Empty<KeyCode>()), new ConfigDescription("Custom shortcut to copy the current tooltip information to the clipboard.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "1 - General",
					Order = 1
				}
			}), synchronizedSetting: false);
			PrefabNameColor = config<Color>("Colors", "Prefab Name Color", new Color(0.2f, 0.62f, 0.4f, 1f), new ConfigDescription("Color of the Prefab Name Hover text.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "2 - Colors"
				}
			}), synchronizedSetting: false);
			ModSourceColor = config<Color>("Colors", "Mod Source Color", new Color(0.2f, 0.77f, 0.4f, 1f), new ConfigDescription("Color of the Mod Source Hover text.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "2 - Colors"
				}
			}), synchronizedSetting: false);
			PieceNameColor = config<Color>("Colors", "Piece Name Color", new Color(0.2f, 1f, 0.4f, 1f), new ConfigDescription("Color of the Piece Name Hover text.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "2 - Colors"
				}
			}), synchronizedSetting: false);
			CreatedColor = config<Color>("Colors", "Created Time Color", new Color(0.02f, 0.51f, 0.51f, 1f), new ConfigDescription("Color of the Created Time Hover text.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "2 - Colors"
				}
			}), synchronizedSetting: false);
			CreatorIDColor = config<Color>("Colors", "Creator ID Color", new Color(0f, 0.686f, 0.83f, 1f), new ConfigDescription("Color of the Creator ID Hover text.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "2 - Colors"
				}
			}), synchronizedSetting: false);
			CreatorNameColor = config<Color>("Colors", "Creator Name Color", new Color(0f, 0.686f, 0.83f, 1f), new ConfigDescription("Color of the Creator Name Hover text.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "2 - Colors"
				}
			}), synchronizedSetting: false);
			CreatorSteamInfoColor = config<Color>("Colors", "Creator Steam Info Color", new Color(0.585f, 0.858f, 0.898f, 1f), new ConfigDescription("Color of the Steam Information Hover text.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "2 - Colors"
				}
			}), synchronizedSetting: false);
			OwnerColor = config<Color>("Colors", "Owner Info Color", new Color(0.756f, 0.917f, 0.941f, 1f), new ConfigDescription("Color of the Owner Hover text.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "2 - Colors"
				}
			}), synchronizedSetting: false);
			ToolTipBkgColor = config<Color>("Attribute Wrapper", "Tooltip Background Color", new Color(0f, 0f, 0f, 0.945f), new ConfigDescription("Color of the background of the tooltip.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "2 - Colors"
				}
			}), synchronizedSetting: false);
			LeftSeperator = config("Attribute Wrapper", "Left", "「", new ConfigDescription("Text to be shown to the left of the attribute labels", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "3 - Attribute Wrapper"
				}
			}), synchronizedSetting: false);
			RightSeperator = config("Attribute Wrapper", "Right", "」", new ConfigDescription("Text to be shown between the attribute labels and the attribute information.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "3 - Attribute Wrapper"
				}
			}), synchronizedSetting: false);
			ToolTipPosition = config<Vector2>("Attribute Wrapper", "Tooltip Position", new Vector2(-500f, 50f), new ConfigDescription("Text to be shown between the attribute labels and the attribute information.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "3 - Attribute Wrapper"
				}
			}), synchronizedSetting: false);
			ToolTipTextSize = config("Attribute Wrapper", "Tooltip Text Size", 16, new ConfigDescription("Font size for the tooltip text", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, int.MaxValue), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "3 - Attribute Wrapper"
				}
			}), synchronizedSetting: false);
			ToolTipTitleSize = config("Attribute Wrapper", "Tooltip Title Size", 18, new ConfigDescription("Font size for the tooltip title text", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, int.MaxValue), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "3 - Attribute Wrapper"
				}
			}), synchronizedSetting: false);
			ToolTipBkgColor.SettingChanged += [<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(0)] (object _, EventArgs _) =>
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)ToolTipGameObject != (Object)null)
				{
					((Graphic)PropertiesText.backgroundcomp).color = ToolTipBkgColor.Value;
				}
			};
			ToolTipPosition.SettingChanged += [<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(0)] (object _, EventArgs _) =>
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				RectTransform val = default(RectTransform);
				if ((Object)(object)ToolTipGameObject != (Object)null && ToolTipGameObject.TryGetComponent<RectTransform>(ref val))
				{
					val.anchoredPosition = ToolTipPosition.Value;
				}
			};
			ToolTipTextSize.SettingChanged += [<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(0)] (object _, EventArgs _) =>
			{
				if ((Object)(object)ToolTipGameObject != (Object)null)
				{
					PropertiesText.textcomp.fontSize = ToolTipTextSize.Value;
				}
			};
			ToolTipTitleSize.SettingChanged += [<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(0)] (object _, EventArgs _) =>
			{
				if ((Object)(object)ToolTipGameObject != (Object)null)
				{
					PropertiesText.titlecomp.fontSize = ToolTipTitleSize.Value;
				}
			};
			ModeratorPermsConfigData.ValueChanged += OnValChangedUpdate;
			LoadTooltipAsset("xraytooltip");
			ToolTipGameObject = new GameObject("XRayVisionPropertiesText");
			ToolTipGameObject.SetActive(false);
			_harmony = new Harmony("Azumatt.XRayVision");
			_harmony.PatchAll();
			SetupWatcher();
		}

		private void Start()
		{
			FileHandler.ModeratorListCreate();
			Game.isModded = true;
			AssetLoadTracker.MapPrefabsToBundles();
			AssetLoadTracker.MapBundlesToAssemblies();
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}

		private void SetupWatcher()
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName);
			fileSystemWatcher.Changed += ReadConfigValues;
			fileSystemWatcher.Created += ReadConfigValues;
			fileSystemWatcher.Renamed += ReadConfigValues;
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
			FileSystemWatcher fileSystemWatcher2 = new FileSystemWatcher(Paths.ConfigPath, "XRayVision_ModeratorList.yml");
			fileSystemWatcher2.Changed += ReadYamlConfigFile;
			fileSystemWatcher2.Created += ReadYamlConfigFile;
			fileSystemWatcher2.Renamed += ReadYamlConfigFile;
			fileSystemWatcher2.IncludeSubdirectories = true;
			fileSystemWatcher2.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher2.EnableRaisingEvents = true;
		}

		private void ReadConfigValues(object sender, FileSystemEventArgs e)
		{
			if (!File.Exists(ConfigFileFullPath))
			{
				return;
			}
			try
			{
				XRayLogger.LogDebug((object)"ReadConfigValues called");
				((BaseUnityPlugin)this).Config.Reload();
			}
			catch
			{
				XRayLogger.LogError((object)("There was an issue loading your " + ConfigFileName));
				XRayLogger.LogError((object)"Please check your config entries for spelling and format!");
			}
		}

		internal static void ReadYamlConfigFile(object sender, FileSystemEventArgs e)
		{
			if (!File.Exists(ModeratorPermsConfigPath))
			{
				return;
			}
			try
			{
				XRayLogger.LogDebug((object)"ReadYamlConfigFile called");
				StreamReader streamReader = File.OpenText(ModeratorPermsConfigPath);
				ModeratorConfigs = new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).Build().Deserialize<SortedDictionary<string, ModeratorPerms>>(streamReader);
				streamReader.Close();
				ModeratorPermsConfigData.AssignLocalValue(File.ReadAllText(ModeratorPermsConfigPath));
			}
			catch
			{
				XRayLogger.LogError((object)"There was an issue loading your XRayVision_ModeratorList.yml");
				XRayLogger.LogError((object)"Please check your config entries for spelling and format!");
			}
		}

		private static void OnValChangedUpdate()
		{
			IDeserializer deserializer = new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).Build();
			XRayLogger.LogDebug((object)"Moderator Perms OnValChanged called");
			try
			{
				ModeratorConfigs = new SortedDictionary<string, ModeratorPerms>(deserializer.Deserialize<Dictionary<string, ModeratorPerms>>(ModeratorPermsConfigData.Value) ?? new Dictionary<string, ModeratorPerms>());
				foreach (ModeratorPerms value in ModeratorConfigs.Values)
				{
					ModeratorPerms current = value;
					bool? showSteamInformation = current.ShowSteamInformation;
					bool valueOrDefault = showSteamInformation.GetValueOrDefault();
					if (!showSteamInformation.HasValue)
					{
						valueOrDefault = false;
						bool? flag2 = (current.ShowSteamInformation = valueOrDefault);
					}
				}
				IsModerator = ModeratorConfigs.ContainsKey(ID);
			}
			catch (Exception arg)
			{
				XRayLogger.LogError((object)$"Failed to deserialize Moderator Config File: {arg}");
			}
		}

		private void LoadTooltipAsset(string bundleName)
		{
			AssetBundle assetBundleFromResources = GetAssetBundleFromResources(bundleName);
			BorrowedTooltip = assetBundleFromResources.LoadAsset<GameObject>("TESTTT");
			BorrowedTooltip.AddComponent<XRayProps>();
			if (assetBundleFromResources != null)
			{
				assetBundleFromResources.Unload(false);
			}
		}

		private static AssetBundle GetAssetBundleFromResources(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single([<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(0)] (string str) => str.EndsWith(filename));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			return AssetBundle.LoadFromStream(stream);
		}

		private ConfigEntry<T> config<[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags);
			ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val);
			configSync.AddConfigEntry<T>(val2).SynchronizedConfig = synchronizedSetting;
			return val2;
		}

		private ConfigEntry<T> config<[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}

		static XRayVisionPlugin()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
			IsAdmin = false;
			IsModerator = false;
			ModeratorPermsConfigPath = null;
			ModeratorConfigs = new SortedDictionary<string, ModeratorPerms>();
			ConnectionError = "";
			instance = null;
			RootObject = null;
			XRayLogger = Logger.CreateLogSource("XRayVision");
			configSync = new ConfigSync("XRayVision")
			{
				DisplayName = "XRayVision",
				CurrentVersion = "2.2.3",
				MinimumRequiredVersion = "2.2.3"
			};
			ModeratorPermsConfigData = new CustomSyncedValue<string>(configSync, "XRayModeratorPerms", "");
			ID = "";
			BorrowedTooltip = null;
			ToolTipGameObject = null;
			PropertiesText = null;
			CleanCopy = "";
			_serverConfigLocked = null;
			ToggleTooltip = null;
			DisableVisuals = null;
			CopyHotkey = null;
			PrefabNameColor = null;
			ModSourceColor = null;
			PieceNameColor = null;
			CreatedColor = null;
			CreatorIDColor = null;
			CreatorNameColor = null;
			CreatorSteamInfoColor = null;
			OwnerColor = null;
			LeftSeperator = null;
			RightSeperator = null;
			ToolTipPosition = null;
			ToolTipTextSize = null;
			ToolTipTitleSize = null;
			ToolTipBkgColor = null;
		}
	}
}
namespace XRayVision.Utilities
{
	[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(0)]
	[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
	public class AssetLoadTracker
	{
		[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(new byte[] { 1, 2, 1 })]
		private static readonly Dictionary<string, string> PrefabToBundleMapping = new Dictionary<string, string>();

		private static readonly Dictionary<string, Assembly> BundleToAssemblyMapping = new Dictionary<string, Assembly>();

		internal static void MapPrefabsToBundles()
		{
			foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles())
			{
				foreach (string item in from name in allLoadedAssetBundle.GetAllAssetNames()
					where name.EndsWith(".prefab")
					select name)
				{
					string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item);
					PrefabToBundleMapping[fileNameWithoutExtension] = ((Object)allLoadedAssetBundle).name;
				}
			}
		}

		internal static void MapBundlesToAssemblies()
		{
			List<Assembly> list = Chainloader.PluginInfos.Select([<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(0)] (KeyValuePair<string, PluginInfo> keyValuePair) => ((object)keyValuePair.Value.Instance).GetType().Assembly).ToList();
			foreach (string bundleName in PrefabToBundleMapping.Values.Distinct())
			{
				foreach (Assembly item in list)
				{
					try
					{
						if (item.GetManifestResourceNames().Any([<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(0)] (string resourceName) => resourceName.EndsWith(bundleName)))
						{
							BundleToAssemblyMapping[bundleName] = item;
							break;
						}
					}
					catch (Exception arg)
					{
						XRayVisionPlugin.XRayLogger.LogError((object)$"Error while getting manifest resource names for assembly {item.GetName().Name}: {arg}");
					}
				}
			}
		}

		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(2)]
		public static Assembly GetAssemblyForPrefab(string prefabName)
		{
			if (PrefabToBundleMapping.TryGetValue(prefabName, out var value) && BundleToAssemblyMapping.TryGetValue(value, out var value2))
			{
				return value2;
			}
			return null;
		}

		public static string GetBundleForPrefab([<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(2)] string prefabName)
		{
			if (!PrefabToBundleMapping.TryGetValue(prefabName, out var value))
			{
				return "";
			}
			return value;
		}
	}
	[Serializable]
	public struct ModeratorPerms
	{
		[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(2)]
		public string moderatorID;

		[YamlMember(Alias = "Steam Display", ApplyNamingConventions = false)]
		public bool? ShowSteamInformation { get; set; }

		public ModeratorPerms()
		{
			moderatorID = null;
			ShowSteamInformation = null;
		}
	}
	[Serializable]
	[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
	[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(0)]
	public static class SerializeUtils
	{
		public static IEnumerable<ModeratorPerms> Parse(string yaml)
		{
			return new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, ModeratorPerms>>(yaml)
				.Select([<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(0)] (KeyValuePair<string, ModeratorPerms> kv) =>
				{
					ModeratorPerms value = kv.Value;
					value.moderatorID = kv.Key;
					return value;
				});
		}

		public static string ToYaml(SortedDictionary<string, string> modDefaultList)
		{
			return new SerializerBuilder().DisableAliases().WithNamingConvention(PascalCaseNamingConvention.Instance).Build()
				.Serialize(modDefaultList);
		}

		public static string ToYAML(this ModeratorPerms self)
		{
			return new SerializerBuilder().DisableAliases().WithNamingConvention(PascalCaseNamingConvention.Instance).Build()
				.Serialize(self);
		}

		public static SortedDictionary<string, string> FromYaml(string yaml)
		{
			return new DeserializerBuilder().WithNamingConvention(UnderscoredNamingConvention.Instance).Build().Deserialize<SortedDictionary<string, string>>(yaml);
		}
	}
	public class FileHandler
	{
		internal static void ModeratorListCreate()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			XRayVisionPlugin.ModeratorPermsConfigPath = configPath + directorySeparatorChar + "XRayVision_ModeratorList.yml";
			string configPath2 = Paths.ConfigPath;
			directorySeparatorChar = Path.DirectorySeparatorChar;
			if (!File.Exists(configPath2 + directorySeparatorChar + "XRayVision_ModeratorList.yml"))
			{
				string configPath3 = Paths.ConfigPath;
				directorySeparatorChar = Path.DirectorySeparatorChar;
				using StreamWriter streamWriter = File.CreateText(configPath3 + directorySeparatorChar + "XRayVision_ModeratorList.yml");
				streamWriter.Write((object?)new StringBuilder().AppendLine("# Configure your per Moderator permissions in this file. Currently there is only one, but we can add more as the suggestions are made.").AppendLine("# Fill out more moderators just like the example given. This uses their Steam64ID as the key.").AppendLine("")
					.AppendLine("12345678998765432:")
					.AppendLine("  Steam Display: false  # When set to true, moderators can see the user's steam information.")
					.AppendLine(""));
				streamWriter.Close();
			}
		}
	}
	[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
	[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(0)]
	internal static class HoverAdditions
	{
		public static bool HoverTextDisplay;

		public static string AddHoverText(GameObject gobj, ref string __result, bool needItCleanJack = false)
		{
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			StringBuilder stringBuilder = new StringBuilder();
			Tuple<ZNetView, GameObject> zNetView = GetZNetView(gobj);
			if (!XRayVisionPlugin.IsModerator && !XRayVisionPlugin.IsAdmin)
			{
				return __result;
			}
			if (!needItCleanJack)
			{
				stringBuilder.Append(GetVisualButtonText());
				stringBuilder.Append(GetCopyButtonText());
			}
			if (!Object.op_Implicit((Object)(object)zNetView.Item1) || !zNetView.Item1.IsValid())
			{
				return __result = __result + "\n\n" + stringBuilder;
			}
			stringBuilder.Append(GetPrefabString(zNetView.Item1, needItCleanJack));
			stringBuilder.Append(GetModSource(zNetView.Item1, needItCleanJack));
			if (Object.op_Implicit((Object)(object)zNetView.Item2.GetComponent<Piece>()))
			{
				stringBuilder.Append(GetPieceString(zNetView.Item2, needItCleanJack));
			}
			if (Object.op_Implicit((Object)(object)zNetView.Item2.GetComponent<ItemDrop>()))
			{
				stringBuilder.Append(GetItemString(zNetView.Item2, needItCleanJack));
			}
			stringBuilder.Append(GetCreationString(zNetView.Item1, needItCleanJack));
			if (ZDOExtraData.s_ints.TryGetValue(zNetView.Item1.m_zdo.m_uid, out var value) && value.Count > 0)
			{
				stringBuilder.Append(GetCreatorString(zNetView.Item1, needItCleanJack));
			}
			if (zNetView.Item1.m_zdo.GetString(ZDOVars.s_creatorName, "").Length > 1)
			{
				stringBuilder.Append(GetCreatorNameString(zNetView.Item1, needItCleanJack));
			}
			if (XRayVisionPlugin.ModeratorConfigs.ContainsKey(XRayVisionPlugin.ID))
			{
				if (XRayVisionPlugin.ModeratorConfigs[XRayVisionPlugin.ID].ShowSteamInformation.Value && (zNetView.Item1.m_zdo.GetString("steamName", "").Length > 1 || zNetView.Item1.m_zdo.GetString("steamID", "").Length > 1))
				{
					stringBuilder.Append(GetSteamInfoString(zNetView.Item1, needItCleanJack));
				}
			}
			else if ((XRayVisionPlugin.IsAdmin || XRayVisionPlugin.configSync.IsAdmin) && (zNetView.Item1.m_zdo.GetString("steamName", "").Length > 1 || zNetView.Item1.m_zdo.GetString("steamID", "").Length > 1))
			{
				stringBuilder.Append(GetSteamInfoString(zNetView.Item1, needItCleanJack));
			}
			stringBuilder.Append(GetZdoOwnerText(zNetView.Item1, needItCleanJack));
			stringBuilder.Append(GetGameObjectsComponents(zNetView.Item2, needItCleanJack));
			KeyboardShortcut value2;
			if (HoverTextDisplay)
			{
				XRayVisionPlugin.PropertiesText.ShowTooltip();
				value2 = XRayVisionPlugin.DisableVisuals.Value;
				if (((KeyboardShortcut)(ref value2)).IsUp() && XRayVisionPlugin.ToggleTooltip.Value == XRayVisionPlugin.Toggle.Off)
				{
					HoverTextDisplay = false;
				}
				value2 = XRayVisionPlugin.DisableVisuals.Value;
				if (((KeyboardShortcut)(ref value2)).IsDown() && XRayVisionPlugin.ToggleTooltip.Value == XRayVisionPlugin.Toggle.On)
				{
					XRayVisionPlugin.XRayLogger.LogDebug((object)"XRayVision: HoverTextDisplay is true, attempting to turn off visuals");
					HoverTextDisplay = false;
				}
				if (needItCleanJack)
				{
					XRayVisionPlugin.CleanCopy = stringBuilder.ToString();
				}
				return __result = stringBuilder.ToString();
			}
			if (XRayVisionPlugin.ToggleTooltip.Value == XRayVisionPlugin.Toggle.On)
			{
				value2 = XRayVisionPlugin.DisableVisuals.Value;
				if (((KeyboardShortcut)(ref value2)).IsDown())
				{
					goto IL_0353;
				}
			}
			if (XRayVisionPlugin.ToggleTooltip.Value == XRayVisionPlugin.Toggle.Off)
			{
				value2 = XRayVisionPlugin.DisableVisuals.Value;
				if (((KeyboardShortcut)(ref value2)).IsPressed())
				{
					goto IL_0353;
				}
			}
			XRayVisionPlugin.PropertiesText.HideTooltip();
			XRayVisionPlugin.PropertiesText.Set("NOT Hovering", "NOTHING");
			if (needItCleanJack)
			{
				XRayVisionPlugin.CleanCopy = stringBuilder.ToString();
			}
			goto IL_0396;
			IL_0353:
			XRayVisionPlugin.XRayLogger.LogDebug((object)"XRayVision: HoverTextDisplay is false, attempting to turn on visuals");
			HoverTextDisplay = true;
			goto IL_0396;
			IL_0396:
			return stringBuilder.ToString();
		}

		private static Tuple<ZNetView, GameObject> GetZNetView(GameObject gobj)
		{
			GameObject gameObject = ((Component)gobj.transform.root).gameObject;
			return Tuple.Create<ZNetView, GameObject>(gameObject.GetComponent<ZNetView>(), gameObject);
		}

		private static string GetVisualButtonText()
		{
			//IL_0040: 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)
			if (XRayVisionPlugin.ToggleTooltip.Value != XRayVisionPlugin.Toggle.On)
			{
				return Localization.instance.Localize($"Release [<color=yellow><b>{XRayVisionPlugin.DisableVisuals.Value}</b></color>] to hide tooltip");
			}
			return Localization.instance.Localize($"[<color=yellow><b>{XRayVisionPlugin.DisableVisuals.Value}</b></color>] $piece_guardstone_deactivate XRayVision");
		}

		private static string GetCopyButtonText()
		{
			//IL_0040: 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)
			if (XRayVisionPlugin.ToggleTooltip.Value != XRayVisionPlugin.Toggle.On)
			{
				return Localization.instance.Localize($"\n Hide tooltip. While hovering object, press [<color=yellow><b>{XRayVisionPlugin.CopyHotkey.Value}</b></color>] to copy tooltip contents to clipboard");
			}
			return Localization.instance.Localize($"\n[<color=yellow><b>{XRayVisionPlugin.CopyHotkey.Value}</b></color>] Copy tooltip contents to clipboard");
		}

		private static string GetPrefabString(ZNetView view, bool clean = false)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (!clean)
			{
				return "\n<color=#" + ColorUtility.ToHtmlStringRGBA(XRayVisionPlugin.PrefabNameColor.Value) + ">" + XRayVisionPlugin.LeftSeperator.Value + "Prefab Name" + XRayVisionPlugin.RightSeperator.Value + "  " + ((view != null) ? view.GetPrefabName() : null) + "</color>";
			}
			return XRayVisionPlugin.LeftSeperator.Value + "Prefab Name" + XRayVisionPlugin.RightSeperator.Value + "  " + ((view != null) ? view.GetPrefabName() : null);
		}

		private static string GetModSource(ZNetView view, bool clean = false)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			string text = AssetLoadTracker.GetAssemblyForPrefab((view == null) ? null : view.GetPrefabName()?.ToLower())?.GetName()?.Name;
			if (string.IsNullOrWhiteSpace(text))
			{
				text = "Valheim";
			}
			if (!clean)
			{
				return "\n<color=#" + ColorUtility.ToHtmlStringRGBA(XRayVisionPlugin.ModSourceColor.Value) + ">" + XRayVisionPlugin.LeftSeperator.Value + "Source" + XRayVisionPlugin.RightSeperator.Value + "  " + text + "</color>";
			}
			return XRayVisionPlugin.LeftSeperator.Value + "Source" + XRayVisionPlugin.RightSeperator.Value + "  " + text;
		}

		private static string GetPieceString(GameObject obj, bool clean = false)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (!clean)
			{
				return "\n<color=#" + ColorUtility.ToHtmlStringRGBA(XRayVisionPlugin.PieceNameColor.Value) + ">" + XRayVisionPlugin.LeftSeperator.Value + "Piece Name" + XRayVisionPlugin.RightSeperator.Value + "   " + obj.GetComponent<Piece>().m_name + "</color>";
			}
			return "\n" + XRayVisionPlugin.LeftSeperator.Value + "Piece Name" + XRayVisionPlugin.RightSeperator.Value + "   " + obj.GetComponent<Piece>().m_name;
		}

		private static string GetItemString(GameObject obj, bool clean = false)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (!clean)
			{
				return $"\n<color={XRayVisionPlugin.PieceNameColor.Value}>{XRayVisionPlugin.LeftSeperator.Value}ItemData Shared Name{XRayVisionPlugin.RightSeperator.Value}   {obj.GetComponent<ItemDrop>().m_itemData.m_shared.m_name}</color>";
			}
			return "\n" + XRayVisionPlugin.LeftSeperator.Value + "ItemData Shared Name" + XRayVisionPlugin.RightSeperator.Value + "   " + obj.GetComponent<ItemDrop>().m_itemData.m_shared.m_name;
		}

		private static string GetCreationString(ZNetView view, bool clean = false)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			long @long = view.m_zdo.GetLong("xray_created", 0L);
			DateTimeOffset minValue = DateTimeOffset.MinValue;
			if (@long >= minValue.Ticks)
			{
				minValue = DateTimeOffset.MaxValue;
				if (@long <= minValue.Ticks)
				{
					string text = new DateTimeOffset(@long, TimeSpan.Zero).ToLocalTime().ToString("MM/dd/yyyy h:mm tt");
					if (!clean)
					{
						return "\n<color=#" + ColorUtility.ToHtmlStringRGBA(XRayVisionPlugin.CreatedColor.Value) + ">" + XRayVisionPlugin.LeftSeperator.Value + "Created" + XRayVisionPlugin.RightSeperator.Value + "  " + text + "</color>";
					}
					return "\n" + XRayVisionPlugin.LeftSeperator.Value + "Created" + XRayVisionPlugin.RightSeperator.Value + "  " + text;
				}
			}
			return $"Invalid timestamp: {@long}";
		}

		private static string GetCreatorString(ZNetView view, bool clean = false)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (!clean)
			{
				return string.Format("\n<color=#{0}>{1}Creator ID{2}  {3}</color>", ColorUtility.ToHtmlStringRGBA(XRayVisionPlugin.CreatorIDColor.Value), XRayVisionPlugin.LeftSeperator.Value, XRayVisionPlugin.RightSeperator.Value, view.GetZDO().GetLong(StringExtensionMethods.GetStableHashCode("creator"), 0L));
			}
			return string.Format("\n{0}Creator ID{1}  {2}", XRayVisionPlugin.LeftSeperator.Value, XRayVisionPlugin.RightSeperator.Value, view.GetZDO().GetLong(StringExtensionMethods.GetStableHashCode("creator"), 0L));
		}

		private static string GetCreatorNameString(ZNetView view, bool clean = false)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (!clean)
			{
				return "\n<color=#" + ColorUtility.ToHtmlStringRGBA(XRayVisionPlugin.CreatorNameColor.Value) + ">" + XRayVisionPlugin.LeftSeperator.Value + "Creator Name" + XRayVisionPlugin.RightSeperator.Value + "  " + view.m_zdo.GetString("creatorName", "") + "</color>";
			}
			return "\n" + XRayVisionPlugin.LeftSeperator.Value + "Creator Name" + XRayVisionPlugin.RightSeperator.Value + "  " + view.m_zdo.GetString("creatorName", "");
		}

		private static string GetZdoOwnerText(ZNetView view, bool clean = false)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (!clean)
			{
				return "\n<color=#" + ColorUtility.ToHtmlStringRGBA(XRayVisionPlugin.OwnerColor.Value) + ">" + XRayVisionPlugin.LeftSeperator.Value + "Owner" + XRayVisionPlugin.RightSeperator.Value + "  " + GetOwnerText(view) + "</color>";
			}
			return "\n" + XRayVisionPlugin.LeftSeperator.Value + "Owner" + XRayVisionPlugin.RightSeperator.Value + "  " + GetOwnerText(view);
		}

		private static string GetOwnerText(ZNetView view, bool clean = false)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			PlayerInfo? val = ZNet.instance.m_players.Where((PlayerInfo i) => ((ZDOID)(ref i.m_characterID)).UserID == view.m_zdo.GetOwner()).Cast<PlayerInfo?>().FirstOrDefault();
			if (!val.HasValue)
			{
				return "-";
			}
			string arg = (view.IsOwner() ? "(Me)" : "");
			return $"{val?.m_name}, {view.m_zdo.GetOwner()} {arg}";
		}

		private static string GetSteamInfoString(ZNetView view, bool clean = false)
		{
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (view.m_zdo.GetString("steamName", "").Length > 1)
			{
				if (!clean)
				{
					return "\n<color=#" + ColorUtility.ToHtmlStringRGBA(XRayVisionPlugin.CreatorSteamInfoColor.Value) + ">" + XRayVisionPlugin.LeftSeperator.Value + "Creator Info" + XRayVisionPlugin.RightSeperator.Value + "  " + view.m_zdo.GetString("steamName", "") + " × " + view.m_zdo.GetString("steamID", "") + "</color>";
				}
				return "\n" + XRayVisionPlugin.LeftSeperator.Value + "Creator Info" + XRayVisionPlugin.RightSeperator.Value + "  " + view.m_zdo.GetString("steamName", "") + " × " + view.m_zdo.GetString("steamID", "");
			}
			if (!clean)
			{
				return "\n<color=#" + ColorUtility.ToHtmlStringRGBA(XRayVisionPlugin.CreatorSteamInfoColor.Value) + ">" + XRayVisionPlugin.LeftSeperator.Value + "Creator Info" + XRayVisionPlugin.RightSeperator.Value + "  " + view.m_zdo.GetString("steamID", "") + "</color>";
			}
			return "\n" + XRayVisionPlugin.LeftSeperator.Value + "Creator Info" + XRayVisionPlugin.RightSeperator.Value + "  " + view.m_zdo.GetString("steamID", "");
		}

		private static string GetGameObjectsComponents(GameObject obj, bool clean = false)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			Component[] components = obj.GetComponents<Component>();
			StringBuilder stringBuilder = new StringBuilder();
			Component[] array = components;
			foreach (Component val in array)
			{
				stringBuilder.Append("\t\t" + ((object)val).GetType().Name + Environment.NewLine);
			}
			if (!clean)
			{
				return $"\n<color=#{ColorUtility.ToHtmlStringRGBA(XRayVisionPlugin.CreatorSteamInfoColor.Value)}>{XRayVisionPlugin.LeftSeperator.Value}Components{XRayVisionPlugin.RightSeperator.Value}  {Environment.NewLine}{stringBuilder}</color>";
			}
			return $"\n{XRayVisionPlugin.LeftSeperator.Value}Components{XRayVisionPlugin.RightSeperator.Value}  {Environment.NewLine} {stringBuilder}";
		}

		public static string AddPlayerHoverText(GameObject gobj, ref string __result)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			if (XRayVisionPlugin.IsAdmin || XRayVisionPlugin.configSync.IsAdmin)
			{
				KeyboardShortcut value;
				if (HoverTextDisplay)
				{
					value = XRayVisionPlugin.DisableVisuals.Value;
					if (((KeyboardShortcut)(ref value)).IsUp())
					{
						HoverTextDisplay = false;
					}
					StringBuilder stringBuilder = new StringBuilder();
					GameObject gameObject = ((Component)gobj.transform.root).gameObject;
					try
					{
						ZNetView component = gameObject.GetComponent<ZNetView>();
						if (((Character)gameObject.GetComponent<Player>()).IsCrouching())
						{
							stringBuilder.Append("<color=#" + ColorUtility.ToHtmlStringRGBA(XRayVisionPlugin.CreatorNameColor.Value) + ">" + XRayVisionPlugin.LeftSeperator.Value + "Name" + XRayVisionPlugin.RightSeperator.Value + "  " + (Object.op_Implicit((Object)(object)component) ? gameObject.GetComponent<Player>().GetPlayerName() : ((Object)gameObject).name) + "</color>");
						}
						stringBuilder.Append($"\n<color=#{ColorUtility.ToHtmlStringRGBA(XRayVisionPlugin.CreatorNameColor.Value)}>{XRayVisionPlugin.LeftSeperator.Value}Player ID{XRayVisionPlugin.RightSeperator.Value}  {gameObject.GetComponent<Player>().GetPlayerID()}</color>");
						stringBuilder.Append("\n<color=#" + ColorUtility.ToHtmlStringRGBA(XRayVisionPlugin.CreatorSteamInfoColor.Value) + ">" + XRayVisionPlugin.LeftSeperator.Value + "Last Spawned" + XRayVisionPlugin.RightSeperator.Value + "  ").Append(DateTimeOffset.Now.AddTicks(ZDOExtraData.GetTimeCreated(component.m_zdo.m_uid) - ZNet.instance.GetTime().Ticks).ToString("g")).Append("</color>");
						if (component.m_zdo.GetString("steamName", "").Length >= 1)
						{
							stringBuilder.Append("\n<color=#" + ColorUtility.ToHtmlStringRGBA(XRayVisionPlugin.CreatorSteamInfoColor.Value) + ">" + XRayVisionPlugin.LeftSeperator.Value + "Player Info" + XRayVisionPlugin.RightSeperator.Value + "  " + component.m_zdo.GetString("steamName", "") + " × " + component.m_zdo.GetString("steamID", "") + "</color>");
						}
						else if (component.m_zdo.GetString("steamID", "").Length >= 1)
						{
							stringBuilder.Append("\n<color=#" + ColorUtility.ToHtmlStringRGBA(XRayVisionPlugin.CreatorSteamInfoColor.Value) + ">" + XRayVisionPlugin.LeftSeperator.Value + "Player Info" + XRayVisionPlugin.RightSeperator.Value + "  " + component.m_zdo.GetString("steamID", "") + "</color>");
						}
					}
					catch
					{
					}
					return __result = __result + "\n\n" + stringBuilder;
				}
				if (!HoverTextDisplay)
				{
					value = XRayVisionPlugin.DisableVisuals.Value;
					if (((KeyboardShortcut)(ref value)).IsPressed())
					{
						HoverTextDisplay = true;
					}
					return __result;
				}
			}
			return __result;
		}
	}
	[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(0)]
	[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
	public static class PlatformUtils
	{
		public static Platform GetPlatform(string hostname)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return PrivilegeManager.ParseUser(hostname).platform;
		}

		public static Platform GetPlatform(ZNetPeer netPeer)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return GetPlatform(netPeer.m_socket.GetHostName());
		}
	}
	[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
	public static class RegisterAndCheckVersion
	{
		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			XRayVisionPlugin.XRayLogger.LogDebug((object)"Registering version RPC handler");
			peer.m_rpc.Register<ZPackage>("XRayVision_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_XRay_Version);
			XRayVisionPlugin.XRayLogger.LogDebug((object)"Invoking version check");
			ZPackage val = new ZPackage();
			val.Write("2.2.3");
			peer.m_rpc.Invoke("XRayVision_VersionCheck", new object[1] { val });
		}
	}
	[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
	[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(0)]
	[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
	public static class VerifyClient
	{
		private static bool Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance)
		{
			if (!__instance.IsServer() || RpcHandlers.ValidatedPeers.Contains(rpc))
			{
				return true;
			}
			XRayVisionPlugin.XRayLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") never sent version or couldn't due to previous disconnect, disconnecting"));
			rpc.Invoke("Error", new object[1] { 3 });
			return false;
		}

		private static void Postfix(ZNet __instance)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "XRayRequestAdminSync", new object[1] { (object)new ZPackage() });
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "ShowConnectError")]
	public class ShowConnectionError
	{
		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
		private static void Postfix(FejdStartup __instance)
		{
			if (__instance.m_connectionFailedPanel.activeSelf)
			{
				__instance.m_connectionFailedError.fontSizeMax = 25f;
				__instance.m_connectionFailedError.fontSizeMin = 15f;
				TMP_Text connectionFailedError = __instance.m_connectionFailedError;
				connectionFailedError.text = connectionFailedError.text + "\n" + XRayVisionPlugin.ConnectionError;
			}
		}
	}
	[HarmonyPatch(typeof(ZNet), "Disconnect")]
	public static class RemoveDisconnectedPeerFromVerified
	{
		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			if (__instance.IsServer())
			{
				XRayVisionPlugin.XRayLogger.LogInfo((object)("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list"));
				RpcHandlers.ValidatedPeers.Remove(peer.m_rpc);
			}
		}
	}
	[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
	[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(0)]
	public static class RpcHandlers
	{
		public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>();

		public static void RPC_XRay_Version(ZRpc rpc, ZPackage pkg)
		{
			string text = pkg.ReadString();
			XRayVisionPlugin.XRayLogger.LogInfo((object)("Version check, local: 2.2.3,  remote: " + text));
			if (text != "2.2.3")
			{
				XRayVisionPlugin.ConnectionError = "XRayVision Installed: 2.2.3\n Needed: " + text;
				if (ZNet.instance.IsServer())
				{
					XRayVisionPlugin.XRayLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") has incompatible version, disconnecting"));
					rpc.Invoke("Error", new object[1] { 3 });
				}
			}
			else if (!ZNet.instance.IsServer())
			{
				XRayVisionPlugin.XRayLogger.LogInfo((object)"Received same version from server!");
			}
			else
			{
				XRayVisionPlugin.XRayLogger.LogInfo((object)("Adding peer (" + rpc.m_socket.GetHostName() + ") to validated list"));
				ValidatedPeers.Add(rpc);
			}
		}
	}
	[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
	[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(0)]
	public class XRayProps : MonoBehaviour
	{
		public string mText = "";

		public string mTopic = "";

		public Text textcomp;

		public Text titlecomp;

		public Image backgroundcomp;

		public void Awake()
		{
			UpdateTextElements();
		}

		public void Start()
		{
			ApplyDefaults();
		}

		public void UpdateTextElements()
		{
			Transform val = Utils.FindChild(((Component)this).transform, "Text", (IterativeSearchType)0);
			if ((Object)(object)val != (Object)null)
			{
				textcomp = ((Component)val).GetComponent<Text>();
				((Component)val).GetComponent<Text>().text = Localization.instance.Localize(mText);
			}
			Transform val2 = Utils.FindChild(((Component)this).transform, "Bkg", (IterativeSearchType)0);
			if ((Object)(object)val2 != (Object)null)
			{
				backgroundcomp = ((Component)val2).GetComponent<Image>();
			}
			Transform val3 = Utils.FindChild(((Component)this).transform, "Topic", (IterativeSearchType)0);
			if (!((Object)(object)val3 == (Object)null))
			{
				titlecomp = ((Component)val3).GetComponent<Text>();
				((Component)val3).GetComponent<Text>().text = Localization.instance.Localize(mTopic);
			}
		}

		public void ApplyDefaults()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			XRayVisionPlugin.XRayLogger.LogDebug((object)"Applying defaults");
			RectTransform val = default(RectTransform);
			if ((Object)(object)XRayVisionPlugin.ToolTipGameObject != (Object)null && XRayVisionPlugin.ToolTipGameObject.TryGetComponent<RectTransform>(ref val))
			{
				val.anchoredPosition = XRayVisionPlugin.ToolTipPosition.Value;
			}
			if (Object.op_Implicit((Object)(object)textcomp))
			{
				textcomp.fontSize = XRayVisionPlugin.ToolTipTextSize.Value;
			}
			if (Object.op_Implicit((Object)(object)titlecomp))
			{
				titlecomp.fontSize = XRayVisionPlugin.ToolTipTitleSize.Value;
			}
			if (Object.op_Implicit((Object)(object)backgroundcomp))
			{
				((Graphic)backgroundcomp).color = XRayVisionPlugin.ToolTipBkgColor.Value;
			}
		}

		public void HideTooltip()
		{
			if (((Component)this).gameObject.activeSelf)
			{
				((Component)this).gameObject.SetActive(false);
			}
		}

		public void ShowTooltip()
		{
			if (!((Component)this).gameObject.activeSelf)
			{
				((Component)this).gameObject.SetActive(true);
			}
		}

		public void Set(string topic, string text)
		{
			if (!(topic == mTopic) || !(text == mText))
			{
				mTopic = topic;
				mText = text;
				if (!((Object)(object)this == (Object)null))
				{
					UpdateTextElements();
				}
			}
		}
	}
}
namespace XRayVision.Utilities.RPCShit
{
	[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
	[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(0)]
	[HarmonyPatch]
	public class XRayClient
	{
		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(0)]
		[HarmonyPatch(typeof(Player), "OnSpawned")]
		public static class PlayerOnSpawnPatch
		{
			private static void Prefix()
			{
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Expected O, but got Unknown
				if (!ZNet.instance.IsDedicated() && ZNet.instance.IsServer())
				{
					XRayVisionPlugin.IsAdmin = true;
					XRayVisionPlugin.XRayLogger.LogInfo((object)$"Local Play Detected setting Admin: {XRayVisionPlugin.IsAdmin}");
				}
				if (ZRoutedRpc.instance != null && Object.op_Implicit((Object)(object)ZNetScene.instance) && !XRayVisionPlugin.IsAdmin && !XRayVisionPlugin.IsModerator)
				{
					ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "XRayRequestAdminSync", new object[1] { (object)new ZPackage() });
				}
			}
		}

		public static void RPC_XRayRequestAdminSync(long sender, ZPackage pkg)
		{
		}

		public static void RPC_XRayBadRequestMsg(long sender, ZPackage pkg)
		{
			if (sender == ZRoutedRpc.instance.GetServerPeerID() && pkg != null && pkg.Size() > 0)
			{
				string text = pkg.ReadString();
				if (!(text == ""))
				{
					((Terminal)Chat.m_instance).AddString("Server", "<color=\"red\">" + text + "</color>", (Type)1, false);
				}
			}
		}

		public static void RPC_XRayEventAdminSync(long sender, ZPackage pkg)
		{
			string iD = pkg.ReadString();
			string text = pkg.ReadString();
			if (!(text == "Admin"))
			{
				if (text == "Moderator")
				{
					XRayVisionPlugin.XRayLogger.LogInfo((object)"This account is a moderator.");
					((Terminal)Chat.m_instance).AddString("[XRay]", "<color=\"orange\">Moderator permissions synced</color>", (Type)1, false);
					XRayVisionPlugin.IsModerator = true;
					XRayVisionPlugin.ID = iD;
				}
			}
			else
			{
				XRayVisionPlugin.XRayLogger.LogInfo((object)"This account is an admin.");
				((Terminal)Chat.m_instance).AddString("[XRay]", "<color=\"green\">Admin permissions synced</color>", (Type)1, false);
				XRayVisionPlugin.IsAdmin = true;
				XRayVisionPlugin.ID = iD;
			}
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "Start")]
	internal static class FejdStartup_Start_Patch
	{
		private static void Postfix()
		{
			Console.SetConsoleEnabled(true);
		}
	}
	[HarmonyPatch]
	internal static class ClientResetPatches
	{
		[HarmonyPatch(typeof(ZNet), "RPC_Error")]
		[HarmonyPatch(typeof(ZNet), "Disconnect")]
		[HarmonyPatch(typeof(Game), "Logout")]
		private static void Prefix()
		{
			if (XRayVisionPlugin.IsAdmin)
			{
				XRayVisionPlugin.IsAdmin = false;
				XRayVisionPlugin.XRayLogger.LogDebug((object)$"Admin Status changed to: {XRayVisionPlugin.IsAdmin}");
			}
			if (XRayVisionPlugin.IsModerator)
			{
				XRayVisionPlugin.IsModerator = false;
				XRayVisionPlugin.XRayLogger.LogDebug((object)$"Moderator Status changed to: {XRayVisionPlugin.IsModerator}");
			}
		}
	}
	[HarmonyPatch(typeof(Game), "Start")]
	internal static class ClientRPC_Registrations
	{
		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
		private static void Prefix(Game __instance)
		{
			if (!ZNet.m_isServer)
			{
				ZRoutedRpc.instance.Register<ZPackage>("XRayRequestAdminSync", (Action<long, ZPackage>)XRayClient.RPC_XRayRequestAdminSync);
				ZRoutedRpc.instance.Register<ZPackage>("XRayEventAdminSync", (Action<long, ZPackage>)XRayClient.RPC_XRayEventAdminSync);
				ZRoutedRpc.instance.Register<ZPackage>("XRayBadRequestMsg", (Action<long, ZPackage>)XRayClient.RPC_XRayBadRequestMsg);
			}
		}
	}
	[<e42f466c-a03d-41ed-b958-4dbecb2066d7>Nullable(0)]
	[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
	[HarmonyPatch]
	public class XRayServer
	{
		public static void RPC_XRayRequestAdminSync(long sender, ZPackage pkg)
		{
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			ZNetPeer peer = ZNet.instance.GetPeer(sender);
			if (peer != null)
			{
				string hostName = peer.m_rpc.GetSocket().GetHostName();
				if (!ZNet.instance.IsDedicated() && ZNet.instance.IsServer())
				{
					XRayVisionPlugin.IsAdmin = true;
					XRayVisionPlugin.XRayLogger.LogDebug((object)$"Local Play Detected setting Admin: {XRayVisionPlugin.IsAdmin}");
				}
				if (ZNet.instance.m_adminList != null && ZNet.instance.ListContainsId(ZNet.instance.m_adminList, hostName))
				{
					XRayVisionPlugin.XRayLogger.LogInfo((object)("Admin Detected: " + peer.m_playerName + " (" + hostName + ")"));
					pkg.Write(hostName);
					pkg.Write("Admin");
					ZRoutedRpc.instance.InvokeRoutedRPC(sender, "XRayEventAdminSync", new object[1] { pkg });
				}
				XRayVisionPlugin.ReadYamlConfigFile(null, null);
				if (XRayVisionPlugin.ModeratorConfigs.ContainsKey(hostName))
				{
					pkg.Write(hostName);
					pkg.Write("Moderator");
					ZRoutedRpc.instance.InvokeRoutedRPC(sender, "XRayEventAdminSync", new object[1] { pkg });
				}
			}
			else
			{
				ZPackage val = new ZPackage();
				val.Write("You aren't an Admin!");
				ZRoutedRpc.instance.InvokeRoutedRPC(sender, "XRayBadRequestMsg", new object[1] { val });
			}
		}

		public static void RPC_XRayEventAdminSync(long sender, ZPackage pkg)
		{
		}
	}
	[HarmonyPatch]
	public class ServerRPC_Registrations
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Game), "Start")]
		public static void Prefix()
		{
			if (ZNet.m_isServer)
			{
				ZRoutedRpc.instance.Register<ZPackage>("XRayRequestAdminSync", (Action<long, ZPackage>)XRayServer.RPC_XRayRequestAdminSync);
				ZRoutedRpc.instance.Register<ZPackage>("XRayEventAdminSync", (Action<long, ZPackage>)XRayServer.RPC_XRayEventAdminSync);
			}
		}
	}
}
namespace XRayVision.Patches
{
	[HarmonyPatch(typeof(Hud), "UpdateCrosshair")]
	internal static class Hud_UpdateCrosshair_Patch
	{
		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
		private static void Postfix(Hud __instance, Player player, float bowDrawPercentage)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			GameObject hoverObject = ((Humanoid)player).GetHoverObject();
			string __result;
			if ((Object.op_Implicit((Object)(object)hoverObject) ? hoverObject.GetComponentInParent<Hoverable>() : null) != null && !TextViewer.instance.IsVisible())
			{
				GameObject gameObject = ((Component)hoverObject.transform.root).gameObject;
				__result = ((TMP_Text)__instance.m_hoverName).text;
				if (Object.op_Implicit((Object)(object)gameObject.GetComponent<Player>()))
				{
					HoverAdditions.AddPlayerHoverText(hoverObject, ref __result);
					return;
				}
				KeyboardShortcut value = XRayVisionPlugin.CopyHotkey.Value;
				if (!((KeyboardShortcut)(ref value)).IsDown())
				{
					value = XRayVisionPlugin.CopyHotkey.Value;
					if (!((KeyboardShortcut)(ref value)).IsPressed())
					{
						value = XRayVisionPlugin.CopyHotkey.Value;
						if (((KeyboardShortcut)(ref value)).IsPressed())
						{
							value = XRayVisionPlugin.DisableVisuals.Value;
							if (((KeyboardShortcut)(ref value)).IsPressed())
							{
								goto IL_00d6;
							}
						}
						value = XRayVisionPlugin.CopyHotkey.Value;
						if (((KeyboardShortcut)(ref value)).IsDown())
						{
							value = XRayVisionPlugin.DisableVisuals.Value;
							if (((KeyboardShortcut)(ref value)).IsPressed())
							{
								goto IL_00d6;
							}
						}
						XRayProps propertiesText = XRayVisionPlugin.PropertiesText;
						ZNetView component = ((Component)hoverObject.transform.root).gameObject.GetComponent<ZNetView>();
						object topic;
						if (((component != null) ? component.GetPrefabName() : null) != null)
						{
							ZNetView component2 = ((Component)hoverObject.transform.root).gameObject.GetComponent<ZNetView>();
							topic = ((component2 != null) ? component2.GetPrefabName() : null);
						}
						else
						{
							topic = "";
						}
						propertiesText.Set((string)topic, HoverAdditions.AddHoverText(hoverObject, ref __result));
						return;
					}
				}
				goto IL_00d6;
			}
			if (Object.op_Implicit((Object)(object)hoverObject))
			{
				if (Object.op_Implicit((Object)(object)((Component)hoverObject.transform.root).gameObject.GetComponent<Piece>()))
				{
					hoverObject.AddComponent<HoverText>();
				}
			}
			else
			{
				XRayVisionPlugin.PropertiesText.HideTooltip();
				XRayVisionPlugin.PropertiesText.Set("NOT Hovering", "NOTHING");
			}
			return;
			IL_00d6:
			((Character)Player.m_localPlayer).Message((MessageType)2, "Copied to clipboard", 0, (Sprite)null);
			GUIUtility.systemCopyBuffer = HoverAdditions.AddHoverText(hoverObject, ref __result, needItCleanJack: true);
		}
	}
	[HarmonyPatch(typeof(Player), "GetHoverText")]
	internal static class Player_AddHover_Patch
	{
		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
		private static void Postfix(Player __instance, ref string __result)
		{
			HoverAdditions.AddPlayerHoverText(((Component)__instance).gameObject, ref __result);
		}
	}
	[HarmonyPatch(typeof(Hud), "Awake")]
	internal static class HudAwakePatch
	{
		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
		private static void Postfix(Hud __instance)
		{
			//IL_0075: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			XRayVisionPlugin.ToolTipGameObject = Object.Instantiate<GameObject>(XRayVisionPlugin.BorrowedTooltip, ((Component)__instance.m_crosshair).transform);
			((Object)XRayVisionPlugin.ToolTipGameObject).name = "XRayVisionProperties";
			XRayVisionPlugin.PropertiesText = XRayVisionPlugin.ToolTipGameObject.GetComponent<XRayProps>();
			XRayVisionPlugin.PropertiesText.textcomp.fontSize = XRayVisionPlugin.ToolTipTextSize.Value;
			XRayVisionPlugin.PropertiesText.titlecomp.fontSize = XRayVisionPlugin.ToolTipTitleSize.Value;
			RectTransform component = XRayVisionPlugin.ToolTipGameObject.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.zero;
			component.pivot = Vector2.one;
			component.anchoredPosition = new Vector2(-75f, 0f);
		}
	}
	[HarmonyPatch(typeof(Hud), "OnDestroy")]
	internal static class Hud_OnDestroy_Patch
	{
		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
		private static void Prefix(ref Hud __instance)
		{
			if (Object.op_Implicit((Object)(object)XRayVisionPlugin.ToolTipGameObject))
			{
				Object.DestroyImmediate((Object)(object)XRayVisionPlugin.ToolTipGameObject);
			}
		}
	}
	[HarmonyPatch(typeof(Player), "SetPlayerID")]
	internal static class PlayerXraySetPlayerIDPatch
	{
		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
		private static void Postfix(Player __instance)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Invalid comparison between Unknown and I4
			//IL_009b: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Invalid comparison between Unknown and I4
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)ZNet.instance))
			{
				return;
			}
			string text = string.Empty;
			string text2 = string.Empty;
			if (ZNet.instance.IsServer() && ZNet.instance.IsDedicated())
			{
				ZNetPeer peer = ZNet.instance.GetPeer(((ZDOID)(ref ((Character)__instance).m_nview.m_zdo.m_uid)).UserID);
				if ((int)PlatformUtils.GetPlatform(peer) == 1)
				{
					CSteamID val = default(CSteamID);
					((CSteamID)(ref val))..ctor(ulong.Parse(peer.m_rpc.GetSocket().GetHostName()));
					text = SteamFriends.GetFriendPersonaName(val);
					text2 = ((object)(CSteamID)(ref val)).ToString();
				}
			}
			else if ((int)PrivilegeManager.GetCurrentPlatform() == 1)
			{
				text = SteamFriends.GetPersonaName();
				CSteamID steamID = SteamUser.GetSteamID();
				text2 = ((object)(CSteamID)(ref steamID)).ToString();
			}
			else
			{
				text = "";
				text2 = PrivilegeManager.GetNetworkUserId();
			}
			((Character)__instance).m_nview.GetZDO().Set("steamName", text);
			((Character)__instance).m_nview.GetZDO().Set("steamID", text2);
		}
	}
	[HarmonyPatch]
	public class WearNTearPatches
	{
		[HarmonyPrefix]
		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
		[HarmonyPatch(typeof(WearNTear), "OnPlaced")]
		private static void Prefix(WearNTear __instance)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.m_nview) && __instance.m_nview.IsValid())
			{
				if (((Component)__instance).gameObject.GetComponent<Hoverable>() == null)
				{
					((Component)__instance).gameObject.AddComponent<HoverText>();
				}
				string text;
				string text2;
				if ((int)PrivilegeManager.GetCurrentPlatform() == 1)
				{
					text = SteamFriends.GetPersonaName();
					CSteamID steamID = SteamUser.GetSteamID();
					text2 = ((object)(CSteamID)(ref steamID)).ToString();
				}
				else
				{
					text = "";
					text2 = PrivilegeManager.GetNetworkUserId();
				}
				__instance.m_nview.GetZDO().Set("creatorName", Player.m_localPlayer.GetPlayerName());
				__instance.m_nview.GetZDO().Set("steamID", text2);
				__instance.m_nview.GetZDO().Set("steamName", text);
			}
		}
	}
	[HarmonyPatch(typeof(ZDOMan), "ConvertCreationTime")]
	public class ConvertCreationTime
	{
		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
		private static void Postfix(List<ZDO> zdos)
		{
			if (!ZDOExtraData.HasTimeCreated())
			{
				return;
			}
			foreach (ZDO zdo in zdos)
			{
				zdo.SetOwner(ZDOMan.GetSessionID());
				zdo.Set(CreateNewZDO.Hash, DateTimeOffset.UtcNow.Ticks);
			}
		}
	}
	[HarmonyPatch(typeof(ZDOMan), "CreateNewZDO", new Type[]
	{
		typeof(ZDOID),
		typeof(Vector3),
		typeof(int)
	})]
	public class CreateNewZDO
	{
		public static int Hash = "xray_created".GetHashCode();

		[<f090e44b-5a3e-475c-bdcf-ecdf6aa8a787>NullableContext(1)]
		private static ZDO Postfix(ZDO result)
		{
			result.Set(Hash, DateTimeOffset.UtcNow.Ticks);
			return result;
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[<df91eb78-0da0-476d-9f76-3d0ad9f5fba8>Embedded]
	[CompilerGenerated]
	internal sealed class <df91eb78-0da0-476d-9f76-3d0ad9f5fba8>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[<df91eb78-0da0-476d-9f76-3d0ad9f5fba8>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <809e9b01-e3ed-4510-aba1-881db2661b07>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <809e9b01-e3ed-4510-aba1-881db2661b07>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <809e9b01-e3ed-4510-aba1-881db2661b07>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[<df91eb78-0da0-476d-9f76-3d0ad9f5fba8>Embedded]
	internal sealed class <a48db08a-f334-4774-95ae-611ad5e1165d>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <a48db08a-f334-4774-95ae-611ad5e1165d>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[<df91eb78-0da0-476d-9f76-3d0ad9f5fba8>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 ServerSync
{
	[PublicAPI]
	[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(0)]
	[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(1)]
	internal abstract class OwnConfigEntryBase
	{
		[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(2)]
		public object LocalBaseValue;

		public bool SynchronizedConfig = true;

		public abstract ConfigEntryBase BaseConfig { get; }
	}
	[PublicAPI]
	[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(0)]
	[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(1)]
	internal class SyncedConfigEntry<[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(2)] T> : OwnConfigEntryBase
	{
		public readonly ConfigEntry<T> SourceConfig;

		public override ConfigEntryBase BaseConfig => (ConfigEntryBase)(object)SourceConfig;

		public T Value
		{
			get
			{
				return SourceConfig.Value;
			}
			set
			{
				SourceConfig.Value = value;
			}
		}

		public SyncedConfigEntry(ConfigEntry<T> sourceConfig)
		{
			SourceConfig = sourceConfig;
		}

		public void AssignLocalValue(T value)
		{
			if (LocalBaseValue == null)
			{
				Value = value;
			}
			else
			{
				LocalBaseValue = value;
			}
		}
	}
	[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(2)]
	[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(0)]
	internal abstract class CustomSyncedValueBase
	{
		public object LocalBaseValue;

		[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(1)]
		public readonly string Identifier;

		[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(1)]
		public readonly Type Type;

		private object boxedValue;

		protected bool localIsOwner;

		public readonly int Priority;

		public object BoxedValue
		{
			get
			{
				return boxedValue;
			}
			set
			{
				boxedValue = value;
				this.ValueChanged?.Invoke();
			}
		}

		public event Action ValueChanged;

		[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(1)]
		protected CustomSyncedValueBase(ConfigSync configSync, string identifier, Type type, int priority)
		{
			Priority = priority;
			Identifier = identifier;
			Type = type;
			configSync.AddCustomValue(this);
			localIsOwner = configSync.IsSourceOfTruth;
			configSync.SourceOfTruthChanged += delegate(bool truth)
			{
				localIsOwner = truth;
			};
		}
	}
	[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(1)]
	[PublicAPI]
	[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(0)]
	internal sealed class CustomSyncedValue<[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(2)] T> : CustomSyncedValueBase
	{
		public T Value
		{
			get
			{
				return (T)base.BoxedValue;
			}
			set
			{
				base.BoxedValue = value;
			}
		}

		public CustomSyncedValue(ConfigSync configSync, string identifier, T value = default(T), int priority = 0)
			: base(configSync, identifier, typeof(T), priority)
		{
			Value = value;
		}

		public void AssignLocalValue(T value)
		{
			if (localIsOwner)
			{
				Value = value;
			}
			else
			{
				LocalBaseValue = value;
			}
		}
	}
	internal class ConfigurationManagerAttributes
	{
		[UsedImplicitly]
		public bool? ReadOnly = false;
	}
	[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(1)]
	[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(0)]
	[PublicAPI]
	internal class ConfigSync
	{
		[HarmonyPatch(typeof(ZRpc), "HandlePackage")]
		[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)]
		private static class SnatchCurrentlyHandlingRPC
		{
			[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(2)]
			public static ZRpc currentRpc;

			[HarmonyPrefix]
			[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(1)]
			private static void Prefix(ZRpc __instance)
			{
				currentRpc = __instance;
			}
		}

		[HarmonyPatch(typeof(ZNet), "Awake")]
		[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)]
		internal static class RegisterRPCPatch
		{
			[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(1)]
			[HarmonyPostfix]
			private static void Postfix(ZNet __instance)
			{
				isServer = __instance.IsServer();
				foreach (ConfigSync configSync2 in configSyncs)
				{
					ZRoutedRpc.instance.Register<ZPackage>(configSync2.Name + " ConfigSync", (Action<long, ZPackage>)configSync2.RPC_FromOtherClientConfigSync);
					if (isServer)
					{
						configSync2.InitialSyncDone = true;
						Debug.Log((object)("Registered '" + configSync2.Name + " ConfigSync' RPC - waiting for incoming connections"));
					}
				}
				if (isServer)
				{
					((MonoBehaviour)__instance).StartCoroutine(WatchAdminListChanges());
				}
				[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(1)]
				static void SendAdmin(List<ZNetPeer> peers, bool isAdmin)
				{
					ZPackage package = ConfigsToPackage(null, null, new PackageEntry[1]
					{
						new PackageEntry
						{
							section = "Internal",
							key = "lockexempt",
							type = typeof(bool),
							value = isAdmin
						}
					});
					ConfigSync configSync = configSyncs.First();
					if (configSync != null)
					{
						((MonoBehaviour)ZNet.instance).StartCoroutine(configSync.sendZPackage(peers, package));
					}
				}
				[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(1)]
				static IEnumerator WatchAdminListChanges()
				{
					MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null);
					SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance);
					List<string> CurrentList = new List<string>(adminList.GetList());
					while (true)
					{
						yield return (object)new WaitForSeconds(30f);
						if (!adminList.GetList().SequenceEqual(CurrentList))
						{
							CurrentList = new List<string>(adminList.GetList());
							List<ZNetPeer> adminPeer = ZNet.instance.GetPeers().Where(delegate(ZNetPeer p)
							{
								string hostName = p.m_rpc.GetSocket().GetHostName();
								return ((object)listContainsId == null) ? adminList.Contains(hostName) : ((bool)listContainsId.Invoke(ZNet.instance, new object[2] { adminList, hostName }));
							}).ToList();
							List<ZNetPeer> nonAdminPeer = ZNet.instance.GetPeers().Except(adminPeer).ToList();
							SendAdmin(nonAdminPeer, isAdmin: false);
							SendAdmin(adminPeer, isAdmin: true);
						}
					}
				}
			}
		}

		[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)]
		[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
		private static class RegisterClientRPCPatch
		{
			[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(1)]
			[HarmonyPostfix]
			private static void Postfix(ZNet __instance, ZNetPeer peer)
			{
				if (__instance.IsServer())
				{
					return;
				}
				foreach (ConfigSync configSync in configSyncs)
				{
					peer.m_rpc.Register<ZPackage>(configSync.Name + " ConfigSync", (Action<ZRpc, ZPackage>)configSync.RPC_FromServerConfigSync);
				}
			}
		}

		[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)]
		private class ParsedConfigs
		{
			[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(new byte[] { 1, 1, 2 })]
			public readonly Dictionary<OwnConfigEntryBase, object> configValues = new Dictionary<OwnConfigEntryBase, object>();

			[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(new byte[] { 1, 1, 2 })]
			public readonly Dictionary<CustomSyncedValueBase, object> customValues = new Dictionary<CustomSyncedValueBase, object>();
		}

		[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)]
		[HarmonyPatch(typeof(ZNet), "Shutdown")]
		private class ResetConfigsOnShutdown
		{
			[HarmonyPostfix]
			private static void Postfix()
			{
				ProcessingServerUpdate = true;
				foreach (ConfigSync configSync in configSyncs)
				{
					configSync.resetConfigsFromServer();
					configSync.IsSourceOfTruth = true;
					configSync.InitialSyncDone = false;
				}
				ProcessingServerUpdate = false;
			}
		}

		[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(0)]
		[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
		private class SendConfigsAfterLogin
		{
			[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(0)]
			private class BufferingSocket : ISocket
			{
				public volatile bool finished = false;

				public volatile int versionMatchQueued = -1;

				public readonly List<ZPackage> Package = new List<ZPackage>();

				public readonly ISocket Original;

				public BufferingSocket(ISocket original)
				{
					Original = original;
				}

				public bool IsConnected()
				{
					return Original.IsConnected();
				}

				public ZPackage Recv()
				{
					return Original.Recv();
				}

				public int GetSendQueueSize()
				{
					return Original.GetSendQueueSize();
				}

				public int GetCurrentSendRate()
				{
					return Original.GetCurrentSendRate();
				}

				public bool IsHost()
				{
					return Original.IsHost();
				}

				public void Dispose()
				{
					Original.Dispose();
				}

				public bool GotNewData()
				{
					return Original.GotNewData();
				}

				public void Close()
				{
					Original.Close();
				}

				public string GetEndPointString()
				{
					return Original.GetEndPointString();
				}

				public void GetAndResetStats(out int totalSent, out int totalRecv)
				{
					Original.GetAndResetStats(ref totalSent, ref totalRecv);
				}

				public void GetConnectionQuality(out float localQuality, out float remoteQuality, out int ping, out float outByteSec, out float inByteSec)
				{
					Original.GetConnectionQuality(ref localQuality, ref remoteQuality, ref ping, ref outByteSec, ref inByteSec);
				}

				public ISocket Accept()
				{
					return Original.Accept();
				}

				public int GetHostPort()
				{
					return Original.GetHostPort();
				}

				public bool Flush()
				{
					return Original.Flush();
				}

				public string GetHostName()
				{
					return Original.GetHostName();
				}

				public void VersionMatch()
				{
					if (finished)
					{
						Original.VersionMatch();
					}
					else
					{
						versionMatchQueued = Package.Count;
					}
				}

				public void Send(ZPackage pkg)
				{
					//IL_0057: Unknown result type (might be due to invalid IL or missing references)
					//IL_005d: Expected O, but got Unknown
					int pos = pkg.GetPos();
					pkg.SetPos(0);
					int num = pkg.ReadInt();
					if ((num == StringExtensionMethods.GetStableHashCode("PeerInfo") || num == StringExtensionMethods.GetStableHashCode("RoutedRPC") || num == StringExtensionMethods.GetStableHashCode("ZDOData")) && !finished)
					{
						ZPackage val = new ZPackage(pkg.GetArray());
						val.SetPos(pos);
						Package.Add(val);
					}
					else
					{
						pkg.SetPos(pos);
						Original.Send(pkg);
					}
				}
			}

			[HarmonyPriority(800)]
			[HarmonyPrefix]
			private static void Prefix([<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(new byte[] { 2, 1, 1 })] ref Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc)
			{
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Invalid comparison between Unknown and I4
				if (__instance.IsServer())
				{
					BufferingSocket value = new BufferingSocket(rpc.GetSocket());
					AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, value);
					object? obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc });
					ZNetPeer val = (ZNetPeer)((obj is ZNetPeer) ? obj : null);
					if (val != null && (int)ZNet.m_onlineBackend > 0)
					{
						AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, value);
					}
					if (__state == null)
					{
						__state = new Dictionary<Assembly, BufferingSocket>();
					}
					__state[Assembly.GetExecutingAssembly()] = value;
				}
			}

			[HarmonyPostfix]
			private static void Postfix(Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc)
			{
				ZNetPeer peer;
				if (__instance.IsServer())
				{
					object obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc });
					peer = (ZNetPeer)((obj is ZNetPeer) ? obj : null);
					if (peer == null)
					{
						SendBufferedData();
					}
					else
					{
						((MonoBehaviour)__instance).StartCoroutine(sendAsync());
					}
				}
				void SendBufferedData()
				{
					if (rpc.GetSocket() is BufferingSocket bufferingSocket)
					{
						AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, bufferingSocket.Original);
						object? obj2 = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc });
						ZNetPeer val = (ZNetPeer)((obj2 is ZNetPeer) ? obj2 : null);
						if (val != null)
						{
							AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, bufferingSocket.Original);
						}
					}
					BufferingSocket bufferingSocket2 = __state[Assembly.GetExecutingAssembly()];
					bufferingSocket2.finished = true;
					for (int i = 0; i < bufferingSocket2.Package.Count; i++)
					{
						if (i == bufferingSocket2.versionMatchQueued)
						{
							bufferingSocket2.Original.VersionMatch();
						}
						bufferingSocket2.Original.Send(bufferingSocket2.Package[i]);
					}
					if (bufferingSocket2.Package.Count == bufferingSocket2.versionMatchQueued)
					{
						bufferingSocket2.Original.VersionMatch();
					}
				}
				IEnumerator sendAsync()
				{
					foreach (ConfigSync configSync in configSyncs)
					{
						List<PackageEntry> entries = new List<PackageEntry>();
						if (configSync.CurrentVersion != null)
						{
							entries.Add(new PackageEntry
							{
								section = "Internal",
								key = "serverversion",
								type = typeof(string),
								value = configSync.CurrentVersion
							});
						}
						MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null);
						SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance);
						entries.Add(new PackageEntry
						{
							section = "Internal",
							key = "lockexempt",
							type = typeof(bool),
							value = (((object)listContainsId == null) ? ((object)adminList.Contains(rpc.GetSocket().GetHostName())) : listContainsId.Invoke(ZNet.instance, new object[2]
							{
								adminList,
								rpc.GetSocket().GetHostName()
							}))
						});
						ZPackage package = ConfigsToPackage(configSync.allConfigs.Select([<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)] (OwnConfigEntryBase c) => c.BaseConfig), configSync.allCustomValues, entries, partial: false);
						yield return ((MonoBehaviour)__instance).StartCoroutine(configSync.sendZPackage(new List<ZNetPeer> { peer }, package));
					}
					SendBufferedData();
				}
			}
		}

		[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(0)]
		private class PackageEntry
		{
			public string section = null;

			public string key = null;

			public Type type = null;

			[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(2)]
			public object value;
		}

		[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)]
		[HarmonyPatch(typeof(ConfigEntryBase), "GetSerializedValue")]
		private static class PreventSavingServerInfo
		{
			[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(1)]
			[HarmonyPrefix]
			private static bool Prefix(ConfigEntryBase __instance, ref string __result)
			{
				OwnConfigEntryBase ownConfigEntryBase = configData(__instance);
				if (ownConfigEntryBase == null || isWritableConfig(ownConfigEntryBase))
				{
					return true;
				}
				__result = TomlTypeConverter.ConvertToString(ownConfigEntryBase.LocalBaseValue, __instance.SettingType);
				return false;
			}
		}

		[HarmonyPatch(typeof(ConfigEntryBase), "SetSerializedValue")]
		[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)]
		private static class PreventConfigRereadChangingValues
		{
			[HarmonyPrefix]
			[<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(1)]
			private static bool Prefix(ConfigEntryBase __instance, string value)
			{
				OwnConfigEntryBase ownConfigEntryBase = configData(__instance);
				if (ownConfigEntryBase == null || ownConfigEntryBase.LocalBaseValue == null)
				{
					return true;
				}
				try
				{
					ownConfigEntryBase.LocalBaseValue = TomlTypeConverter.ConvertToValue(value, __instance.SettingType);
				}
				catch (Exception ex)
				{
					Debug.LogWarning((object)$"Config value of setting \"{__instance.Definition}\" could not be parsed and will be ignored. Reason: {ex.Message}; Value: {value}");
				}
				return false;
			}
		}

		[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(0)]
		private class InvalidDeserializationTypeException : Exception
		{
			public string expected = null;

			public string received = null;

			public string field = "";
		}

		public static bool ProcessingServerUpdate;

		public readonly string Name;

		[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(2)]
		public string DisplayName;

		[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(2)]
		public string CurrentVersion;

		[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(2)]
		public string MinimumRequiredVersion;

		public bool ModRequired = false;

		private bool? forceConfigLocking;

		private bool isSourceOfTruth = true;

		private static readonly HashSet<ConfigSync> configSyncs;

		private readonly HashSet<OwnConfigEntryBase> allConfigs = new HashSet<OwnConfigEntryBase>();

		private HashSet<CustomSyncedValueBase> allCustomValues = new HashSet<CustomSyncedValueBase>();

		private static bool isServer;

		private static bool lockExempt;

		[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(2)]
		private OwnConfigEntryBase lockedConfig = null;

		private const byte PARTIAL_CONFIGS = 1;

		private const byte FRAGMENTED_CONFIG = 2;

		private const byte COMPRESSED_CONFIG = 4;

		private readonly Dictionary<string, SortedDictionary<int, byte[]>> configValueCache = new Dictionary<string, SortedDictionary<int, byte[]>>();

		[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(new byte[] { 1, 0, 1 })]
		private readonly List<KeyValuePair<long, string>> cacheExpirations = new List<KeyValuePair<long, string>>();

		private static long packageCounter;

		public bool IsLocked
		{
			get
			{
				bool? flag = forceConfigLocking;
				bool num;
				if (!flag.HasValue)
				{
					if (lockedConfig == null)
					{
						goto IL_0052;
					}
					num = ((IConvertible)lockedConfig.BaseConfig.BoxedValue).ToInt32(CultureInfo.InvariantCulture) != 0;
				}
				else
				{
					num = flag.GetValueOrDefault();
				}
				if (!num)
				{
					goto IL_0052;
				}
				int result = ((!lockExempt) ? 1 : 0);
				goto IL_0053;
				IL_0053:
				return (byte)result != 0;
				IL_0052:
				result = 0;
				goto IL_0053;
			}
			set
			{
				forceConfigLocking = value;
			}
		}

		public bool IsAdmin => lockExempt || isSourceOfTruth;

		public bool IsSourceOfTruth
		{
			get
			{
				return isSourceOfTruth;
			}
			private set
			{
				if (value != isSourceOfTruth)
				{
					isSourceOfTruth = value;
					this.SourceOfTruthChanged?.Invoke(value);
				}
			}
		}

		public bool InitialSyncDone { get; private set; } = false;


		[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(2)]
		[method: <a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(2)]
		[field: <809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(2)]
		public event Action<bool> SourceOfTruthChanged;

		[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(2)]
		[method: <a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(2)]
		[field: <809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(2)]
		private event Action lockedConfigChanged;

		static ConfigSync()
		{
			ProcessingServerUpdate = false;
			configSyncs = new HashSet<ConfigSync>();
			lockExempt = false;
			packageCounter = 0L;
			RuntimeHelpers.RunClassConstructor(typeof(VersionCheck).TypeHandle);
		}

		public ConfigSync(string name)
		{
			Name = name;
			configSyncs.Add(this);
			new VersionCheck(this);
		}

		public SyncedConfigEntry<T> AddConfigEntry<[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(2)] T>(ConfigEntry<T> configEntry)
		{
			OwnConfigEntryBase ownConfigEntryBase = configData((ConfigEntryBase)(object)configEntry);
			SyncedConfigEntry<T> syncedEntry = ownConfigEntryBase as SyncedConfigEntry<T>;
			if (syncedEntry == null)
			{
				syncedEntry = new SyncedConfigEntry<T>(configEntry);
				AccessTools.DeclaredField(typeof(ConfigDescription), "<Tags>k__BackingField").SetValue(((ConfigEntryBase)configEntry).Description, new object[1]
				{
					new ConfigurationManagerAttributes()
				}.Concat(((ConfigEntryBase)configEntry).Description.Tags ?? Array.Empty<object>()).Concat(new SyncedConfigEntry<T>[1] { syncedEntry }).ToArray());
				configEntry.SettingChanged += [<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)] (object _, EventArgs _) =>
				{
					if (!ProcessingServerUpdate && syncedEntry.SynchronizedConfig)
					{
						Broadcast(ZRoutedRpc.Everybody, (ConfigEntryBase)configEntry);
					}
				};
				allConfigs.Add(syncedEntry);
			}
			return syncedEntry;
		}

		public SyncedConfigEntry<T> AddLockingConfigEntry<[<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(0)] T>(ConfigEntry<T> lockingConfig) where T : IConvertible
		{
			if (lockedConfig != null)
			{
				throw new Exception("Cannot initialize locking ConfigEntry twice");
			}
			lockedConfig = AddConfigEntry<T>(lockingConfig);
			lockingConfig.SettingChanged += [<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)] (object _, EventArgs _) =>
			{
				this.lockedConfigChanged?.Invoke();
			};
			return (SyncedConfigEntry<T>)lockedConfig;
		}

		internal void AddCustomValue(CustomSyncedValueBase customValue)
		{
			if (allCustomValues.Select([<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)] (CustomSyncedValueBase v) => v.Identifier).Concat(new string[1] { "serverversion" }).Contains(customValue.Identifier))
			{
				throw new Exception("Cannot have multiple settings with the same name or with a reserved name (serverversion)");
			}
			allCustomValues.Add(customValue);
			allCustomValues = new HashSet<CustomSyncedValueBase>(allCustomValues.OrderByDescending([<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)] (CustomSyncedValueBase v) => v.Priority));
			customValue.ValueChanged += delegate
			{
				if (!ProcessingServerUpdate)
				{
					Broadcast(ZRoutedRpc.Everybody, customValue);
				}
			};
		}

		private void RPC_FromServerConfigSync(ZRpc rpc, ZPackage package)
		{
			lockedConfigChanged += serverLockedSettingChanged;
			IsSourceOfTruth = false;
			if (HandleConfigSyncRPC(0L, package, clientUpdate: false))
			{
				InitialSyncDone = true;
			}
		}

		private void RPC_FromOtherClientConfigSync(long sender, ZPackage package)
		{
			HandleConfigSyncRPC(sender, package, clientUpdate: true);
		}

		private bool HandleConfigSyncRPC(long sender, ZPackage package, bool clientUpdate)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Expected O, but got Unknown
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Expected O, but got Unknown
			try
			{
				if (isServer && IsLocked)
				{
					ZRpc currentRpc = SnatchCurrentlyHandlingRPC.currentRpc;
					object obj;
					if (currentRpc == null)
					{
						obj = null;
					}
					else
					{
						ISocket socket = currentRpc.GetSocket();
						obj = ((socket != null) ? socket.GetHostName() : null);
					}
					string text = (string)obj;
					if (text != null)
					{
						MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null);
						SyncedList val = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance);
						if (!(((object)methodInfo == null) ? val.Contains(text) : ((bool)methodInfo.Invoke(ZNet.instance, new object[2] { val, text }))))
						{
							return false;
						}
					}
				}
				cacheExpirations.RemoveAll(([<809e9b01-e3ed-4510-aba1-881db2661b07>Nullable(new byte[] { 0, 1 })] KeyValuePair<long, string> kv) =>
				{
					if (kv.Key < DateTimeOffset.Now.Ticks)
					{
						configValueCache.Remove(kv.Value);
						return true;
					}
					return false;
				});
				byte b = package.ReadByte();
				if ((b & 2u) != 0)
				{
					long num = package.ReadLong();
					string text2 = sender.ToString() + num;
					if (!configValueCache.TryGetValue(text2, out var value))
					{
						value = new SortedDictionary<int, byte[]>();
						configValueCache[text2] = value;
						cacheExpirations.Add(new KeyValuePair<long, string>(DateTimeOffset.Now.AddSeconds(60.0).Ticks, text2));
					}
					int key = package.ReadInt();
					int num2 = package.ReadInt();
					value.Add(key, package.ReadByteArray());
					if (value.Count < num2)
					{
						return false;
					}
					configValueCache.Remove(text2);
					package = new ZPackage(value.Values.SelectMany([<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)] (byte[] a) => a).ToArray());
					b = package.ReadByte();
				}
				ProcessingServerUpdate = true;
				if ((b & 4u) != 0)
				{
					byte[] buffer = package.ReadByteArray();
					MemoryStream stream = new MemoryStream(buffer);
					MemoryStream memoryStream = new MemoryStream();
					using (DeflateStream deflateStream = new DeflateStream(stream, CompressionMode.Decompress))
					{
						deflateStream.CopyTo(memoryStream);
					}
					package = new ZPackage(memoryStream.ToArray());
					b = package.ReadByte();
				}
				if ((b & 1) == 0)
				{
					resetConfigsFromServer();
				}
				ParsedConfigs parsedConfigs = ReadConfigsFromPackage(package);
				ConfigFile val2 = null;
				bool saveOnConfigSet = false;
				foreach (KeyValuePair<OwnConfigEntryBase, object> configValue in parsedConfigs.configValues)
				{
					if (!isServer && configValue.Key.LocalBaseValue == null)
					{
						configValue.Key.LocalBaseValue = configValue.Key.BaseConfig.BoxedValue;
					}
					if (val2 == null)
					{
						val2 = configValue.Key.BaseConfig.ConfigFile;
						saveOnConfigSet = val2.SaveOnConfigSet;
						val2.SaveOnConfigSet = false;
					}
					configValue.Key.BaseConfig.BoxedValue = configValue.Value;
				}
				if (val2 != null)
				{
					val2.SaveOnConfigSet = saveOnConfigSet;
				}
				foreach (KeyValuePair<CustomSyncedValueBase, object> customValue in parsedConfigs.customValues)
				{
					if (!isServer)
					{
						CustomSyncedValueBase key2 = customValue.Key;
						if (key2.LocalBaseValue == null)
						{
							key2.LocalBaseValue = customValue.Key.BoxedValue;
						}
					}
					customValue.Key.BoxedValue = customValue.Value;
				}
				Debug.Log((object)string.Format("Received {0} configs and {1} custom values from {2} for mod {3}", parsedConfigs.configValues.Count, parsedConfigs.customValues.Count, (isServer || clientUpdate) ? $"client {sender}" : "the server", DisplayName ?? Name));
				if (!isServer)
				{
					serverLockedSettingChanged();
				}
				return true;
			}
			finally
			{
				ProcessingServerUpdate = false;
			}
		}

		private ParsedConfigs ReadConfigsFromPackage(ZPackage package)
		{
			ParsedConfigs parsedConfigs = new ParsedConfigs();
			Dictionary<string, OwnConfigEntryBase> dictionary = allConfigs.Where([<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)] (OwnConfigEntryBase c) => c.SynchronizedConfig).ToDictionary([<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)] (OwnConfigEntryBase c) => c.BaseConfig.Definition.Section + "_" + c.BaseConfig.Definition.Key, [<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)] (OwnConfigEntryBase c) => c);
			Dictionary<string, CustomSyncedValueBase> dictionary2 = allCustomValues.ToDictionary([<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)] (CustomSyncedValueBase c) => c.Identifier, [<a48db08a-f334-4774-95ae-611ad5e1165d>NullableContext(0)] (CustomSyncedValueBase c) => c);
			int num = package.ReadInt();
			for (int i = 0; i < num; i++)
			{
				string text = package.ReadString();
				string text2 = package.ReadString();
				string text3 = package.ReadString();
				Type type = Type.GetType(text3);
				if (text3 == "" || type != null)
				{
					object obj;
					try
					{
						obj = ((text3 == "") ? nul