Decompiled source of SeedBed v1.2.8
SeedBed.dll
Decompiled 13 hours 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.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; 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 BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using PieceManager; using SeedBed.Functions; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.ObjectPool; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("blacks7ar")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.8")] [assembly: AssemblyInformationalVersion("1.2.8")] [assembly: AssemblyProduct("SeedBed")] [assembly: AssemblyTitle("SeedBed")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.8.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SeedBed { [BepInPlugin("blacks7ar.SeedBed", "SeedBed", "1.2.8")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public struct ItemConversions { [YamlMember(Alias = "From", ApplyNamingConventions = false)] public string m_from { get; set; } [YamlMember(Alias = "To", ApplyNamingConventions = false)] public string m_to { get; set; } [YamlMember(Alias = "SeedAmount", ApplyNamingConventions = false)] public int m_seedAmount { get; set; } [YamlMember(Alias = "ProducedItems", ApplyNamingConventions = false)] public int m_producedItems { get; set; } public ItemConversions() { m_from = ""; m_to = ""; m_seedAmount = 0; m_producedItems = 0; } } [HarmonyPatch] private static class Patches { [HarmonyPriority(0)] [HarmonyPostfix] [HarmonyPatch(typeof(ZNetScene), "Awake")] private static void Awake_Postfix(ZNetScene __instance) { GetResourcesFromZNetScene(__instance); SetupPrefabs.SetCollector(__instance); } } private const string modGUID = "blacks7ar.SeedBed"; public const string modName = "SeedBed"; public const string modAuthor = "blacks7ar"; public const string modVersion = "1.2.8"; public const string modLink = "https://valheim.thunderstore.io/package/blacks7ar/SeedBed/"; public static string ymlFileName = "blacks7ar.SeedBed.yml"; private static string ymlFullPath = Paths.ConfigPath + Path.DirectorySeparatorChar + ymlFileName; private static readonly Harmony _harmony = new Harmony("blacks7ar.SeedBed"); private static readonly ConfigSync _configSync = new ConfigSync("blacks7ar.SeedBed") { DisplayName = "SeedBed", CurrentVersion = "1.2.8", MinimumRequiredVersion = "1.2.8" }; private static ConfigEntry<Toggle> _serverConfigLocked; public static ConfigEntry<float> _germinationDuration; public static ConfigEntry<float> _harvestDelay; public static ConfigEntry<float> _expAmountFarming; public static ConfigEntry<float> _expAmountHerbalist; public static List<ItemConversions> _itemConversions = new List<ItemConversions>(); private static readonly CustomSyncedValue<string> _ItemConversionsSyncedValue = new CustomSyncedValue<string>(_configSync, "Item Conversions", ""); public static bool _hasFarmingMod; public static bool _hasHerbalistMod; public static readonly IDictionary<string, GameObject> _ResourceDB = new Dictionary<string, GameObject>(); public static readonly HashSet<string> _herbalPlants = new HashSet<string> { "$bh_boswellia", "$bh_chamomile", "$bh_chicory", "$bh_daisy", "$bh_echinacea", "$bh_lavender", "$item_dandelion", "$item_thistle" }; public static readonly HashSet<string> _notAllowedItems = new HashSet<string> { "$item_grausten", "$item_blackcore", "$item_ironore", "$item_wood", "$item_charredskull", "$item_dragonegg", "$item_lantern", "$item_coins", "$item_dvergrtankard", "$item_fishingrod", "$item_flint", "$item_bonefragments", "$item_wolfhairbundle", "$item_entrails", "$item_moltencore", "$item_crystal", "$item_obsidian", "$item_pot_shard_green", "$item_royaljelly", "$item_stone", "$item_sulfurstone", "$item_surtlingcore", "$item_Dyrnwyn_hilt", "$item_Dyrnwyn_blade", "$item_tar", "$item_tinore", "$item_voltureegg", "$item_Dyrnwyn_tip", "$item_goblintotem", "$item_wisp" }; private ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool synchronizedConfig = true) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown ConfigDescription val = new ConfigDescription(description.Description + (synchronizedConfig ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags); ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val); _configSync.AddConfigEntry<T>(val2).SynchronizedConfig = synchronizedConfig; return val2; } private static void YmlDataWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ymlFileName); fileSystemWatcher.Changed += YmlDataChanged; fileSystemWatcher.Created += YmlDataChanged; fileSystemWatcher.Renamed += YmlDataChanged; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private static void YmlDataChanged(object sender, FileSystemEventArgs e) { if (!File.Exists(ymlFullPath)) { return; } try { Logging.LogDebug("YmlDataWatcher called.."); _ItemConversionsSyncedValue.AssignLocalValue(File.ReadAllText(ymlFullPath)); } catch { Logging.LogError("There was an issue loading your " + ymlFileName); Logging.LogError("Please check your entries for spelling and format!"); } } public void Awake() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown Localizer.Load(); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; _serverConfigLocked = config("1- ServerSync", "Lock Configuration", Toggle.On, new ConfigDescription("If On, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, Array.Empty<object>())); _configSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked); _germinationDuration = config("2- General", "Germination Duration", 4000f, new ConfigDescription("How many seconds would it take to finished germination.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(60f, 5000f), Array.Empty<object>())); _harvestDelay = config("2- General", "Harvest Delay", 1.5f, new ConfigDescription("Delay in seconds before the produced items spawns.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>())); _hasFarmingMod = Helper.CheckFarmingMod(); if (_hasFarmingMod) { _expAmountFarming = config("3- Farming", "Exp Amount", 1f, new ConfigDescription("Exp amount given to Farming skill when harvesting from seedbed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>())); } _hasHerbalistMod = Helper.CheckHerbalistMod(); if (_hasHerbalistMod) { _expAmountHerbalist = config("4- Herbalist", "Exp Amount", 1f, new ConfigDescription("Exp amount given to Herbalist skill when harvesting herbal plants from the seedbed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f), Array.Empty<object>())); } Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; ((BaseUnityPlugin)this).Config.Save(); if (!File.Exists(ymlFullPath)) { CreateItemConversionYml(); Logging.LogWarning("File not found - " + ymlFileName + "!"); Logging.LogWarning("Creating a new one.."); } _ItemConversionsSyncedValue.ValueChanged += ItemConversionsSyncedValueOnValueChanged; _ItemConversionsSyncedValue.AssignLocalValue(File.ReadAllText(ymlFullPath)); SetupPrefabs.Init(); YmlDataWatcher(); } public static void ItemConversionsSyncedValueOnValueChanged() { Logging.LogDebug("ItemConversionsSyncedValueOnChanged called.."); try { _itemConversions.Clear(); _itemConversions = new DeserializerBuilder().Build().Deserialize<List<ItemConversions>>(_ItemConversionsSyncedValue.Value); } catch (Exception arg) { Logging.LogError($"Failed to deserializer {ymlFileName}: {arg}"); } } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private static void GetResourcesFromZNetScene(ZNetScene zNetScene) { if (!Helper.ZNetSceneAwake()) { return; } _ResourceDB.Clear(); foreach (GameObject prefab in zNetScene.m_prefabs) { if (!Object.op_Implicit((Object)(object)prefab.GetComponent<Pickable>()) || ((Object)prefab).name.ToLower().EndsWith("_wild") || ((Object)prefab).name.ToLower().Contains("dvergerthing") || ((Object)prefab).name.ToLower().Contains("_wild_")) { continue; } Pickable component = prefab.GetComponent<Pickable>(); if ((Object)(object)component.m_itemPrefab == (Object)null) { continue; } string name = component.m_itemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name; if (_notAllowedItems.Contains(name)) { continue; } string key = name; if (!(name == "$item_carrot")) { switch (name) { case "$item_onion": case "$item_turnip": case "$bca_chilipepper": case "$bca_tomato": break; default: goto IL_0115; } } bool flag = true; goto IL_0118; IL_0115: flag = false; goto IL_0118; IL_0118: if (flag) { key = name + "seeds"; } else { switch (name) { case "$item_carrotseeds": case "$item_onionseeds": case "$item_turnipseeds": flag = true; break; default: flag = false; break; } if (flag) { key = name.Replace("seeds", ""); } } if (!_ResourceDB.ContainsKey(key)) { _ResourceDB.Add(key, prefab); } if (((Object)prefab).name.ToLower().StartsWith("bca_") && ((Object)prefab).name.ToLower().EndsWith("plant") && !_ResourceDB.ContainsKey(name)) { _ResourceDB.Add(name, prefab); } } } private static void CreateItemConversionYml() { List<ItemConversions> graph = new List<ItemConversions> { new ItemConversions { m_from = "Barley", m_to = "Barley", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "CarrotSeeds", m_to = "Carrot", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "Dandelion", m_to = "Dandelion", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "Fiddleheadfern", m_to = "Fiddleheadfern", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "Flax", m_to = "Flax", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "Mushroom", m_to = "Mushroom", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "MushroomMagecap", m_to = "MushroomMagecap", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "MushroomYellow", m_to = "MushroomYellow", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "MushroomJotunPuffs", m_to = "MushroomJotunPuffs", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "OnionSeeds", m_to = "Onion", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "Carrot", m_to = "CarrotSeeds", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "Onion", m_to = "OnionSeeds", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "Turnip", m_to = "TurnipSeeds", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "MushroomSmokePuff", m_to = "MushroomSmokePuff", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "Thistle", m_to = "Thistle", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "TurnipSeeds", m_to = "Turnip", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "Blueberries", m_to = "Blueberries", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "Cloudberry", m_to = "Cloudberry", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "Raspberry", m_to = "Raspberry", m_seedAmount = 5, m_producedItems = 15 }, new ItemConversions { m_from = "Vineberry", m_to = "Vineberry", m_seedAmount = 5, m_producedItems = 15 } }; string contents = new SerializerBuilder().Build().Serialize(graph); File.WriteAllText(ymlFullPath, contents); } } } namespace SeedBed.Functions { public class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [UsedImplicitly] public string Category; [UsedImplicitly] public Action<ConfigEntryBase> CustomDrawer; } public class Germination : MonoBehaviour, Hoverable, Interactable { private class ItemConversion { public ItemDrop m_from; public ItemDrop m_to; public int m_seedAmount = 5; public int m_producedItems = 15; } private enum Status { Empty, Germinating, Ready } public string m_name = "Seed Bed"; public float m_germinationDuration = 2400f; public GameObject m_sapling; public GameObject m_grown; public GameObject m_saplingT5x5; public GameObject m_grownT5x5; public GameObject m_saplingT3x1; public GameObject m_grownT3x1; public GameObject m_saplingVine; public GameObject m_grownVine; public GameObject m_saplingVineWall; public GameObject m_GrownVineWall; public EffectList m_addEffects = new EffectList(); public EffectList m_harvestEffects = new EffectList(); public EffectList m_spawnEffects = new EffectList(); public Switch m_addSwitch; public Switch m_harvestSwitch; public float m_harvestDelay = 1.5f; public Transform m_spawnPoint; private List<ItemConversion> m_conversion = new List<ItemConversion>(); public ZNetView m_nview; public string m_delayedTapItem = ""; public void Awake() { m_nview = ((Component)this).GetComponent<ZNetView>(); SetTransforms(); SetConversion(); if (!((Object)(object)m_nview == (Object)null) && m_nview.GetZDO() != null) { DisableGameObject(); ReapplyVisuals(); m_nview.Register<string>("RPC_AddItem", (Action<long, string>)RPC_AddItem); m_nview.Register("RPC_Tap", (Action<long>)RPC_Tap); ((MonoBehaviour)this).InvokeRepeating("SlowUpdate", (GetStatus() == Status.Germinating) ? 2f : 0f, 2f); WearNTear component = ((Component)this).GetComponent<WearNTear>(); if (Object.op_Implicit((Object)(object)component)) { component.m_onDestroyed = (Action)Delegate.Combine(component.m_onDestroyed, new Action(OnDestroyed)); } } } public void DisableGameObject() { m_sapling.SetActive(false); m_grown.SetActive(false); } public void SetTransforms() { if (!((Object)(object)m_nview == (Object)null) && m_nview.GetZDO() != null) { m_sapling = ((Component)((Component)this).transform.Find("_sapling")).gameObject; m_grown = ((Component)((Component)this).transform.Find("_grown")).gameObject; m_saplingT5x5 = ((Component)m_sapling.transform.Find("_sapling5x5")).gameObject; m_grownT5x5 = ((Component)m_grown.transform.Find("_grown5x5")).gameObject; m_saplingT3x1 = ((Component)m_sapling.transform.Find("_sapling3x1")).gameObject; m_grownT3x1 = ((Component)m_grown.transform.Find("_grown3x1")).gameObject; m_saplingVine = ((Component)m_sapling.transform.Find("_saplingvine")).gameObject; m_saplingVineWall = ((Component)m_sapling.transform.Find("deco")).gameObject; m_grownVine = ((Component)m_grown.transform.Find("_grownvine")).gameObject; m_GrownVineWall = ((Component)m_grown.transform.Find("deco")).gameObject; m_addSwitch = ((Component)((Component)this).transform.Find("add_seeds")).GetComponent<Switch>(); m_harvestSwitch = ((Component)((Component)this).transform.Find("collect_produce")).GetComponent<Switch>(); m_spawnPoint = ((Component)this).transform.Find("spawnpoint"); } } public void SetConversion() { foreach (List<ItemConversion> item in Enumerable.Select(Enumerable.Where(Enumerable.SelectMany(Enumerable.Select(Enumerable.Where(Enumerable.Where(Plugin._itemConversions, delegate(Plugin.ItemConversions data) { ObjectDB instance5 = ObjectDB.instance; Plugin.ItemConversions itemConversions3 = data; if ((Object)(object)instance5.GetItemPrefab(StringExtensionMethods.GetStableHashCode(itemConversions3.m_from)) != (Object)null) { ObjectDB instance6 = ObjectDB.instance; itemConversions3 = data; return (Object)(object)instance6.GetItemPrefab(StringExtensionMethods.GetStableHashCode(itemConversions3.m_to)) != (Object)null; } return false; }), delegate(Plugin.ItemConversions data) { ObjectDB instance3 = ObjectDB.instance; Plugin.ItemConversions itemConversions2 = data; if (Object.op_Implicit((Object)(object)instance3.GetItemPrefab(StringExtensionMethods.GetStableHashCode(itemConversions2.m_from)).GetComponent<ItemDrop>())) { ObjectDB instance4 = ObjectDB.instance; itemConversions2 = data; return Object.op_Implicit((Object)(object)instance4.GetItemPrefab(StringExtensionMethods.GetStableHashCode(itemConversions2.m_to)).GetComponent<ItemDrop>()); } return false; }), delegate(Plugin.ItemConversions data) { List<ItemConversion> list = new List<ItemConversion>(); ItemConversion itemConversion = new ItemConversion(); ObjectDB instance = ObjectDB.instance; Plugin.ItemConversions itemConversions = data; itemConversion.m_from = instance.GetItemPrefab(StringExtensionMethods.GetStableHashCode(itemConversions.m_from)).GetComponent<ItemDrop>(); ObjectDB instance2 = ObjectDB.instance; itemConversions = data; itemConversion.m_to = instance2.GetItemPrefab(StringExtensionMethods.GetStableHashCode(itemConversions.m_to)).GetComponent<ItemDrop>(); itemConversions = data; itemConversion.m_seedAmount = itemConversions.m_seedAmount; itemConversions = data; itemConversion.m_producedItems = itemConversions.m_producedItems; list.Add(itemConversion); return list; }), (List<ItemConversion> conversion) => conversion, (List<ItemConversion> conversion, ItemConversion item) => new { conversion, item }), <>h__TransparentIdentifier0 => !m_conversion.Contains(<>h__TransparentIdentifier0.item)), <>h__TransparentIdentifier0 => <>h__TransparentIdentifier0.conversion)) { m_conversion.AddRange(item); } Logging.LogDebug("Added " + m_conversion.Count + " items to conversion list from " + Plugin._itemConversions.Count + " items in " + Plugin.ymlFileName + " file."); } public void DropAllItems() { Status status = GetStatus(); string content = GetContent(); if (string.IsNullOrEmpty(content)) { return; } if (status == Status.Ready) { ItemConversion itemConversion = GetItemConversion(content); if (itemConversion != null) { for (int i = 0; i < itemConversion.m_producedItems; i++) { drop(itemConversion.m_to); } } } else { ItemConversion itemConversion2 = GetItemConversion(content); if (itemConversion2 != null) { for (int j = 0; j < itemConversion2.m_seedAmount; j++) { drop(itemConversion2.m_from); } } } m_nview.GetZDO().Set(ZDOVars.s_content, ""); m_nview.GetZDO().Set(ZDOVars.s_startTime, 0, false); void drop(ItemDrop item) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.position + Vector3.up + Random.insideUnitSphere * 0.3f; Quaternion val2 = Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f); ItemDrop.OnCreateNew(Object.Instantiate<GameObject>(((Component)item).gameObject, val, val2)); } } public void OnDestroyed() { m_nview.IsOwner(); DropAllItems(); } public string GetHoverName() { return m_name; } public string GetHoverText() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false)) { return Localization.instance.Localize(m_name + "\n$bsb_noaccess"); } switch (GetStatus()) { case Status.Ready: { string contentName2 = GetContentName(); return Localization.instance.Localize(m_name + "\n( " + contentName2 + ", $bsb_germentation_ready )\n[<color=yellow><b>$KEY_Use</b></color>] $bsb_seedbed_harvest"); } case Status.Germinating: { string contentName = GetContentName(); return Localization.instance.Localize(m_name + " <color=orange><b>" + TimeLeft(this) + "</b></color>\n( " + contentName + ", $bsb_seedbed_germinating )"); } case Status.Empty: return Localization.instance.Localize(m_name + " ( $bsb_seedbed_empty )\n[<color=yellow><b>$KEY_Use</b></color>] $bsb_seedbed_add"); default: return m_name; } } public bool Interact(Humanoid user, bool hold, bool alt) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) if (hold) { return false; } if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { return false; } switch (GetStatus()) { case Status.Empty: { ItemData val = FindPlantableSeed(user.GetInventory()); if (val == null) { ((Character)user).Message((MessageType)2, "$bsb_notenoughseeds", 0, (Sprite)null); return false; } ItemConversion itemConversion2 = GetItemConversion(((Object)val.m_dropPrefab).name); AddItem(user, val, itemConversion2.m_seedAmount); return true; } case Status.Ready: m_nview.InvokeRPC("RPC_Tap", Array.Empty<object>()); if (Plugin._hasFarmingMod) { ((Character)user).GetSkills().m_skillData.TryGetValue((SkillType)Mathf.Abs(StringExtensionMethods.GetStableHashCode("Farming")), out var value); if (value != null) { ((Character)user).RaiseSkill(value.m_info.m_skill, Plugin._expAmountFarming.Value); } } if (Plugin._hasHerbalistMod) { ItemConversion itemConversion = GetItemConversion(m_delayedTapItem); if (Plugin._herbalPlants.Contains(itemConversion.m_to.m_itemData.m_shared.m_name)) { ((Character)user).GetSkills().m_skillData.TryGetValue((SkillType)Mathf.Abs(StringExtensionMethods.GetStableHashCode("Herbalist")), out var value2); if (value2 != null) { ((Character)user).RaiseSkill(value2.m_info.m_skill, Plugin._expAmountHerbalist.Value); } } } return true; default: return false; } } public bool UseItem(Humanoid user, ItemData item) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { return false; } ItemConversion itemConversion = GetItemConversion(((Object)item.m_dropPrefab).name); if (itemConversion == null) { return false; } if (item.m_stack < itemConversion.m_seedAmount) { ((Character)user).Message((MessageType)2, "$bsb_notenoughseeds", 0, (Sprite)null); return false; } if (!AddItem(user, item, itemConversion.m_seedAmount)) { return false; } return true; } public void ReapplyVisuals() { string fromName = GetFromName(); SetVisuals(fromName); } public void SlowUpdate() { switch (GetStatus()) { case Status.Empty: DisableGameObject(); break; case Status.Germinating: m_sapling.SetActive(true); m_grown.SetActive(false); break; case Status.Ready: m_sapling.SetActive(false); m_grown.SetActive(true); break; } } private Status GetStatus() { if (string.IsNullOrEmpty(GetContent())) { return Status.Empty; } if (GetGerminationTime() > (double)m_germinationDuration) { return Status.Ready; } return Status.Germinating; } private bool AddItem(Humanoid user, ItemData item, int amount) { if (GetStatus() != 0) { return false; } if (!IsItemAllowed(item)) { return false; } if (!user.GetInventory().RemoveItem(item, amount)) { return false; } m_nview.InvokeRPC("RPC_AddItem", new object[1] { ((Object)item.m_dropPrefab).name }); SetVisuals(item.m_shared.m_name); return true; } public void ResetVisuals() { for (int i = 0; i < m_saplingT5x5.transform.childCount; i++) { GameObject gameObject = ((Component)m_saplingT5x5.transform.GetChild(i)).gameObject; for (int j = 0; j < gameObject.transform.childCount; j++) { Object.Destroy((Object)(object)((Component)gameObject.transform.GetChild(j)).gameObject); } } for (int k = 0; k < m_grownT5x5.transform.childCount; k++) { GameObject gameObject2 = ((Component)m_grownT5x5.transform.GetChild(k)).gameObject; for (int l = 0; l < gameObject2.transform.childCount; l++) { Object.Destroy((Object)(object)((Component)gameObject2.transform.GetChild(l)).gameObject); } } for (int m = 0; m < m_saplingT3x1.transform.childCount; m++) { GameObject gameObject3 = ((Component)m_saplingT3x1.transform.GetChild(m)).gameObject; for (int n = 0; n < gameObject3.transform.childCount; n++) { Object.Destroy((Object)(object)((Component)gameObject3.transform.GetChild(n)).gameObject); } } for (int num = 0; num < m_grownT3x1.transform.childCount; num++) { GameObject gameObject4 = ((Component)m_grownT3x1.transform.GetChild(num)).gameObject; for (int num2 = 0; num2 < gameObject4.transform.childCount; num2++) { Object.Destroy((Object)(object)((Component)gameObject4.transform.GetChild(num2)).gameObject); } } for (int num3 = 0; num3 < m_saplingVine.transform.childCount; num3++) { GameObject gameObject5 = ((Component)m_saplingVine.transform.GetChild(num3)).gameObject; for (int num4 = 0; num4 < gameObject5.transform.childCount; num4++) { Object.Destroy((Object)(object)((Component)gameObject5.transform.GetChild(num4)).gameObject); } } for (int num5 = 0; num5 < m_grownVine.transform.childCount; num5++) { GameObject gameObject6 = ((Component)m_grownVine.transform.GetChild(num5)).gameObject; for (int num6 = 0; num6 < gameObject6.transform.childCount; num6++) { Object.Destroy((Object)(object)((Component)gameObject6.transform.GetChild(num6)).gameObject); } } } public void SetVisuals(string itemName) { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_06b8: Unknown result type (might be due to invalid IL or missing references) //IL_06d7: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: Unknown result type (might be due to invalid IL or missing references) foreach (string key in Plugin._ResourceDB.Keys) { if (itemName != key) { continue; } string text = ((Object)Plugin._ResourceDB[key]).name.ToLower(); if (text.Contains("pickable_")) { for (int i = 0; i < Plugin._ResourceDB[key].transform.childCount; i++) { GameObject gameObject = ((Component)Plugin._ResourceDB[key].transform.GetChild(i)).gameObject; for (int j = 0; j < m_saplingT5x5.transform.childCount; j++) { GameObject val = Object.Instantiate<GameObject>(gameObject, m_saplingT5x5.transform.GetChild(j)); ((Object)val).name = ((Object)Plugin._ResourceDB[key]).name; val.transform.SetParent(m_saplingT5x5.transform.GetChild(j)); val.transform.localPosition = new Vector3(0f, 0f, 0f); m_saplingT5x5.ChangeColor(new Color(0f, 1f, 0.45f)); m_saplingVineWall.SetActive(false); for (int k = 0; k < val.transform.childCount; k++) { ((Component)val.transform.GetChild(k)).gameObject.RemoveComponent(typeof(ParticleSystem)); ((Component)val.transform.GetChild(k)).gameObject.RemoveComponent(typeof(Light)); ((Component)val.transform.GetChild(k)).gameObject.RemoveComponent(typeof(LightLod)); } val.RemoveComponent(typeof(Light)); val.RemoveComponent(typeof(ParticleSystem)); val.RemoveComponent(typeof(LightLod)); } for (int l = 0; l < m_grownT5x5.transform.childCount; l++) { GameObject obj = Object.Instantiate<GameObject>(gameObject, m_grownT5x5.transform.GetChild(l)); ((Object)obj).name = ((Object)Plugin._ResourceDB[key]).name; obj.transform.SetParent(m_grownT5x5.transform.GetChild(l)); obj.transform.localPosition = new Vector3(0f, 0f, 0f); m_GrownVineWall.SetActive(false); } } } else if (text.Contains("blueberrybush") || text.Contains("raspberrybush") || text.EndsWith("plant")) { for (int m = 0; m < Plugin._ResourceDB[key].transform.childCount; m++) { GameObject gameObject2 = ((Component)Plugin._ResourceDB[key].transform.GetChild(m)).gameObject; for (int n = 0; n < m_saplingT3x1.transform.childCount; n++) { GameObject obj2 = Object.Instantiate<GameObject>(gameObject2, m_saplingT3x1.transform.GetChild(n)); ((Object)obj2).name = ((Object)Plugin._ResourceDB[key]).name; obj2.transform.SetParent(m_saplingT3x1.transform.GetChild(n)); obj2.transform.localPosition = new Vector3(0f, 0f, 0f); m_saplingT3x1.ChangeColor(new Color(0f, 1f, 0.45f)); m_saplingVineWall.SetActive(false); } for (int num = 0; num < m_grownT3x1.transform.childCount; num++) { GameObject obj3 = Object.Instantiate<GameObject>(gameObject2, m_grownT3x1.transform.GetChild(num)); ((Object)obj3).name = ((Object)Plugin._ResourceDB[key]).name; obj3.transform.SetParent(m_grownT3x1.transform.GetChild(num)); obj3.transform.localPosition = new Vector3(0f, 0f, 0f); m_GrownVineWall.SetActive(false); } } } else if (text.Contains("cloudberrybush")) { for (int num2 = 0; num2 < Plugin._ResourceDB[key].transform.childCount; num2++) { GameObject gameObject3 = ((Component)Plugin._ResourceDB[key].transform.GetChild(num2)).gameObject; for (int num3 = 0; num3 < m_saplingT5x5.transform.childCount; num3++) { GameObject obj4 = Object.Instantiate<GameObject>(gameObject3, m_saplingT5x5.transform.GetChild(num3)); ((Object)obj4).name = ((Object)Plugin._ResourceDB[key]).name; obj4.transform.SetParent(m_saplingT5x5.transform.GetChild(num3)); obj4.transform.localPosition = new Vector3(0f, 0f, 0f); m_saplingT5x5.ChangeColor(new Color(0f, 1f, 0.45f)); m_saplingVineWall.SetActive(false); } for (int num4 = 0; num4 < m_grownT5x5.transform.childCount; num4++) { GameObject obj5 = Object.Instantiate<GameObject>(gameObject3, m_grownT5x5.transform.GetChild(num4)); ((Object)obj5).name = ((Object)Plugin._ResourceDB[key]).name; obj5.transform.SetParent(m_grownT5x5.transform.GetChild(num4)); obj5.transform.localPosition = new Vector3(0f, 0f, 0f); m_GrownVineWall.SetActive(false); } } } else { if (!text.Contains("vineash")) { continue; } for (int num5 = 0; num5 < Plugin._ResourceDB[key].transform.childCount; num5++) { GameObject gameObject4 = ((Component)Plugin._ResourceDB[key].transform.GetChild(num5)).gameObject; for (int num6 = 0; num6 < m_saplingVine.transform.childCount; num6++) { GameObject obj6 = Object.Instantiate<GameObject>(gameObject4, m_saplingVine.transform.GetChild(num6)); ((Object)obj6).name = ((Object)Plugin._ResourceDB[key]).name; obj6.transform.SetParent(m_saplingVine.transform.GetChild(num6)); obj6.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f); m_saplingVine.ChangeColor(new Color(0f, 1f, 0.45f)); } for (int num7 = 0; num7 < m_grownVine.transform.childCount; num7++) { GameObject obj7 = Object.Instantiate<GameObject>(gameObject4, m_grownVine.transform.GetChild(num7)); ((Object)obj7).name = ((Object)Plugin._ResourceDB[key]).name; obj7.transform.SetParent(m_grownVine.transform.GetChild(num7)); } } m_saplingVineWall.SetActive(true); m_GrownVineWall.SetActive(true); } } } public void RPC_AddItem(long sender, string name) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (m_nview.IsOwner() && GetStatus() == Status.Empty) { if (!IsItemAllowed(name)) { ZLog.DevLog((object)"Item not allowed"); return; } m_addEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1); m_nview.GetZDO().Set(ZDOVars.s_content, name); m_nview.GetZDO().Set(ZDOVars.s_startTime, ZNet.instance.GetTime().Ticks); } } public void RPC_Tap(long sender) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (m_nview.IsOwner() && GetStatus() == Status.Ready) { m_delayedTapItem = GetContent(); ((MonoBehaviour)this).Invoke("DelayedTap", m_harvestDelay); m_harvestEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1); m_nview.GetZDO().Set(ZDOVars.s_content, ""); m_nview.GetZDO().Set(ZDOVars.s_startTime, 0, false); ResetVisuals(); } } public void DelayedTap() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) m_spawnEffects.Create(((Component)this).transform.position, Quaternion.identity, (Transform)null, 1f, -1); ItemConversion itemConversion = GetItemConversion(m_delayedTapItem); if (itemConversion != null) { for (int i = 0; i < itemConversion.m_producedItems; i++) { Vector3 val = m_spawnPoint.position + Vector3.up * 0.3f; ItemDrop.OnCreateNew(Object.Instantiate<ItemDrop>(itemConversion.m_to, val, Quaternion.identity)); } } } public void ResetGerminationTimer() { if (GetStatus() == Status.Germinating) { m_nview.GetZDO().Set(ZDOVars.s_startTime, ZNet.instance.GetTime().Ticks); } } private double GetGerminationTime() { DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong(ZDOVars.s_startTime, 0L)); if (dateTime.Ticks == 0L) { return -1.0; } return (ZNet.instance.GetTime() - dateTime).TotalSeconds; } private string GetFromName() { string content = GetContent(); if (string.IsNullOrEmpty(content)) { return ""; } ItemConversion itemConversion = GetItemConversion(content); if (itemConversion == null) { return "Invalid"; } return itemConversion.m_from.m_itemData.m_shared.m_name; } private string GetContentName() { string content = GetContent(); if (string.IsNullOrEmpty(content)) { return ""; } ItemConversion itemConversion = GetItemConversion(content); if (itemConversion == null) { return "Invalid"; } return itemConversion.m_to.m_itemData.m_shared.m_name; } private string GetContent() { if (m_nview.GetZDO() != null) { return m_nview.GetZDO().GetString(ZDOVars.s_content, ""); } return ""; } private bool IsItemAllowed(ItemData item) { return IsItemAllowed(((Object)item.m_dropPrefab).name); } private bool IsItemAllowed(string itemName) { return Enumerable.Any(m_conversion, (ItemConversion item) => ((Object)((Component)item.m_from).gameObject).name == itemName); } private ItemData FindPlantableSeed(Inventory inventory) { return Enumerable.FirstOrDefault(Enumerable.Select(Enumerable.Where(Enumerable.Where(Enumerable.Select(m_conversion, (ItemConversion item2) => new { item2 = item2, item = inventory.GetItem(item2.m_from.m_itemData.m_shared.m_name, -1, false) }), <>h__TransparentIdentifier0 => <>h__TransparentIdentifier0.item != null), <>h__TransparentIdentifier0 => <>h__TransparentIdentifier0.item.m_stack >= <>h__TransparentIdentifier0.item2.m_seedAmount), <>h__TransparentIdentifier0 => <>h__TransparentIdentifier0.item)); } private ItemConversion GetItemConversion(string itemName) { return Enumerable.FirstOrDefault(m_conversion, (ItemConversion item) => ((Object)((Component)item.m_from).gameObject).name == itemName); } private static string TimeLeft(Germination germination) { double num = (double)germination.m_germinationDuration - germination.GetGerminationTime(); float num2 = Mathf.FloorToInt((float)((int)num / 60)); float num3 = Mathf.FloorToInt((float)((int)num % 60)); return $"({num2:00}:{num3:00})"; } } public static class Helper { public static bool ZNetSceneAwake() { if ((Object)(object)ZNetScene.instance != (Object)null && ZNetScene.instance.m_prefabs.Count != 0) { return (Object)(object)ZNetScene.instance.GetPrefab("piece_workbench") != (Object)null; } return false; } public static bool CheckFarmingMod() { if (!Chainloader.PluginInfos.ContainsKey("org.bepinex.plugins.farming")) { return false; } Logging.LogInfo("Farming mod detected! Applying patch.."); return true; } public static bool CheckHerbalistMod() { if (!Chainloader.PluginInfos.ContainsKey("blacks7ar.Herbalist")) { return false; } Logging.LogInfo("Herbalist mod detected! Applying patch.."); return true; } public static void ChangeColor(this GameObject gameObject, Color color) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gameObject == (Object)null) { return; } Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return; } for (int i = 0; i < componentsInChildren.Length; i++) { Material material = componentsInChildren[i].material; if (!((Object)(object)material == (Object)null)) { material.SetColor("_Color", color); } } } public static void RemoveComponent(this GameObject gameObject, Type type) { Component component = gameObject.GetComponent(type); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } if ((Object)(object)gameObject.GetComponentInChildren(type) != (Object)null) { Object.Destroy((Object)(object)component); } } } public static class Logging { private static readonly ManualLogSource SBLogger = Logger.CreateLogSource("SeedBed"); public static void LogDebug(string debug) { SBLogger.LogDebug((object)debug); } public static void LogInfo(string info) { SBLogger.LogInfo((object)info); } public static void LogWarning(string warning) { SBLogger.LogWarning((object)warning); } public static void LogError(string error) { SBLogger.LogError((object)error); } } public static class SetupPrefabs { private static AssetBundle _seedBundle; public static void Init() { _seedBundle = PiecePrefabManager.RegisterAssetBundle("seedbedbundle"); BuildPiece buildPiece = new BuildPiece(_seedBundle, "BSB_SeedBed"); buildPiece.Crafting.Set(CraftingTable.Workbench); buildPiece.Category.Set("CollectorSeries"); buildPiece.RequiredItems.Add("YmirRemains", 5, recover: true); buildPiece.RequiredItems.Add("BronzeNails", 8, recover: true); buildPiece.RequiredItems.Add("Wood", 18, recover: true); buildPiece.SpecialProperties = new SpecialProperties { AdminOnly = false, NoConfig = false }; ShaderReplacer.Replace(buildPiece.Prefab); if (!Object.op_Implicit((Object)(object)buildPiece.Prefab.GetComponent<Germination>())) { buildPiece.Prefab.AddComponent<Germination>(); } PiecePrefabManager.RegisterPrefab(_seedBundle, "bsb_sfx_build_hammer_wood"); PiecePrefabManager.RegisterPrefab(_seedBundle, "bsb_sfx_wood_destroyed"); PiecePrefabManager.RegisterPrefab(_seedBundle, "bsb_vfx_Place_workbench"); PiecePrefabManager.RegisterPrefab(_seedBundle, "bsb_vfx_SawDust"); } public static void SetCollector(ZNetScene zNetScene) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0117: 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) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown if (Helper.ZNetSceneAwake()) { Germination component = _seedBundle.LoadAsset<GameObject>("BSB_SeedBed").GetComponent<Germination>(); component.m_name = "$bsb_seedbed"; Plugin._germinationDuration.SettingChanged += delegate { component.m_germinationDuration = Plugin._germinationDuration.Value; }; component.m_germinationDuration = Plugin._germinationDuration.Value; component.m_addEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[2] { new EffectData { m_prefab = zNetScene.GetPrefab("sfx_fermenter_add"), m_enabled = true, m_variant = -1 }, new EffectData { m_prefab = zNetScene.GetPrefab("vfx_fermenter_add"), m_enabled = true, m_variant = -1 } }; component.m_harvestEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("sfx_pickable_pick"), m_enabled = true, m_variant = -1 } }; component.m_spawnEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[2] { new EffectData { m_prefab = zNetScene.GetPrefab("sfx_lootspawn"), m_enabled = true, m_variant = -1 }, new EffectData { m_prefab = zNetScene.GetPrefab("vfx_lootspawn"), m_enabled = true, m_variant = -1 } }; Plugin._harvestDelay.SettingChanged += delegate { component.m_harvestDelay = Plugin._harvestDelay.Value; }; component.m_harvestDelay = Plugin._harvestDelay.Value; } } } public static class ShaderReplacer { private static readonly List<GameObject> GOToSwap; static ShaderReplacer() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown GOToSwap = new List<GameObject>(); new Harmony("blacks7ar.utilities.ShaderReplacer").Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ShaderReplacer), "ReplaceShaderPatch", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static void Replace(GameObject gameObject) { GOToSwap.Add(gameObject); } [HarmonyPriority(700)] private static void ReplaceShaderPatch() { foreach (Material item in Enumerable.Select(Enumerable.Where(Enumerable.SelectMany(Enumerable.Where(Enumerable.SelectMany(Enumerable.Select(GOToSwap, (GameObject gameObject) => gameObject.GetComponentsInChildren<Renderer>(true)), (Renderer[] renderers) => renderers, (Renderer[] renderers, Renderer renderer) => new { renderers, renderer }), <>h__TransparentIdentifier0 => (Object)(object)<>h__TransparentIdentifier0.renderer != (Object)null), <>h__TransparentIdentifier0 => <>h__TransparentIdentifier0.renderer.sharedMaterials, (<>h__TransparentIdentifier0, Material material) => new { <>h__TransparentIdentifier0, material }), <>h__TransparentIdentifier1 => (Object)(object)<>h__TransparentIdentifier1.material != (Object)null), <>h__TransparentIdentifier1 => <>h__TransparentIdentifier1.material)) { Shader[] array = Resources.FindObjectsOfTypeAll<Shader>(); foreach (Shader val in array) { if (((Object)item.shader).name == ((Object)val).name) { item.shader = val; } } } } } public enum Toggle { On, Off } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<3e7cb476-3e99-4a0d-bd0e-ef440cfd11ed>Embedded] internal sealed class <3e7cb476-3e99-4a0d-bd0e-ef440cfd11ed>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [CompilerGenerated] [<3e7cb476-3e99-4a0d-bd0e-ef440cfd11ed>Embedded] internal sealed class <ebf027a2-2528-414f-83fa-a726e5347298>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <ebf027a2-2528-414f-83fa-a726e5347298>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <ebf027a2-2528-414f-83fa-a726e5347298>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [<3e7cb476-3e99-4a0d-bd0e-ef440cfd11ed>Embedded] [CompilerGenerated] internal sealed class <741d9a84-1b1d-43b5-b3b8-95103fa6550f>NullableContextAttribute : Attribute { public readonly byte Flag; public <741d9a84-1b1d-43b5-b3b8-95103fa6550f>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace LocalizationManager { [PublicAPI] [<741d9a84-1b1d-43b5-b3b8-95103fa6550f>NullableContext(1)] [<ebf027a2-2528-414f-83fa-a726e5347298>Nullable(0)] internal 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; [<ebf027a2-2528-414f-83fa-a726e5347298>Nullable(2)] 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 = Enumerable.ToList(Assembly.GetExecutingAssembly().DefinedTypes); } catch (ReflectionTypeLoadException ex) { source = Enumerable.Select(Enumerable.Where(ex.Types, [<741d9a84-1b1d-43b5-b3b8-95103fa6550f>NullableContext(0)] (Type t) => t != null), [<741d9a84-1b1d-43b5-b3b8-95103fa6550f>NullableContext(0)] (Type t) => t.GetTypeInfo()); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)Enumerable.First(source, [<741d9a84-1b1d-43b5-b3b8-95103fa6550f>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out var value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out var value2)) { text = Enumerable.Aggregate(value2, text, [<741d9a84-1b1d-43b5-b3b8-95103fa6550f>NullableContext(0)] (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, [<ebf027a2-2528-414f-83fa-a726e5347298>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null) { if (convertConfigValue == null) { convertConfigValue = (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary<string, Func<string>>(); } config.SettingChanged += [<741d9a84-1b1d-43b5-b3b8-95103fa6550f>NullableContext(0)] (object _, EventArgs _) => { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value); UpdatePlaceholderText(Localization.instance, key); } } 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() { _ = plugin; } public static void LoadLocalizationLater(Localization __instance) { LoadLocalization(Localization.instance, __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 Enumerable.Where(Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories), [<741d9a84-1b1d-43b5-b3b8-95103fa6550f>NullableContext(0)] (string f) => fileExtensions.IndexOf(Path.GetExtension(f)) >= 0)) { 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 <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>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.TryGetValue(language, out var value)) { text2 = File.ReadAllText(value); } else { byte[] array2 = LoadTranslationFromAssembly(language); if (array2 != null) { text2 = Encoding.UTF8.GetString(array2); } } } if (text2 == null && dictionary.TryGetValue("English", out var value2)) { text2 = File.ReadAllText(value2); } if (text2 != null) { foreach (KeyValuePair<string, string> item2 in new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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" }; Harmony val = new Harmony("org.bepinex.helpers.LocalizationManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "SetupGui", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalizationLater", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } [return: <ebf027a2-2528-414f-83fa-a726e5347298>Nullable(2)] private static byte[] LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension); if (array != null) { return array; } } return null; } [<741d9a84-1b1d-43b5-b3b8-95103fa6550f>NullableContext(2)] public static byte[] ReadEmbeddedFileBytes([<ebf027a2-2528-414f-83fa-a726e5347298>Nullable(1)] string resourceFileName, Assembly containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = Enumerable.FirstOrDefault(containingAssembly.GetManifestResourceNames(), [<741d9a84-1b1d-43b5-b3b8-95103fa6550f>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } } namespace System.Runtime.CompilerServices { [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [CompilerGenerated] 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; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] internal sealed class AllowNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] internal sealed class DisallowNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Method, Inherited = false)] internal sealed class DoesNotReturnAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] internal sealed class DoesNotReturnIfAttribute : Attribute { public bool ParameterValue { get; } public DoesNotReturnIfAttribute(bool parameterValue) { ParameterValue = parameterValue; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)] internal sealed class MaybeNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] internal sealed class MaybeNullWhenAttribute : Attribute { public bool ReturnValue { get; } public MaybeNullWhenAttribute(bool returnValue) { ReturnValue = returnValue; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)] internal sealed class NotNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] internal sealed class NotNullIfNotNullAttribute : Attribute { public string ParameterName { get; } public NotNullIfNotNullAttribute(string parameterName) { ParameterName = parameterName; } } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] internal sealed class NotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public NotNullWhenAttribute(bool returnValue) { ReturnValue = returnValue; } } } namespace System.Collections.Generic { internal static class DeconstructionExtensions { public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> pair, out TKey key, out TValue value) { key = pair.Key; value = pair.Value; } } } namespace YamlDotNet { internal sealed class <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>CultureInfoAdapter : CultureInfo { private readonly IFormatProvider provider; public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider) : base(baseCulture.LCID) { this.provider = provider; } public override object? GetFormat(Type? formatType) { return provider.GetFormat(formatType); } } internal static class <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ReflectionExtensions { private static readonly FieldInfo? RemoteStackTraceField = typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic); public static Type? BaseType(this Type type) { return type.BaseType; } public static bool IsValueType(this Type type) { return type.IsValueType; } public static bool IsGenericType(this Type type) { return type.IsGenericType; } public static bool IsGenericTypeDefinition(this Type type) { return type.IsGenericTypeDefinition; } public static bool IsInterface(this Type type) { return type.IsInterface; } public static bool IsEnum(this Type type) { return type.IsEnum; } public static bool IsDbNull(this object value) { return value is DBNull; } public static bool HasDefaultConstructor(this Type type) { if (!type.IsValueType) { return type.GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, Type.EmptyTypes, null) != null; } return true; } public static TypeCode GetTypeCode(this Type type) { return Type.GetTypeCode(type); } public static PropertyInfo? GetPublicProperty(this Type type, string name) { return type.GetProperty(name); } public static FieldInfo? GetPublicStaticField(this Type type, string name) { return type.GetField(name, BindingFlags.Static | BindingFlags.Public); } public static IEnumerable<PropertyInfo> GetProperties(this Type type, bool includeNonPublic) { BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public; if (includeNonPublic) { bindingFlags |= BindingFlags.NonPublic; } if (!type.IsInterface) { return type.GetProperties(bindingFlags); } return Enumerable.SelectMany(Enumerable.Concat(new Type[1] { type }, type.GetInterfaces()), (Type i) => i.GetProperties(bindingFlags)); } public static IEnumerable<PropertyInfo> GetPublicProperties(this Type type) { return GetProperties(type, includeNonPublic: false); } public static IEnumerable<FieldInfo> GetPublicFields(this Type type) { return type.GetFields(BindingFlags.Instance | BindingFlags.Public); } public static IEnumerable<MethodInfo> GetPublicStaticMethods(this Type type) { return type.GetMethods(BindingFlags.Static | BindingFlags.Public); } public static MethodInfo GetPrivateStaticMethod(this Type type, string name) { return type.GetMethod(name, BindingFlags.Static | BindingFlags.NonPublic) ?? throw new MissingMethodException("Expected to find a method named '" + name + "' in '" + type.FullName + "'."); } public static MethodInfo? GetPublicStaticMethod(this Type type, string name, params Type[] parameterTypes) { return type.GetMethod(name, BindingFlags.Static | BindingFlags.Public, null, parameterTypes, null); } public static MethodInfo? GetPublicInstanceMethod(this Type type, string name) { return type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public); } public static Exception Unwrap(this TargetInvocationException ex) { Exception innerException = ex.InnerException; if (innerException == null) { return ex; } if (RemoteStackTraceField != null) { RemoteStackTraceField.SetValue(innerException, innerException.StackTrace + "\r\n"); } return innerException; } public static bool IsInstanceOf(this Type type, object o) { return type.IsInstanceOfType(o); } public static Attribute[] GetAllCustomAttributes<TAttribute>(this PropertyInfo property) { return Attribute.GetCustomAttributes(property, typeof(TAttribute)); } } internal static class <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>PropertyInfoExtensions { public static object? ReadValue(this PropertyInfo property, object target) { return property.GetValue(target, null); } } internal static class <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>StandardRegexOptions { public const RegexOptions Compiled = RegexOptions.Compiled; } } namespace YamlDotNet.Serialization { internal abstract class <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>BuilderSkeleton<TBuilder> where TBuilder : <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>BuilderSkeleton<TBuilder> { internal <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INamingConvention namingConvention = <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>NullNamingConvention.Instance; internal <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeResolver typeResolver; internal readonly <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>YamlAttributeOverrides overrides; internal readonly <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>LazyComponentRegistrationList<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter> typeConverterFactories; internal readonly <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>LazyComponentRegistrationList<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector> typeInspectorFactories; private bool ignoreFields; private bool includeNonPublicProperties; protected abstract TBuilder Self { get; } internal <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>BuilderSkeleton(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeResolver typeResolver) { overrides = new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>YamlAttributeOverrides(); typeConverterFactories = new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>LazyComponentRegistrationList<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter> { { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>GuidConverter), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>GuidConverter(jsonCompatible: false) }, { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>SystemTypeConverter), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>SystemTypeConverter() } }; typeInspectorFactories = new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>LazyComponentRegistrationList<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector>(); this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver"); } internal <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector BuildTypeInspector() { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector2 = new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ReadablePropertiesTypeInspector(typeResolver, includeNonPublicProperties); if (!ignoreFields) { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector2 = new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>CompositeTypeInspector(new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ReadableFieldsTypeInspector(typeResolver), <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector2); } return typeInspectorFactories.BuildComponentChain(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector2); } public TBuilder IgnoreFields() { ignoreFields = true; return Self; } public TBuilder IncludeNonPublicProperties() { includeNonPublicProperties = true; return Self; } public TBuilder WithNamingConvention(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INamingConvention namingConvention) { this.namingConvention = namingConvention ?? throw new ArgumentNullException("namingConvention"); return Self; } public TBuilder WithTypeResolver(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeResolver typeResolver) { this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver"); return Self; } public abstract TBuilder WithTagMapping(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>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(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter typeConverter) { return WithTypeConverter(typeConverter, delegate(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IRegistrationLocationSelectionSyntax<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter> w) { w.OnTop(); }); } public TBuilder WithTypeConverter(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter typeConverter, Action<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IRegistrationLocationSelectionSyntax<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter>> where) { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter typeConverter2 = typeConverter; if (typeConverter2 == null) { throw new ArgumentNullException("typeConverter"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateRegistrationLocationSelector(typeConverter2.GetType(), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => typeConverter2)); return Self; } public TBuilder WithTypeConverter<TYamlTypeConverter>(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>WrapperFactory<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter> typeConverterFactory, Action<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITrackingRegistrationLocationSelectionSyntax<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter>> where) where TYamlTypeConverter : <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>WrapperFactory<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter> typeConverterFactory2 = typeConverterFactory; if (typeConverterFactory2 == null) { throw new ArgumentNullException("typeConverterFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateTrackingRegistrationLocationSelector(typeof(TYamlTypeConverter), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter wrapped, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => typeConverterFactory2(wrapped))); return Self; } public TBuilder WithoutTypeConverter<TYamlTypeConverter>() where TYamlTypeConverter : <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>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<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector, TTypeInspector> typeInspectorFactory) where TTypeInspector : <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector { return WithTypeInspector(typeInspectorFactory, delegate(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IRegistrationLocationSelectionSyntax<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector> w) { w.OnTop(); }); } public TBuilder WithTypeInspector<TTypeInspector>(Func<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector, TTypeInspector> typeInspectorFactory, Action<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IRegistrationLocationSelectionSyntax<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector>> where) where TTypeInspector : <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector { Func<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector, TTypeInspector> typeInspectorFactory2 = typeInspectorFactory; if (typeInspectorFactory2 == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateRegistrationLocationSelector(typeof(TTypeInspector), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector inner) => typeInspectorFactory2(inner))); return Self; } public TBuilder WithTypeInspector<TTypeInspector>(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>WrapperFactory<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector, TTypeInspector> typeInspectorFactory, Action<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITrackingRegistrationLocationSelectionSyntax<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector>> where) where TTypeInspector : <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>WrapperFactory<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector, TTypeInspector> typeInspectorFactory2 = typeInspectorFactory; if (typeInspectorFactory2 == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateTrackingRegistrationLocationSelector(typeof(TTypeInspector), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector wrapped, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector inner) => typeInspectorFactory2(wrapped, inner))); return Self; } public TBuilder WithoutTypeInspector<TTypeInspector>() where TTypeInspector : <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector { return WithoutTypeInspector(typeof(TTypeInspector)); } public TBuilder WithoutTypeInspector(Type inspectorType) { if (inspectorType == null) { throw new ArgumentNullException("inspectorType"); } typeInspectorFactories.Remove(inspectorType); return Self; } protected IEnumerable<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter> BuildTypeConverters() { return typeConverterFactories.BuildComponentList(); } } internal delegate TComponent <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>WrapperFactory<TComponentBase, TComponent>(TComponentBase wrapped) where TComponent : TComponentBase; internal delegate TComponent <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>WrapperFactory<TArgument, TComponentBase, TComponent>(TComponentBase wrapped, TArgument argument) where TComponent : TComponentBase; [Flags] internal enum <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DefaultValuesHandling { Preserve = 0, OmitNull = 1, OmitDefaults = 2, OmitEmptyCollections = 4 } internal sealed class <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Deserializer : <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IDeserializer { private readonly <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IValueDeserializer valueDeserializer; public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Deserializer() : this(new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder().BuildValueDeserializer()) { } private <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Deserializer(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IValueDeserializer valueDeserializer) { this.valueDeserializer = valueDeserializer ?? throw new ArgumentNullException("valueDeserializer"); } public static <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Deserializer FromValueDeserializer(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IValueDeserializer valueDeserializer) { return new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>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 <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Parser(input)); } public object? Deserialize(TextReader input) { return Deserialize(input, 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 <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Parser(input), type); } public T Deserialize<T>(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IParser parser) { return (T)Deserialize(parser, typeof(T)); } public object? Deserialize(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IParser parser) { return Deserialize(parser, typeof(object)); } public object? Deserialize(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IParser parser, Type type) { if (parser == null) { throw new ArgumentNullException("parser"); } if (type == null) { throw new ArgumentNullException("type"); } YamlDotNet.Core.Events.<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>StreamStart @event; bool flag = parser.TryConsume<YamlDotNet.Core.Events.<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>StreamStart>(out @event); YamlDotNet.Core.Events.<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DocumentStart event2; bool flag2 = parser.TryConsume<YamlDotNet.Core.Events.<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DocumentStart>(out event2); object result = null; if (!parser.Accept<YamlDotNet.Core.Events.<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DocumentEnd>(out var _) && !parser.Accept<YamlDotNet.Core.Events.<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>StreamEnd>(out var _)) { using <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>SerializerState <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>SerializerState = new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>SerializerState(); result = valueDeserializer.DeserializeValue(parser, type, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>SerializerState, valueDeserializer); <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>SerializerState.OnDeserialization(); } if (flag2) { parser.Consume<YamlDotNet.Core.Events.<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DocumentEnd>(); } if (flag) { parser.Consume<YamlDotNet.Core.Events.<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>StreamEnd>(); } return result; } } internal sealed class <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder : <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>BuilderSkeleton<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder> { private Lazy<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IObjectFactory> objectFactory; private readonly <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>LazyComponentRegistrationList<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeDeserializer> nodeDeserializerFactories; private readonly <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>LazyComponentRegistrationList<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeTypeResolver> nodeTypeResolverFactories; private readonly Dictionary<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>TagName, Type> tagMappings; private readonly Dictionary<Type, Type> typeMappings; private bool ignoreUnmatched; protected override <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder Self => this; public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder() : base((<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeResolver)new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>StaticTypeResolver()) { typeMappings = new Dictionary<Type, Type>(); objectFactory = new Lazy<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IObjectFactory>(() => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DefaultObjectFactory(typeMappings), isThreadSafe: true); tagMappings = new Dictionary<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>TagName, Type> { { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>FailsafeSchema.Tags.Map, typeof(Dictionary<object, object>) }, { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>FailsafeSchema.Tags.Str, typeof(string) }, { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>JsonSchema.Tags.Bool, typeof(bool) }, { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>JsonSchema.Tags.Float, typeof(double) }, { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>JsonSchema.Tags.Int, typeof(int) }, { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DefaultSchema.Tags.Timestamp, typeof(DateTime) } }; typeInspectorFactories.Add(typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>CachedTypeInspector), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector inner) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>CachedTypeInspector(inner)); typeInspectorFactories.Add(typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>NamingConventionTypeInspector), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector inner) => (!(namingConvention is <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>NullNamingConvention)) ? new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>NamingConventionTypeInspector(inner, namingConvention) : inner); typeInspectorFactories.Add(typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>YamlAttributesTypeInspector), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector inner) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>YamlAttributesTypeInspector(inner)); typeInspectorFactories.Add(typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>YamlAttributeOverridesInspector), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector inner) => (overrides == null) ? inner : new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>YamlAttributeOverridesInspector(inner, overrides.Clone())); typeInspectorFactories.Add(typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ReadableAndWritablePropertiesTypeInspector), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITypeInspector inner) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ReadableAndWritablePropertiesTypeInspector(inner)); nodeDeserializerFactories = new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>LazyComponentRegistrationList<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeDeserializer> { { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>YamlConvertibleNodeDeserializer), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>YamlConvertibleNodeDeserializer(objectFactory.Value) }, { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>YamlSerializableNodeDeserializer), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>YamlSerializableNodeDeserializer(objectFactory.Value) }, { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>TypeConverterNodeDeserializer), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>TypeConverterNodeDeserializer(BuildTypeConverters()) }, { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>NullNodeDeserializer), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>NullNodeDeserializer() }, { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ScalarNodeDeserializer), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ScalarNodeDeserializer() }, { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ArrayNodeDeserializer), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ArrayNodeDeserializer() }, { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DictionaryNodeDeserializer), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DictionaryNodeDeserializer(objectFactory.Value) }, { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>CollectionNodeDeserializer), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>CollectionNodeDeserializer(objectFactory.Value) }, { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>EnumerableNodeDeserializer), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>EnumerableNodeDeserializer() }, { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ObjectNodeDeserializer), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ObjectNodeDeserializer(objectFactory.Value, BuildTypeInspector(), ignoreUnmatched) } }; nodeTypeResolverFactories = new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>LazyComponentRegistrationList<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeTypeResolver> { { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>MappingNodeTypeResolver), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>MappingNodeTypeResolver(typeMappings) }, { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>YamlConvertibleTypeResolver), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>YamlConvertibleTypeResolver() }, { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>YamlSerializableTypeResolver), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>YamlSerializableTypeResolver() }, { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>TagNodeTypeResolver), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>TagNodeTypeResolver(tagMappings) }, { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>PreventUnknownTagsNodeTypeResolver), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>PreventUnknownTagsNodeTypeResolver() }, { typeof(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DefaultContainersNodeTypeResolver), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DefaultContainersNodeTypeResolver() } }; } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder WithObjectFactory(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IObjectFactory objectFactory) { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IObjectFactory objectFactory2 = objectFactory; if (objectFactory2 == null) { throw new ArgumentNullException("objectFactory"); } this.objectFactory = new Lazy<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IObjectFactory>(() => objectFactory2, isThreadSafe: true); return this; } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder WithObjectFactory(Func<Type, object> objectFactory) { if (objectFactory == null) { throw new ArgumentNullException("objectFactory"); } return WithObjectFactory(new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>LambdaObjectFactory(objectFactory)); } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder WithNodeDeserializer(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeDeserializer nodeDeserializer) { return WithNodeDeserializer(nodeDeserializer, delegate(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IRegistrationLocationSelectionSyntax<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeDeserializer> w) { w.OnTop(); }); } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder WithNodeDeserializer(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeDeserializer nodeDeserializer, Action<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IRegistrationLocationSelectionSyntax<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeDeserializer>> where) { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeDeserializer nodeDeserializer2 = nodeDeserializer; if (nodeDeserializer2 == null) { throw new ArgumentNullException("nodeDeserializer"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateRegistrationLocationSelector(nodeDeserializer2.GetType(), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => nodeDeserializer2)); return this; } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder WithNodeDeserializer<TNodeDeserializer>(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>WrapperFactory<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory, Action<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITrackingRegistrationLocationSelectionSyntax<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeDeserializer>> where) where TNodeDeserializer : <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeDeserializer { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>WrapperFactory<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory2 = nodeDeserializerFactory; if (nodeDeserializerFactory2 == null) { throw new ArgumentNullException("nodeDeserializerFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeDeserializer), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeDeserializer wrapped, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => nodeDeserializerFactory2(wrapped))); return this; } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder WithoutNodeDeserializer<TNodeDeserializer>() where TNodeDeserializer : <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeDeserializer { return WithoutNodeDeserializer(typeof(TNodeDeserializer)); } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder WithoutNodeDeserializer(Type nodeDeserializerType) { if (nodeDeserializerType == null) { throw new ArgumentNullException("nodeDeserializerType"); } nodeDeserializerFactories.Remove(nodeDeserializerType); return this; } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder WithNodeTypeResolver(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeTypeResolver nodeTypeResolver) { return WithNodeTypeResolver(nodeTypeResolver, delegate(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IRegistrationLocationSelectionSyntax<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeTypeResolver> w) { w.OnTop(); }); } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder WithNodeTypeResolver(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeTypeResolver nodeTypeResolver, Action<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IRegistrationLocationSelectionSyntax<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeTypeResolver>> where) { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeTypeResolver nodeTypeResolver2 = nodeTypeResolver; if (nodeTypeResolver2 == null) { throw new ArgumentNullException("nodeTypeResolver"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeTypeResolverFactories.CreateRegistrationLocationSelector(nodeTypeResolver2.GetType(), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => nodeTypeResolver2)); return this; } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder WithNodeTypeResolver<TNodeTypeResolver>(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>WrapperFactory<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeTypeResolver, TNodeTypeResolver> nodeTypeResolverFactory, Action<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ITrackingRegistrationLocationSelectionSyntax<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeTypeResolver>> where) where TNodeTypeResolver : <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeTypeResolver { <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>WrapperFactory<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeTypeResolver, TNodeTypeResolver> nodeTypeResolverFactory2 = nodeTypeResolverFactory; if (nodeTypeResolverFactory2 == null) { throw new ArgumentNullException("nodeTypeResolverFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeTypeResolverFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeTypeResolver), (<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeTypeResolver wrapped, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing _) => nodeTypeResolverFactory2(wrapped))); return this; } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder WithoutNodeTypeResolver<TNodeTypeResolver>() where TNodeTypeResolver : <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>INodeTypeResolver { return WithoutNodeTypeResolver(typeof(TNodeTypeResolver)); } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder WithoutNodeTypeResolver(Type nodeTypeResolverType) { if (nodeTypeResolverType == null) { throw new ArgumentNullException("nodeTypeResolverType"); } nodeTypeResolverFactories.Remove(nodeTypeResolverType); return this; } public override <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder WithTagMapping(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>TagName tag, Type type) { if (tag.IsEmpty) { throw new ArgumentException("Non-specific tags cannot be maped"); } if (type == null) { throw new ArgumentNullException("type"); } if (tagMappings.TryGetValue(tag, out Type value)) { throw new ArgumentException($"Type already has a registered type '{value.FullName}' for tag '{tag}'", "tag"); } tagMappings.Add(tag, type); return this; } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder WithTypeMapping<TInterface, TConcrete>() where TConcrete : TInterface { Type typeFromHandle = typeof(TInterface); Type typeFromHandle2 = typeof(TConcrete); if (!typeFromHandle.IsAssignableFrom(typeFromHandle2)) { throw new InvalidOperationException("The type '" + typeFromHandle2.Name + "' does not implement interface '" + typeFromHandle.Name + "'."); } if (typeMappings.ContainsKey(typeFromHandle)) { typeMappings[typeFromHandle] = typeFromHandle2; } else { typeMappings.Add(typeFromHandle, typeFromHandle2); } return this; } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder WithoutTagMapping(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>TagName tag) { if (tag.IsEmpty) { throw new ArgumentException("Non-specific tags cannot be maped"); } if (!tagMappings.Remove(tag)) { throw new KeyNotFoundException($"Tag '{tag}' is not registered"); } return this; } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>DeserializerBuilder IgnoreUnmatchedProperties() { ignoreUnmatched = true; return this; } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IDeserializer Build() { return <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Deserializer.FromValueDeserializer(BuildValueDeserializer()); } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IValueDeserializer BuildValueDeserializer() { return new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>AliasValueDeserializer(new <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>NodeValueDeserializer(nodeDeserializerFactories.BuildComponentList(), nodeTypeResolverFactories.BuildComponentList())); } } internal sealed class <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>EmissionPhaseObjectGraphVisitorArgs { private readonly IEnumerable<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IObjectGraphVisitor<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing>> preProcessingPhaseVisitors; public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IObjectGraphVisitor<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IEmitter> InnerVisitor { get; private set; } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IEventEmitter EventEmitter { get; private set; } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>ObjectSerializer NestedObjectSerializer { get; private set; } public IEnumerable<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter> TypeConverters { get; private set; } public <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>EmissionPhaseObjectGraphVisitorArgs(<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IObjectGraphVisitor<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IEmitter> innerVisitor, <4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IEventEmitter eventEmitter, IEnumerable<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IObjectGraphVisitor<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>Nothing>> preProcessingPhaseVisitors, IEnumerable<<4e6e711c-ab19-4eeb-bc3e-1b81ab5e9b05>IYamlTypeConverter> typeConverters, <4e6e7