Decompiled source of ValheimWitch v1.0.5
ValheimWitch.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using ValheimWitch.Functions; using ValheimWitch.Utils; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: Guid("B368356E-EA90-4D3D-B519-6D59527F7F5D")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyProduct("ValheimWitch")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("https://valheim.thunderstore.io/package/blacks7ar/ValheimWitch/")] [assembly: AssemblyTitle("ValheimWitch")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyFileVersion("1.0.5")] [assembly: AssemblyCompany("blacks7ar")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.5.0")] [module: <7f21093f-340c-409b-a17d-53b5667407c2>RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<6e2cbf48-29b6-4f70-9aa0-cfb41338ba0a>Embedded] internal sealed class <6e2cbf48-29b6-4f70-9aa0-cfb41338ba0a>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [<6e2cbf48-29b6-4f70-9aa0-cfb41338ba0a>Embedded] [CompilerGenerated] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class <7f21093f-340c-409b-a17d-53b5667407c2>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <7f21093f-340c-409b-a17d-53b5667407c2>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ValheimWitch { [BepInPlugin("blacks7ar.ValheimWitch", "ValheimWitch", "1.0.5")] public class Plugin : BaseUnityPlugin { private enum Toggle { On = 1, Off = 0 } private const string modGUID = "blacks7ar.ValheimWitch"; public const string modName = "ValheimWitch"; public const string modAuthor = "blacks7ar"; public const string modVersion = "1.0.5"; public const string modLink = "https://valheim.thunderstore.io/package/blacks7ar/ValheimWitch/"; private static readonly Harmony _harmony = new Harmony("blacks7ar.ValheimWitch"); private static readonly ConfigSync _configSync = new ConfigSync("blacks7ar.ValheimWitch") { DisplayName = "ValheimWitch", CurrentVersion = "1.0.5", MinimumRequiredVersion = "1.0.5", ModRequired = true }; private static ConfigEntry<Toggle> _serverConfigLocked; public static AssetBundle _witchBundle; public static GameObject _projectileSpirit; public static GameObject _summonBatsSpawn; public static GameObject _summonSkeletonSpawn; public static GameObject _attackSummonSkeleton; public static GameObject _attackSummonBats; public static GameObject _attackSpirit; public static GameObject _forestWitch; public static GameObject _swampWitch; public static GameObject _summonedSkeleton; public static GameObject _summonedBats; public static GameObject _PrefabContainer; public static Plugin _Instance; public 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; } public void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown _Instance = this; 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); ConfigSetup.Init(); PrefabContainer(); _witchBundle = GetAssetBundleFromResources("witchbundle"); _projectileSpirit = _witchBundle.LoadAsset<GameObject>("bvw_projectile_spirit"); _summonBatsSpawn = _witchBundle.LoadAsset<GameObject>("bvw_summon_bats_spawn"); _summonSkeletonSpawn = _witchBundle.LoadAsset<GameObject>("bvw_summon_skeleton_spawn"); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; ((BaseUnityPlugin)this).Config.Save(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } public static void PrefabContainer() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown _PrefabContainer = new GameObject("BVW_ClonedPrefabs"); _PrefabContainer.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_PrefabContainer); } private static AssetBundle GetAssetBundleFromResources(string filename) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetManifestResourceNames().Single((string x) => x.EndsWith(filename)); using Stream stream = executingAssembly.GetManifestResourceStream(name); return AssetBundle.LoadFromStream(stream); } } } namespace ValheimWitch.Utils { public static class Helper { public static GameObject Clone(this GameObject gameObject, string name) { GameObject obj = Object.Instantiate<GameObject>(gameObject, Plugin._PrefabContainer.transform, false); ((Object)obj).name = name; obj.transform.SetParent(Plugin._PrefabContainer.transform, false); return obj; } public static GameObject CloneItem(this GameObject gameObject, string name) { GameObject obj = Object.Instantiate<GameObject>(gameObject, Plugin._PrefabContainer.transform, false); ((Object)obj).name = name; return obj; } public static void AddClonedObject(this ZNetScene zNetScene, GameObject gameObject, bool overWrite = true) { GameObject prefab; if ((Object)(object)(prefab = zNetScene.GetPrefab(((Object)gameObject).name)) != (Object)null) { if (!overWrite) { return; } zNetScene.m_prefabs.Remove(prefab); zNetScene.m_namedPrefabs.Remove(StringExtensionMethods.GetStableHashCode(((Object)gameObject).name)); } zNetScene.m_prefabs.Add(gameObject); zNetScene.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)gameObject).name), gameObject); } public static void AddClonedObject(this ObjectDB objectDB, GameObject gameObject, bool overWrite = true) { GameObject itemPrefab; if ((Object)(object)(itemPrefab = objectDB.GetItemPrefab(((Object)gameObject).name)) != (Object)null) { if (!overWrite) { return; } objectDB.m_items.Remove(itemPrefab); objectDB.m_itemByHash.Remove(StringExtensionMethods.GetStableHashCode(((Object)gameObject).name)); } objectDB.m_items.Add(gameObject); objectDB.m_itemByHash.Add(StringExtensionMethods.GetStableHashCode(((Object)gameObject).name), gameObject); } public static bool ObjectDBAwake() { if ((Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0) { return (Object)(object)ObjectDB.instance.GetItemPrefab("Wood") != (Object)null; } return false; } 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 void ChangeColor(this GameObject gameObject, Color color) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gameObject == (Object)null) { return; } Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>(); 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.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); } } } } namespace ValheimWitch.Patches { [HarmonyPatch] public class ObjectDBPatch { [HarmonyPostfix] [HarmonyPriority(700)] [HarmonyPatch(typeof(ObjectDB), "Awake")] public static void Awake_Postfix(ObjectDB __instance) { RegisterPrefabs.ToObjectDB(); __instance.UpdateRegisters(); } [HarmonyPriority(700)] [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] public static void CopyOtherDB_Postfix(ObjectDB __instance) { RegisterPrefabs.ToObjectDB(); __instance.UpdateRegisters(); } } [HarmonyPatch(typeof(SpawnSystem), "UpdateSpawnList")] public class SpawnSystemPatch { public static void Prefix(SpawnSystem __instance) { SpawnerSetup.Init(__instance); } } [HarmonyPatch(typeof(ZNetScene), "Awake")] public class ZNetScenePatch { public static void Postfix(ZNetScene __instance) { if (!((Object)(object)__instance == (Object)null)) { List<GameObject> prefabs = __instance.m_prefabs; if (prefabs != null && prefabs.Count > 0) { Plugin.PrefabContainer(); RegisterPrefabs.ToZNetScene(); } } } } } namespace ValheimWitch.Functions { public static class ConfigSetup { public static ConfigEntry<float> _forestWitchHealth; public static ConfigEntry<bool> _forestWitchEnable; public static ConfigEntry<Biome> _forestWitchBiome; public static ConfigEntry<BiomeArea> _forestWitchBiomeArea; public static ConfigEntry<int> _forestWitchMaxSpawned; public static ConfigEntry<float> _forestWitchSpawnInterval; public static ConfigEntry<float> _forestWitchSpawnChance; public static ConfigEntry<float> _forestWitchSpawnDistance; public static ConfigEntry<string> _forestWitchGlobalKey; public static ConfigEntry<int> _forestWitchGroupSizeMin; public static ConfigEntry<int> _forestWitchGroupSizeMax; public static ConfigEntry<float> _forestWitchGroupRadius; public static ConfigEntry<bool> _forestWitchSpawnAtDay; public static ConfigEntry<bool> _forestWitchSpawnAtNight; public static ConfigEntry<float> _forestWitchMinAltitude; public static ConfigEntry<float> _forestWitchMaxAltitude; public static ConfigEntry<float> _forestWitchMinTilt; public static ConfigEntry<float> _forestWitchMaxTilt; public static ConfigEntry<bool> _forestWitchInForest; public static ConfigEntry<bool> _forestWitchOutForest; public static ConfigEntry<bool> _forestWitchHuntPlayer; public static ConfigEntry<float> _forestWitchGroundOffset; public static ConfigEntry<int> _forestWitchMaxLevel; public static ConfigEntry<int> _forestWitchMinLevel; public static ConfigEntry<float> _forestWitchOverrideLevelUpChance; public static ConfigEntry<float> _forestWitchLevelUpMinCenterDistance; public static ConfigEntry<float> _swampWitchHealth; public static ConfigEntry<bool> _swampWitchEnable; public static ConfigEntry<Biome> _swampWitchBiome; public static ConfigEntry<BiomeArea> _swampWitchBiomeArea; public static ConfigEntry<int> _swampWitchMaxSpawned; public static ConfigEntry<float> _swampWitchSpawnInterval; public static ConfigEntry<float> _swampWitchSpawnChance; public static ConfigEntry<float> _swampWitchSpawnDistance; public static ConfigEntry<string> _swampWitchGlobalKey; public static ConfigEntry<int> _swampWitchGroupSizeMin; public static ConfigEntry<int> _swampWitchGroupSizeMax; public static ConfigEntry<float> _swampWitchGroupRadius; public static ConfigEntry<bool> _swampWitchSpawnAtDay; public static ConfigEntry<bool> _swampWitchSpawnAtNight; public static ConfigEntry<float> _swampWitchMinAltitude; public static ConfigEntry<float> _swampWitchMaxAltitude; public static ConfigEntry<float> _swampWitchMinTilt; public static ConfigEntry<float> _swampWitchMaxTilt; public static ConfigEntry<bool> _swampWitchInForest; public static ConfigEntry<bool> _swampWitchOutForest; public static ConfigEntry<bool> _swampWitchHuntPlayer; public static ConfigEntry<float> _swampWitchGroundOffset; public static ConfigEntry<int> _swampWitchMaxLevel; public static ConfigEntry<int> _swampWitchMinLevel; public static ConfigEntry<float> _swampWitchOverrideLevelUpChance; public static ConfigEntry<float> _swampWitchLevelUpMinCenterDistance; private const string _enableDesc = "Enable/Disables spawning this vikings."; private const string _biomeDesc = "The biome to spawn this viking."; private const string _biomeAreaDesc = "Biome Area."; private const string _maxSpawnedDesc = "Total nr of instances (if near player is set, only instances within the max spawn radius is counted)"; private const string _spawnIntervalDesc = "How often do we spawn"; private const string _spawnChanceDesc = "Chance to spawn each spawn interval"; private const string _spawnDistanceDesc = "Minimum distance to another instance"; private const string _globalKeyDesc = "Only spawn if this key is set"; private const string _groupingDesc = "Group spawning"; private const string _timeOfDayDesc = "Time of day"; private const string _altitudeDesc = "Altitude"; private const string _terrainTiltDesc = "Terrain tilt"; private const string _forestDesc = "Forest"; private const string _statesDesc = "States"; private const string _levelDesc = "Level"; private static Localization english; public static void Init() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown english = new Localization(); english.SetupLanguage("English"); ForestWitch(); SwampWitch(); } private static void ForestWitch() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Expected O, but got Unknown //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Expected O, but got Unknown //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Expected O, but got Unknown //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Expected O, but got Unknown //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Expected O, but got Unknown //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Expected O, but got Unknown //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Expected O, but got Unknown //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Expected O, but got Unknown //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Expected O, but got Unknown //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Expected O, but got Unknown //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Expected O, but got Unknown //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Expected O, but got Unknown //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Expected O, but got Unknown //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Expected O, but got Unknown string group = english.Localize("$bvw_forestwitch"); _forestWitchHealth = Plugin._Instance.config(group, "Health", 200f, new ConfigDescription("Base health points.", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchEnable = Plugin._Instance.config(group, "Enable", value: true, new ConfigDescription("Enable/Disables spawning this vikings.", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchBiome = Plugin._Instance.config<Biome>(group, "Biome", (Biome)13, new ConfigDescription("The biome to spawn this viking.", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchBiomeArea = Plugin._Instance.config<BiomeArea>(group, "Biome Area", (BiomeArea)3, new ConfigDescription("Biome Area.", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchMaxSpawned = Plugin._Instance.config(group, "Max Spawned", 2, new ConfigDescription("Total nr of instances (if near player is set, only instances within the max spawn radius is counted)", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchSpawnInterval = Plugin._Instance.config(group, "Spawn Interval", 120f, new ConfigDescription("How often do we spawn", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchSpawnChance = Plugin._Instance.config(group, "Spawn Chance", 100f, new ConfigDescription("Chance to spawn each spawn interval", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchSpawnDistance = Plugin._Instance.config(group, "Spawn Distance", 64f, new ConfigDescription("Minimum distance to another instance", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchGlobalKey = Plugin._Instance.config(group, "Required Global Key", "defeated_gdking", new ConfigDescription("Only spawn if this key is set", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchGroupSizeMin = Plugin._Instance.config(group, "Group Size Min", 1, new ConfigDescription("Group spawning", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchGroupSizeMax = Plugin._Instance.config(group, "Group Size Max", 1, new ConfigDescription("Group spawning", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchGroupRadius = Plugin._Instance.config(group, "Group Radius", 10f, new ConfigDescription("Group spawning", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchSpawnAtDay = Plugin._Instance.config(group, "Spawn At Day", value: false, new ConfigDescription("Time of day", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchSpawnAtNight = Plugin._Instance.config(group, "Spawn At Night", value: true, new ConfigDescription("Time of day", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchMinAltitude = Plugin._Instance.config(group, "Min Altitude", 0f, new ConfigDescription("Altitude", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchMaxAltitude = Plugin._Instance.config(group, "Max Altitude", 1000f, new ConfigDescription("Altitude", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchMinTilt = Plugin._Instance.config(group, "Min Tilt", 0f, new ConfigDescription("Terrain tilt", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchMaxTilt = Plugin._Instance.config(group, "Max Tilt", 35f, new ConfigDescription("Terrain tilt", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchInForest = Plugin._Instance.config(group, "In Forest", value: true, new ConfigDescription("Forest", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchOutForest = Plugin._Instance.config(group, "Outside Forest", value: true, new ConfigDescription("Forest", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchHuntPlayer = Plugin._Instance.config(group, "Hunt Player", value: false, new ConfigDescription("States", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchGroundOffset = Plugin._Instance.config(group, "Ground Offset", 0.5f, new ConfigDescription("States", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchMaxLevel = Plugin._Instance.config(group, "Max Level", 3, new ConfigDescription("Level", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchMinLevel = Plugin._Instance.config(group, "Min Level", 1, new ConfigDescription("Level", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchLevelUpMinCenterDistance = Plugin._Instance.config(group, "LevelUp Min Center Distance", 0f, new ConfigDescription("Level", (AcceptableValueBase)null, Array.Empty<object>())); _forestWitchOverrideLevelUpChance = Plugin._Instance.config(group, "Override LevelUp Chance", -1f, new ConfigDescription("Level", (AcceptableValueBase)null, Array.Empty<object>())); } private static void SwampWitch() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected O, but got Unknown //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Expected O, but got Unknown //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Expected O, but got Unknown //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Expected O, but got Unknown //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Expected O, but got Unknown //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Expected O, but got Unknown //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Expected O, but got Unknown //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Expected O, but got Unknown //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Expected O, but got Unknown //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Expected O, but got Unknown //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Expected O, but got Unknown //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Expected O, but got Unknown //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Expected O, but got Unknown //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Expected O, but got Unknown //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Expected O, but got Unknown //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Expected O, but got Unknown string group = english.Localize("$bvw_swampwitch"); _swampWitchHealth = Plugin._Instance.config(group, "Health", 500f, new ConfigDescription("Base health points.", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchEnable = Plugin._Instance.config(group, "Enable", value: true, new ConfigDescription("Enable/Disables spawning this vikings.", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchBiome = Plugin._Instance.config<Biome>(group, "Biome", (Biome)530, new ConfigDescription("The biome to spawn this viking.", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchBiomeArea = Plugin._Instance.config<BiomeArea>(group, "Biome Area", (BiomeArea)3, new ConfigDescription("Biome Area.", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchMaxSpawned = Plugin._Instance.config(group, "Max Spawned", 2, new ConfigDescription("Total nr of instances (if near player is set, only instances within the max spawn radius is counted)", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchSpawnInterval = Plugin._Instance.config(group, "Spawn Interval", 120f, new ConfigDescription("How often do we spawn", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchSpawnChance = Plugin._Instance.config(group, "Spawn Chance", 100f, new ConfigDescription("Chance to spawn each spawn interval", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchSpawnDistance = Plugin._Instance.config(group, "Spawn Distance", 64f, new ConfigDescription("Minimum distance to another instance", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchGlobalKey = Plugin._Instance.config(group, "Required Global Key", "defeated_bonemass", new ConfigDescription("Only spawn if this key is set", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchGroupSizeMin = Plugin._Instance.config(group, "Group Size Min", 1, new ConfigDescription("Group spawning", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchGroupSizeMax = Plugin._Instance.config(group, "Group Size Max", 1, new ConfigDescription("Group spawning", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchGroupRadius = Plugin._Instance.config(group, "Group Radius", 10f, new ConfigDescription("Group spawning", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchSpawnAtDay = Plugin._Instance.config(group, "Spawn At Day", value: false, new ConfigDescription("Time of day", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchSpawnAtNight = Plugin._Instance.config(group, "Spawn At Night", value: true, new ConfigDescription("Time of day", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchMinAltitude = Plugin._Instance.config(group, "Min Altitude", 0f, new ConfigDescription("Altitude", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchMaxAltitude = Plugin._Instance.config(group, "Max Altitude", 1000f, new ConfigDescription("Altitude", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchMinTilt = Plugin._Instance.config(group, "Min Tilt", 0f, new ConfigDescription("Terrain tilt", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchMaxTilt = Plugin._Instance.config(group, "Max Tilt", 35f, new ConfigDescription("Terrain tilt", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchInForest = Plugin._Instance.config(group, "In Forest", value: true, new ConfigDescription("Forest", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchOutForest = Plugin._Instance.config(group, "Outside Forest", value: true, new ConfigDescription("Forest", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchHuntPlayer = Plugin._Instance.config(group, "Hunt Player", value: false, new ConfigDescription("States", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchGroundOffset = Plugin._Instance.config(group, "Ground Offset", 0.5f, new ConfigDescription("States", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchMaxLevel = Plugin._Instance.config(group, "Max Level", 3, new ConfigDescription("Level", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchMinLevel = Plugin._Instance.config(group, "Min Level", 1, new ConfigDescription("Level", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchLevelUpMinCenterDistance = Plugin._Instance.config(group, "LevelUp Min Center Distance", 0f, new ConfigDescription("Level", (AcceptableValueBase)null, Array.Empty<object>())); _swampWitchOverrideLevelUpChance = Plugin._Instance.config(group, "Override LevelUp Chance", -1f, new ConfigDescription("Level", (AcceptableValueBase)null, Array.Empty<object>())); } } public class FixedDespawn : MonoBehaviour { public float m_unsummonDistance = 40f; public EffectList m_unsummonEffect = new EffectList(); public MonsterAI m_monsterAI; public ZNetView m_nview; public GameObject m_master; public void Awake() { m_nview = ((Component)this).GetComponent<ZNetView>(); m_monsterAI = ((Component)this).GetComponent<MonsterAI>(); if (m_nview.IsValid()) { m_nview.Register("RPC_UnSummon", (Action<long>)RPC_UnSummon); GetMaster(); } } public void Update() { UpdateSummon(); UpdateMaster(); } private void GetMaster() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) List<Character> list = new List<Character>(); Character.GetCharactersInRange(((Component)this).transform.position, 30f, list); foreach (Character item in list) { if (((Object)((Component)this).gameObject).name.StartsWith("BVW_Skeleton") && item.m_name.Contains("forestwitch")) { m_master = ((Component)item).gameObject; } if (((Object)((Component)this).gameObject).name.StartsWith("BVW_Bat") && item.m_name.Contains("swampwitch")) { m_master = ((Component)item).gameObject; } } } public void UpdateMaster() { if (!((Object)(object)m_master != (Object)null) && m_nview.IsOwner()) { UnSummon(); } } public void UpdateSummon() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (m_nview.IsValid() && m_nview.IsOwner() && m_unsummonDistance > 0f && Object.op_Implicit((Object)(object)m_monsterAI) && Object.op_Implicit((Object)(object)m_master) && Vector3.Distance(m_master.transform.position, ((Component)this).gameObject.transform.position) > m_unsummonDistance) { UnSummon(); } } public void UnSummon() { if (m_nview.IsValid()) { m_nview.InvokeRPC(ZNetView.Everybody, "RPC_UnSummon", Array.Empty<object>()); } } public void RPC_UnSummon(long sender) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) m_unsummonEffect.Create(((Component)this).gameObject.transform.position, ((Component)this).gameObject.transform.rotation, (Transform)null, 1f, -1); if (m_nview.IsValid() && m_nview.IsOwner()) { ZNetScene.instance.Destroy(((Component)this).gameObject); } } } public static class RegisterPrefabs { private static ZNetScene _zNetScene => ZNetScene.instance; private static ObjectDB _objectDB => ObjectDB.instance; public static void ToObjectDB() { if (Helper.ObjectDBAwake()) { Plugin._attackSummonSkeleton = _objectDB.GetItemPrefab("GoblinShaman_attack_protect").CloneItem("BVW_AttackSummon_Skeleton"); ItemDrop component = Plugin._attackSummonSkeleton.GetComponent<ItemDrop>(); component.m_itemData.m_shared.m_name = "$bvw_attacksummon_skeleton"; component.m_itemData.m_shared.m_attackStatusEffect = null; component.m_itemData.m_shared.m_attack.m_attackProjectile = Plugin._summonSkeletonSpawn; component.m_itemData.m_shared.m_aiAttackInterval = 20f; component.m_itemData.m_shared.m_trailStartEffect = null; _objectDB.AddClonedObject(Plugin._attackSummonSkeleton); Plugin._attackSpirit = _objectDB.GetItemPrefab("GoblinShaman_attack_fireball").CloneItem("BVW_AttackSpirit"); ItemDrop component2 = Plugin._attackSpirit.GetComponent<ItemDrop>(); component2.m_itemData.m_shared.m_name = "$bvw_attackspirit"; component2.m_itemData.m_shared.m_damages.m_blunt = 35f; component2.m_itemData.m_shared.m_damages.m_fire = 0f; component2.m_itemData.m_shared.m_damages.m_poison = 60f; component2.m_itemData.m_shared.m_attack.m_attackProjectile = Plugin._projectileSpirit; _objectDB.AddClonedObject(Plugin._attackSpirit); Plugin._attackSummonBats = _objectDB.GetItemPrefab("GoblinShaman_attack_protect").CloneItem("BVW_AttackSummon_Bats"); ItemDrop component3 = Plugin._attackSummonBats.GetComponent<ItemDrop>(); component3.m_itemData.m_shared.m_name = "$bvw_attacksummon_bats"; component3.m_itemData.m_shared.m_attackStatusEffect = null; component3.m_itemData.m_shared.m_attack.m_attackProjectile = Plugin._summonBatsSpawn; component3.m_itemData.m_shared.m_aiAttackInterval = 20f; component3.m_itemData.m_shared.m_trailStartEffect = null; _objectDB.AddClonedObject(Plugin._attackSummonBats); } } public static void ToZNetScene() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown if (Helper.ZNetSceneAwake()) { SummonSkeleton(); SummonBats(); _zNetScene.AddClonedObject(Plugin._attackSummonSkeleton); Plugin._attackSummonSkeleton.GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_startEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = _zNetScene.GetPrefab("fx_summon_skeleton"), m_enabled = true, m_variant = 0 } }; _zNetScene.AddClonedObject(Plugin._attackSummonBats); Plugin._attackSummonBats.GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_startEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = _zNetScene.GetPrefab("fx_summon_skeleton"), m_enabled = true, m_variant = 0 } }; _zNetScene.AddClonedObject(Plugin._attackSpirit); _zNetScene.AddClonedObject(Plugin._summonSkeletonSpawn); SpawnAbility component = Plugin._summonSkeletonSpawn.GetComponent<SpawnAbility>(); component.m_spawnPrefab = (GameObject[])(object)new GameObject[1] { Plugin._summonedSkeleton }; component.m_preSpawnDelay = 1f; component.m_preSpawnEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = _zNetScene.GetPrefab("fx_summon_skeleton_spawn"), m_enabled = true, m_variant = 0 } }; _zNetScene.AddClonedObject(Plugin._summonBatsSpawn); SpawnAbility component2 = Plugin._summonBatsSpawn.GetComponent<SpawnAbility>(); component2.m_spawnPrefab = (GameObject[])(object)new GameObject[1] { Plugin._summonedBats }; component2.m_preSpawnDelay = 1f; component2.m_preSpawnEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = _zNetScene.GetPrefab("fx_summon_skeleton_spawn"), m_enabled = true, m_variant = 0 } }; _zNetScene.AddClonedObject(Plugin._projectileSpirit); GameObject gameObject = Plugin._witchBundle.LoadAsset<GameObject>("bvw_fx_attack_projectile_exp"); _zNetScene.AddClonedObject(gameObject); ForestWitch(); SwampWitch(); } } private static void SummonSkeleton() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown Plugin._summonedSkeleton = _zNetScene.GetPrefab("Skeleton_Friendly").Clone("BVW_SkeletonEnemy"); Plugin._summonedSkeleton.transform.SetParent(Plugin._PrefabContainer.transform, false); Humanoid component = Plugin._summonedSkeleton.GetComponent<Humanoid>(); ((Character)component).m_name = "$bvw_summoned_skeleton"; ((Character)component).m_faction = (Faction)4; ((Character)component).m_health = 100f; Plugin._summonedSkeleton.RemoveComponent(typeof(Tameable)); Plugin._summonedSkeleton.ChangeColor(Color.red); FixedDespawn(Plugin._summonedSkeleton); Plugin._summonedSkeleton.GetComponent<FixedDespawn>().m_unsummonEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = _zNetScene.GetPrefab("vfx_skeleton_death"), m_enabled = true, m_variant = 0 } }; _zNetScene.AddClonedObject(Plugin._summonedSkeleton); } private static void SummonBats() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown Plugin._summonedBats = _zNetScene.GetPrefab("Bat").Clone("BVW_BatEnemy"); Plugin._summonedBats.transform.SetParent(Plugin._PrefabContainer.transform, false); Humanoid component = Plugin._summonedBats.GetComponent<Humanoid>(); ((Character)component).m_name = "$bvw_summoned_bat"; ((Character)component).m_faction = (Faction)4; ((Character)component).m_defeatSetGlobalKey = string.Empty; ((Character)component).m_health = 50f; Plugin._summonedBats.RemoveComponent(typeof(CharacterDrop)); Plugin._summonedBats.ChangeColor(Color.red); FixedDespawn(Plugin._summonedBats); Plugin._summonedBats.GetComponent<FixedDespawn>().m_unsummonEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = _zNetScene.GetPrefab("vfx_ghost_death"), m_enabled = true, m_variant = -1 } }; _zNetScene.AddClonedObject(Plugin._summonedBats); } private static void ForestWitch() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_00eb: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) Plugin._forestWitch = _zNetScene.GetPrefab("GoblinShaman").Clone("BVW_ForestWitch"); Plugin._forestWitch.transform.SetParent(Plugin._PrefabContainer.transform, false); Humanoid component = Plugin._forestWitch.GetComponent<Humanoid>(); ((Character)component).m_name = "$bvw_forestwitch"; ((Character)component).m_group = "Witch"; ((Character)component).m_faction = (Faction)4; ((Character)component).m_health = ConfigSetup._forestWitchHealth.Value; component.m_defaultItems = (GameObject[])(object)new GameObject[2] { Plugin._attackSummonSkeleton, Plugin._attackSpirit }; Plugin._forestWitch.GetComponent<CharacterDrop>().m_drops = new List<Drop>(3) { new Drop { m_prefab = _zNetScene.GetPrefab("Coins"), m_amountMin = 20, m_amountMax = 40, m_chance = 0.25f, m_onePerPlayer = false, m_levelMultiplier = true, m_dontScale = false }, new Drop { m_prefab = _zNetScene.GetPrefab("SurtlingCore"), m_amountMin = 1, m_amountMax = 1, m_chance = 0.25f, m_onePerPlayer = false, m_levelMultiplier = true, m_dontScale = false }, new Drop { m_prefab = _zNetScene.GetPrefab("AncientSeed"), m_amountMin = 1, m_amountMax = 1, m_chance = 0.25f, m_onePerPlayer = false, m_levelMultiplier = true, m_dontScale = false } }; Plugin._forestWitch.ChangeColor(Color.red); _zNetScene.AddClonedObject(Plugin._forestWitch); } private static void SwampWitch() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_00eb: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) Plugin._swampWitch = _zNetScene.GetPrefab("GoblinShaman").Clone("BVW_SwampWitch"); Plugin._swampWitch.transform.SetParent(Plugin._PrefabContainer.transform, false); Humanoid component = Plugin._swampWitch.GetComponent<Humanoid>(); ((Character)component).m_name = "$bvw_swampwitch"; ((Character)component).m_group = "Witch"; ((Character)component).m_faction = (Faction)4; ((Character)component).m_health = ConfigSetup._swampWitchHealth.Value; component.m_defaultItems = (GameObject[])(object)new GameObject[2] { Plugin._attackSummonBats, Plugin._attackSpirit }; Plugin._swampWitch.GetComponent<CharacterDrop>().m_drops = new List<Drop>(3) { new Drop { m_prefab = _zNetScene.GetPrefab("Coins"), m_amountMin = 30, m_amountMax = 50, m_chance = 0.25f, m_onePerPlayer = false, m_levelMultiplier = true, m_dontScale = false }, new Drop { m_prefab = _zNetScene.GetPrefab("SurtlingCore"), m_amountMin = 1, m_amountMax = 3, m_chance = 0.25f, m_onePerPlayer = false, m_levelMultiplier = true, m_dontScale = false }, new Drop { m_prefab = _zNetScene.GetPrefab("Guck"), m_amountMin = 2, m_amountMax = 4, m_chance = 0.25f, m_onePerPlayer = false, m_levelMultiplier = true, m_dontScale = false } }; Plugin._swampWitch.ChangeColor(Color.green); _zNetScene.AddClonedObject(Plugin._swampWitch); } private static void FixedDespawn(GameObject summon) { if (!Object.op_Implicit((Object)(object)summon.GetComponent<FixedDespawn>())) { summon.AddComponent<FixedDespawn>(); } } } public static class SpawnerSetup { private static readonly List<SpawnData> _witchSpawnList = new List<SpawnData>(); public static void Init(SpawnSystem __instance) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Expected O, but got Unknown //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Expected O, but got Unknown SpawnSystemList val = __instance.m_spawnLists.First(); foreach (SpawnData witchSpawn in _witchSpawnList) { val.m_spawners.Remove(witchSpawn); } _witchSpawnList.Clear(); SpawnData item = new SpawnData { m_name = "ForestWitches", m_enabled = ConfigSetup._forestWitchEnable.Value, m_prefab = ZNetScene.instance.GetPrefab("BVW_ForestWitch"), m_biome = ConfigSetup._forestWitchBiome.Value, m_biomeArea = ConfigSetup._forestWitchBiomeArea.Value, m_maxSpawned = ConfigSetup._forestWitchMaxSpawned.Value, m_spawnInterval = ConfigSetup._forestWitchSpawnInterval.Value, m_spawnChance = ConfigSetup._forestWitchSpawnChance.Value, m_spawnDistance = ConfigSetup._forestWitchSpawnDistance.Value, m_requiredGlobalKey = ConfigSetup._forestWitchGlobalKey.Value, m_groupSizeMax = ConfigSetup._forestWitchGroupSizeMax.Value, m_groupSizeMin = ConfigSetup._forestWitchGroupSizeMin.Value, m_groupRadius = ConfigSetup._forestWitchGroupRadius.Value, m_spawnAtNight = ConfigSetup._forestWitchSpawnAtNight.Value, m_spawnAtDay = ConfigSetup._forestWitchSpawnAtDay.Value, m_minAltitude = ConfigSetup._forestWitchMinAltitude.Value, m_maxAltitude = ConfigSetup._forestWitchMaxAltitude.Value, m_minTilt = ConfigSetup._forestWitchMinTilt.Value, m_maxTilt = ConfigSetup._forestWitchMaxTilt.Value, m_inForest = ConfigSetup._forestWitchInForest.Value, m_outsideForest = ConfigSetup._forestWitchOutForest.Value, m_huntPlayer = ConfigSetup._forestWitchHuntPlayer.Value, m_groundOffset = ConfigSetup._forestWitchGroundOffset.Value, m_maxLevel = ConfigSetup._forestWitchMaxLevel.Value, m_minLevel = ConfigSetup._forestWitchMinLevel.Value, m_levelUpMinCenterDistance = ConfigSetup._forestWitchLevelUpMinCenterDistance.Value, m_overrideLevelupChance = ConfigSetup._forestWitchOverrideLevelUpChance.Value }; SpawnData item2 = new SpawnData { m_name = "SwampWitches", m_enabled = ConfigSetup._swampWitchEnable.Value, m_prefab = ZNetScene.instance.GetPrefab("BVW_SwampWitch"), m_biome = ConfigSetup._swampWitchBiome.Value, m_biomeArea = ConfigSetup._swampWitchBiomeArea.Value, m_maxSpawned = ConfigSetup._swampWitchMaxSpawned.Value, m_spawnInterval = ConfigSetup._swampWitchSpawnInterval.Value, m_spawnChance = ConfigSetup._swampWitchSpawnChance.Value, m_spawnDistance = ConfigSetup._swampWitchSpawnDistance.Value, m_requiredGlobalKey = ConfigSetup._swampWitchGlobalKey.Value, m_groupSizeMax = ConfigSetup._swampWitchGroupSizeMax.Value, m_groupSizeMin = ConfigSetup._swampWitchGroupSizeMin.Value, m_groupRadius = ConfigSetup._swampWitchGroupRadius.Value, m_spawnAtNight = ConfigSetup._swampWitchSpawnAtNight.Value, m_spawnAtDay = ConfigSetup._swampWitchSpawnAtDay.Value, m_minAltitude = ConfigSetup._swampWitchMinAltitude.Value, m_maxAltitude = ConfigSetup._swampWitchMaxAltitude.Value, m_minTilt = ConfigSetup._swampWitchMinTilt.Value, m_maxTilt = ConfigSetup._swampWitchMaxTilt.Value, m_inForest = ConfigSetup._swampWitchInForest.Value, m_outsideForest = ConfigSetup._swampWitchOutForest.Value, m_huntPlayer = ConfigSetup._swampWitchHuntPlayer.Value, m_groundOffset = ConfigSetup._swampWitchGroundOffset.Value, m_maxLevel = ConfigSetup._swampWitchMaxLevel.Value, m_minLevel = ConfigSetup._swampWitchMinLevel.Value, m_levelUpMinCenterDistance = ConfigSetup._swampWitchOverrideLevelUpChance.Value, m_overrideLevelupChance = ConfigSetup._swampWitchOverrideLevelUpChance.Value }; _witchSpawnList.Add(item); _witchSpawnList.Add(item2); foreach (SpawnData witchSpawn2 in _witchSpawnList) { val.m_spawners.Add(witchSpawn2); } } } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded] internal sealed class <b89b921d-8954-4084-bd4d-1feb826a594e>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)] [<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded] [CompilerGenerated] internal sealed class <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [CompilerGenerated] [<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded] internal sealed class <bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContextAttribute : Attribute { public readonly byte Flag; public <bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace LocalizationManager { [<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(0)] [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(1)] [PublicAPI] 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; [<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>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 = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>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 = value2.Aggregate(text, [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>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, [<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null) { if (convertConfigValue == null) { convertConfigValue = [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] [return: <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(1)] (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary<string, Func<string>>(); } config.SettingChanged += [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>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() { LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage()); } private static void LoadLocalization(Localization __instance, string language) { if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference<Localization>(__instance)); } localizationLanguage.Add(__instance, language); Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories) where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0 select f) { string text = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' })[1]; if (dictionary.ContainsKey(text)) { Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped.")); } else { dictionary[text] = item; } } byte[] array = LoadTranslationFromAssembly("English"); if (array == null) { throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml."); } Dictionary<string, string> dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array)); if (dictionary2 == null) { throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text2 = null; if (language != "English") { if (dictionary.ContainsKey(language)) { text2 = File.ReadAllText(dictionary[language]); } else { byte[] array2 = LoadTranslationFromAssembly(language); if (array2 != null) { text2 = Encoding.UTF8.GetString(array2); } } } if (text2 == null && dictionary.ContainsKey("English")) { text2 = File.ReadAllText(dictionary["English"]); } if (text2 != null) { foreach (KeyValuePair<string, string> item2 in new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>()) { dictionary2[item2.Key] = item2.Value; } } loadedTexts[language] = dictionary2; foreach (KeyValuePair<string, string> item3 in dictionary2) { UpdatePlaceholderText(__instance, item3.Key); } } static Localizer() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>(); loadedTexts = new Dictionary<string, Dictionary<string, string>>(); localizationLanguage = new ConditionalWeakTable<Localization, string>(); localizationObjects = new List<WeakReference<Localization>>(); fileExtensions = new List<string> { ".json", ".yml" }; new Harmony("org.bepinex.helpers.LocalizationManager").Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } [return: <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>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; } [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(2)] public static byte[] ReadEmbeddedFileBytes([<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(1)] string resourceFileName, Assembly containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>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 Microsoft.CodeAnalysis { [<7c9c1df5-8a07-4120-8775-24248bd20b58>Embedded] [CompilerGenerated] internal sealed class <7c9c1df5-8a07-4120-8775-24248bd20b58>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] [<7c9c1df5-8a07-4120-8775-24248bd20b58>Embedded] internal sealed class <7f235c7c-3216-4afd-b6c6-fe898b76be04>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <7f235c7c-3216-4afd-b6c6-fe898b76be04>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <7f235c7c-3216-4afd-b6c6-fe898b76be04>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<7c9c1df5-8a07-4120-8775-24248bd20b58>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <4aa927ea-6568-4f49-90a3-4f4db0d19bb8>NullableContextAttribute : Attribute { public readonly byte Flag; public <4aa927ea-6568-4f49-90a3-4f4db0d19bb8>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 { } [<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] [AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] [<4aa927ea-6568-4f49-90a3-4f4db0d19bb8>NullableContext(1)] 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 { [<4aa927ea-6568-4f49-90a3-4f4db0d19bb8>NullableContext(1)] public static void Deconstruct<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] TKey, [<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] TValue>([<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(new byte[] { 0, 1, 1 })] this KeyValuePair<TKey, TValue> pair, out TKey key, out TValue value) { key = pair.Key; value = pair.Value; } } } namespace YamlDotNet { [<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] [<4aa927ea-6568-4f49-90a3-4f4db0d19bb8>NullableContext(1)] internal sealed class CultureInfoAdapter : CultureInfo { private readonly IFormatProvider provider; public CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider) : base(baseCulture.LCID) { this.provider = provider; } [<4aa927ea-6568-4f49-90a3-4f4db0d19bb8>NullableContext(2)] public override object GetFormat(Type formatType) { return provider.GetFormat(formatType); } } [<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] [<4aa927ea-6568-4f49-90a3-4f4db0d19bb8>NullableContext(1)] internal static class ReflectionExtensions { [<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] private static readonly FieldInfo RemoteStackTraceField = typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic); [return: <7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] 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); } [return: <7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] public static PropertyInfo GetPublicProperty(this Type type, string name) { return type.GetProperty(name); } [return: <7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] 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 new Type[1] { type }.Concat(type.GetInterfaces()).SelectMany([<4aa927ea-6568-4f49-90a3-4f4db0d19bb8>NullableContext(0)] (Type i) => i.GetProperties(bindingFlags)); } public static IEnumerable<PropertyInfo> GetPublicProperties(this Type type) { return type.GetProperties(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 + "'."); } [return: <7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] public static MethodInfo GetPublicStaticMethod(this Type type, string name, params Type[] parameterTypes) { return type.GetMethod(name, BindingFlags.Static | BindingFlags.Public, null, parameterTypes, null); } [return: <7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] 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<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] TAttribute>(this PropertyInfo property) { return Attribute.GetCustomAttributes(property, typeof(TAttribute)); } } internal static class PropertyInfoExtensions { [<4aa927ea-6568-4f49-90a3-4f4db0d19bb8>NullableContext(1)] [return: <7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] public static object ReadValue(this PropertyInfo property, object target) { return property.GetValue(target, null); } } internal static class StandardRegexOptions { public const RegexOptions Compiled = RegexOptions.Compiled; } } namespace YamlDotNet.Serialization { [<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] [<4aa927ea-6568-4f49-90a3-4f4db0d19bb8>NullableContext(1)] internal abstract class BuilderSkeleton<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] TBuilder> where TBuilder : BuilderSkeleton<TBuilder> { internal INamingConvention namingConvention = NullNamingConvention.Instance; internal ITypeResolver typeResolver; internal readonly YamlAttributeOverrides overrides; internal readonly LazyComponentRegistrationList<Nothing, IYamlTypeConverter> typeConverterFactories; internal readonly LazyComponentRegistrationList<ITypeInspector, ITypeInspector> typeInspectorFactories; private bool ignoreFields; private bool includeNonPublicProperties; protected abstract TBuilder Self { get; } internal BuilderSkeleton(ITypeResolver typeResolver) { overrides = new YamlAttributeOverrides(); typeConverterFactories = new LazyComponentRegistrationList<Nothing, IYamlTypeConverter> { { typeof(YamlDotNet.Serialization.Converters.GuidConverter), (Nothing _) => new YamlDotNet.Serialization.Converters.GuidConverter(jsonCompatible: false) }, { typeof(SystemTypeConverter), (Nothing _) => new SystemTypeConverter() } }; typeInspectorFactories = new LazyComponentRegistrationList<ITypeInspector, ITypeInspector>(); this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver"); } internal ITypeInspector BuildTypeInspector() { ITypeInspector typeInspector = new ReadablePropertiesTypeInspector(typeResolver, includeNonPublicProperties); if (!ignoreFields) { typeInspector = new CompositeTypeInspector(new ReadableFieldsTypeInspector(typeResolver), typeInspector); } return typeInspectorFactories.BuildComponentChain(typeInspector); } public TBuilder IgnoreFields() { ignoreFields = true; return Self; } public TBuilder IncludeNonPublicProperties() { includeNonPublicProperties = true; return Self; } public TBuilder WithNamingConvention(INamingConvention namingConvention) { this.namingConvention = namingConvention ?? throw new ArgumentNullException("namingConvention"); return Self; } public TBuilder WithTypeResolver(ITypeResolver typeResolver) { this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver"); return Self; } public abstract TBuilder WithTagMapping(TagName tag, Type type); public TBuilder WithAttributeOverride<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] TClass>(Expression<Func<TClass, object>> propertyAccessor, Attribute attribute) { overrides.Add(propertyAccessor, attribute); return Self; } public TBuilder WithAttributeOverride(Type type, string member, Attribute attribute) { overrides.Add(type, member, attribute); return Self; } public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter) { return WithTypeConverter(typeConverter, delegate(IRegistrationLocationSelectionSyntax<IYamlTypeConverter> w) { w.OnTop(); }); } public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter, Action<IRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) { if (typeConverter == null) { throw new ArgumentNullException("typeConverter"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateRegistrationLocationSelector(typeConverter.GetType(), (Nothing _) => typeConverter)); return Self; } public TBuilder WithTypeConverter<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] TYamlTypeConverter>(WrapperFactory<IYamlTypeConverter, IYamlTypeConverter> typeConverterFactory, Action<ITrackingRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) where TYamlTypeConverter : IYamlTypeConverter { if (typeConverterFactory == null) { throw new ArgumentNullException("typeConverterFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateTrackingRegistrationLocationSelector(typeof(TYamlTypeConverter), (IYamlTypeConverter wrapped, Nothing _) => typeConverterFactory(wrapped))); return Self; } public TBuilder WithoutTypeConverter<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] TYamlTypeConverter>() where TYamlTypeConverter : IYamlTypeConverter { return WithoutTypeConverter(typeof(TYamlTypeConverter)); } public TBuilder WithoutTypeConverter(Type converterType) { if (converterType == null) { throw new ArgumentNullException("converterType"); } typeConverterFactories.Remove(converterType); return Self; } public TBuilder WithTypeInspector<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory) where TTypeInspector : ITypeInspector { return WithTypeInspector(typeInspectorFactory, delegate(IRegistrationLocationSelectionSyntax<ITypeInspector> w) { w.OnTop(); }); } public TBuilder WithTypeInspector<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory, Action<IRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector { if (typeInspectorFactory == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector inner) => typeInspectorFactory(inner))); return Self; } public TBuilder WithTypeInspector<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] TTypeInspector>(WrapperFactory<ITypeInspector, ITypeInspector, TTypeInspector> typeInspectorFactory, Action<ITrackingRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector { if (typeInspectorFactory == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateTrackingRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector wrapped, ITypeInspector inner) => typeInspectorFactory(wrapped, inner))); return Self; } public TBuilder WithoutTypeInspector<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] TTypeInspector>() where TTypeInspector : ITypeInspector { return WithoutTypeInspector(typeof(TTypeInspector)); } public TBuilder WithoutTypeInspector(Type inspectorType) { if (inspectorType == null) { throw new ArgumentNullException("inspectorType"); } typeInspectorFactories.Remove(inspectorType); return Self; } protected IEnumerable<IYamlTypeConverter> BuildTypeConverters() { return typeConverterFactories.BuildComponentList(); } } internal delegate TComponent WrapperFactory<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] TComponentBase, TComponent>(TComponentBase wrapped) where TComponent : TComponentBase; internal delegate TComponent WrapperFactory<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] TArgument, [<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] TComponentBase, TComponent>(TComponentBase wrapped, TArgument argument) where TComponent : TComponentBase; [Flags] internal enum DefaultValuesHandling { Preserve = 0, OmitNull = 1, OmitDefaults = 2, OmitEmptyCollections = 4 } [<4aa927ea-6568-4f49-90a3-4f4db0d19bb8>NullableContext(1)] [<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] internal sealed class Deserializer : IDeserializer { private readonly IValueDeserializer valueDeserializer; public Deserializer() : this(new DeserializerBuilder().BuildValueDeserializer()) { } private Deserializer(IValueDeserializer valueDeserializer) { this.valueDeserializer = valueDeserializer ?? throw new ArgumentNullException("valueDeserializer"); } public static Deserializer FromValueDeserializer(IValueDeserializer valueDeserializer) { return new Deserializer(valueDeserializer); } public T Deserialize<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] T>(string input) { using StringReader input2 = new StringReader(input); return Deserialize<T>(input2); } public T Deserialize<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] T>(TextReader input) { return Deserialize<T>(new Parser(input)); } [return: <7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] public object Deserialize(TextReader input) { return Deserialize(input, typeof(object)); } [return: <7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] public object Deserialize(string input, Type type) { using StringReader input2 = new StringReader(input); return Deserialize(input2, type); } [return: <7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] public object Deserialize(TextReader input, Type type) { return Deserialize(new Parser(input), type); } public T Deserialize<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] T>(IParser parser) { return (T)Deserialize(parser, typeof(T)); } [return: <7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] public object Deserialize(IParser parser) { return Deserialize(parser, typeof(object)); } [return: <7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] public object Deserialize(IParser parser, Type type) { if (parser == null) { throw new ArgumentNullException("parser"); } if (type == null) { throw new ArgumentNullException("type"); } YamlDotNet.Core.Events.StreamStart @event; bool flag = parser.TryConsume<YamlDotNet.Core.Events.StreamStart>(out @event); YamlDotNet.Core.Events.DocumentStart event2; bool flag2 = parser.TryConsume<YamlDotNet.Core.Events.DocumentStart>(out event2); object result = null; if (!parser.Accept<YamlDotNet.Core.Events.DocumentEnd>(out var _) && !parser.Accept<YamlDotNet.Core.Events.StreamEnd>(out var _)) { using SerializerState serializerState = new SerializerState(); result = valueDeserializer.DeserializeValue(parser, type, serializerState, valueDeserializer); serializerState.OnDeserialization(); } if (flag2) { parser.Consume<YamlDotNet.Core.Events.DocumentEnd>(); } if (flag) { parser.Consume<YamlDotNet.Core.Events.StreamEnd>(); } return result; } } [<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(new byte[] { 0, 1 })] [<4aa927ea-6568-4f49-90a3-4f4db0d19bb8>NullableContext(1)] internal sealed class DeserializerBuilder : BuilderSkeleton<DeserializerBuilder> { private Lazy<IObjectFactory> objectFactory; private readonly LazyComponentRegistrationList<Nothing, INodeDeserializer> nodeDeserializerFactories; private readonly LazyComponentRegistrationList<Nothing, INodeTypeResolver> nodeTypeResolverFactories; private readonly Dictionary<TagName, Type> tagMappings; private readonly Dictionary<Type, Type> typeMappings; private bool ignoreUnmatched; protected override DeserializerBuilder Self => this; public DeserializerBuilder() : base((ITypeResolver)new StaticTypeResolver()) { typeMappings = new Dictionary<Type, Type>(); objectFactory = new Lazy<IObjectFactory>(() => new DefaultObjectFactory(typeMappings), isThreadSafe: true); tagMappings = new Dictionary<TagName, Type> { { FailsafeSchema.Tags.Map, typeof(Dictionary<object, object>) }, { FailsafeSchema.Tags.Str, typeof(string) }, { JsonSchema.Tags.Bool, typeof(bool) }, { JsonSchema.Tags.Float, typeof(double) }, { JsonSchema.Tags.Int, typeof(int) }, { DefaultSchema.Tags.Timestamp, typeof(DateTime) } }; typeInspectorFactories.Add(typeof(CachedTypeInspector), (ITypeInspector inner) => new CachedTypeInspector(inner)); typeInspectorFactories.Add(typeof(NamingConventionTypeInspector), (ITypeInspector inner) => (!(namingConvention is NullNamingConvention)) ? new NamingConventionTypeInspector(inner, namingConvention) : inner); typeInspectorFactories.Add(typeof(YamlAttributesTypeInspector), (ITypeInspector inner) => new YamlAttributesTypeInspector(inner)); typeInspectorFactories.Add(typeof(YamlAttributeOverridesInspector), (ITypeInspector inner) => (overrides == null) ? inner : new YamlAttributeOverridesInspector(inner, overrides.Clone())); typeInspectorFactories.Add(typeof(ReadableAndWritablePropertiesTypeInspector), (ITypeInspector inner) => new ReadableAndWritablePropertiesTypeInspector(inner)); nodeDeserializerFactories = new LazyComponentRegistrationList<Nothing, INodeDeserializer> { { typeof(YamlConvertibleNodeDeserializer), (Nothing _) => new YamlConvertibleNodeDeserializer(objectFactory.Value) }, { typeof(YamlSerializableNodeDeserializer), (Nothing _) => new YamlSerializableNodeDeserializer(objectFactory.Value) }, { typeof(TypeConverterNodeDeserializer), (Nothing _) => new TypeConverterNodeDeserializer(BuildTypeConverters()) }, { typeof(NullNodeDeserializer), (Nothing _) => new NullNodeDeserializer() }, { typeof(ScalarNodeDeserializer), (Nothing _) => new ScalarNodeDeserializer() }, { typeof(ArrayNodeDeserializer), (Nothing _) => new ArrayNodeDeserializer() }, { typeof(DictionaryNodeDeserializer), (Nothing _) => new DictionaryNodeDeserializer(objectFactory.Value) }, { typeof(CollectionNodeDeserializer), (Nothing _) => new CollectionNodeDeserializer(objectFactory.Value) }, { typeof(EnumerableNodeDeserializer), (Nothing _) => new EnumerableNodeDeserializer() }, { typeof(ObjectNodeDeserializer), (Nothing _) => new ObjectNodeDeserializer(objectFactory.Value, BuildTypeInspector(), ignoreUnmatched) } }; nodeTypeResolverFactories = new LazyComponentRegistrationList<Nothing, INodeTypeResolver> { { typeof(MappingNodeTypeResolver), (Nothing _) => new MappingNodeTypeResolver(typeMappings) }, { typeof(YamlConvertibleTypeResolver), (Nothing _) => new YamlConvertibleTypeResolver() }, { typeof(YamlSerializableTypeResolver), (Nothing _) => new YamlSerializableTypeResolver() }, { typeof(TagNodeTypeResolver), (Nothing _) => new TagNodeTypeResolver(tagMappings) }, { typeof(PreventUnknownTagsNodeTypeResolver), (Nothing _) => new PreventUnknownTagsNodeTypeResolver() }, { typeof(DefaultContainersNodeTypeResolver), (Nothing _) => new DefaultContainersNodeTypeResolver() } }; } public DeserializerBuilder WithObjectFactory(IObjectFactory objectFactory) { if (objectFactory == null) { throw new ArgumentNullException("objectFactory"); } this.objectFactory = new Lazy<IObjectFactory>(() => objectFactory, isThreadSafe: true); return this; } public DeserializerBuilder WithObjectFactory(Func<Type, object> objectFactory) { if (objectFactory == null) { throw new ArgumentNullException("objectFactory"); } return WithObjectFactory(new LambdaObjectFactory(objectFactory)); } public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer) { return WithNodeDeserializer(nodeDeserializer, delegate(IRegistrationLocationSelectionSyntax<INodeDeserializer> w) { w.OnTop(); }); } public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer, Action<IRegistrationLocationSelectionSyntax<INodeDeserializer>> where) { if (nodeDeserializer == null) { throw new ArgumentNullException("nodeDeserializer"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateRegistrationLocationSelector(nodeDeserializer.GetType(), (Nothing _) => nodeDeserializer)); return this; } public DeserializerBuilder WithNodeDeserializer<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] TNodeDeserializer>(WrapperFactory<INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeDeserializer>> where) where TNodeDeserializer : INodeDeserializer { if (nodeDeserializerFactory == null) { throw new ArgumentNullException("nodeDeserializerFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeDeserializer), (INodeDeserializer wrapped, Nothing _) => nodeDeserializerFactory(wrapped))); return this; } public DeserializerBuilder WithoutNodeDeserializer<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] TNodeDeserializer>() where TNodeDeserializer : INodeDeserializer { return WithoutNodeDeserializer(typeof(TNodeDeserializer)); } public DeserializerBuilder WithoutNodeDeserializer(Type nodeDeserializerType) { if (nodeDeserializerType == null) { throw new ArgumentNullException("nodeDeserializerType"); } nodeDeserializerFactories.Remove(nodeDeserializerType); return this; } public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver) { return WithNodeTypeResolver(nodeTypeResolver, delegate(IRegistrationLocationSelectionSyntax<INodeTypeResolver> w) { w.OnTop(); }); } public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver, Action<IRegistrationLocationSelectionSyntax<INodeTypeResolver>> where) { if (nodeTypeResolver == null) { throw new ArgumentNullException("nodeTypeResolver"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeTypeResolverFactories.CreateRegistrationLocationSelector(nodeTypeResolver.GetType(), (Nothing _) => nodeTypeResolver)); return this; } public DeserializerBuilder WithNodeTypeResolver<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] TNodeTypeResolver>(WrapperFactory<INodeTypeResolver, TNodeTypeResolver> nodeTypeResolverFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeTypeResolver>> where) where TNodeTypeResolver : INodeTypeResolver { if (nodeTypeResolverFactory == null) { throw new ArgumentNullException("nodeTypeResolverFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeTypeResolverFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeTypeResolver), (INodeTypeResolver wrapped, Nothing _) => nodeTypeResolverFactory(wrapped))); return this; } public DeserializerBuilder WithoutNodeTypeResolver<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] TNodeTypeResolver>() where TNodeTypeResolver : INodeTypeResolver { return WithoutNodeTypeResolver(typeof(TNodeTypeResolver)); } public DeserializerBuilder WithoutNodeTypeResolver(Type nodeTypeResolverType) { if (nodeTypeResolverType == null) { throw new ArgumentNullException("nodeTypeResolverType"); } nodeTypeResolverFactories.Remove(nodeTypeResolverType); return this; } public override DeserializerBuilder WithTagMapping(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 var value)) { throw new ArgumentException($"Type already has a registered type '{value.FullName}' for tag '{tag}'", "tag"); } tagMappings.Add(tag, type); return this; } public DeserializerBuilder WithTypeMapping<[<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(2)] TInterface, [<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] 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 DeserializerBuilder WithoutTagMapping(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 DeserializerBuilder IgnoreUnmatchedProperties() { ignoreUnmatched = true; return this; } public IDeserializer Build() { return Deserializer.FromValueDeserializer(BuildValueDeserializer()); } public IValueDeserializer BuildValueDeserializer() { return new AliasValueDeserializer(new NodeValueDeserializer(nodeDeserializerFactories.BuildComponentList(), nodeTypeResolverFactories.BuildComponentList())); } } [<7f235c7c-3216-4afd-b6c6-fe898b76be04>Nullable(0)] [<4aa927ea-6568-4f49-90a3-4f4db0d19bb8>NullableContext(1)] internal sealed class EmissionPhaseObjectGraphVisitorArgs { private readonly IEnumerable<IObjectGraphVisitor<Nothing>> preProcessingPhaseVisitors; public IObjectGraphVisitor<IEmitter> InnerVisitor { get; private set; } public IEventEmitter EventEmitter { get; private set; } public ObjectSerializer NestedObjectSerializer { get; private set; } public IEnumerable<IYamlTypeConverter> TypeConverters { get; private set; } public EmissionPhaseObjectGraphVisitorArgs(IObjectGraphVisitor<IEmitter> innerVisitor, IEventEmitter eventEmitter, IEnumerable<IObjectGraphVisitor<Nothing>> preProcessingPhaseVisitors, IEnumerable<IYamlTypeConverter> typeConverters, ObjectSerializer nestedObjectSerializer) { InnerVisitor = innerVisitor ?? throw new ArgumentNullException("innerVisitor"); EventEmitter = eventEmitter ?? throw new ArgumentNullException("eventEmitter")