Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ValheimWitch v1.0.9
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: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("blacks7ar")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.9")] [assembly: AssemblyInformationalVersion("1.0.9")] [assembly: AssemblyProduct("ValheimWitch")] [assembly: AssemblyTitle("ValheimWitch")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.9.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ValheimWitch { [BepInPlugin("blacks7ar.ValheimWitch", "ValheimWitch", "1.0.9")] 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.9"; 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.9", MinimumRequiredVersion = "1.0.9", 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; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; Localizer.Load(); _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"); Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; ((BaseUnityPlugin)this).Config.Save(); } 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 = Enumerable.Single(executingAssembly.GetManifestResourceNames(), (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 { [HarmonyPriority(700)] [HarmonyPostfix] [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"; public static void Init() { ForestWitch(); SwampWitch(); } private static void ForestWitch() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Expected O, but got Unknown //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Expected O, but got Unknown //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Expected O, but got Unknown //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Expected O, but got Unknown //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Expected O, but got Unknown //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Expected O, but got Unknown //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Expected O, but got Unknown //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Expected O, but got Unknown //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Expected O, but got Unknown //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Expected O, but got Unknown //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Expected O, but got Unknown //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Expected O, but got Unknown //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Expected O, but got Unknown //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Expected O, but got Unknown //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Expected O, but got Unknown string group = "Forest Witch"; _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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected O, but got Unknown //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Expected O, but got Unknown //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Expected O, but got Unknown //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Expected O, but got Unknown //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Expected O, but got Unknown //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Expected O, but got Unknown //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Expected O, but got Unknown //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Expected O, but got Unknown //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Expected O, but got Unknown //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Expected O, but got Unknown //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Expected O, but got Unknown //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Expected O, but got Unknown string group = "Swamp Witch"; _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 = Enumerable.First(__instance.m_spawnLists); 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] [<112b52fc-385e-4422-8766-76e3d2c67965>Embedded] internal sealed class <112b52fc-385e-4422-8766-76e3d2c67965>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<112b52fc-385e-4422-8766-76e3d2c67965>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [<112b52fc-385e-4422-8766-76e3d2c67965>Embedded] internal sealed class <79594173-e941-4ad9-973e-713c0d41eb0b>NullableContextAttribute : Attribute { public readonly byte Flag; public <79594173-e941-4ad9-973e-713c0d41eb0b>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace LocalizationManager { [<1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>Nullable(0)] [<79594173-e941-4ad9-973e-713c0d41eb0b>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; [<1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>Nullable(2)] private static BaseUnityPlugin _plugin; private static readonly List<string> fileExtensions; private static BaseUnityPlugin plugin { get { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown if (_plugin == null) { IEnumerable<TypeInfo> source; try { source = Enumerable.ToList(Assembly.GetExecutingAssembly().DefinedTypes); } catch (ReflectionTypeLoadException ex) { source = Enumerable.Select(Enumerable.Where(ex.Types, [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(0)] (Type t) => t != null), [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(0)] (Type t) => t.GetTypeInfo()); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)Enumerable.First(source, [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } [<1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>Nullable(2)] [method: <79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(2)] [field: <1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>Nullable(2)] public static event Action OnLocalizationComplete; private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out var value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out var value2)) { text = Enumerable.Aggregate(value2, text, [<79594173-e941-4ad9-973e-713c0d41eb0b>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, [<1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null) { if (convertConfigValue == null) { convertConfigValue = (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary<string, Func<string>>(); } config.SettingChanged += [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(0)] (object _, EventArgs _) => { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value); UpdatePlaceholderText(Localization.instance, key); } } public static void AddText(string key, string text) { List<WeakReference<Localization>> list = new List<WeakReference<Localization>>(); foreach (WeakReference<Localization> localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference<Localization> item in list) { localizationObjects.Remove(item); } } public static void Load() { _ = plugin; } public static void LoadLocalizationLater(Localization __instance) { LoadLocalization(Localization.instance, __instance.GetSelectedLanguage()); } public static void SafeCallLocalizeComplete() { Localizer.OnLocalizationComplete?.Invoke(); } private static void LoadLocalization(Localization __instance, string language) { if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference<Localization>(__instance)); } localizationLanguage.Add(__instance, language); Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (string item in Enumerable.Where(Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories), [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(0)] (string f) => fileExtensions.IndexOf(Path.GetExtension(f)) >= 0)) { string text = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' })[1]; if (dictionary.ContainsKey(text)) { Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped.")); } else { dictionary[text] = item; } } byte[] array = LoadTranslationFromAssembly("English"); if (array == null) { throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml."); } Dictionary<string, string> dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array)); if (dictionary2 == null) { throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text2 = null; if (language != "English") { if (dictionary.TryGetValue(language, out var value)) { text2 = File.ReadAllText(value); } else { byte[] array2 = LoadTranslationFromAssembly(language); if (array2 != null) { text2 = Encoding.UTF8.GetString(array2); } } } if (text2 == null && dictionary.TryGetValue("English", out var value2)) { text2 = File.ReadAllText(value2); } if (text2 != null) { foreach (KeyValuePair<string, string> item2 in new 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_008f: 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_00ca: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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>(2) { ".json", ".yml" }; Harmony val = new Harmony("org.bepinex.helpers.LocalizationManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "SetupGui", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalizationLater", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "SafeCallLocalizeComplete", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } [return: <1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>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; } [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(2)] public static byte[] ReadEmbeddedFileBytes([<1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>Nullable(1)] string resourceFileName, Assembly containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = Enumerable.FirstOrDefault(containingAssembly.GetManifestResourceNames(), [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } internal static class LocalizationManagerVersion { [<1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>Nullable(1)] public const string Version = "1.4.0"; } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] internal sealed class AllowNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] internal sealed class DisallowNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Method, Inherited = false)] internal sealed class DoesNotReturnAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] internal sealed class DoesNotReturnIfAttribute : Attribute { public bool ParameterValue { get; } public DoesNotReturnIfAttribute(bool parameterValue) { ParameterValue = parameterValue; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)] internal sealed class MaybeNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] internal sealed class MaybeNullWhenAttribute : Attribute { public bool ReturnValue { get; } public MaybeNullWhenAttribute(bool returnValue) { ReturnValue = returnValue; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)] internal sealed class NotNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] internal sealed class NotNullIfNotNullAttribute : Attribute { public string ParameterName { get; } public NotNullIfNotNullAttribute(string parameterName) { ParameterName = parameterName; } } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] internal sealed class NotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public NotNullWhenAttribute(bool returnValue) { ReturnValue = returnValue; } } } namespace System.Collections.Generic { internal static class DeconstructionExtensions { public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> pair, out TKey key, out TValue value) { key = pair.Key; value = pair.Value; } } } namespace YamlDotNet { internal sealed class CultureInfoAdapter : CultureInfo { private readonly IFormatProvider provider; public CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider) : base(baseCulture.LCID) { this.provider = provider; } public override object? GetFormat(Type? formatType) { return provider.GetFormat(formatType); } } internal static class ReflectionExtensions { private static readonly FieldInfo? RemoteStackTraceField = typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic); public static Type? BaseType(this Type type) { return type.BaseType; } public static bool IsValueType(this Type type) { return type.IsValueType; } public static bool IsGenericType(this Type type) { return type.IsGenericType; } public static bool IsGenericTypeDefinition(this Type type) { return type.IsGenericTypeDefinition; } public static bool IsInterface(this Type type) { return type.IsInterface; } public static bool IsEnum(this Type type) { return type.IsEnum; } public static bool IsDbNull(this object value) { return value is DBNull; } public static bool HasDefaultConstructor(this Type type) { if (!type.IsValueType) { return type.GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, Type.EmptyTypes, null) != null; } return true; } public static TypeCode GetTypeCode(this Type type) { return Type.GetTypeCode(type); } public static PropertyInfo? GetPublicProperty(this Type type, string name) { return type.GetProperty(name); } public static FieldInfo? GetPublicStaticField(this Type type, string name) { return type.GetField(name, BindingFlags.Static | BindingFlags.Public); } public static IEnumerable<PropertyInfo> GetProperties(this Type type, bool includeNonPublic) { BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public; if (includeNonPublic) { bindingFlags |= BindingFlags.NonPublic; } if (!type.IsInterface) { return type.GetProperties(bindingFlags); } return Enumerable.SelectMany(Enumerable.Concat(new Type[1] { type }, type.GetInterfaces()), (Type i) => i.GetProperties(bindingFlags)); } public static IEnumerable<PropertyInfo> GetPublicProperties(this Type type) { return 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 + "'."); } public static MethodInfo? GetPublicStaticMethod(this Type type, string name, params Type[] parameterTypes) { return type.GetMethod(name, BindingFlags.Static | BindingFlags.Public, null, parameterTypes, null); } public static MethodInfo? GetPublicInstanceMethod(this Type type, string name) { return type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public); } public static Exception Unwrap(this TargetInvocationException ex) { Exception innerException = ex.InnerException; if (innerException == null) { return ex; } if (RemoteStackTraceField != null) { RemoteStackTraceField.SetValue(innerException, innerException.StackTrace + "\r\n"); } return innerException; } public static bool IsInstanceOf(this Type type, object o) { return type.IsInstanceOfType(o); } public static Attribute[] GetAllCustomAttributes<TAttribute>(this PropertyInfo property) { return Attribute.GetCustomAttributes(property, typeof(TAttribute)); } } internal static class PropertyInfoExtensions { 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 { internal abstract class BuilderSkeleton<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<TClass>(Expression<Func<TClass, object>> propertyAccessor, Attribute attribute) { overrides.Add(propertyAccessor, attribute); return Self; } public TBuilder WithAttributeOverride(Type type, string member, Attribute attribute) { overrides.Add(type, member, attribute); return Self; } public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter) { return WithTypeConverter(typeConverter, delegate(IRegistrationLocationSelectionSyntax<IYamlTypeConverter> w) { w.OnTop(); }); } public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter, Action<IRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) { IYamlTypeConverter typeConverter2 = typeConverter; if (typeConverter2 == null) { throw new ArgumentNullException("typeConverter"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateRegistrationLocationSelector(typeConverter2.GetType(), (Nothing _) => typeConverter2)); return Self; } public TBuilder WithTypeConverter<TYamlTypeConverter>(WrapperFactory<IYamlTypeConverter, IYamlTypeConverter> typeConverterFactory, Action<ITrackingRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) where TYamlTypeConverter : IYamlTypeConverter { WrapperFactory<IYamlTypeConverter, IYamlTypeConverter> typeConverterFactory2 = typeConverterFactory; if (typeConverterFactory2 == null) { throw new ArgumentNullException("typeConverterFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateTrackingRegistrationLocationSelector(typeof(TYamlTypeConverter), (IYamlTypeConverter wrapped, Nothing _) => typeConverterFactory2(wrapped))); return Self; } public TBuilder WithoutTypeConverter<TYamlTypeConverter>() where TYamlTypeConverter : IYamlTypeConverter { return WithoutTypeConverter(typeof(TYamlTypeConverter)); } public TBuilder WithoutTypeConverter(Type converterType) { if (converterType == null) { throw new ArgumentNullException("converterType"); } typeConverterFactories.Remove(converterType); return Self; } public TBuilder WithTypeInspector<TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory) where TTypeInspector : ITypeInspector { return WithTypeInspector(typeInspectorFactory, delegate(IRegistrationLocationSelectionSyntax<ITypeInspector> w) { w.OnTop(); }); } public TBuilder WithTypeInspector<TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory, Action<IRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector { Func<ITypeInspector, TTypeInspector> typeInspectorFactory2 = typeInspectorFactory; if (typeInspectorFactory2 == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector inner) => typeInspectorFactory2(inner))); return Self; } public TBuilder WithTypeInspector<TTypeInspector>(WrapperFactory<ITypeInspector, ITypeInspector, TTypeInspector> typeInspectorFactory, Action<ITrackingRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector { WrapperFactory<ITypeInspector, ITypeInspector, TTypeInspector> typeInspectorFactory2 = typeInspectorFactory; if (typeInspectorFactory2 == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateTrackingRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector wrapped, ITypeInspector inner) => typeInspectorFactory2(wrapped, inner))); return Self; } public TBuilder WithoutTypeInspector<TTypeInspector>() where TTypeInspector : ITypeInspector { return WithoutTypeInspector(typeof(TTypeInspector)); } public TBuilder WithoutTypeInspector(Type inspectorType) { if (inspectorType == null) { throw new ArgumentNullException("inspectorType"); } typeInspectorFactories.Remove(inspectorType); return Self; } protected IEnumerable<IYamlTypeConverter> BuildTypeConverters() { return typeConverterFactories.BuildComponentList(); } } internal delegate TComponent WrapperFactory<TComponentBase, TComponent>(TComponentBase wrapped) where TComponent : TComponentBase; internal delegate TComponent WrapperFactory<TArgument, TComponentBase, TComponent>(TComponentBase wrapped, TArgument argument) where TComponent : TComponentBase; [Flags] internal enum DefaultValuesHandling { Preserve = 0, OmitNull = 1, OmitDefaults = 2, OmitEmptyCollections = 4 } internal sealed class Deserializer : IDeserializer { private readonly IValueDeserializer valueDeserializer; public Deserializer() : this(new DeserializerBuilder().BuildValueDeserializer()) { } private Deserializer(IValueDeserializer valueDeserializer) { this.valueDeserializer = valueDeserializer ?? throw new ArgumentNullException("valueDeserializer"); } public static Deserializer FromValueDeserializer(IValueDeserializer valueDeserializer) { return new Deserializer(valueDeserializer); } public T Deserialize<T>(string input) { using StringReader input2 = new StringReader(input); return Deserialize<T>(input2); } public T Deserialize<T>(TextReader input) { return Deserialize<T>(new Parser(input)); } public object? Deserialize(TextReader input) { return Deserialize(input, typeof(object)); } public object? Deserialize(string input, Type type) { using StringReader input2 = new StringReader(input); return Deserialize(input2, type); } public object? Deserialize(TextReader input, Type type) { return Deserialize(new Parser(input), type); } public T Deserialize<T>(IParser parser) { return (T)Deserialize(parser, typeof(T)); } public object? Deserialize(IParser parser) { return Deserialize(parser, typeof(object)); } public object? Deserialize(IParser parser, Type type) { if (parser == null) { throw new ArgumentNullException("parser"); } if (type == null) { throw new ArgumentNullException("type"); } YamlDotNet.Core.Events.StreamStart @event; bool flag = parser.TryConsume<YamlDotNet.Core.Events.StreamStart>(out @event); YamlDotNet.Core.Events.DocumentStart event2; bool flag2 = parser.TryConsume<YamlDotNet.Core.Events.DocumentStart>(out event2); object result = null; if (!parser.Accept<YamlDotNet.Core.Events.DocumentEnd>(out var _) && !parser.Accept<YamlDotNet.Core.Events.StreamEnd>(out var _)) { using SerializerState serializerState = new SerializerState(); result = valueDeserializer.DeserializeValue(parser, type, serializerState, valueDeserializer); serializerState.OnDeserialization(); } if (flag2) { parser.Consume<YamlDotNet.Core.Events.DocumentEnd>(); } if (flag) { parser.Consume<YamlDotNet.Core.Events.StreamEnd>(); } return result; } } internal sealed class DeserializerBuilder : BuilderSkeleton<DeserializerBuilder> { private Lazy<IObjectFactory> objectFactory; private readonly LazyComponentRegistrationList<Nothing, INodeDeserializer> nodeDeserializerFactories; private readonly LazyComponentRegistrationList<Nothing, INodeTypeResolver> nodeTypeResolverFactories; private readonly Dictionary<TagName, Type> tagMappings; private readonly Dictionary<Type, Type> typeMappings; private 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) { IObjectFactory objectFactory2 = objectFactory; if (objectFactory2 == null) { throw new ArgumentNullException("objectFactory"); } this.objectFactory = new Lazy<IObjectFactory>(() => objectFactory2, isThreadSafe: true); return this; } public DeserializerBuilder WithObjectFactory(Func<Type, object> objectFactory) { if (objectFactory == null) { throw new ArgumentNullException("objectFactory"); } return WithObjectFactory(new LambdaObjectFactory(objectFactory)); } public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer) { return WithNodeDeserializer(nodeDeserializer, delegate(IRegistrationLocationSelectionSyntax<INodeDeserializer> w) { w.OnTop(); }); } public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer, Action<IRegistrationLocationSelectionSyntax<INodeDeserializer>> where) { INodeDeserializer nodeDeserializer2 = nodeDeserializer; if (nodeDeserializer2 == null) { throw new ArgumentNullException("nodeDeserializer"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateRegistrationLocationSelector(nodeDeserializer2.GetType(), (Nothing _) => nodeDeserializer2)); return this; } public DeserializerBuilder WithNodeDeserializer<TNodeDeserializer>(WrapperFactory<INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeDeserializer>> where) where TNodeDeserializer : INodeDeserializer { WrapperFactory<INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory2 = nodeDeserializerFactory; if (nodeDeserializerFactory2 == null) { throw new ArgumentNullException("nodeDeserializerFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeDeserializer), (INodeDeserializer wrapped, Nothing _) => nodeDeserializerFactory2(wrapped))); return this; } public DeserializerBuilder WithoutNodeDeserializer<TNodeDeserializer>() where TNodeDeserializer : INodeDeserializer { return WithoutNodeDeserializer(typeof(TNodeDeserializer)); } public DeserializerBuilder WithoutNodeDeserializer(Type nodeDeserializerType) { if (nodeDeserializerType == null) { throw new ArgumentNullException("nodeDeserializerType"); } nodeDeserializerFactories.Remove(nodeDeserializerType); return this; } public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver) { return WithNodeTypeResolver(nodeTypeResolver, delegate(IRegistrationLocationSelectionSyntax<INodeTypeResolver> w) { w.OnTop(); }); } public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver, Action<IRegistrationLocationSelectionSyntax<INodeTypeResolver>> where) { INodeTypeResolver nodeTypeResolver2 = nodeTypeResolver; if (nodeTypeResolver2 == null) { throw new ArgumentNullException("nodeTypeResolver"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeTypeResolverFactories.CreateRegistrationLocationSelector(nodeTypeResolver2.GetType(), (Nothing _) => nodeTypeResolver2)); return this; } public DeserializerBuilder WithNodeTypeResolver<TNodeTypeResolver>(WrapperFactory<INodeTypeResolver, TNodeTypeResolver> nodeTypeResolverFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeTypeResolver>> where) where TNodeTypeResolver : INodeTypeResolver { WrapperFactory<INodeTypeResolver, TNodeTypeResolver> nodeTypeResolverFactory2 = nodeTypeResolverFactory; if (nodeTypeResolverFactory2 == null) { throw new ArgumentNullException("nodeTypeResolverFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeTypeResolverFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeTypeResolver), (INodeTypeResolver wrapped, Nothing _) => nodeTypeResolverFactory2(wrapped))); return this; } public DeserializerBuilder WithoutNodeTypeResolver<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 Type 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<TInterface, TConcrete>() where TConcrete : TInterface { Type typeFromHandle = typeof(TInterface); Type typeFromHandle2 = typeof(TConcrete); if (!typeFromHandle.IsAssignableFrom(typeFromHandle2)) { throw new InvalidOperationException("The type '" + typeFromHandle2.Name + "' does not implement interface '" + typeFromHandle.Name + "'."); } if (typeMappings.ContainsKey(typeFromHandle)) { typeMappings[typeFromHandle] = typeFromHandle2; } else { typeMappings.Add(typeFromHandle, typeFromHandle2); } return this; } public 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())); } } 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"); this.preProcessingPhaseVisitors = preProcessingPhaseVisitors ?? throw new ArgumentNullException("preProcessingPhaseVisitors"); TypeConverters = typeConverters ?? throw new ArgumentNullException("typeConverters"); NestedObjectSerializer = nestedObjectSerializer ?? throw new ArgumentNullException("nestedObjectSerializer"); } public T GetPreProcessingPhaseObjectGraphVisitor<T>() where T : IObjectGraphVisitor<Nothing> { return Enumerable.Single(Enumerable.OfType<T>(preProcessingPhaseVisitors)); } } internal abstract class EventInfo { public IObjectDescriptor Source { get; } protected EventInfo(IObjectDescriptor source) { Source = source ?? throw new ArgumentNullException("source"); } } internal class AliasEventInfo : EventInfo { public AnchorName Alias { get; } public bool NeedsExpansion { get; set; } public AliasEventInfo(IObjectDescriptor source, AnchorName alias) : base(source) { if (alias.IsEmpty) { throw new ArgumentNullException("alias"); } Alias = alias; } } internal class ObjectEventInfo : EventInfo { public AnchorName Anchor { get; set; } public TagName Tag { get; set; } protected ObjectEventInfo(IObjectDescriptor source) : base(source) { } } internal sealed class ScalarEventInfo : ObjectEventInfo { public string RenderedValue { get; set; } public ScalarStyle Style { get; set; } public bool IsPlainImplicit { get; set; } public bool IsQuotedImplicit { get; set; } public ScalarEventInfo(IObjectDescriptor sourc