Decompiled source of AzuHoverStats v1.1.8
AzuHoverStats.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
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.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 System.Threading; using AzuHoverStats.Compatibility.WardIsLove; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Callbacks; 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: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("AzuHoverStats")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Azumatt")] [assembly: AssemblyProduct("AzuHoverStats")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")] [assembly: AssemblyFileVersion("1.1.8")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.8.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace LocalizationManager { [PublicAPI] public class Localizer { private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors; private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts; private static readonly ConditionalWeakTable<Localization, string> localizationLanguage; private static readonly List<WeakReference<Localization>> localizationObjects; private static BaseUnityPlugin? _plugin; private static readonly List<string> fileExtensions; private static BaseUnityPlugin plugin { get { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown if (_plugin == null) { IEnumerable<TypeInfo> source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First((TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out string value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out Dictionary<string, Func<string>> value2)) { text = value2.Aggregate(text, (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value())); } localization.AddWord(key, text); } public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, Func<T, string>? convertConfigValue = null) where T : notnull { string key2 = key; string placeholder2 = placeholder; Func<T, string> convertConfigValue2 = convertConfigValue; ConfigEntry<T> config2 = config; if (convertConfigValue2 == null) { convertConfigValue2 = (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key2)) { PlaceholderProcessors[key2] = new Dictionary<string, Func<string>>(); } config2.SettingChanged += delegate { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key2][placeholder2] = () => convertConfigValue2(config2.Value); UpdatePlaceholderText(Localization.instance, key2); } } public static void AddText(string key, string text) { List<WeakReference<Localization>> list = new List<WeakReference<Localization>>(); foreach (WeakReference<Localization> localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference<Localization> item in list) { localizationObjects.Remove(item); } } public static void Load() { LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage()); } private static void LoadLocalization(Localization __instance, string language) { if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference<Localization>(__instance)); } localizationLanguage.Add(__instance, language); Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories) where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0 select f) { string text = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' })[1]; if (dictionary.ContainsKey(text)) { Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped.")); } else { dictionary[text] = item; } } byte[] array = LoadTranslationFromAssembly("English"); if (array == null) { throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml."); } Dictionary<string, string> dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array)); if (dictionary2 == null) { throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text2 = null; if (language != "English") { if (dictionary.ContainsKey(language)) { text2 = File.ReadAllText(dictionary[language]); } else { byte[] array2 = LoadTranslationFromAssembly(language); if (array2 != null) { text2 = Encoding.UTF8.GetString(array2); } } } if (text2 == null && dictionary.ContainsKey("English")) { text2 = File.ReadAllText(dictionary["English"]); } if (text2 != null) { foreach (KeyValuePair<string, string> item2 in new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>()) { dictionary2[item2.Key] = item2.Value; } } loadedTexts[language] = dictionary2; foreach (KeyValuePair<string, string> item3 in dictionary2) { UpdatePlaceholderText(__instance, item3.Key); } } static Localizer() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>(); loadedTexts = new Dictionary<string, Dictionary<string, string>>(); localizationLanguage = new ConditionalWeakTable<Localization, string>(); localizationObjects = new List<WeakReference<Localization>>(); fileExtensions = new List<string> { ".json", ".yml" }; new Harmony("org.bepinex.helpers.LocalizationManager").Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static byte[]? LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension); if (array != null) { return array; } } return null; } public static byte[]? ReadEmbeddedFileBytes(string resourceFileName, Assembly? containingAssembly = null) { string resourceFileName2 = resourceFileName; using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault((string str) => str.EndsWith(resourceFileName2, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } } namespace AzuHoverStats { public class HoverTextPatches { [HarmonyPatch(typeof(Hud), "UpdateCrosshair")] public static class HudUpdateCrosshairPatch { public static void Postfix(Hud __instance, Player player, float bowDrawPercentage) { GameObject hoverObject = ((Humanoid)player).GetHoverObject(); if ((Object.op_Implicit((Object)(object)hoverObject) ? hoverObject.GetComponentInParent<Hoverable>() : null) != null && !TextViewer.instance.IsVisible()) { string __result = ((TMP_Text)__instance.m_hoverName).text; ((TMP_Text)__instance.m_hoverName).text = Utilities.AddHoverText(hoverObject, ref __result); } else if (Object.op_Implicit((Object)(object)hoverObject) && Object.op_Implicit((Object)(object)((Component)hoverObject.transform.root).gameObject.GetComponent<Piece>())) { hoverObject.AddComponent<HoverText>(); } } public static void CheckAndAppend(GameObject obj, ref StringBuilder sb) { Fermenter fermenter = default(Fermenter); if (obj.TryGetComponent<Fermenter>(ref fermenter)) { sb.Append(Utilities.GetFermenterString(fermenter)); } Piece piece = default(Piece); if (obj.TryGetComponent<Piece>(ref piece)) { Utilities.GetPieceString(piece); } Fireplace fireplaceComp = default(Fireplace); if (obj.TryGetComponent<Fireplace>(ref fireplaceComp)) { sb.Append(Utilities.GetFireplaceString(fireplaceComp)); } CookingStation cookingStationComp = default(CookingStation); if (obj.TryGetComponent<CookingStation>(ref cookingStationComp)) { sb.Append(Utilities.GetCookingStationString(cookingStationComp)); } MineRock5 mineRock = default(MineRock5); if (obj.TryGetComponent<MineRock5>(ref mineRock)) { sb.Append(Utilities.GetMineRock5String(mineRock)); } MineRock mineRock2 = default(MineRock); if (obj.TryGetComponent<MineRock>(ref mineRock2)) { sb.Append(Utilities.GetMineRockString(mineRock2)); } Destructible destructible = default(Destructible); if (obj.TryGetComponent<Destructible>(ref destructible)) { sb.Append(Utilities.GetDestructibleString(destructible)); } TreeLog treelog = default(TreeLog); if (obj.TryGetComponent<TreeLog>(ref treelog)) { sb.Append(Utilities.GetTreeLogString(treelog)); } TreeBase treebase = default(TreeBase); if (obj.TryGetComponent<TreeBase>(ref treebase)) { sb.Append(Utilities.GetTreeBaseString(treebase)); } Pickable pickableComp = default(Pickable); if (obj.TryGetComponent<Pickable>(ref pickableComp)) { sb.Append(Utilities.GetPickableString(pickableComp)); } Plant plantComp = default(Plant); if (obj.TryGetComponent<Plant>(ref plantComp)) { sb.Append(Utilities.GetPlantString(plantComp)); } Beehive hiveComp = default(Beehive); if (obj.TryGetComponent<Beehive>(ref hiveComp)) { sb.Append(Utilities.GetBeehiveString(hiveComp)); } SapCollector sapCollector = default(SapCollector); if (obj.TryGetComponent<SapCollector>(ref sapCollector)) { sb.Append(Utilities.GetSapCollectorString(sapCollector)); } } } [HarmonyPatch(typeof(Hud), "Awake")] private static class HudAwakePatch { public static Transform? ClonedSelectedInfo; public static GameObject ClonedSelectedInfoGo; public static TextMeshProUGUI ClonedSelectedInfoTmp; public static RectTransform ClonedSelectedInfoRt; public static BaseUnityPlugin? MinimalUIInstance; [HarmonyAfter(new string[] { "Azumatt.MinimalUI" })] private static void Postfix(Hud __instance) { //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) AzuHoverStatsPlugin.PiecehealthBar = __instance.m_pieceHealthBar; AzuHoverStatsPlugin.PiecehealthBarGo = ((Component)AzuHoverStatsPlugin.PiecehealthBar).gameObject; Transform parent = AzuHoverStatsPlugin.PiecehealthBarGo.transform.parent; AzuHoverStatsPlugin.PiecehealthBarBkg = ((Component)parent.Find("bkg")).gameObject; AzuHoverStatsPlugin.PiecehealthBarDarken = ((Component)parent.Find("darken")).gameObject; if (Chainloader.PluginInfos.TryGetValue("Azumatt.MinimalUI", out var value)) { MinimalUIInstance = value.Instance; } Transform val = ((Component)__instance).transform.Find("hudroot").Find("BuildHud"); if ((Object)(object)val == (Object)null) { return; } Transform val2 = val.Find("SelectedInfo"); if (!((Object)(object)val2 == (Object)null)) { ClonedSelectedInfo = Object.Instantiate<Transform>(val2, val2.parent); ((Object)ClonedSelectedInfo).name = "ComfortSelectedInfo"; ClonedSelectedInfoGo = ((Component)ClonedSelectedInfo).gameObject; ClonedSelectedInfoRt = ((Component)ClonedSelectedInfo).GetComponent<RectTransform>(); if (!((Object)(object)ClonedSelectedInfoRt == (Object)null)) { RectTransform component = ((Component)val2).GetComponent<RectTransform>(); float num = 75f; float x = component.anchoredPosition.x; Rect rect = component.rect; float num2 = x + ((Rect)(ref rect)).width + num; ClonedSelectedInfoRt.anchoredPosition = new Vector2(num2, component.anchoredPosition.y); ClonedSelectedInfoRt.anchorMax = new Vector2(0.35f, 0f); ClonedSelectedInfoRt.anchorMin = new Vector2(0.5f, 0f); ClonedSelectedInfoRt.sizeDelta = component.sizeDelta; ((Transform)ClonedSelectedInfoRt).localScale = ((Transform)component).localScale; ((Component)ClonedSelectedInfo.Find("selected_piece")).gameObject.SetActive(false); ((Component)ClonedSelectedInfo.Find("requirements")).gameObject.SetActive(false); ClonedSelectedInfoTmp = ClonedSelectedInfoGo.AddComponent<TextMeshProUGUI>(); ((TMP_Text)ClonedSelectedInfoTmp).text = ""; ((TMP_Text)ClonedSelectedInfoTmp).font = Hud.instance.m_pieceDescription.font; ((TMP_Text)ClonedSelectedInfoTmp).fontSize = Hud.instance.m_pieceDescription.fontSize; ((TMP_Text)ClonedSelectedInfoTmp).alignment = (TextAlignmentOptions)544; ClonedSelectedInfoGo.SetActive(false); } } } } [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int) })] private static class ItemDropItemDataGetTooltipPatch { private static void Postfix(ItemData item, ref string __result) { if (item.m_dropPrefab != null && AzuHoverStatsPlugin.showTooltipInformation.Value == AzuHoverStatsPlugin.Toggle.On) { StringBuilder stringBuilder = new StringBuilder("\n"); stringBuilder.Append(Localization.instance.Localize("\n$azuhoverstats_itemtype: " + ((object)(ItemType)(ref item.m_shared.m_itemType)).ToString() + "\n$azuhoverstats_itemtooltier: " + item.m_shared.m_toolTier)); __result += stringBuilder.ToString(); } } } [HarmonyPatch(typeof(WearNTear), "Highlight")] private static class WearNTearHighlightPatch { private static void Postfix(WearNTear __instance) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) if (AzuHoverStatsPlugin.customIntegrityColors.Value == AzuHoverStatsPlugin.Toggle.Off) { return; } float support = __instance.GetSupport(); float maxSupport = __instance.GetMaxSupport(); if (!(support < 0f) && !(maxSupport < support)) { Color val = default(Color); if ((double)__instance.GetSupportColorValue() >= 0.0) { val = ((support / maxSupport >= 0.5f) ? Color.Lerp(AzuHoverStatsPlugin.midIntegrityColor.Value, AzuHoverStatsPlugin.highIntegrityColor.Value, (support / maxSupport - 0.5f) * 2f) : Color.Lerp(AzuHoverStatsPlugin.lowIntegrityColor.Value, AzuHoverStatsPlugin.midIntegrityColor.Value, support / maxSupport * 2f)); } else { ((Color)(ref val))..ctor(0.6f, 0.8f, 1f); } MaterialMan.instance.SetValue<Color>(((Component)__instance).gameObject, ShaderProps._EmissionColor, val); MaterialMan.instance.SetValue<Color>(((Component)__instance).gameObject, ShaderProps._Color, val); ((MonoBehaviour)__instance).CancelInvoke("ResetHighlight"); ((MonoBehaviour)__instance).Invoke("ResetHighlight", 0.2f); } } } [HarmonyPatch(typeof(Hud), "OnHoverPiece")] private static class PlayerGetPiecePatch { private static void Postfix(Hud __instance) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance.m_hoveredPiece == (Object)null) && !((Object)(object)HudAwakePatch.ClonedSelectedInfoGo == (Object)null) && __instance.m_hoveredPiece.m_comfort > 0) { RectTransform component = ((Component)Hud.instance.m_buildHud.transform.Find("SelectedInfo")).GetComponent<RectTransform>(); float num = 1f; ConfigEntry<float> val = default(ConfigEntry<float>); if ((Object)(object)HudAwakePatch.MinimalUIInstance != (Object)null && HudAwakePatch.MinimalUIInstance.Config.TryGetEntry<float>("2 - Inventory", "Selected Build Panel Scale", ref val)) { num = val.Value; } float num2 = 75f * num; float x = component.anchoredPosition.x; Rect rect = component.rect; float num3 = x + ((Rect)(ref rect)).width + num2; HudAwakePatch.ClonedSelectedInfoRt.anchoredPosition = new Vector2(num3, component.anchoredPosition.y); Vector3 localScale = ((Transform)component).localScale; ((Transform)HudAwakePatch.ClonedSelectedInfoRt).localScale = new Vector3(localScale.x, localScale.y, localScale.z); HudAwakePatch.ClonedSelectedInfoGo.SetActive(true); ((TMP_Text)HudAwakePatch.ClonedSelectedInfoTmp).text = $"Comfort Level: {__instance.m_hoveredPiece.m_comfort}\nComfort Group: {__instance.m_hoveredPiece.m_comfortGroup}\n"; } } } [HarmonyPatch(typeof(Hud), "OnHoverPieceExit")] private static class HudOnHoverPieceExitPatch { private static void Postfix(Hud __instance) { if ((Object)(object)HudAwakePatch.ClonedSelectedInfoGo != (Object)null) { HudAwakePatch.ClonedSelectedInfoGo.SetActive(false); ((TMP_Text)HudAwakePatch.ClonedSelectedInfoTmp).text = ""; } } } [HarmonyPatch(typeof(Container), "GetHoverText")] internal static class GetHoverTextPatch { [HarmonyPriority(0)] private static void Postfix(Container __instance, ref string __result) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (AzuHoverStatsPlugin.ShowChestContents.Value == AzuHoverStatsPlugin.Toggle.Off || !HoverTextDisplay || (__instance.m_checkGuardStone && !PrivateArea.CheckAccess(((Component)__instance).transform.position, 0f, false, false)) || (WardIsLovePlugin.IsLoaded() && WardIsLovePlugin.WardEnabled().Value && __instance.m_checkGuardStone && !WardMonoscript.CheckAccess(((Component)__instance).transform.position, 0f, flash: false)) || __instance.GetInventory().NrOfItems() == 0) { return; } List<ItemData> list = (from idd in __instance.GetInventory().GetAllItems() select new ItemData(idd)).ToList(); Utilities.SortByType(AzuHoverStatsPlugin.sortType.Value, list, AzuHoverStatsPlugin.SortAsc.Value == AzuHoverStatsPlugin.Toggle.On); int num = 0; int num2 = 0; string text = ""; if (AzuHoverStatsPlugin.CapacityText.Value.Trim().Length > 0) { __result = __result.Replace("\n", string.Format(AzuHoverStatsPlugin.CapacityText.Value, __instance.GetInventory().GetAllItems().Count, __instance.GetInventory().GetWidth() * __instance.GetInventory().GetHeight()) + "\n"); } for (int i = 0; i < list.Count; i++) { if (AzuHoverStatsPlugin.MaxEntries.Value >= 0 && num >= AzuHoverStatsPlugin.MaxEntries.Value) { if (AzuHoverStatsPlugin.OverFlowText.Value.Length > 0) { __result = __result + "\n" + AzuHoverStatsPlugin.OverFlowText.Value; } break; } ItemData itemData = list[i]; if (itemData.m_shared.m_name == text || text == "") { num2 += itemData.m_stack; } else { __result = __result + "\n" + string.Format(AzuHoverStatsPlugin.EntryString.Value, num2, Localization.instance.Localize(text)); num++; num2 = itemData.m_stack; } text = itemData.m_shared.m_name; if (i == list.Count - 1) { __result = __result + "\n" + string.Format(AzuHoverStatsPlugin.EntryString.Value, num2, Localization.instance.Localize(text)); } } } } public class ItemData { public SharedData m_shared; public int m_stack; public ItemData(ItemData idd) { m_shared = idd.m_shared; m_stack = idd.m_stack; } } public enum SortType { Name, Weight, Amount, Value } public static bool HoverTextDisplay = true; } [BepInPlugin("Azumatt.AzuHoverStats", "AzuHoverStats", "1.1.8")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class AzuHoverStatsPlugin : BaseUnityPlugin { public enum Toggle { On = 1, Off = 0 } private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [UsedImplicitly] public string? Category; [UsedImplicitly] public Action<ConfigEntryBase>? CustomDrawer; } 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); } } internal const string ModName = "AzuHoverStats"; internal const string ModVersion = "1.1.8"; internal const string Author = "Azumatt"; private const string ModGUID = "Azumatt.AzuHoverStats"; private static string _configFileName = "Azumatt.AzuHoverStats.cfg"; private static string _configFileFullPath; internal static string ConnectionError; private readonly Harmony _harmony = new Harmony("Azumatt.AzuHoverStats"); public static readonly ManualLogSource AzuHoverStatsLogger; internal static GuiBar PiecehealthBar; internal static GameObject PiecehealthBarGo; internal static GameObject PiecehealthBarBkg; internal static GameObject PiecehealthBarDarken; public static ConfigEntry<KeyboardShortcut> DisableVisuals; public static ConfigEntry<Toggle> ShowMineRockStatus; public static ConfigEntry<Toggle> ShowFermenterStatus; public static ConfigEntry<Toggle> ShowTreeStatus; public static ConfigEntry<Toggle> ShowBushStatus; public static ConfigEntry<Toggle> ShowPlantStatus; public static ConfigEntry<Toggle> ShowPickableStatus; public static ConfigEntry<Toggle> ShowBeehiveStatus; public static ConfigEntry<Toggle> ShowSapCollectorStatus; public static ConfigEntry<Toggle> ShowBuildPieceStatus; public static ConfigEntry<Toggle> ShowFireplaceStatus; public static ConfigEntry<Toggle> ShowCookingStationStatus; public static ConfigEntry<Toggle> ShowSmelterStatus; private static ConfigEntry<Toggle> _serverConfigLocked; internal static ConfigEntry<Toggle> showTooltipInformation; public static ConfigEntry<Toggle> showHealthBar; public static ConfigEntry<Toggle> showHealthText; public static ConfigEntry<Toggle> showIntegrityText; public static ConfigEntry<Toggle> customHealthColors; public static ConfigEntry<Toggle> customIntegrityColors; public static ConfigEntry<HoverTextPatches.SortType> sortType; public static ConfigEntry<Toggle> SortAsc; public static ConfigEntry<Toggle> ShowChestContents; public static ConfigEntry<string> healthText; public static ConfigEntry<string> integrityText; public static ConfigEntry<string> EntryString; public static ConfigEntry<string> OverFlowText; public static ConfigEntry<string> CapacityText; public static ConfigEntry<Vector2> healthTextPosition; public static ConfigEntry<Vector2> healthBarPosition; public static ConfigEntry<Vector2> integrityTextPosition; public static ConfigEntry<int> healthTextSize; public static ConfigEntry<int> integrityTextSize; public static ConfigEntry<int> MaxEntries; public static ConfigEntry<Color> lowColor; public static ConfigEntry<Color> midColor; public static ConfigEntry<Color> highColor; public static ConfigEntry<Color> lowIntegrityColor; public static ConfigEntry<Color> midIntegrityColor; public static ConfigEntry<Color> highIntegrityColor; public void Awake() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Expected O, but got Unknown Localizer.Load(); DisableVisuals = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("1 - General", "Disable All Visuals", new KeyboardShortcut((KeyCode)104, Array.Empty<KeyCode>()), new ConfigDescription("Custom shortcut to enable or disable the hover text visuals.", (AcceptableValueBase)(object)new AcceptableShortcuts(), Array.Empty<object>())); showTooltipInformation = ((BaseUnityPlugin)this).Config.Bind<Toggle>("1 - General", "Show Tooltip Information", Toggle.On, "Show additional tooltip information on hover of an item in inventory?"); showHealthBar = ((BaseUnityPlugin)this).Config.Bind<Toggle>("2 - Build Piece", "Show Health Bar", Toggle.On, "Show health bar on building piece hover (with hammer)?"); showHealthText = ((BaseUnityPlugin)this).Config.Bind<Toggle>("2 - Build Piece", "Show Health Text", Toggle.On, "Show health text on building piece hover (with hammer)?"); showIntegrityText = ((BaseUnityPlugin)this).Config.Bind<Toggle>("2 - Build Piece", "Show Integrity Text", Toggle.On, "Show integrity text on building piece hover (with hammer)?"); customHealthColors = ((BaseUnityPlugin)this).Config.Bind<Toggle>("2 - Build Piece", "Custom Health Colors", Toggle.On, "Use custom health colors on building piece hover (with hammer)?"); customIntegrityColors = ((BaseUnityPlugin)this).Config.Bind<Toggle>("2 - Build Piece", "Custom Integrity Colors", Toggle.On, "Use custom integrity colors on building piece hover (with hammer)?"); lowColor = ((BaseUnityPlugin)this).Config.Bind<Color>("2 - Build Piece", "LowColor", Color.red, "Color used for low health. When hovering a build piece with hammer"); midColor = ((BaseUnityPlugin)this).Config.Bind<Color>("2 - Build Piece", "MidColor", Color.yellow, "Color used for mid health. When hovering a build piece with hammer"); highColor = ((BaseUnityPlugin)this).Config.Bind<Color>("2 - Build Piece", "HighColor", Color.green, "Color used for high health. When hovering a build piece with hammer"); lowIntegrityColor = ((BaseUnityPlugin)this).Config.Bind<Color>("2 - Build Piece", "Low Integrity Color", Color.red, "Color used for low integrity. When hovering a build piece with hammer"); midIntegrityColor = ((BaseUnityPlugin)this).Config.Bind<Color>("2 - Build Piece", "Mid Integrity Color", Color.yellow, "Color used for mid integrity. When hovering a build piece with hammer"); highIntegrityColor = ((BaseUnityPlugin)this).Config.Bind<Color>("2 - Build Piece", "High Integrity Color", Color.green, "Color used for high integrity. When hovering a build piece with hammer"); healthText = ((BaseUnityPlugin)this).Config.Bind<string>("2 - Build Piece", "Health Text", "{0}/{1} ({2}%)", "Health text. {0} is replaced by current health. {1} is replaced by max health. {2} is replaced by percentage health."); integrityText = ((BaseUnityPlugin)this).Config.Bind<string>("2 - Build Piece", "Integrity Text", "{0}/{1} ({2}%)", "Integrity text. {0} is replaced by current integrity. {1} is replaced by max integrity. {2} is replaced by percentage integrity."); healthTextSize = ((BaseUnityPlugin)this).Config.Bind<int>("2 - Build Piece", "Health Text Size", 18, "Health text size. When hovering a build piece with hammer"); integrityTextSize = ((BaseUnityPlugin)this).Config.Bind<int>("2 - Build Piece", "Integrity Text Size", 18, "Integrity text size. When hovering a build piece with hammer"); healthTextPosition = ((BaseUnityPlugin)this).Config.Bind<Vector2>("2 - Build Piece", "Health Text Position", new Vector2(170f, -10f), "Health text position offset. When hovering a build piece with hammer/placement object"); healthBarPosition = ((BaseUnityPlugin)this).Config.Bind<Vector2>("2 - Build Piece", "Health Bar Position", new Vector2(170f, -50f), "Health bar position offset. When hovering a build piece with hammer/placement object"); integrityTextPosition = ((BaseUnityPlugin)this).Config.Bind<Vector2>("2 - Build Piece", "Integrity Text Position", new Vector2(170f, -90f), "Integrity text position offset. When hovering a build piece with hammer/placement object"); ShowBuildPieceStatus = ((BaseUnityPlugin)this).Config.Bind<Toggle>("3 - Hover Texts", "Show Build Piece Status", Toggle.On, "Display health and integrity based on your configurations when hovering a building piece with the hammer/placement object"); ShowFireplaceStatus = ((BaseUnityPlugin)this).Config.Bind<Toggle>("3 - Hover Texts", "Show Fireplace Status", Toggle.On, "Display time left when hovering a lit fireplace"); ShowCookingStationStatus = ((BaseUnityPlugin)this).Config.Bind<Toggle>("3 - Hover Texts", "Show Cooking Station Status", Toggle.On, "Display cooking time and burn time when hovering a cooking station that is currently cooking food."); ShowMineRockStatus = ((BaseUnityPlugin)this).Config.Bind<Toggle>("3 - Hover Texts", "Show Mine Rock Status", Toggle.On, "Display the health of mineable rocks when hovered"); ShowTreeStatus = ((BaseUnityPlugin)this).Config.Bind<Toggle>("3 - Hover Texts", "Show Tree Status", Toggle.On, "Display health and tool tier requirements when hovering trees and stumps"); ShowPickableStatus = ((BaseUnityPlugin)this).Config.Bind<Toggle>("3 - Hover Texts", "Show Pickable Status", Toggle.On, "Display time left when hovering over pickable objects."); ShowPlantStatus = ((BaseUnityPlugin)this).Config.Bind<Toggle>("3 - Hover Texts", "Show Plant Status", Toggle.On, "Display time left when hovering over a plant"); ShowSapCollectorStatus = ((BaseUnityPlugin)this).Config.Bind<Toggle>("3 - Hover Texts", "Show Sap Collector Status", Toggle.On, "Display time left when hovering over a sap collector"); ShowBeehiveStatus = ((BaseUnityPlugin)this).Config.Bind<Toggle>("3 - Hover Texts", "Show Beehive Status", Toggle.On, "Display time left when hovering over an active beehive."); ShowFermenterStatus = ((BaseUnityPlugin)this).Config.Bind<Toggle>("3 - Hover Texts", "Show Fermenter Status", Toggle.On, "Display time left in fermentation process when hovering a fermenter"); ShowChestContents = ((BaseUnityPlugin)this).Config.Bind<Toggle>("4 - Show Chest Contents", "Show Chest Contents", Toggle.On, new ConfigDescription("If on, the below settings for chest content showing will take effect. If off, the patch is skipped and nothing will display. None of the below settings will take effect.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 2 } })); MaxEntries = ((BaseUnityPlugin)this).Config.Bind<int>("4 - Show Chest Contents", "MaxEntries", -1, "Max number of entries to show (-1 means show all)"); sortType = ((BaseUnityPlugin)this).Config.Bind<HoverTextPatches.SortType>("4 - Show Chest Contents", "SortType", HoverTextPatches.SortType.Value, "Type by which to sort entries."); SortAsc = ((BaseUnityPlugin)this).Config.Bind<Toggle>("4 - Show Chest Contents", "SortAsc", Toggle.Off, "Sort ascending?"); EntryString = TextEntryConfig("4 - Show Chest Contents", "EntryText", "<color=#FFFFAAFF>{0}</color> <color=#AAFFAAFF>{1}</color>", "Entry text. {0} is replaced by the total amount, {1} is replaced by the item name."); OverFlowText = TextEntryConfig("4 - Show Chest Contents", "OverFlowText", "<color=#AAAAAAFF>...</color>", "Overflow text if more items than max entries."); CapacityText = TextEntryConfig("4 - Show Chest Contents", "CapacityText", "<color=#FFFFAAFF> {0}/{1}</color>", "Text to show capacity. {0} is replaced by number of full slots, {1} is replaced by total slots."); AutoDoc(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); SetupWatcher(); PluginInfo value2; if (Chainloader.PluginInfos.TryGetValue("com.Bento.MissingPieces", out var value)) { CheckAndPatch(value); } else if (Chainloader.PluginInfos.TryGetValue("MagicMike.CoreWoodExtras", out value2)) { CheckAndPatch(value2); } } private void CheckAndPatch(PluginInfo pluginInfo) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown if ((Object)(object)pluginInfo.Instance == (Object)null) { return; } Type type = ((object)pluginInfo.Instance).GetType().Assembly.GetType("CustomInteract"); if (!(type == null)) { MethodInfo method = type.GetMethod("GetHoverText"); if (method != null) { _harmony.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(typeof(AzuHoverStatsPlugin), "CustomInteract_GetHoverText_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } private static void CustomInteract_GetHoverText_Postfix(object __instance, ref string __result) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) try { if (!(__instance.GetType().Name == "CustomInteract")) { return; } object? obj = __instance.GetType().GetProperty("gameObject")?.GetValue(__instance, null); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if ((Object)(object)val == (Object)null) { return; } Container component = val.GetComponent<Container>(); if ((Object)(object)component == (Object)null || ShowChestContents.Value == Toggle.Off || !HoverTextPatches.HoverTextDisplay || (component.m_checkGuardStone && !PrivateArea.CheckAccess(((Component)component).transform.position, 0f, false, false)) || (WardIsLovePlugin.IsLoaded() && WardIsLovePlugin.WardEnabled().Value && component.m_checkGuardStone && !WardMonoscript.CheckAccess(((Component)component).transform.position, 0f, flash: false)) || component.GetInventory().NrOfItems() == 0) { return; } List<HoverTextPatches.ItemData> list = (from idd in component.GetInventory().GetAllItems() select new HoverTextPatches.ItemData(idd)).ToList(); Utilities.SortByType(sortType.Value, list, SortAsc.Value == Toggle.On); int num = 0; int num2 = 0; string text = ""; if (CapacityText.Value.Trim().Length > 0) { FieldInfo field = __instance.GetType().GetField("Name", BindingFlags.Public); if (field != null) { string text2 = field.GetValue(__instance) as string; __result = __result.Replace(text2 + "\n", text2 + " " + string.Format(CapacityText.Value, component.GetInventory().GetAllItems().Count, component.GetInventory().GetWidth() * component.GetInventory().GetHeight()) + "\n"); } } for (int i = 0; i < list.Count; i++) { if (MaxEntries.Value >= 0 && num >= MaxEntries.Value) { if (OverFlowText.Value.Length > 0) { __result = __result + "\n" + OverFlowText.Value; } break; } HoverTextPatches.ItemData itemData = list[i]; if (itemData.m_shared.m_name == text || text == "") { num2 += itemData.m_stack; } else { __result = __result + "\n" + string.Format(EntryString.Value, num2, Localization.instance.Localize(text)); num++; num2 = itemData.m_stack; } text = itemData.m_shared.m_name; if (i == list.Count - 1) { __result = __result + "\n" + string.Format(EntryString.Value, num2, Localization.instance.Localize(text)); } } } catch (Exception ex) { Debug.LogError((object)("Error in CustomInteract_GetHoverText_Postfix: " + ex.Message)); } } internal void AutoDoc() { } 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; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(_configFileFullPath)) { return; } try { AzuHoverStatsLogger.LogDebug((object)"ReadConfigValues called"); ((BaseUnityPlugin)this).Config.Reload(); } catch { AzuHoverStatsLogger.LogError((object)("There was an issue loading your " + _configFileName)); AzuHoverStatsLogger.LogError((object)"Please check your config entries for spelling and format!"); } } internal static void TextAreaDrawer(ConfigEntryBase entry) { GUILayout.ExpandHeight(true); GUILayout.ExpandWidth(true); entry.BoxedValue = GUILayout.TextArea((string)entry.BoxedValue, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); } internal ConfigEntry<T> TextEntryConfig<T>(string group, string name, T value, string desc) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes { CustomDrawer = TextAreaDrawer }; return ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); } static AzuHoverStatsPlugin() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; _configFileFullPath = configPath + directorySeparatorChar + _configFileName; ConnectionError = ""; AzuHoverStatsLogger = Logger.CreateLogSource("AzuHoverStats"); PiecehealthBar = null; PiecehealthBarGo = null; PiecehealthBarBkg = null; PiecehealthBarDarken = null; DisableVisuals = null; ShowMineRockStatus = null; ShowFermenterStatus = null; ShowTreeStatus = null; ShowBushStatus = null; ShowPlantStatus = null; ShowPickableStatus = null; ShowBeehiveStatus = null; ShowSapCollectorStatus = null; ShowBuildPieceStatus = null; ShowFireplaceStatus = null; ShowCookingStationStatus = null; ShowSmelterStatus = null; _serverConfigLocked = null; showTooltipInformation = null; sortType = null; SortAsc = null; ShowChestContents = null; EntryString = null; OverFlowText = null; CapacityText = null; MaxEntries = null; } } public class Utilities { public static string TimeCalc(DateTime placedTime, float growthTime) { TimeSpan timeSpan = ZNet.instance.GetTime() - placedTime; TimeSpan timeSpan2 = TimeSpan.FromSeconds((double)growthTime - timeSpan.TotalSeconds); double num = (double)(growthTime / 60f) - timeSpan.TotalMinutes; string text = ((timeSpan2.Hours > 0) ? $"{timeSpan2.Hours:D2}h {timeSpan2.Minutes:D2}m {timeSpan2.Seconds:D2}s" : ((timeSpan2.Minutes <= 0) ? $"{timeSpan2.Seconds:D2}s" : $"{timeSpan2.Minutes:D2}m {timeSpan2.Seconds:D2}s")); if (!(num < 0.0)) { return "(" + text + ")"; } return ""; } public static string AddHoverText(GameObject gobj, ref string __result) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) StringBuilder sb = new StringBuilder(); Tuple<ZNetView, GameObject> zNetView = GetZNetView(gobj); if (!Object.op_Implicit((Object)(object)zNetView.Item1) || !zNetView.Item1.IsValid()) { return __result = __result + "\n\n" + sb; } KeyboardShortcut value; if (HoverTextPatches.HoverTextDisplay) { if (AzuHoverStatsPlugin.DisableVisuals != null) { value = AzuHoverStatsPlugin.DisableVisuals.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { HoverTextPatches.HoverTextDisplay = false; } } try { HoverTextPatches.HudUpdateCrosshairPatch.CheckAndAppend(zNetView.Item2, ref sb); } catch { } return __result = __result + "\n" + sb; } if (AzuHoverStatsPlugin.DisableVisuals != null) { value = AzuHoverStatsPlugin.DisableVisuals.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { HoverTextPatches.HoverTextDisplay = true; } } return __result = __result + "\n" + sb; } private static Tuple<ZNetView, GameObject> GetZNetView(GameObject gobj) { GameObject gameObject = ((Component)gobj.transform.root).gameObject; return Tuple.Create<ZNetView, GameObject>(gameObject.GetComponent<ZNetView>(), gameObject); } internal static string GetFermenterString(Fermenter fermenter) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 if (AzuHoverStatsPlugin.ShowFermenterStatus.Value == AzuHoverStatsPlugin.Toggle.Off) { return ""; } if ((int)fermenter.GetStatus() != 1) { return ""; } return TimeCalc(new DateTime(fermenter.m_nview.GetZDO().GetLong("StartTime", 0L)), fermenter.m_fermentationDuration) ?? ""; } internal static void GetPieceString(Piece piece) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) WearNTear component = ((Component)piece).gameObject.GetComponent<WearNTear>(); if (AzuHoverStatsPlugin.ShowBuildPieceStatus.Value == AzuHoverStatsPlugin.Toggle.Off || !Object.op_Implicit((Object)(object)component)) { return; } AzuHoverStatsPlugin.PiecehealthBarBkg.SetActive(AzuHoverStatsPlugin.showHealthBar.Value == AzuHoverStatsPlugin.Toggle.On); AzuHoverStatsPlugin.PiecehealthBarDarken.SetActive(AzuHoverStatsPlugin.showHealthBar.Value == AzuHoverStatsPlugin.Toggle.On); AzuHoverStatsPlugin.PiecehealthBarGo.SetActive(AzuHoverStatsPlugin.showHealthBar.Value == AzuHoverStatsPlugin.Toggle.On); AzuHoverStatsPlugin.PiecehealthBarBkg.GetComponent<RectTransform>().anchoredPosition = new Vector2(AzuHoverStatsPlugin.healthBarPosition.Value.y, AzuHoverStatsPlugin.healthBarPosition.Value.x); AzuHoverStatsPlugin.PiecehealthBarDarken.GetComponent<RectTransform>().anchoredPosition = new Vector2(AzuHoverStatsPlugin.healthBarPosition.Value.y, AzuHoverStatsPlugin.healthBarPosition.Value.x); AzuHoverStatsPlugin.PiecehealthBarGo.GetComponent<RectTransform>().anchoredPosition = new Vector2(AzuHoverStatsPlugin.healthBarPosition.Value.y, AzuHoverStatsPlugin.healthBarPosition.Value.x); float healthPercentage = component.GetHealthPercentage(); if (AzuHoverStatsPlugin.customHealthColors.Value == AzuHoverStatsPlugin.Toggle.On) { AzuHoverStatsPlugin.PiecehealthBar.SetValue(component.GetHealthPercentage()); if ((double)healthPercentage < 0.5) { AzuHoverStatsPlugin.PiecehealthBar.SetColor(Color.Lerp(AzuHoverStatsPlugin.lowColor.Value, AzuHoverStatsPlugin.midColor.Value, healthPercentage * 2f)); } else { AzuHoverStatsPlugin.PiecehealthBar.SetColor(Color.Lerp(AzuHoverStatsPlugin.midColor.Value, AzuHoverStatsPlugin.highColor.Value, (healthPercentage - 0.5f) * 2f)); } } if (AzuHoverStatsPlugin.showHealthText.Value != 0) { Transform val = ((Transform)Hud.instance.m_pieceHealthRoot).Find("_HealthText"); if ((Object)(object)val == (Object)null) { val = Object.Instantiate<TMP_Text>(Hud.instance.m_healthText, ((Component)Hud.instance.m_pieceHealthRoot).transform).transform; ((Transform)((Component)val).GetComponent<RectTransform>()).localEulerAngles = new Vector3(0f, 0f, -90f); } ((Object)val).name = "_HealthText"; ((Component)val).GetComponent<TMP_Text>().text = string.Format(AzuHoverStatsPlugin.healthText.Value, Mathf.RoundToInt(piece.m_nview.GetZDO().GetFloat("health", component.m_health)), Mathf.RoundToInt(component.m_health), Mathf.RoundToInt(healthPercentage * 100f)); ((Component)val).GetComponent<TMP_Text>().fontSize = AzuHoverStatsPlugin.healthTextSize.Value; ((Component)val).GetComponent<TMP_Text>().fontSizeMax = ((Component)val).GetComponent<TMP_Text>().text.Length; ((Component)val).GetComponent<RectTransform>().anchoredPosition = new Vector2(AzuHoverStatsPlugin.healthTextPosition.Value.y, AzuHoverStatsPlugin.healthTextPosition.Value.x); } float support = component.GetSupport(); float maxSupport = component.GetMaxSupport(); if (AzuHoverStatsPlugin.showIntegrityText.Value == AzuHoverStatsPlugin.Toggle.On && maxSupport >= support) { Transform val2 = ((Transform)Hud.instance.m_pieceHealthRoot).Find("_IntegrityText"); if ((Object)(object)val2 == (Object)null) { val2 = Object.Instantiate<TMP_Text>(Hud.instance.m_healthText, ((Component)Hud.instance.m_pieceHealthRoot).transform).transform; ((Transform)((Component)val2).GetComponent<RectTransform>()).localEulerAngles = new Vector3(0f, 0f, -90f); } ((Object)val2).name = "_IntegrityText"; ((Component)val2).GetComponent<TMP_Text>().text = string.Format(AzuHoverStatsPlugin.integrityText.Value, Mathf.RoundToInt(support), Mathf.RoundToInt(maxSupport), Mathf.RoundToInt(support / maxSupport * 100f)); ((Component)val2).GetComponent<TMP_Text>().fontSize = AzuHoverStatsPlugin.integrityTextSize.Value; ((Component)val2).GetComponent<TMP_Text>().fontSizeMax = ((Component)val2).GetComponent<TMP_Text>().text.Length; ((Component)val2).GetComponent<RectTransform>().anchoredPosition = new Vector2(AzuHoverStatsPlugin.integrityTextPosition.Value.y, AzuHoverStatsPlugin.integrityTextPosition.Value.x); } } internal static string GetFireplaceString(Fireplace fireplaceComp) { if (AzuHoverStatsPlugin.ShowFireplaceStatus.Value == AzuHoverStatsPlugin.Toggle.Off) { return ""; } float @float = fireplaceComp.m_nview.GetZDO().GetFloat("fuel", 0f); if (@float == 0f) { return ""; } TimeSpan timeSpan = TimeSpan.FromMinutes(@float * fireplaceComp.m_secPerFuel / 60f); string text = ((timeSpan.Hours > 0) ? $"{timeSpan.Hours:D2}h {timeSpan.Minutes:D2}m {timeSpan.Seconds:D2}s" : ((timeSpan.Minutes <= 0) ? $"{timeSpan.Seconds:D2}s" : $"{timeSpan.Minutes:D2}m {timeSpan.Seconds:D2}s")); return "(" + text + ")"; } internal static string GetCookingStationString(CookingStation cookingStationComp) { if (AzuHoverStatsPlugin.ShowCookingStationStatus.Value == AzuHoverStatsPlugin.Toggle.Off) { return ""; } StringBuilder stringBuilder = new StringBuilder(); string text = default(string); float num = default(float); Status val = default(Status); for (int i = 0; i < cookingStationComp.m_slots.Length; i++) { cookingStationComp.GetSlot(i, ref text, ref num, ref val); if (!(text != "")) { continue; } ItemConversion itemConversion = cookingStationComp.GetItemConversion(text); if (itemConversion != null) { float num2 = itemConversion.m_cookTime - num; TimeSpan timeSpan = TimeSpan.FromMinutes((itemConversion.m_cookTime * 2f - num) / 60f); TimeSpan timeSpan2 = TimeSpan.FromMinutes(num2 / 60f); string text2 = ((timeSpan.Hours > 0) ? $"{timeSpan.Hours:D2}h {timeSpan.Minutes:D2}m {timeSpan.Seconds:D2}s" : ((timeSpan.Minutes <= 0) ? $"{timeSpan.Seconds:D2}s" : $"{timeSpan.Minutes:D2}m {timeSpan.Seconds:D2}s")); string text3 = ((timeSpan2.Hours > 0) ? $"{timeSpan2.Hours:D2}h {timeSpan2.Minutes:D2}m {timeSpan2.Seconds:D2}s" : ((timeSpan2.Minutes <= 0) ? $"{timeSpan2.Seconds:D2}s" : $"{timeSpan2.Minutes:D2}m {timeSpan2.Seconds:D2}s")); if (num > itemConversion.m_cookTime) { stringBuilder.Append(Localization.instance.Localize("<color=\"red\">$azuhoverstats_burnsin [" + text2 + "]</color>\n")); continue; } string text4 = Localization.instance.Localize(itemConversion.m_to.GetHoverName()); stringBuilder.Append(Localization.instance.Localize(text4 + " (" + text3 + ") <color=\"red\">$azuhoverstats_burnsin [" + text2 + "]</color>\n")); } } return $"{stringBuilder}"; } internal static string GetMineRock5String(MineRock5 mineRock5) { if (AzuHoverStatsPlugin.ShowMineRockStatus.Value == AzuHoverStatsPlugin.Toggle.Off) { return ""; } if (!mineRock5.m_nview.IsValid()) { return ""; } StringBuilder stringBuilder = new StringBuilder(); float num = mineRock5.m_health * (float)mineRock5.m_hitAreas.Count; float num2 = mineRock5.m_hitAreas.Sum((HitArea t) => t.m_health); if (num2 > 0f) { stringBuilder.Append(Localization.instance.Localize($"$azuhoverstats_currenthealth: {num2:N0}\n$azuhoverstats_initialhealth: {num:N0}")); } return stringBuilder.ToString(); } internal static string GetMineRockString(MineRock mineRock) { MineRock mineRock2 = mineRock; if (AzuHoverStatsPlugin.ShowMineRockStatus.Value == AzuHoverStatsPlugin.Toggle.Off) { return ""; } if (!mineRock2.m_nview.IsValid()) { return ""; } StringBuilder stringBuilder = new StringBuilder(); float num = mineRock2.m_health * (float)mineRock2.m_hitAreas.Length; float num2 = mineRock2.m_hitAreas.Select((Collider a, int i) => Math.Max(0f, mineRock2.m_nview.GetZDO().GetFloat($"Health{i}", mineRock2.m_health))).Sum(); if (num2 > 0f) { stringBuilder.Append(Localization.instance.Localize($"$azuhoverstats_currenthealth: {num2:N0}\n$azuhoverstats_initialhealth: {num:N0}")); } return stringBuilder.ToString(); } internal static string GetDestructibleString(Destructible destructible) { if (AzuHoverStatsPlugin.ShowMineRockStatus.Value == AzuHoverStatsPlugin.Toggle.Off) { return ""; } if (((Object)((Component)destructible).gameObject).name.ToLower().Contains("tree") && AzuHoverStatsPlugin.ShowTreeStatus.Value == AzuHoverStatsPlugin.Toggle.Off) { return ""; } float @float = destructible.m_nview.GetZDO().GetFloat("health", destructible.m_health); if (!(@float > 0f)) { return ""; } return Localization.instance.Localize($"$azuhoverstats_currenthealth: {@float:N0}\n$azuhoverstats_initialhealth: {destructible.m_health:N0}\n"); } internal static string GetTreeLogString(TreeLog treelog) { if (AzuHoverStatsPlugin.ShowTreeStatus.Value == AzuHoverStatsPlugin.Toggle.Off) { return ""; } float @float = treelog.m_nview.GetZDO().GetFloat("health", treelog.m_health); if (!(@float > 0f)) { return ""; } return Localization.instance.Localize($"$azuhoverstats_currenthealth: {@float:N0}\n$azuhoverstats_initialhealth: {treelog.m_health:N0}\n$azuhoverstats_tooltierrequired: {treelog.m_minToolTier}"); } internal static string GetTreeBaseString(TreeBase treebase) { if (AzuHoverStatsPlugin.ShowTreeStatus.Value == AzuHoverStatsPlugin.Toggle.Off) { return ""; } float @float = treebase.m_nview.GetZDO().GetFloat("health", treebase.m_health); if (!(@float > 0f)) { return ""; } return Localization.instance.Localize($"$azuhoverstats_currenthealth: {@float:N0}\n$azuhoverstats_initialhealth: {treebase.m_health:N0}\n$azuhoverstats_tooltierrequired: {treebase.m_minToolTier}"); } internal static string GetPickableString(Pickable pickableComp) { if (AzuHoverStatsPlugin.ShowPickableStatus.Value == AzuHoverStatsPlugin.Toggle.Off) { return ""; } if (((Object)pickableComp).name.ToLower().Contains("surt")) { return ""; } float growthTime = pickableComp.m_respawnTimeMinutes * 60f; return TimeCalc(new DateTime(pickableComp.m_nview.GetZDO().GetLong("picked_time", 0L)), growthTime) ?? ""; } internal static string GetPlantString(Plant plantComp) { if (AzuHoverStatsPlugin.ShowPlantStatus.Value == AzuHoverStatsPlugin.Toggle.Off) { return ""; } if (((Object)((Component)plantComp).gameObject).name.ToLower().Contains("sapling") && AzuHoverStatsPlugin.ShowTreeStatus.Value == AzuHoverStatsPlugin.Toggle.Off) { return ""; } double num = plantComp.TimeSincePlanted(); DateTime placedTime = new DateTime(plantComp.m_nview.GetZDO().GetLong("plantTime", ZNet.instance.GetTime().Ticks)); float growTime = plantComp.GetGrowTime(); if (!(num <= (double)growTime)) { return ""; } return TimeCalc(placedTime, growTime); } internal static string GetBeehiveString(Beehive hiveComp) { if (AzuHoverStatsPlugin.ShowBeehiveStatus.Value == AzuHoverStatsPlugin.Toggle.Off) { return ""; } string text = Localization.instance.Localize(hiveComp.m_honeyItem.m_itemData.m_shared.m_name); float num = (float)hiveComp.GetHoneyLevel() / (float)hiveComp.m_maxHoney; if (hiveComp.GetHoneyLevel() == hiveComp.m_maxHoney) { return Localization.instance.Localize("\n" + text + " $azuhoverstats_fullness: " + num.ToString("P2")); } string text2 = ""; float num2 = hiveComp.m_nview.GetZDO().GetFloat("product", 0f) + HoneyGetTimeSinceLastUpdate(hiveComp); if (num2 < hiveComp.m_secPerUnit) { string text3 = TimeSpan.FromSeconds(Mathf.RoundToInt(hiveComp.m_secPerUnit - num2)).ToString("hh\\h\\ mm\\m\\ ss\\s", CultureInfo.InvariantCulture); text3 = text3.Replace("00h ", ""); text3 = text3.Replace("00m ", ""); text3 = text3.Replace("00s", ""); text3 = text3.Replace(" ", " "); text3 = text3.Trim(); int num3 = Mathf.RoundToInt(num2); string text4 = TimeSpan.FromSeconds(num3).ToString("hh\\h\\ mm\\m\\ ss\\s", CultureInfo.InvariantCulture).Replace("00h ", "") .Replace("00m ", "") .Replace("00s", "") .Replace(" ", " ") .Trim(); string text5 = TimeSpan.FromSeconds((float)hiveComp.m_maxHoney * hiveComp.m_secPerUnit - ((float)num3 + (float)hiveComp.GetHoneyLevel() * hiveComp.m_secPerUnit)).ToString("hh\\h\\ mm\\m\\ ss\\s", CultureInfo.InvariantCulture); text5 = text5.Replace("00h ", ""); text5 = text5.Replace("00m ", ""); text5 = text5.Replace("00s", ""); text5 = text5.Replace(" ", " "); text5 = text5.Trim(); text2 = Localization.instance.Localize("$azuhoverstats_approximatenext " + text + ": " + text3 + Environment.NewLine + "$azuhoverstats_timeelapsed: " + text4 + Environment.NewLine + "$azuhoverstats_timeuntilfull: " + text5); } else { text2 = Localization.instance.Localize(text + " $azuhoverstats_isready"); } return Localization.instance.Localize("\n" + text + " $azuhoverstats_fullness: " + num.ToString("P2") + Environment.NewLine + text2); } internal static string GetSapCollectorString(SapCollector sapCollector) { if (AzuHoverStatsPlugin.ShowSapCollectorStatus.Value == AzuHoverStatsPlugin.Toggle.Off) { return ""; } string text = ""; float num = sapCollector.m_nview.GetZDO().GetFloat("product", 0f) + SapGetTimeSinceLastUpdate(sapCollector); if (num < sapCollector.m_secPerUnit) { string text2 = TimeSpan.FromSeconds(Mathf.RoundToInt(sapCollector.m_secPerUnit - num)).ToString("hh\\h\\ mm\\m\\ ss\\s", CultureInfo.InvariantCulture); text2 = text2.Replace("00h ", ""); text2 = text2.Replace("00m ", ""); text2 = text2.Replace("00s", ""); text2 = text2.Replace(" ", " "); text2 = text2.Trim(); int num2 = Mathf.RoundToInt(num); string text3 = TimeSpan.FromSeconds(num2).ToString("hh\\h\\ mm\\m\\ ss\\s", CultureInfo.InvariantCulture).Replace("00h ", "") .Replace("00m ", "") .Replace("00s", "") .Replace(" ", " ") .Trim(); string text4 = TimeSpan.FromSeconds((float)sapCollector.m_maxLevel * sapCollector.m_secPerUnit - ((float)num2 + (float)sapCollector.GetLevel() * sapCollector.m_secPerUnit)).ToString("hh\\h\\ mm\\m\\ ss\\s", CultureInfo.InvariantCulture); text4 = text4.Replace("00h ", ""); text4 = text4.Replace("00m ", ""); text4 = text4.Replace("00s", ""); text4 = text4.Replace(" ", " "); text4 = text4.Trim(); return Localization.instance.Localize("$azuhoverstats_approximatenext $item_sap: " + text2 + Environment.NewLine + "$azuhoverstats_timeelapsed: " + text3 + Environment.NewLine + "$azuhoverstats_timeuntilfinished: " + text4); } return Localization.instance.Localize("$item_sap $azuhoverstats_isready"); } public static float SapGetTimeSinceLastUpdate(SapCollector sapCollector) { DateTime dateTime = new DateTime(sapCollector.m_nview.GetZDO().GetLong("lastTime", ZNet.instance.GetTime().Ticks)); double num = (ZNet.instance.GetTime() - dateTime).TotalSeconds; if (num < 0.0) { num = 0.0; } return (float)num; } public static float HoneyGetTimeSinceLastUpdate(Beehive sapCollector) { DateTime dateTime = new DateTime(sapCollector.m_nview.GetZDO().GetLong("lastTime", ZNet.instance.GetTime().Ticks)); double num = (ZNet.instance.GetTime() - dateTime).TotalSeconds; if (num < 0.0) { num = 0.0; } return (float)num; } public static void SortByType(HoverTextPatches.SortType type, List<HoverTextPatches.ItemData> items, bool asc) { SortByName(items, asc: true); for (int i = 0; i < items.Count; i++) { while (i < items.Count - 1 && items[i].m_stack < items[i].m_shared.m_maxStackSize && items[i + 1].m_shared.m_name == items[i].m_shared.m_name) { int num = Mathf.Min(items[i].m_shared.m_maxStackSize - items[i].m_stack, items[i + 1].m_stack); items[i].m_stack += num; if (num == items[i + 1].m_stack) { items.RemoveAt(i + 1); } else { items[i + 1].m_stack -= num; } } } switch (type) { case HoverTextPatches.SortType.Name: SortByName(items, asc); break; case HoverTextPatches.SortType.Weight: SortByWeight(items, asc); break; case HoverTextPatches.SortType.Value: SortByValue(items, asc); break; case HoverTextPatches.SortType.Amount: SortByAmount(items, asc); break; } } public static void SortByName(List<HoverTextPatches.ItemData> items, bool asc) { items.Sort((HoverTextPatches.ItemData a, HoverTextPatches.ItemData b) => (a.m_shared.m_name == b.m_shared.m_name) ? CompareInts(a.m_stack, b.m_stack, asc: false) : CompareStrings(Localization.instance.Localize(a.m_shared.m_name), Localization.instance.Localize(b.m_shared.m_name), asc)); } public static void SortByWeight(List<HoverTextPatches.ItemData> items, bool asc) { items.Sort(delegate(HoverTextPatches.ItemData a, HoverTextPatches.ItemData b) { if (a.m_shared.m_weight != b.m_shared.m_weight) { return CompareFloats(a.m_shared.m_weight, b.m_shared.m_weight, asc); } return (a.m_shared.m_name == b.m_shared.m_name) ? CompareInts(a.m_stack, b.m_stack, asc: false) : CompareStrings(Localization.instance.Localize(a.m_shared.m_name), Localization.instance.Localize(b.m_shared.m_name), asc: true); }); } public static void SortByValue(List<HoverTextPatches.ItemData> items, bool asc) { items.Sort(delegate(HoverTextPatches.ItemData a, HoverTextPatches.ItemData b) { if (a.m_shared.m_value != b.m_shared.m_value) { return CompareInts(a.m_shared.m_value, b.m_shared.m_value, asc); } return (a.m_shared.m_name == b.m_shared.m_name) ? CompareInts(a.m_stack, b.m_stack, asc: false) : CompareStrings(Localization.instance.Localize(a.m_shared.m_name), Localization.instance.Localize(b.m_shared.m_name), asc: true); }); } public static void SortByAmount(List<HoverTextPatches.ItemData> items, bool asc) { items.Sort((HoverTextPatches.ItemData a, HoverTextPatches.ItemData b) => (a.m_stack == b.m_stack) ? CompareStrings(Localization.instance.Localize(a.m_shared.m_name), Localization.instance.Localize(b.m_shared.m_name), asc: true) : CompareInts(a.m_stack, b.m_stack, asc)); } public static int CompareStrings(string a, string b, bool asc) { if (!asc) { return string.Compare(b, a, StringComparison.Ordinal); } return string.Compare(a, b, StringComparison.Ordinal); } public static int CompareFloats(float a, float b, bool asc) { if (!asc) { return b.CompareTo(a); } return a.CompareTo(b); } public static int CompareInts(float a, float b, bool asc) { if (!asc) { return b.CompareTo(a); } return a.CompareTo(b); } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] public static class RegisterAndCheckVersion { 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 AzuHoverStatsPlugin.AzuHoverStatsLogger.LogDebug((object)"Registering version RPC handler"); peer.m_rpc.Register<ZPackage>("AzuHoverStats_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_AzuHoverStats_Version); AzuHoverStatsPlugin.AzuHoverStatsLogger.LogInfo((object)"Invoking version check"); ZPackage val = new ZPackage(); val.Write("1.1.8"); peer.m_rpc.Invoke("AzuHoverStats_VersionCheck", new object[1] { val }); } } [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; } AzuHoverStatsPlugin.AzuHoverStatsLogger.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(), "AzuHoverStatsRequestAdminSync", new object[1] { (object)new ZPackage() }); } } [HarmonyPatch(typeof(FejdStartup), "ShowConnectError")] public class ShowConnectionError { 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" + AzuHoverStatsPlugin.ConnectionError; } } } [HarmonyPatch(typeof(ZNet), "Disconnect")] public static class RemoveDisconnectedPeerFromVerified { private static void Prefix(ZNetPeer peer, ref ZNet __instance) { if (__instance.IsServer()) { AzuHoverStatsPlugin.AzuHoverStatsLogger.LogInfo((object)("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list")); RpcHandlers.ValidatedPeers.Remove(peer.m_rpc); } } } public static class RpcHandlers { public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>(); public static void RPC_AzuHoverStats_Version(ZRpc rpc, ZPackage pkg) { string text = pkg.ReadString(); AzuHoverStatsPlugin.AzuHoverStatsLogger.LogInfo((object)("Version check, local: 1.1.8, remote: " + text)); if (text != "1.1.8") { AzuHoverStatsPlugin.ConnectionError = "AzuHoverStats Installed: 1.1.8\n Needed: " + text; if (ZNet.instance.IsServer()) { AzuHoverStatsPlugin.AzuHoverStatsLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") has incompatible version, disconnecting...")); rpc.Invoke("Error", new object[1] { 3 }); } } else if (!ZNet.instance.IsServer()) { AzuHoverStatsPlugin.AzuHoverStatsLogger.LogInfo((object)"Received same version from server!"); } else { AzuHoverStatsPlugin.AzuHoverStatsLogger.LogInfo((object)("Adding peer (" + rpc.m_socket.GetHostName() + ") to validated list")); ValidatedPeers.Add(rpc); } } } } namespace AzuHoverStats.Compatibility.WardIsLove { public class WardIsLovePlugin : WILCompat { private const string GUID = "Azumatt.WardIsLove"; private static readonly System.Version MinVersion = new System.Version(2, 3, 3); private static Type ClassType() { return Type.GetType("WardIsLove.WardIsLovePlugin, WardIsLove"); } public static bool IsLoaded() { if (Chainloader.PluginInfos.ContainsKey("Azumatt.WardIsLove")) { return Chainloader.PluginInfos["Azumatt.WardIsLove"].Metadata.Version >= MinVersion; } return false; } public static ConfigEntry<bool>? WardEnabled() { return WILCompat.GetField<ConfigEntry<bool>>(ClassType(), null, "WardEnabled"); } } public class WardMonoscript : WILCompat { public static Type ClassType() { return Type.GetType("WardIsLove.Util.WardMonoscript, WardIsLove"); } public static bool CheckInWardMonoscript(Vector3 point, bool flash = false) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) return WILCompat.InvokeMethod<bool>(ClassType(), null, "CheckInWardMonoscript", new object[2] { point, flash }); } public static bool CheckAccess(Vector3 point, float radius = 0f, bool flash = true, bool wardCheck = false) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) return WILCompat.InvokeMethod<bool>(ClassType(), null, "CheckAccess", new object[4] { point, radius, flash, wardCheck }); } public static bool InsideWard(Vector3 pos) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (WardIsLovePlugin.WardEnabled().Value) { return CheckInWardMonoscript(pos); } return false; } } public class WILCompat { protected static T InvokeMethod<T>(Type type, object instance, string methodName, object[] parameter) { return (T)(type.GetMethod(methodName)?.Invoke(instance, parameter)); } protected static T? GetField<T>(Type type, object instance, string fieldName) { return (T)(type.GetField(fieldName)?.GetValue(instance)); } } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } } namespace YamlDotNet { internal sealed class CultureInfoAdapter : CultureInfo { private readonly IFormatProvider provider; public CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider) : base(baseCulture.Name) { this.provider = provider; } public override object GetFormat(Type? formatType) { return provider.GetFormat(formatType); } } internal static class PropertyInfoExtensions { public static object? ReadValue(this PropertyInfo property, object target) { return property.GetValue(target, null); } } internal static class ReflectionExtensions { private static readonly Func<PropertyInfo, bool> IsInstance = (PropertyInfo property) => !(property.GetMethod ?? property.SetMethod).IsStatic; private static readonly Func<PropertyInfo, bool> IsInstancePublic = (PropertyInfo property) => IsInstance(property) && (property.GetMethod ?? property.SetMethod).IsPublic; public static Type? BaseType(this Type type) { return type.GetTypeInfo().BaseType; } public static bool IsValueType(this Type type) { return type.GetTypeInfo().IsValueType; } public static bool IsGenericType(this Type type) { return type.GetTypeInfo().IsGenericType; } public static bool IsGenericTypeDefinition(this Type type) { return type.GetTypeInfo().IsGenericTypeDefinition; } public static bool IsInterface(this Type type) { return type.GetTypeInfo().IsInterface; } public static bool IsEnum(this Type type) { return type.GetTypeInfo().IsEnum; } public static bool HasDefaultConstructor(this Type type, bool allowPrivateConstructors) { BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public; if (allowPrivateConstructors) { bindingFlags |= BindingFlags.NonPublic; } if (!type.IsValueType) { return type.GetConstructor(bindingFlags, null, Type.EmptyTypes, null) != null; } return true; } public static bool IsAssignableFrom(this Type type, Type source) { return type.IsAssignableFrom(source.GetTypeInfo()); } public static bool IsAssignableFrom(this Type type, TypeInfo source) { return type.GetTypeInfo().IsAssignableFrom(source); } public static TypeCode GetTypeCode(this Type type) { if (type.IsEnum()) { type = Enum.GetUnderlyingType(type); } if (type == typeof(bool)) { return TypeCode.Boolean; } if (type == typeof(char)) { return TypeCode.Char; } if (type == typeof(sbyte)) { return TypeCode.SByte; } if (type == typeof(byte)) { return TypeCode.Byte; } if (type == typeof(short)) { return TypeCode.Int16; } if (type == typeof(ushort)) { return TypeCode.UInt16; } if (type == typeof(int)) { return TypeCode.Int32; } if (type == typeof(uint)) { return TypeCode.UInt32; } if (type == typeof(long)) { return TypeCode.Int64; } if (type == typeof(ulong)) { return TypeCode.UInt64; } if (type == typeof(float)) { return TypeCode.Single; } if (type == typeof(double)) { return TypeCode.Double; } if (type == typeof(decimal)) { return TypeCode.Decimal; } if (type == typeof(DateTime)) { return TypeCode.DateTime; } if (type == typeof(string)) { return TypeCode.String; } return TypeCode.Object; } public static bool IsDbNull(this object value) { return value?.GetType()?.FullName == "System.DBNull"; } public static Type[] GetGenericArguments(this Type type) { return type.GetTypeInfo().GenericTypeArguments; } public static PropertyInfo? GetPublicProperty(this Type type, string name) { return type.GetRuntimeProperty(name); } public static FieldInfo? GetPublicStaticField(this Type type, string name) { return type.GetRuntimeField(name); } public static IEnumerable<PropertyInfo> GetProperties(this Type type, bool includeNonPublic) { Func<PropertyInfo, bool> predicate = (includeNonPublic ? IsInstance : IsInstancePublic); if (!type.IsInterface()) { return type.GetRuntimeProperties().Where(predicate); } return new Type[1] { type }.Concat(type.GetInterfaces()).SelectMany((Type i) => i.GetRuntimeProperties().Where(predicate)); } public static IEnumerable<PropertyInfo> GetPublicProperties(this Type type) { return type.GetProperties(includeNonPublic: false); } public static IEnumerable<FieldInfo> GetPublicFields(this Type type) { return from f in type.GetRuntimeFields() where !f.IsStatic && f.IsPublic select f; } public static IEnumerable<MethodInfo> GetPublicStaticMethods(this Type type) { return from m in type.GetRuntimeMethods() where m.IsPublic && m.IsStatic select m; } public static MethodInfo GetPrivateStaticMethod(this Type type, string name) { string name2 = name; return type.GetRuntimeMethods().FirstOrDefault((MethodInfo m) => !m.IsPublic && m.IsStatic && m.Name.Equals(name2)) ?? throw new MissingMethodException("Expected to find a method named '" + name2 + "' in '" + type.FullName + "'."); } public static MethodInfo? GetPublicStaticMethod(this Type type, string name, params Type[] parameterTypes) { string name2 = name; Type[] parameterTypes2 = parameterTypes; return type.GetRuntimeMethods().FirstOrDefault(delegate(MethodInfo m) { if (m.IsPublic && m.IsStatic && m.Name.Equals(name2)) { ParameterInfo[] parameters = m.GetParameters(); if (parameters.Length == parameterTypes2.Length) { return parameters.Zip(parameterTypes2, (ParameterInfo pi, Type pt) => pi.ParameterType == pt).All((bool r) => r); } return false; } return false; }); } public static MethodInfo? GetPublicInstanceMethod(this Type type, string name) { string name2 = name; return type.GetRuntimeMethods().FirstOrDefault((MethodInfo m) => m.IsPublic && !m.IsStatic && m.Name.Equals(name2)); } public static MethodInfo? GetGetMethod(this PropertyInfo property, bool nonPublic) { MethodInfo methodInfo = property.GetMethod; if (!nonPublic && !methodInfo.IsPublic) { methodInfo = null; } return methodInfo; } public static MethodInfo? GetSetMethod(this PropertyInfo property) { return property.SetMethod; } public static IEnumerable<Type> GetInterfaces(this Type type) { return type.GetTypeInfo().ImplementedInterfaces; } public static bool IsInstanceOf(this Type type, object o) { if (!(o.GetType() == type)) { return o.GetType().GetTypeInfo().IsSubclassOf(type); } return true; } public static Attribute[] GetAllCustomAttributes<TAttribute>(this PropertyInfo member) { List<Attribute> list = new List<Attribute>(); Type type = member.DeclaringType; while (type != null) { type.GetPublicProperty(member.Name); list.AddRange(member.GetCustomAttributes(typeof(TAttribute))); type = type.BaseType(); } return list.ToArray(); } } internal static class StandardRegexOptions { public const RegexOptions Compiled = RegexOptions.Compiled; } } namespace YamlDotNet.Serialization { internal abstract class BuilderSkeleton<TBuilder> where TBuilder : BuilderSkeleton<TBuilder> { internal INamingConvention namingConvention = NullNamingConvention.Instance; internal INamingConvention enumNamingConvention = NullNamingConvention.Instance; internal ITypeResolver typeResolver; internal readonly YamlAttributeOverrides overrides; internal readonly LazyComponentRegistrationList<Nothing, IYamlTypeConverter> typeConverterFactories; internal readonly LazyComponentRegistrationList<ITypeInspector, ITypeInspector> typeInspectorFactories; internal bool ignoreFields; internal bool includeNonPublicProperties; internal Settings settings; internal YamlFormatter yamlFormatter = YamlFormatter.Default; protected abstract TBuilder Self { get; } internal BuilderSkeleton(ITypeResolver typeResolver) { overrides = new YamlAttributeOverrides(); typeConverterFactories = new LazyComponentRegistrationList<Nothing, IYamlTypeConverter> { { typeof(YamlDotNet.Serialization.Converters.GuidConverter), (Nothing _) => new YamlDotNet.Serialization.Converters.GuidConverter(jsonCompatible: false) }, { typeof(SystemTypeConverter), (Nothing _) => new SystemTypeConverter() } }; typeInspectorFactories = new LazyComponentRegistrationList<ITypeInspector, ITypeInspector>(); this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver"); settings = new Settings(); } public TBuilder IgnoreFields() { ignoreFields = true; return Self; } public TBuilder IncludeNonPublicProperties() { includeNonPublicProperties = true; return Self; } public TBuilder EnablePrivateConstructors() { settings.AllowPrivateConstructors = true; return Self; } public TBuilder WithNamingConvention(INamingConvention namingConvention) { this.namingConvention = namingConvention ?? throw new ArgumentNullException("namingConvention"); return Self; } public TBuilder WithEnumNamingConvention(INamingConvention enumNamingConvention) { this.enumNamingConvention = enumNamingConvention; return Self; } public TBuilder WithTypeResolver(ITypeResolver typeResolver) { this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver"); return Self; } public abstract TBuilder WithTagMapping(TagName tag, Type type); public TBuilder WithAttributeOverride<TClass>(Expression<Func<TClass, object>> propertyAccessor, Attribute attribute) { overrides.Add(propertyAccessor, attribute); return Self; } public TBuilder WithAttributeOverride(Type type, string member, Attribute attribute) { overrides.Add(type, member, attribute); return Self; } public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter) { return WithTypeConverter(typeConverter, delegate(IRegistrationLocationSelectionSyntax<IYamlTypeConverter> w) { w.OnTop(); }); } public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter, Action<IRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) { IYamlTypeConverter typeConverter2 = typeConverter; if (typeConverter2 == null) { throw new ArgumentNullException("typeConverter"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateRegistrationLocationSelector(typeConverter2.GetType(), (Nothing _) => typeConverter2)); return Self; } public TBuilder WithTypeConverter<TYamlTypeConverter>(WrapperFactory<IYamlTypeConverter, IYamlTypeConverter> typeConverterFactory, Action<ITrackingRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) where TYamlTypeConverter : IYamlTypeConverter { WrapperFactory<IYamlTypeConverter, IYamlTypeConverter> typeConverterFactory2 = typeConverterFactory; if (typeConverterFactory2 == null) { throw new ArgumentNullException("typeConverterFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateTrackingRegistrationLocationSelector(typeof(TYamlTypeConverter), (IYamlTypeConverter wrapped, Nothing _) => typeConverterFactory2(wrapped))); return Self; } public TBuilder WithoutTypeConverter<TYamlTypeConverter>() where TYamlTypeConverter : IYamlTypeConverter { return WithoutTypeConverter(typeof(TYamlTypeConverter)); } public TBuilder WithoutTypeConverter(Type converterType) { if (converterType == null) { throw new ArgumentNullException("converterType"); } typeConverterFactories.Remove(converterType); return Self; } public TBuilder WithTypeInspector<TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory) where TTypeInspector : ITypeInspector { return WithTypeInspector(typeInspectorFactory, delegate(IRegistrationLocationSelectionSyntax<ITypeInspector> w) { w.OnTop(); }); } public TBuilder WithTypeInspector<TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory, Action<IRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector { Func<ITypeInspector, TTypeInspector> typeInspectorFactory2 = typeInspectorFactory; if (typeInspectorFactory2 == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector inner) => typeInspectorFactory2(inner))); return Self; } public TBuilder WithTypeInspector<TTypeInspector>(WrapperFactory<ITypeInspector, ITypeInspector, TTypeInspector> typeInspectorFactory, Action<ITrackingRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector { WrapperFactory<ITypeInspector, ITypeInspector, TTypeInspector> typeInspectorFactory2 = typeInspectorFactory; if (typeInspectorFactory2 == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateTrackingRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector wrapped, ITypeInspector inner) => typeInspectorFactory2(wrapped, inner))); return Self; } public TBuilder WithoutTypeInspector<TTypeInspector>() where TTypeInspector : ITypeInspector { return WithoutTypeInspector(typeof(TTypeInspector)); } public TBuilder WithoutTypeInspector(Type inspectorType) { if (inspectorType == null) { throw new ArgumentNullException("inspectorType"); } typeInspectorFactories.Remove(inspectorType); return Self; } public TBuilder WithYamlFormatter(YamlFormatter formatter) { yamlFormatter = formatter ?? throw new ArgumentNullException("formatter"); return Self; } protected IEnumerable<IYamlTypeConverter> BuildTypeConverters() { return typeConverterFactories.BuildComponentList(); } } internal delegate TComponent WrapperFactory<TComponentBase, TComponent>(TComponentBase wrapped) where TComponent : TComponentBase; internal delegate TComponent WrapperFactory<TArgument, TComponentBase, TComponent>(TComponentBase wrapped, TArgument argument) where TComponent : TComponentBase; [Flags] internal enum DefaultValuesHandling { Preserve = 0, OmitNull = 1, OmitDefaults = 2, OmitEmptyCollections = 4 } internal sealed class Deserializer : IDeserializer { private readonly IValueDeserializer valueDeserializer; public Deserializer() : this(new DeserializerBuilder().BuildValueDeserializer()) { } private Deserializer(IValueDeserializer valueDeserializer) { this.valueDeserializer = valueDeserializer ?? throw new ArgumentNullException("valueDeserializer"); } public static Deserializer FromValueDeserializer(IValueDeserializer valueDeserializer) { return new Deserializer(valueDeserializer); } public T Deserialize<T>(string input) { using StringReader input2 = new StringReader(input); return Deserialize<T>(input2); } public T Deserialize<T>(TextReader input) { return Deserialize<T>(new Parser(input)); } public T Deserialize<T>(IParser parser) { return (T)Deserialize(parser, typeof(T)); } public object? Deserialize(string input) { return Deserialize(input, typeof(object)); } public object? Deserialize(TextReader input) { return Deserialize(input, typeof(object)); } public object? Deserialize(IParser parser) { return Deserialize(parser, typeof(object)); } public object? Deserialize(string input, Type type) { using StringReader input2 = new StringReader(input); return Deserialize(input2, type); } public object? Deserialize(TextReader input, Type type) { return Deserialize(new Parser(input), type); } public object? Deserialize(IParser parser, Type type) { if (parser == null) { throw new ArgumentNullException("parser"); } if (type == null) { throw new ArgumentNullException("type"); } YamlDotNet.Core.Events.StreamStart @event; bool flag = parser.TryConsume<YamlDotNet.Core.Events.StreamStart>(out @event); YamlDotNet.Core.Events.DocumentStart event2; bool flag2 = parser.TryConsume<YamlDotNet.Core.Events.DocumentStart>(out event2); object result = null; if (!parser.Accept<YamlDotNet.Core.Events.DocumentEnd>(out var _) && !parser.Accept<YamlDotNet.Core.Events.StreamEnd>(out var _)) { using SerializerState serializerState = new SerializerState(); result = valueDeserializer.DeserializeValue(parser, type, serializerState, valueDeserializer); serializerState.OnDeserialization(); } if (flag2) { parser.Consume<YamlDotNet.Core.Events.DocumentEnd>(); } if (flag) { parser.Consume<YamlDotNet.Core.Events.StreamEnd>(); } return result; } } internal sealed class DeserializerBuilder : BuilderSkeleton<DeserializerBuilder> { private Lazy<IObjectFactory> objectFactory; private readonly LazyComponentRegistrationList<Nothing, INodeDeserializer> nodeDeserializerFactories; private readonly LazyComponentRegistrationList<Nothing, INodeTypeResolver> nodeTypeResolverFactories; private readonly Dictionary<TagName, Type> tagMappings; private readonly Dictionary<Type, Type> typeMappings; private readonly ITypeConverter typeConverter; private bool ignoreUnmatched; private bool duplicateKeyChecking; private bool attemptUnknownTypeDeserialization; protected override DeserializerBuilder Self => this; public DeserializerBuilder() : base((ITypeResolver)new StaticTypeResolver()) { typeMappings = new Dictionary<Type, Type>(); objectFactory = new Lazy<IObjectFactory>(() => new DefaultObjectFactory(typeMappings, settings), isThreadSafe: true); tagMappings = new Dictionary<TagName, Type> { { FailsafeSchema.Tags.Map, typeof(Dictionary<object, object>) }, { FailsafeSchema.Tags.Str, typeof(string) }, { JsonSchema.Tags.Bool, typeof(bool) }, { JsonSchema.Tags.Float, typeof(double) }, { JsonSchema.Tags.Int, typeof(int) }, { DefaultSchema.Tags.Timestamp, typeof(DateTime) } }; typeInspectorFactories.Add(typeof(CachedTypeInspector), (ITypeInspector inner) => new CachedTypeInspector(inner)); typeInspectorFactories.Add(typeof(NamingConventionTypeInspector), (ITypeInspector inner) => (!(namingConvention is NullNamingConvention)) ? new NamingConventionTypeInspector(inner, namingConvention) : inner); typeInspectorFactories.Add(typeof(YamlAttributesTypeInspector), (ITypeInspector inner) => new YamlAttributesTypeInspector(inner)); typeInspectorFactories.Add(typeof(YamlAttributeOverridesInspector), (ITypeInspector inner) => (overrides == null) ? inner : new YamlAttributeOverridesInspector(inner, overrides.Clone())); typeInspectorFactories.Add(typeof(ReadableAndWritablePropertiesTypeInspector), (ITypeInspector inner) => new ReadableAndWritablePropertiesTypeInspector(inner)); nodeDeserializerFactories = new LazyComponentRegistrationList<Nothing, INodeDeserializer> { { typeof(YamlConvertibleNodeDeserializer), (Nothing _) => new YamlConvertibleNodeDeserializer(objectFactory.Value) }, { typeof(YamlSerializableNodeDeserializer), (Nothing _) => new YamlSerializableNodeDeserializer(objectFactory.Value) }, { typeof(TypeConverterNodeDeserializer), (Nothing _) => new TypeConverterNodeDeserializer(BuildTypeConverters()) }, { typeof(NullNodeDeserializer), (Nothing _) => new NullNodeDeserializer() }, { typeof(ScalarNodeDeserializer), (Nothing _) => new ScalarNodeDeserializer(attemptUnknownTypeDeserialization, typeConverter, yamlFormatter, enumNamingConvention) }, { typeof(ArrayNodeDeserializer), (Nothing _) => new ArrayNodeDeserializer(enumNamingConvention) }, { typeof(DictionaryNodeDeserializer), (Nothing _) => new DictionaryNodeDeserializer(objectFactory.Value, duplicateKeyChecking) }, { typeof(CollectionNodeDeserializer), (Nothing _) => new CollectionNodeDeserializer(objectFactory.Value, enumNamingConvention) }, { typeof(EnumerableNodeDeserializer), (Nothing _) => new EnumerableNodeDeserializer() }, { typeof(ObjectNodeDeserializer), (Nothing _) => new ObjectNodeDeserializer(objectFactory.Value, BuildTypeInspector(), ignoreUnmatched, duplicateKeyChecking, typeConverter, enumNamingConvention) } }; nodeTypeResolverFactories = new LazyComponentRegistrationList<Nothing, INodeTypeResolver> { { typeof(MappingNodeTypeResolver), (Nothing _) => new MappingNodeTypeResolver(typeMappings) }, { typeof(YamlConvertibleTypeResolver), (Nothing _) => new YamlConvertibleTypeResolver() }, { typeof(YamlSerializableTypeResolver), (Nothing _) => new YamlSerializableTypeResolver() }, { typeof(TagNodeTypeResolver), (Nothing _) => new TagNodeTypeResolver(tagMappings) }, { typeof(PreventUnknownTagsNodeTypeResolver), (Nothing _) => new PreventUnknownTagsNodeTypeResolver() }, { typeof(DefaultContainersNodeTypeResolver), (Nothing _) => new DefaultContainersNodeTypeResolver() } }; typeConverter = new ReflectionTypeConverter(); } internal ITypeInspector BuildTypeInspector() { ITypeInspector typeInspector = new WritablePropertiesTypeInspector(typeResolver, includeNonPublicProperties); if (!ignoreFields) { typeInspector = new CompositeTypeInspector(new ReadableFieldsTypeInspector(typeResolver), typeInspector); } return typeInspectorFactories.BuildComponentChain(typeInspector); } public DeserializerBuilder WithAttemptingUnquotedStringTypeDeserialization() { attemptUnknownTypeDeserialization = true; return this; } public DeserializerBuilder WithObjectFactory(IObjectFactory objectFactory) { IObjectFactory objectFactory2 = objectFactory; if (objectFactory2 == null) { throw new ArgumentNullException("objectFactory"); } this.objectFactory = new Lazy<IObjectFactory>(() => objectFactory2, isThreadSafe: true); return this; } public DeserializerBuilder WithObjectFactory(Func<Type, object> objectFactory) { if (objectFactory == null) { throw new ArgumentNullException("objectFactory"); } return WithObjectFactory(new LambdaObjectFactory(objectFactory)); } public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer) { return WithNodeDeserializer(nodeDeserializer, delegate(IRegistrationLocationSelectionSyntax<INodeDeserializer> w) { w.OnTop(); }); } public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer, Action<IRegistrationLocationSelectionSyntax<INodeDeserializer>> where) { INodeDeserializer nodeDeserializer2 = nodeDeserializer; if (nodeDeserializer2 == null) { throw new ArgumentNullException("nodeDeserializer"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateRegistrationLocationSelector(nodeDeserializer2.GetType(), (Nothing _) => nodeDeserializer2)); return this; } public DeserializerBuilder WithNodeDeserializer<TNodeDeserializer>(WrapperFactory<INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeDeserializer>> where) where TNodeDeserializer : INodeDeserializer { WrapperFactory<INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory2 = nodeDeserializerFactory; if (nodeDeserializerFactory2 == null) { throw new ArgumentNullException("nodeDeserializerFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeDeserializer), (INodeDeserializer wrapped, Nothing _) => nodeDeserializerFactory2(wrapped))); return this; } public DeserializerBuilder WithoutNodeDeserializer<TNodeDeserializer>() where TNodeDeserializer : INodeDeserializer { return WithoutNodeDeserializer(typeof(TNodeDeserializer)); } public DeserializerBuilder WithoutNodeDeserializer(Type nodeDeserializerType) { if (nodeDeserializerType == null) { throw new ArgumentNullException("nodeDeserializerType"); } nodeDeserializerFactories.Remove(nodeDeserializerType); return this; } public DeserializerBuilder WithTypeDiscriminatingNodeDeserializer(Action<ITypeDiscriminatingNodeDeserializerOptions> configureTypeDiscriminatingNodeDeserializerOptions, int maxDepth = -1, int maxLength = -1) { TypeDiscriminatingNodeDeserializerOptions typeDiscriminatingNodeDeserializerOptions = new TypeDiscriminatingNodeDeserializerOptions(); configureTypeDiscriminatingNodeDeserializerOptions(typeDiscriminatingNodeDeserializerOptions); TypeDiscriminatingNodeDeserializer nodeDeserializer = new TypeDiscriminatingNodeDeserializer(nodeDeserializerFactories.BuildComponentList(), typeDiscriminatingNodeDeserializerOptions.discriminators, maxDepth, maxLength); return WithNodeDeserializer(nodeDeserializer, delegate(IRegistrationLocationSelectionSyntax<INodeDeserializer> s) { s.Before<DictionaryNodeDeserializer>(); }); } public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver) { return WithNodeTypeResolver(nodeTypeResolver, delegate(IRegistrationLocationSelectionSyntax<INodeTypeResolver> w) { w.OnTop(); }); } public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver, Action<IRegistrationLocationSelectionSyntax<INodeTypeResolver>> where) { INodeTypeResolver nodeTypeResolver2 = nodeTypeResolver; if (nodeTypeResolver2 == null) { throw new ArgumentNullException("nodeTypeResolver"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeTypeResolverFactories.CreateRegistrationLocatio