Decompiled source of VikingsDoSwim v1.3.6
VikingsDoSwim.dll
Decompiled a month 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 UnityEngine.PostProcessing; using UnityEngine.Rendering; using VikingsDoSwim.Functions; using VikingsDoSwim.Utils; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: Guid("ABF1247D-F396-4452-AAB0-6005C5115448")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyProduct("VikingsDoSwim")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("https://valheim.thunderstore.io/package/blacks7ar/VikingsDoSwim/")] [assembly: AssemblyTitle("VikingsDoSwim")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyFileVersion("1.3.6")] [assembly: AssemblyCompany("blacks7ar")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.6.0")] [module: <843c35e3-02db-46b5-be79-8a200694caaf>RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<2300f665-7e95-4aec-81ab-1f6edb1c8eb8>Embedded] internal sealed class <2300f665-7e95-4aec-81ab-1f6edb1c8eb8>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] [<2300f665-7e95-4aec-81ab-1f6edb1c8eb8>Embedded] internal sealed class <843c35e3-02db-46b5-be79-8a200694caaf>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <843c35e3-02db-46b5-be79-8a200694caaf>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace VikingsDoSwim { [BepInPlugin("blacks7ar.VikingsDoSwim", "VikingsDoSwim", "1.3.6")] public class Plugin : BaseUnityPlugin { private const string modGUID = "blacks7ar.VikingsDoSwim"; public const string modName = "VikingsDoSwim"; public const string modAuthor = "blacks7ar"; public const string modVersion = "1.3.6"; public const string modLink = "https://valheim.thunderstore.io/package/blacks7ar/VikingsDoSwim/"; private static readonly Harmony _harmony = new Harmony("blacks7ar.VikingsDoSwim"); private static readonly ConfigSync _configSync = new ConfigSync("blacks7ar.VikingsDoSwim") { DisplayName = "VikingsDoSwim", CurrentVersion = "1.3.6", MinimumRequiredVersion = "1.3.6" }; private static ConfigEntry<Toggle> _serverConfigLocked; public static ConfigEntry<float> _maxSwimSpeed; public static ConfigEntry<Toggle> _enableExpMultiplier; public static ConfigEntry<float> _swimExpMultiplier; public static ConfigEntry<Toggle> _displayExpGained; public static ConfigEntry<KeyCode> _diveHotkey; public static ConfigEntry<KeyCode> _ascendHotkey; public static ConfigEntry<float> _colorBrightnessFactor; public static ConfigEntry<float> _minFogDensity; public static ConfigEntry<float> _maxFogDensity; private static ConfigEntry<KeyCode> _sprintKey; public static ConfigEntry<float> _swimStaminaDrainMinSkill; public static ConfigEntry<float> _swimStaminaDrainMaxSkill; public static bool _SprintKeyHeld; public static int _forwardSpeed; public static int _sidewaySpeed; public static int _turnSpeed; public static int _inWater; public static int _onGround; public static int _encumbered; public static int _flying; public static bool _RestInWater = false; public static float _WaterLevelPlayer = 30f; public static float _WaterLevelCamera = 30f; public static Vector3 _CharacterPosition; public static float _CharacterSwimDepth = 0f; public static float _DiveAxis = 0f; public static bool _IsDiving = false; public static bool _IsSwimming = false; public static float _PlayerDistance = 0f; public static string _EnvName = ""; public static float _MaxDistance = 0f; public static float _WaterDistance = -5000f; public static float _CameraPositionY = 0f; public static bool _RenderSettingsUpdateCamera = true; public static bool _SetForceEnv = false; public static float _MinWaterDistance = 0f; public static string _LastActivity = ""; public static bool _CameFromDiving = false; 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 //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Expected O, but got Unknown //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Expected O, but got Unknown Localizer.Load(); _Instance = this; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; _serverConfigLocked = config("1- ServerSync", "Lock Configuration", Toggle.On, new ConfigDescription("If On, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, Array.Empty<object>())); _configSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked); _maxSwimSpeed = config("2- General", "Max Swim Speed", 4f, new ConfigDescription("Max swim speed at skill level 100.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>())); _sprintKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("2- General", "Sprint Hotkey", (KeyCode)304, "Hotkey to swim faster."); _enableExpMultiplier = config("3- Skill Exp", "Enable Exp Multiplier", Toggle.On, new ConfigDescription("Enable/Disables exp multiplier.", (AcceptableValueBase)null, Array.Empty<object>())); _swimExpMultiplier = config("3- Skill Exp", "Exp Gain Factor", 1f, new ConfigDescription("Swim skill exp gain factor.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); _displayExpGained = config("3- Skill Exp", "Display Exp Gained", Toggle.On, new ConfigDescription("Enable/Disables exp gained notifications.", (AcceptableValueBase)null, Array.Empty<object>())); _diveHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("2- General", "Dive Hotkey", (KeyCode)306, "Hotkey to dive underwater."); _ascendHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("2- General", "Ascend Hotkey", (KeyCode)32, "Hotkey to ascend to the surface."); _colorBrightnessFactor = config("4- Underwater Effects", "Color Brightness Factor", -0.0392f, new ConfigDescription("Brightness factor, higher value, darker surroundings.\nRecommended: -0.0392", (AcceptableValueBase)null, Array.Empty<object>())); _maxFogDensity = config("4- Underwater Effects", "Maximum Fog Density", 1.8f, new ConfigDescription("Max fog density, higher value, thicker fog.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>())); _minFogDensity = config("4- Underwater Effects", "Minimum Fog Density", 0.065f, new ConfigDescription("Minimum fog density, higher value, thicker fog.\nSet to 0 to disable fog Effect", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[1] { new VikingsDoSwim.Utils.ConfigurationManagerAttributes { ShowRangeAsPercent = false } })); _swimStaminaDrainMinSkill = config("2- General", "Swim Stamina Drain Min Skill", 5f, new ConfigDescription("Stamina drain at minimum skill level.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); _swimStaminaDrainMaxSkill = config("2- General", "Swim Stamina Drain Max Skill", 2f, new ConfigDescription("Stamina drain at max skill level.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); _forwardSpeed = ZSyncAnimation.GetHash("forward_speed"); _sidewaySpeed = ZSyncAnimation.GetHash("sideway_speed"); _turnSpeed = ZSyncAnimation.GetHash("turn_speed"); _inWater = ZSyncAnimation.GetHash("inWater"); _onGround = ZSyncAnimation.GetHash("onGround"); _encumbered = ZSyncAnimation.GetHash("encumbered"); _flying = ZSyncAnimation.GetHash("flying"); PrefabSetup.Init(); ConfigSetup.Init(); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; ((BaseUnityPlugin)this).Config.Save(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); } private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) _SprintKeyHeld = Input.GetKey(_sprintKey.Value); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } } } namespace VikingsDoSwim.Utils { public class ConfigurationManagerAttributes { [UsedImplicitly] public bool? ShowRangeAsPercent; } public static class Helper { public static float tFloat(this float value, int digits) { double num = Math.Pow(10.0, digits); return (float)Math.Truncate(num * (double)value / num); } public static bool IsEnvAllowed() { return Plugin._EnvName != "SunkenCrypt"; } 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 void AddRecipe(this ObjectDB objectDB, Recipe recipe, bool overWrite = true) { Recipe recipe2; if ((Object)(object)(recipe2 = objectDB.GetRecipe(recipe.m_item.m_itemData)) != (Object)null) { if (!overWrite) { return; } objectDB.m_recipes.Remove(recipe2); } objectDB.m_recipes.Add(recipe); } 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 enum Toggle { On = 1, Off = 0 } } namespace VikingsDoSwim.Patches { [HarmonyPatch] internal class CharacterPatch { [HarmonyPatch(typeof(Character), "Awake")] public class CharacterAwakePatch { public static void Prefix(Character __instance) { if (__instance.IsPlayer()) { __instance.m_swimDepth = 1.5f; Plugin._PlayerDistance = __instance.m_swimDepth; } } } [HarmonyPatch(typeof(Character), "CustomFixedUpdate")] public class CharacterFixedUpdatePatch { public static void Prefix(Character __instance, ref Vector3 ___m_lookDir) { //IL_0032: 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_00b7: 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) if (!__instance.IsPlayer() || !Helper.IsEnvAllowed() || (Object)(object)__instance == (Object)null) { return; } if (!__instance.InWater()) { __instance.m_swimDepth = 1.4f; } if (Input.GetKey(Plugin._diveHotkey.Value) && __instance.InWater() && !__instance.IsOnGround() && __instance.IsSwimming()) { if (__instance.m_swimDepth > 2.2f) { Player localPlayer = Player.m_localPlayer; localPlayer.m_swimSkillImproveTimer += Time.deltaTime; if (localPlayer.m_swimSkillImproveTimer > 1f) { localPlayer.m_swimSkillImproveTimer = 0f; ((Character)localPlayer).RaiseSkill((SkillType)103, 1f); } } Plugin._CharacterPosition = ((Component)__instance).transform.position; Plugin._CharacterSwimDepth = __instance.m_swimDepth; if ((double)___m_lookDir.y < -0.25) { Plugin._DiveAxis = 1f; } if ((double)___m_lookDir.y > 0.15) { Plugin._DiveAxis = 0f; } float num = ___m_lookDir.y * ___m_lookDir.y * 0.25f; if (num > 0.025f) { num = 0.025f; } float y = ___m_lookDir.y; if (y > -0.25f && y < 0.15f) { num = 0f; } y = Plugin._DiveAxis; if (y != 1f) { if (y == 0f) { if (__instance.m_swimDepth > 1.5f) { __instance.m_swimDepth -= num; } if (__instance.m_swimDepth < 1.5f) { __instance.m_swimDepth = 1.5f; } } } else { __instance.m_swimDepth += num; } if (__instance.m_swimDepth > 2.2f) { __instance.SetMoveDir(___m_lookDir); } } else if ((__instance.IsOnGround() || !Plugin._IsDiving) && !Plugin._RestInWater) { __instance.m_swimDepth = 1.5f; } } } [HarmonyPatch(typeof(Character), "UpdateMotion")] public class CharacterUpdateMotionPatch { public static void Prefix(Character __instance, ref float ___m_lastGroundTouch, ref float ___m_swimTimer) { if (__instance.IsPlayer() && Helper.IsEnvAllowed()) { if (__instance.m_swimDepth > 2.2f) { Plugin._IsDiving = true; Plugin._RestInWater = false; ___m_lastGroundTouch = 0.3f; ___m_swimTimer = 0f; } else { Plugin._IsDiving = false; } Plugin._PlayerDistance = __instance.m_swimDepth; } } } [HarmonyPrefix] [HarmonyPatch(typeof(Character), "UpdateSwimming")] public static bool UpdateSwimming_Prefix(float dt, ref Character __instance) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_004c: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0167: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0315: 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_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: 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_029e: 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_036a: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: 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_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) Character obj = __instance; Player val = (Player)(object)((obj is Player) ? obj : null); if (val == null) { return true; } bool flag = ((Character)val).IsOnGround(); Vector3 position = ((Component)val).transform.position; if (Mathf.Max(0f, ((Character)val).m_maxAirAltitude - position.y) > 0.5f && ((Character)val).m_onLand != null) { ((Character)val).m_onLand(new Vector3(position.x, ((Character)val).m_waterLevel, position.z)); } ((Character)val).m_maxAirAltitude = position.y; float skillFactor = val.m_skills.GetSkillFactor((SkillType)103); float num = (((Character)val).m_swimSpeed + (Plugin._maxSwimSpeed.Value - 1f) * skillFactor) * ((Character)val).GetAttackSpeedFactorMovement(); float num2 = Mathf.Lerp(1f, 1.5f, skillFactor); num *= num2; if (Plugin._SprintKeyHeld && ((Character)val).HaveStamina(0f) && !__instance.IsEncumbered()) { num *= 2f; } if (Plugin._IsDiving && ((Character)val).m_swimDepth > 2.2f && !__instance.IsEncumbered()) { num /= 1.4f; } if (((Character)val).IsEncumbered()) { num *= 0.3f; } if (((Character)val).InMinorAction()) { num = 0f; } ((Character)val).m_seman.ApplyStatusEffectSpeedMods(ref num, ((Character)val).m_moveDir); Vector3 val2 = ((Character)val).m_moveDir * num; if (((Vector3)(ref val2)).magnitude > 0f && ((Character)val).IsOnGround()) { Vector3 val3 = Vector3.ProjectOnPlane(val2, ((Character)val).m_lastGroundNormal); val2 = ((Vector3)(ref val3)).normalized * ((Vector3)(ref val2)).magnitude; } ((Character)val).m_currentVel = Vector3.Lerp(((Character)val).m_currentVel, val2, ((Character)val).m_swimAcceleration); if (((Vector3)(ref val2)).magnitude > 0.1f) { ((Character)val).AddNoise(15f); } ((Character)val).AddPushbackForce(ref ((Character)val).m_currentVel); Vector3 val4 = ((Character)val).m_currentVel - ((Character)val).m_body.velocity; val4.y = 0f; if (((Vector3)(ref val4)).magnitude > 20f) { val4 = ((Vector3)(ref val4)).normalized * 20f; } ((Character)val).m_body.AddForce(val4, (ForceMode)2); float num3 = ((Character)val).m_waterLevel - ((Character)val).m_swimDepth; if (((Component)val).transform.position.y < num3) { float num4 = Mathf.Clamp01((num3 - ((Component)val).transform.position.y) / 2f); float num5 = Mathf.Lerp(0f, 10f, num4); Vector3 velocity = ((Character)val).m_body.velocity; velocity.y = Mathf.MoveTowards(velocity.y, num5, 50f * dt); ((Character)val).m_body.velocity = velocity; } else { float num6 = Mathf.Clamp01((0f - (num3 - ((Component)val).transform.position.y)) / 1f); float num7 = Mathf.Lerp(0f, 10f, num6); Vector3 velocity2 = ((Character)val).m_body.velocity; velocity2.y = Mathf.MoveTowards(velocity2.y, 0f - num7, 30f * dt); ((Character)val).m_body.velocity = velocity2; } float num8 = 0f; if (((Vector3)(ref ((Character)val).m_moveDir)).magnitude > 0.1f || ((Character)val).AlwaysRotateCamera()) { float swimTurnSpeed = ((Character)val).m_swimTurnSpeed; ((Character)val).m_seman.ApplyStatusEffectSpeedMods(ref swimTurnSpeed, ((Character)val).m_moveDir); num8 = ((Character)val).UpdateRotation(swimTurnSpeed, dt, true); } ((Character)val).m_body.angularVelocity = Vector3.zero; ((Character)val).UpdateEyeRotation(); ((Character)val).m_body.useGravity = true; Vector3 forward = ((Component)val).transform.forward; float num9 = Vector3.Dot(((Character)val).m_currentVel, forward); float num10 = Vector3.Dot(((Character)val).m_currentVel, ((Component)val).transform.right); float num11 = Vector3.Dot(((Character)val).m_body.velocity, forward); ((Character)val).m_currentTurnVel = Mathf.SmoothDamp(((Character)val).m_currentTurnVel, num8, ref ((Character)val).m_currentTurnVelChange, 0.5f, 99f); ((Character)val).m_zanim.SetFloat(Plugin._forwardSpeed, ((Character)val).IsPlayer() ? num9 : num11); ((Character)val).m_zanim.SetFloat(Plugin._sidewaySpeed, num10); ((Character)val).m_zanim.SetFloat(Plugin._turnSpeed, ((Character)val).m_currentTurnVel); ((Character)val).m_zanim.SetBool(Plugin._inWater, !flag); ((Character)val).m_zanim.SetBool(Plugin._onGround, false); ((Character)val).m_zanim.SetBool(Plugin._encumbered, false); ((Character)val).m_zanim.SetBool(Plugin._flying, false); if (flag) { return false; } ((Character)val).OnSwimming(val2, dt); return false; } } [HarmonyPatch] internal class GameCameraPatch { [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] public class GameCameraUpdateCameraPatch { private static Color ChangeColorBrightness(Color color, float correctionFactor) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) float r = color.r; float g = color.g; float b = color.b; if (!(correctionFactor < 0f)) { return new Color(r, g, b, color.a); } correctionFactor *= -1f; r -= r * correctionFactor; if (r < 0f) { r = 0f; } g -= g * correctionFactor; if (g < 0f) { g = 0f; } b -= b * correctionFactor; if (b < 0f) { b = 0f; } return new Color(r, g, b, color.a); } public static void Prefix(GameCamera __instance, Camera ___m_camera) { //IL_00a9: 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_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } if (Plugin._EnvName != EnvMan.instance.GetCurrentEnvironment().m_name) { Plugin._EnvName = EnvMan.instance.GetCurrentEnvironment().m_name; } int num2 = (((Plugin._IsDiving || Plugin._IsSwimming) && !Plugin._RestInWater && Helper.IsEnvAllowed()) ? 1 : 0); __instance.m_minWaterDistance = ((num2 == 0) ? 0.3f : (-5000f)); if (__instance.m_maxDistance != 4f && Plugin._MaxDistance == 0f) { Plugin._MaxDistance = __instance.m_maxDistance; } CameraEffects component = ((Component)__instance).GetComponent<CameraEffects>(); Plugin._CameraPositionY = ((Component)___m_camera).gameObject.transform.position.y; if (((Component)___m_camera).gameObject.transform.position.y < Plugin._WaterLevelCamera && (Plugin._IsSwimming || Plugin._IsDiving) && Helper.IsEnvAllowed()) { if (__instance.m_minWaterDistance != -5000f) { __instance.m_minWaterDistance = -5000f; } if (Plugin._IsDiving) { __instance.m_maxDistance = 4f; } if (!(((Character)Player.m_localPlayer).m_swimDepth > 2.2f)) { return; } EnvSetup currentEnvironment = EnvMan.instance.GetCurrentEnvironment(); Color color = ((!EnvMan.IsNight()) ? currentEnvironment.m_fogColorDay : currentEnvironment.m_fogColorNight); color.a = 1f; Plugin._colorBrightnessFactor.SettingChanged += delegate { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) color = ChangeColorBrightness(color, Plugin._CharacterSwimDepth * Plugin._colorBrightnessFactor.Value); }; color = ChangeColorBrightness(color, Plugin._CharacterSwimDepth * Plugin._colorBrightnessFactor.Value); RenderSettings.fogColor = color; float num = 0f; Plugin._minFogDensity.SettingChanged += delegate { if (num < Plugin._minFogDensity.Value) { num = Plugin._minFogDensity.Value; } }; if (num < Plugin._minFogDensity.Value) { num = Plugin._minFogDensity.Value; } Plugin._maxFogDensity.SettingChanged += delegate { if (num > Plugin._maxFogDensity.Value) { num = Plugin._maxFogDensity.Value; } }; if (num > Plugin._maxFogDensity.Value) { num = Plugin._maxFogDensity.Value; } RenderSettings.fogDensity = num; Plugin._RenderSettingsUpdateCamera = false; if (Plugin._IsDiving && ((Character)Player.m_localPlayer).m_swimDepth > 2.2f && ((Component)Player.m_localPlayer).transform.position.y < Plugin._WaterLevelCamera) { ((PostProcessingModel)component.m_postProcessing.profile.depthOfField).enabled = true; } return; } if (((Component)___m_camera).gameObject.transform.position.y > Plugin._WaterLevelCamera) { if (!Plugin._RenderSettingsUpdateCamera) { if (Plugin._MaxDistance != 0f) { __instance.m_maxDistance = Plugin._MaxDistance; } if (!Plugin._IsDiving || !(((Character)Player.m_localPlayer).m_swimDepth > 2.2f) || ((Character)Player.m_localPlayer).IsOnGround() || !((Character)Player.m_localPlayer).InWater() || ((Component)Player.m_localPlayer).transform.position.y > Plugin._WaterLevelCamera) { ((PostProcessingModel)component.m_postProcessing.profile.depthOfField).enabled = false; } EnvMan.instance.SetForceEnvironment(EnvMan.instance.GetCurrentEnvironment().m_name); Plugin._RenderSettingsUpdateCamera = true; Plugin._SetForceEnv = true; } if (Plugin._SetForceEnv) { EnvMan.instance.SetForceEnvironment(""); Plugin._SetForceEnv = false; } } if (!Plugin._IsDiving && Plugin._MaxDistance != 0f) { __instance.m_maxDistance = Plugin._MaxDistance; } if (!Plugin._IsDiving && Plugin._MinWaterDistance != 0f) { __instance.m_minWaterDistance = Plugin._MinWaterDistance; } } } } [HarmonyPatch] public class ObjectDBPatch { [HarmonyPostfix] [HarmonyPriority(700)] [HarmonyPatch(typeof(ObjectDB), "Awake")] public static void Awake_Postfix(ObjectDB __instance) { ItemSetup.RegisterToObjectDB(); ItemSetup.RegisterRecipeToObjectDB(); __instance.UpdateRegisters(); } [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] [HarmonyPriority(700)] public static void CopyOtherDB_Postfix(ObjectDB __instance) { ItemSetup.RegisterToObjectDB(); ItemSetup.RegisterRecipeToObjectDB(); __instance.UpdateRegisters(); } } [HarmonyPatch] internal class PlayerPatch { [HarmonyPatch(typeof(Player), "OnSwimming")] public class OnSwimmingPatch { public static bool Prefix(Vector3 targetVel, float dt, Player __instance) { //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Expected O, but got Unknown //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037d: 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_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) bool flag = (Object)(object)__instance == (Object)(object)Player.m_localPlayer; float skillFactor = __instance.m_skills.GetSkillFactor((SkillType)103); if (((Vector3)(ref targetVel)).magnitude <= 0.1f && !Plugin._IsDiving && !(((Character)__instance).m_swimDepth > 2.2f) && !((Character)__instance).IsEncumbered()) { float maxStamina = ((Character)__instance).GetMaxStamina(); float num = __instance.m_staminaRegen + (1f - __instance.m_stamina / maxStamina) * __instance.m_staminaRegen * __instance.m_staminaRegenTimeMultiplier; float num2 = 1f; ((Character)__instance).m_seman.ModifyStaminaRegen(ref num2); num *= num2; __instance.m_staminaRegenTimer -= dt; float num3 = Mathf.Lerp(0.3f, 0.9f, skillFactor); num *= num3; if (__instance.m_stamina < maxStamina && __instance.m_staminaRegenTimer <= 0f) { __instance.m_stamina = Mathf.Min(maxStamina, __instance.m_stamina + num * dt); } ((Character)__instance).m_nview.GetZDO().Set("stamina", __instance.m_stamina); Plugin._RestInWater = true; } else if (((Vector3)(ref targetVel)).magnitude <= 0.1f && Plugin._IsDiving && ((Character)__instance).m_swimDepth > 2.2f && ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("vds_oxygenbuble")) && !((Character)__instance).IsEncumbered()) { float maxStamina2 = ((Character)__instance).GetMaxStamina(); float num4 = __instance.m_staminaRegen + (1f - __instance.m_stamina / maxStamina2) * __instance.m_staminaRegen * __instance.m_staminaRegenTimeMultiplier; float num5 = 1f; ((Character)__instance).m_seman.ModifyStaminaRegen(ref num5); num4 *= num5; __instance.m_staminaRegenTimer -= dt; float num6 = Mathf.Lerp(0.3f, 0.9f, skillFactor); num4 *= num6; if (__instance.m_stamina < maxStamina2 && __instance.m_staminaRegenTimer <= 0f) { __instance.m_stamina = Mathf.Min(maxStamina2, __instance.m_stamina + num4 * dt); } ((Character)__instance).m_nview.GetZDO().Set("stamina", __instance.m_stamina); Plugin._RestInWater = true; } else if (((Vector3)(ref targetVel)).magnitude <= 0.1f && Plugin._IsDiving && ((Character)__instance).m_swimDepth > 2.2f && !Plugin._RestInWater && !((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("vds_oxygenbuble"))) { if (((Character)__instance).IsEncumbered()) { ((Character)__instance).UseStamina(dt * 2f); } ((Character)__instance).UseStamina(dt * 1.5f); Plugin._RestInWater = false; } if (((Vector3)(ref targetVel)).magnitude > 0.1f && !((Character)__instance).IsEncumbered()) { float num7 = Mathf.Lerp(__instance.m_swimStaminaDrainMinSkill, __instance.m_swimStaminaDrainMaxSkill, skillFactor); if (flag && Plugin._SprintKeyHeld) { num7 *= 3f; } ((Character)__instance).UseStamina(dt * num7); __instance.m_swimSkillImproveTimer += dt; if (__instance.m_swimSkillImproveTimer > 1f) { __instance.m_swimSkillImproveTimer = 0f; ((Character)__instance).RaiseSkill((SkillType)103, 1f); } Plugin._RestInWater = false; } if (((Character)__instance).HaveStamina(0f)) { return false; } __instance.m_drownDamageTimer += dt; if (!(__instance.m_drownDamageTimer > 1f)) { return false; } __instance.m_drownDamageTimer = 0f; float damage = Mathf.Ceil(((Character)__instance).GetMaxHealth() / 20f); HitData val = new HitData(); val.m_damage.m_damage = damage; val.m_point = ((Character)__instance).GetCenterPoint(); val.m_dir = Vector3.down; val.m_pushForce = 10f; ((Character)__instance).Damage(val); Transform transform = ((Component)__instance).transform; Vector3 position = transform.position; position.y = ((Character)__instance).m_waterLevel; __instance.m_drownEffects.Create(position, transform.rotation, (Transform)null, 1f, -1); return false; } } [HarmonyPatch(typeof(Player), "Update")] public class PlayerUpdatePatch { public static void Prefix(Player __instance) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return; } if (!Plugin._IsDiving && ((Character)Player.m_localPlayer).IsSwimming()) { Plugin._RestInWater = false; } if (Input.GetKeyDown(Plugin._diveHotkey.Value)) { Plugin._IsDiving = true; Plugin._RestInWater = false; } if (Input.GetKeyDown((KeyCode)119) || Input.GetKeyDown((KeyCode)115) || Input.GetKeyDown((KeyCode)100) || (Input.GetKeyDown((KeyCode)97) && Input.GetKeyDown(Plugin._diveHotkey.Value))) { Plugin._RestInWater = false; } if (Plugin._IsSwimming != ((Character)Player.m_localPlayer).IsSwimming()) { Plugin._IsSwimming = ((Character)Player.m_localPlayer).IsSwimming(); } if (Plugin._IsDiving && Plugin._IsSwimming) { Plugin._LastActivity = "diving"; Plugin._CameFromDiving = true; if (Input.GetKeyDown(Plugin._ascendHotkey.Value)) { ((Character)__instance).SetMoveDir(((Component)__instance).transform.forward); ((Character)__instance).m_swimDepth = ((Character)__instance).m_swimDepth - 1f; if (((Character)__instance).m_swimDepth > 1.5f) { ((Character)__instance).m_swimDepth = 1.5f; } } } else if (((Character)Player.m_localPlayer).IsSwimming() && (((Input.GetKey((KeyCode)119) || Input.GetKey((KeyCode)115) || Input.GetKey((KeyCode)100) || Input.GetKey((KeyCode)97) || Input.GetKey(Plugin._diveHotkey.Value)) && Input.GetKeyDown((KeyCode)119)) || Input.GetKeyDown((KeyCode)115) || Input.GetKeyDown((KeyCode)100) || (Input.GetKeyDown((KeyCode)97) && Input.GetKeyDown(Plugin._diveHotkey.Value)))) { Plugin._CameFromDiving = false; Plugin._LastActivity = "swimming"; } } } [HarmonyPatch(typeof(Player), "Awake")] [HarmonyPostfix] private static void Awake_Postfix(Player __instance) { if (!((Object)(object)__instance == (Object)null)) { Plugin._swimStaminaDrainMinSkill.SettingChanged += delegate { __instance.m_swimStaminaDrainMinSkill = Plugin._swimStaminaDrainMinSkill.Value; }; __instance.m_swimStaminaDrainMinSkill = Plugin._swimStaminaDrainMinSkill.Value; Plugin._swimStaminaDrainMaxSkill.SettingChanged += delegate { __instance.m_swimStaminaDrainMaxSkill = Plugin._swimStaminaDrainMaxSkill.Value; }; __instance.m_swimStaminaDrainMaxSkill = Plugin._swimStaminaDrainMaxSkill.Value; } } } [HarmonyPatch] internal class SkillsPatch { [HarmonyPatch(typeof(Skills), "RaiseSkill")] public static class RaiseSkillPatch { private static void Prefix(ref SkillType skillType, ref float factor) { if (Plugin._enableExpMultiplier.Value == Toggle.On && (int)skillType == 103) { factor *= Plugin._swimExpMultiplier.Value; } } private static void Postfix(Skills __instance, ref SkillType skillType) { if (Plugin._enableExpMultiplier.Value != Toggle.On || Plugin._displayExpGained.Value != Toggle.On || (int)skillType != 103) { return; } try { if (__instance.GetSkillLevel((SkillType)103) < 100f) { Skill skill = __instance.GetSkill((SkillType)103); float value = skill.m_accumulator / (skill.GetNextLevelRequirement() / 100f); ((Character)__instance.m_player).Message((MessageType)1, $"Level {skill.m_level.tFloat(0)} {((object)(SkillType)(ref skill.m_info.m_skill)).ToString()} [{skill.m_accumulator.tFloat(2)} / {skill.GetNextLevelRequirement().tFloat(2)}] ({value.tFloat(2)}%)", 0, skill.m_info.m_icon); } else { __instance.GetSkillLevel((SkillType)103); _ = 100f; } } catch { } } } } [HarmonyPatch] internal class WaterVolumePatch { [HarmonyPatch(typeof(WaterVolume), "UpdateMaterials")] public class WaterVolumeUpdatePatch { public static void Prefix(WaterVolume __instance, ref float[] ___m_normalizedDepth) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)GameCamera.instance)) { Vector3 position = ((Component)GameCamera.instance).transform.position; Plugin._WaterLevelCamera = __instance.GetWaterSurface(new Vector3(position.x, position.y, position.z), 1f); } if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { Vector3 position2 = ((Component)Player.m_localPlayer).transform.position; Plugin._WaterLevelPlayer = __instance.GetWaterSurface(new Vector3(position2.x, position2.y, position2.z), 1f); } Quaternion rotation; if (Plugin._CameraPositionY < Plugin._WaterLevelCamera && Plugin._IsSwimming) { rotation = ((Component)((Component)__instance.m_waterSurface).GetComponent<MeshRenderer>()).transform.rotation; if (!((Quaternion)(ref rotation)).eulerAngles.y.Equals(180f) && Helper.IsEnvAllowed()) { ((Component)__instance.m_waterSurface).transform.Rotate(180f, 0f, 0f); ((Renderer)__instance.m_waterSurface).shadowCastingMode = (ShadowCastingMode)2; if (__instance.m_forceDepth >= 0f) { ((Renderer)__instance.m_waterSurface).material.SetFloatArray(Shader.PropertyToID("_depth"), new float[4] { __instance.m_forceDepth, __instance.m_forceDepth, __instance.m_forceDepth, __instance.m_forceDepth }); } else { ((Renderer)__instance.m_waterSurface).material.SetFloatArray(Shader.PropertyToID("_depth"), ___m_normalizedDepth); } ((Renderer)__instance.m_waterSurface).material.SetFloat(Shader.PropertyToID("_UseGlobalWind"), __instance.m_useGlobalWind ? 1f : 0f); } Transform transform = ((Component)__instance.m_waterSurface).transform; Vector3 position3 = transform.position; ((Vector3)(ref position3))..ctor(position3.x, Plugin._WaterLevelCamera, position3.z); transform.position = position3; return; } rotation = ((Component)((Component)__instance.m_waterSurface).GetComponent<MeshRenderer>()).transform.rotation; if (((Quaternion)(ref rotation)).eulerAngles.y.Equals(180f) && Helper.IsEnvAllowed()) { ((Component)__instance.m_waterSurface).transform.Rotate(-180f, 0f, 0f); if (__instance.m_forceDepth >= 0f) { ((Renderer)__instance.m_waterSurface).material.SetFloatArray(Shader.PropertyToID("_depth"), new float[4] { __instance.m_forceDepth, __instance.m_forceDepth, __instance.m_forceDepth, __instance.m_forceDepth }); } else { ((Renderer)__instance.m_waterSurface).material.SetFloatArray(Shader.PropertyToID("_depth"), ___m_normalizedDepth); } Transform transform2 = ((Component)__instance.m_waterSurface).transform; Vector3 position4 = transform2.position; ((Vector3)(ref position4))..ctor(position4.x, 30f, position4.z); transform2.position = position4; ((Renderer)__instance.m_waterSurface).material.SetFloat(Shader.PropertyToID("_UseGlobalWind"), __instance.m_useGlobalWind ? 1f : 0f); } } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] public class ZNetScenePatch { public static void Postfix() { ItemSetup.RegisterToZNetScene(); } } } namespace VikingsDoSwim.Functions { public static class ConfigSetup { public static ConfigEntry<bool> _crownEnable; public static ConfigEntry<string> _crownMat1; public static ConfigEntry<string> _crownMat2; public static ConfigEntry<string> _crownMat3; public static ConfigEntry<string> _crownMat4; private static Localization english; public static void Init() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown english = new Localization(); english.SetupLanguage("English"); string group = english.Localize("$vds_atlantian_crown"); _crownEnable = Plugin._Instance.config(group, "Recipe", value: true, new ConfigDescription("Enable/Disables recipe. (Needs logout)", (AcceptableValueBase)null, Array.Empty<object>())); _crownMat1 = Plugin._Instance.config(group, "Required Material 1", "Ruby:1", new ConfigDescription("Item name : amount (Needs logout)", (AcceptableValueBase)null, Array.Empty<object>())); _crownMat2 = Plugin._Instance.config(group, "Required Material 2", "Silver:10", new ConfigDescription("Item name : amount (Needs logout)", (AcceptableValueBase)null, Array.Empty<object>())); _crownMat3 = Plugin._Instance.config(group, "Required Material 3", "Iron:10", new ConfigDescription("Item name : amount (Needs logout)", (AcceptableValueBase)null, Array.Empty<object>())); _crownMat4 = Plugin._Instance.config(group, "Required Material 4", "Bronze:10", new ConfigDescription("Item name : amount (Needs logout)", (AcceptableValueBase)null, Array.Empty<object>())); } } public static class ItemSetup { private static ZNetScene _zNetScene => ZNetScene.instance; private static ObjectDB _objectDB => ObjectDB.instance; public static void RegisterToObjectDB() { if (Helper.ObjectDBAwake()) { _objectDB.AddClonedObject(PrefabSetup._diveCrown); SE_OxygenBuble sE_OxygenBuble = ScriptableObject.CreateInstance<SE_OxygenBuble>(); ItemDrop component = PrefabSetup._diveCrown.GetComponent<ItemDrop>(); ((StatusEffect)sE_OxygenBuble).m_icon = component.m_itemData.GetIcon(); component.m_itemData.m_shared.m_equipStatusEffect = (StatusEffect)(object)sE_OxygenBuble; RegisterStatusEffects(component.m_itemData.m_shared.m_equipStatusEffect); } } public static void RegisterToZNetScene() { if (Helper.ZNetSceneAwake()) { _zNetScene.AddClonedObject(PrefabSetup._diveCrown); } } public static void RegisterRecipeToObjectDB() { //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: 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_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Expected O, but got Unknown //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: 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_0207: 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_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Expected O, but got Unknown if (Helper.ObjectDBAwake() && Helper.ZNetSceneAwake()) { Recipe val = ScriptableObject.CreateInstance<Recipe>(); ((Object)val).name = "Recipe_VDS_AtlantianCrown"; val.m_item = PrefabSetup._diveCrown.GetComponent<ItemDrop>(); val.m_amount = 1; val.m_enabled = ConfigSetup._crownEnable.Value; val.m_qualityResultAmountMultiplier = 1f; val.m_craftingStation = _zNetScene.GetPrefab("piece_workbench").GetComponent<CraftingStation>(); val.m_repairStation = val.m_craftingStation; val.m_minStationLevel = 1; val.m_requireOnlyOneIngredient = false; string[] array = ConfigSetup._crownMat1.Value.Split(':', ' '); string[] array2 = ConfigSetup._crownMat2.Value.Split(':', ' '); string[] array3 = ConfigSetup._crownMat3.Value.Split(':', ' '); string[] array4 = ConfigSetup._crownMat4.Value.Split(':', ' '); val.m_resources = (Requirement[])(object)new Requirement[4] { new Requirement { m_resItem = _objectDB.GetItemPrefab(array[0]).GetComponent<ItemDrop>(), m_amount = int.Parse(array[1]), m_extraAmountOnlyOneIngredient = 0, m_amountPerLevel = 0, m_recover = true }, new Requirement { m_resItem = _objectDB.GetItemPrefab(array2[0]).GetComponent<ItemDrop>(), m_amount = int.Parse(array2[1]), m_extraAmountOnlyOneIngredient = 0, m_amountPerLevel = 0, m_recover = true }, new Requirement { m_resItem = _objectDB.GetItemPrefab(array3[0]).GetComponent<ItemDrop>(), m_amount = int.Parse(array3[1]), m_extraAmountOnlyOneIngredient = 0, m_amountPerLevel = 0, m_recover = true }, new Requirement { m_resItem = _objectDB.GetItemPrefab(array4[0]).GetComponent<ItemDrop>(), m_amount = int.Parse(array4[1]), m_extraAmountOnlyOneIngredient = 0, m_amountPerLevel = 1, m_recover = true } }; _objectDB.AddRecipe(val); } } private static void RegisterStatusEffects(StatusEffect statusEffect) { if (statusEffect != null && !Object.op_Implicit((Object)(object)_objectDB.GetStatusEffect(StringExtensionMethods.GetStableHashCode(((Object)statusEffect).name)))) { _objectDB.m_StatusEffects.Add(statusEffect); } } } public static class PrefabSetup { private static AssetBundle _vdsBundle; public static GameObject _diveCrown; public static void Init() { _vdsBundle = GetAssetBundleFromResources("vdsbundle"); _diveCrown = _vdsBundle.LoadAsset<GameObject>("VDS_AtlantianCrown"); } private static AssetBundle GetAssetBundleFromResources(string filename) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetManifestResourceNames().Single((string x) => x.EndsWith(filename)); using Stream stream = executingAssembly.GetManifestResourceStream(name); return AssetBundle.LoadFromStream(stream); } } public class SE_OxygenBuble : StatusEffect { public void Awake() { base.m_name = "Oxygen Bubble"; ((Object)this).name = "vds_oxygenbuble"; base.m_tooltip = ""; } public override void Setup(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("vfx_StaffShield"), m_enabled = true, m_variant = -1, m_attach = true, m_scale = true } }; base.m_startEffects = val; ((StatusEffect)this).Setup(character); } } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded] internal sealed class <b89b921d-8954-4084-bd4d-1feb826a594e>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded] [CompilerGenerated] internal sealed class <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded] [CompilerGenerated] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContextAttribute : Attribute { public readonly byte Flag; public <bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace LocalizationManager { [<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(0)] [PublicAPI] [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(1)] internal class Localizer { private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors; private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts; private static readonly ConditionalWeakTable<Localization, string> localizationLanguage; private static readonly List<WeakReference<Localization>> localizationObjects; [<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(2)] private static BaseUnityPlugin _plugin; private static readonly List<string> fileExtensions; private static BaseUnityPlugin plugin { get { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown if (_plugin == null) { IEnumerable<TypeInfo> source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out var value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out var value2)) { text = value2.Aggregate(text, [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value())); } localization.AddWord(key, text); } public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, [<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null) { if (convertConfigValue == null) { convertConfigValue = [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] [return: <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(1)] (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary<string, Func<string>>(); } config.SettingChanged += [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] (object _, EventArgs _) => { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value); UpdatePlaceholderText(Localization.instance, key); } } public static void AddText(string key, string text) { List<WeakReference<Localization>> list = new List<WeakReference<Localization>>(); foreach (WeakReference<Localization> localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference<Localization> item in list) { localizationObjects.Remove(item); } } public static void Load() { LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage()); } private static void LoadLocalization(Localization __instance, string language) { if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference<Localization>(__instance)); } localizationLanguage.Add(__instance, language); Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories) where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0 select f) { string text = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' })[1]; if (dictionary.ContainsKey(text)) { Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped.")); } else { dictionary[text] = item; } } byte[] array = LoadTranslationFromAssembly("English"); if (array == null) { throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml."); } Dictionary<string, string> dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array)); if (dictionary2 == null) { throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text2 = null; if (language != "English") { if (dictionary.ContainsKey(language)) { text2 = File.ReadAllText(dictionary[language]); } else { byte[] array2 = LoadTranslationFromAssembly(language); if (array2 != null) { text2 = Encoding.UTF8.GetString(array2); } } } if (text2 == null && dictionary.ContainsKey("English")) { text2 = File.ReadAllText(dictionary["English"]); } if (text2 != null) { foreach (KeyValuePair<string, string> item2 in new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>()) { dictionary2[item2.Key] = item2.Value; } } loadedTexts[language] = dictionary2; foreach (KeyValuePair<string, string> item3 in dictionary2) { UpdatePlaceholderText(__instance, item3.Key); } } static Localizer() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>(); loadedTexts = new Dictionary<string, Dictionary<string, string>>(); localizationLanguage = new ConditionalWeakTable<Localization, string>(); localizationObjects = new List<WeakReference<Localization>>(); fileExtensions = new List<string> { ".json", ".yml" }; new Harmony("org.bepinex.helpers.LocalizationManager").Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } [return: <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(2)] private static byte[] LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension); if (array != null) { return array; } } return null; } [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(2)] public static byte[] ReadEmbeddedFileBytes([<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(1)] string resourceFileName, Assembly containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } } namespace Microsoft.CodeAnalysis { [<83d04e38-68f1-4d80-b0c1-87b836d505e1>Embedded] [CompilerGenerated] internal sealed class <83d04e38-68f1-4d80-b0c1-87b836d505e1>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [<83d04e38-68f1-4d80-b0c1-87b836d505e1>Embedded] [CompilerGenerated] internal sealed class <bc71f7de-afef-4d40-a6bb-7d2fe813953f>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <bc71f7de-afef-4d40-a6bb-7d2fe813953f>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <bc71f7de-afef-4d40-a6bb-7d2fe813953f>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [<83d04e38-68f1-4d80-b0c1-87b836d505e1>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [CompilerGenerated] internal sealed class <4a18eb94-4585-4427-bd06-310d110af9e4>NullableContextAttribute : Attribute { public readonly byte Flag; public <4a18eb94-4585-4427-bd06-310d110af9e4>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 { } [<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(1)] [<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] [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 { [<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(1)] public static void Deconstruct<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] TKey, [<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] TValue>([<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(new byte[] { 0, 1, 1 })] this KeyValuePair<TKey, TValue> pair, out TKey key, out TValue value) { key = pair.Key; value = pair.Value; } } } namespace YamlDotNet { [<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] [<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(1)] internal sealed class CultureInfoAdapter : CultureInfo { private readonly IFormatProvider provider; public CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider) : base(baseCulture.LCID) { this.provider = provider; } [<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(2)] public override object GetFormat(Type formatType) { return provider.GetFormat(formatType); } } [<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(1)] [<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] internal static class ReflectionExtensions { [<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] private static readonly FieldInfo RemoteStackTraceField = typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic); [return: <bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] public static Type BaseType(this Type type) { return type.BaseType; } public static bool IsValueType(this Type type) { return type.IsValueType; } public static bool IsGenericType(this Type type) { return type.IsGenericType; } public static bool IsGenericTypeDefinition(this Type type) { return type.IsGenericTypeDefinition; } public static bool IsInterface(this Type type) { return type.IsInterface; } public static bool IsEnum(this Type type) { return type.IsEnum; } public static bool IsDbNull(this object value) { return value is DBNull; } public static bool HasDefaultConstructor(this Type type) { if (!type.IsValueType) { return type.GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, Type.EmptyTypes, null) != null; } return true; } public static TypeCode GetTypeCode(this Type type) { return Type.GetTypeCode(type); } [return: <bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] public static PropertyInfo GetPublicProperty(this Type type, string name) { return type.GetProperty(name); } [return: <bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] public static FieldInfo GetPublicStaticField(this Type type, string name) { return type.GetField(name, BindingFlags.Static | BindingFlags.Public); } public static IEnumerable<PropertyInfo> GetProperties(this Type type, bool includeNonPublic) { BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public; if (includeNonPublic) { bindingFlags |= BindingFlags.NonPublic; } if (!type.IsInterface) { return type.GetProperties(bindingFlags); } return new Type[1] { type }.Concat(type.GetInterfaces()).SelectMany([<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(0)] (Type i) => i.GetProperties(bindingFlags)); } public static IEnumerable<PropertyInfo> GetPublicProperties(this Type type) { return type.GetProperties(includeNonPublic: false); } public static IEnumerable<FieldInfo> GetPublicFields(this Type type) { return type.GetFields(BindingFlags.Instance | BindingFlags.Public); } public static IEnumerable<MethodInfo> GetPublicStaticMethods(this Type type) { return type.GetMethods(BindingFlags.Static | BindingFlags.Public); } public static MethodInfo GetPrivateStaticMethod(this Type type, string name) { return type.GetMethod(name, BindingFlags.Static | BindingFlags.NonPublic) ?? throw new MissingMethodException("Expected to find a method named '" + name + "' in '" + type.FullName + "'."); } [return: <bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] public static MethodInfo GetPublicStaticMethod(this Type type, string name, params Type[] parameterTypes) { return type.GetMethod(name, BindingFlags.Static | BindingFlags.Public, null, parameterTypes, null); } [return: <bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] public static MethodInfo GetPublicInstanceMethod(this Type type, string name) { return type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public); } public static Exception Unwrap(this TargetInvocationException ex) { Exception innerException = ex.InnerException; if (innerException == null) { return ex; } if (RemoteStackTraceField != null) { RemoteStackTraceField.SetValue(innerException, innerException.StackTrace + "\r\n"); } return innerException; } public static bool IsInstanceOf(this Type type, object o) { return type.IsInstanceOfType(o); } public static Attribute[] GetAllCustomAttributes<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] TAttribute>(this PropertyInfo property) { return Attribute.GetCustomAttributes(property, typeof(TAttribute)); } } internal static class PropertyInfoExtensions { [<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(1)] [return: <bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] public static object ReadValue(this PropertyInfo property, object target) { return property.GetValue(target, null); } } internal static class StandardRegexOptions { public const RegexOptions Compiled = RegexOptions.Compiled; } } namespace YamlDotNet.Serialization { [<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] [<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(1)] internal abstract class BuilderSkeleton<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] TBuilder> where TBuilder : BuilderSkeleton<TBuilder> { internal INamingConvention namingConvention = NullNamingConvention.Instance; internal ITypeResolver typeResolver; internal readonly YamlAttributeOverrides overrides; internal readonly LazyComponentRegistrationList<Nothing, IYamlTypeConverter> typeConverterFactories; internal readonly LazyComponentRegistrationList<ITypeInspector, ITypeInspector> typeInspectorFactories; private bool ignoreFields; private bool includeNonPublicProperties; protected abstract TBuilder Self { get; } internal BuilderSkeleton(ITypeResolver typeResolver) { overrides = new YamlAttributeOverrides(); typeConverterFactories = new LazyComponentRegistrationList<Nothing, IYamlTypeConverter> { { typeof(YamlDotNet.Serialization.Converters.GuidConverter), (Nothing _) => new YamlDotNet.Serialization.Converters.GuidConverter(jsonCompatible: false) }, { typeof(SystemTypeConverter), (Nothing _) => new SystemTypeConverter() } }; typeInspectorFactories = new LazyComponentRegistrationList<ITypeInspector, ITypeInspector>(); this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver"); } internal ITypeInspector BuildTypeInspector() { ITypeInspector typeInspector = new ReadablePropertiesTypeInspector(typeResolver, includeNonPublicProperties); if (!ignoreFields) { typeInspector = new CompositeTypeInspector(new ReadableFieldsTypeInspector(typeResolver), typeInspector); } return typeInspectorFactories.BuildComponentChain(typeInspector); } public TBuilder IgnoreFields() { ignoreFields = true; return Self; } public TBuilder IncludeNonPublicProperties() { includeNonPublicProperties = true; return Self; } public TBuilder WithNamingConvention(INamingConvention namingConvention) { this.namingConvention = namingConvention ?? throw new ArgumentNullException("namingConvention"); return Self; } public TBuilder WithTypeResolver(ITypeResolver typeResolver) { this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver"); return Self; } public abstract TBuilder WithTagMapping(TagName tag, Type type); public TBuilder WithAttributeOverride<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] TClass>(Expression<Func<TClass, object>> propertyAccessor, Attribute attribute) { overrides.Add(propertyAccessor, attribute); return Self; } public TBuilder WithAttributeOverride(Type type, string member, Attribute attribute) { overrides.Add(type, member, attribute); return Self; } public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter) { return WithTypeConverter(typeConverter, delegate(IRegistrationLocationSelectionSyntax<IYamlTypeConverter> w) { w.OnTop(); }); } public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter, Action<IRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) { if (typeConverter == null) { throw new ArgumentNullException("typeConverter"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateRegistrationLocationSelector(typeConverter.GetType(), (Nothing _) => typeConverter)); return Self; } public TBuilder WithTypeConverter<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] TYamlTypeConverter>(WrapperFactory<IYamlTypeConverter, IYamlTypeConverter> typeConverterFactory, Action<ITrackingRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) where TYamlTypeConverter : IYamlTypeConverter { if (typeConverterFactory == null) { throw new ArgumentNullException("typeConverterFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateTrackingRegistrationLocationSelector(typeof(TYamlTypeConverter), (IYamlTypeConverter wrapped, Nothing _) => typeConverterFactory(wrapped))); return Self; } public TBuilder WithoutTypeConverter<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] TYamlTypeConverter>() where TYamlTypeConverter : IYamlTypeConverter { return WithoutTypeConverter(typeof(TYamlTypeConverter)); } public TBuilder WithoutTypeConverter(Type converterType) { if (converterType == null) { throw new ArgumentNullException("converterType"); } typeConverterFactories.Remove(converterType); return Self; } public TBuilder WithTypeInspector<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory) where TTypeInspector : ITypeInspector { return WithTypeInspector(typeInspectorFactory, delegate(IRegistrationLocationSelectionSyntax<ITypeInspector> w) { w.OnTop(); }); } public TBuilder WithTypeInspector<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory, Action<IRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector { if (typeInspectorFactory == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector inner) => typeInspectorFactory(inner))); return Self; } public TBuilder WithTypeInspector<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] TTypeInspector>(WrapperFactory<ITypeInspector, ITypeInspector, TTypeInspector> typeInspectorFactory, Action<ITrackingRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector { if (typeInspectorFactory == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateTrackingRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector wrapped, ITypeInspector inner) => typeInspectorFactory(wrapped, inner))); return Self; } public TBuilder WithoutTypeInspector<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] TTypeInspector>() where TTypeInspector : ITypeInspector { return WithoutTypeInspector(typeof(TTypeInspector)); } public TBuilder WithoutTypeInspector(Type inspectorType) { if (inspectorType == null) { throw new ArgumentNullException("inspectorType"); } typeInspectorFactories.Remove(inspectorType); return Self; } protected IEnumerable<IYamlTypeConverter> BuildTypeConverters() { return typeConverterFactories.BuildComponentList(); } } internal delegate TComponent WrapperFactory<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] TComponentBase, TComponent>(TComponentBase wrapped) where TComponent : TComponentBase; internal delegate TComponent WrapperFactory<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] TArgument, [<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] TComponentBase, TComponent>(TComponentBase wrapped, TArgument argument) where TComponent : TComponentBase; [Flags] internal enum DefaultValuesHandling { Preserve = 0, OmitNull = 1, OmitDefaults = 2, OmitEmptyCollections = 4 } [<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] [<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(1)] 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<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] T>(string input) { using StringReader input2 = new StringReader(input); return Deserialize<T>(input2); } public T Deserialize<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] T>(TextReader input) { return Deserialize<T>(new Parser(input)); } [return: <bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] public object Deserialize(TextReader input) { return Deserialize(input, typeof(object)); } [return: <bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] public object Deserialize(string input, Type type) { using StringReader input2 = new StringReader(input); return Deserialize(input2, type); } [return: <bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] public object Deserialize(TextReader input, Type type) { return Deserialize(new Parser(input), type); } public T Deserialize<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] T>(IParser parser) { return (T)Deserialize(parser, typeof(T)); } [return: <bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] public object Deserialize(IParser parser) { return Deserialize(parser, typeof(object)); } [return: <bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] public object Deserialize(IParser parser, Type type) { if (parser == null) { throw new ArgumentNullException("parser"); } if (type == null) { throw new ArgumentNullException("type"); } YamlDotNet.Core.Events.StreamStart @event; bool flag = parser.TryConsume<YamlDotNet.Core.Events.StreamStart>(out @event); YamlDotNet.Core.Events.DocumentStart event2; bool flag2 = parser.TryConsume<YamlDotNet.Core.Events.DocumentStart>(out event2); object result = null; if (!parser.Accept<YamlDotNet.Core.Events.DocumentEnd>(out var _) && !parser.Accept<YamlDotNet.Core.Events.StreamEnd>(out var _)) { using SerializerState serializerState = new SerializerState(); result = valueDeserializer.DeserializeValue(parser, type, serializerState, valueDeserializer); serializerState.OnDeserialization(); } if (flag2) { parser.Consume<YamlDotNet.Core.Events.DocumentEnd>(); } if (flag) { parser.Consume<YamlDotNet.Core.Events.StreamEnd>(); } return result; } } [<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(new byte[] { 0, 1 })] [<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(1)] internal sealed class DeserializerBuilder : BuilderSkeleton<DeserializerBuilder> { private Lazy<IObjectFactory> objectFactory; private readonly LazyComponentRegistrationList<Nothing, INodeDeserializer> nodeDeserializerFactories; private readonly LazyComponentRegistrationList<Nothing, INodeTypeResolver> nodeTypeResolverFactories; private readonly Dictionary<TagName, Type> tagMappings; private readonly Dictionary<Type, Type> typeMappings; private bool ignoreUnmatched; protected override DeserializerBuilder Self => this; public DeserializerBuilder() : base((ITypeResolver)new StaticTypeResolver()) { typeMappings = new Dictionary<Type, Type>(); objectFactory = new Lazy<IObjectFactory>(() => new DefaultObjectFactory(typeMappings), isThreadSafe: true); tagMappings = new Dictionary<TagName, Type> { { FailsafeSchema.Tags.Map, typeof(Dictionary<object, object>) }, { FailsafeSchema.Tags.Str, typeof(string) }, { JsonSchema.Tags.Bool, typeof(bool) }, { JsonSchema.Tags.Float, typeof(double) }, { JsonSchema.Tags.Int, typeof(int) }, { DefaultSchema.Tags.Timestamp, typeof(DateTime) } }; typeInspectorFactories.Add(typeof(CachedTypeInspector), (ITypeInspector inner) => new CachedTypeInspector(inner)); typeInspectorFactories.Add(typeof(NamingConventionTypeInspector), (ITypeInspector inner) => (!(namingConvention is NullNamingConvention)) ? new NamingConventionTypeInspector(inner, namingConvention) : inner); typeInspectorFactories.Add(typeof(YamlAttributesTypeInspector), (ITypeInspector inner) => new YamlAttributesTypeInspector(inner)); typeInspectorFactories.Add(typeof(YamlAttributeOverridesInspector), (ITypeInspector inner) => (overrides == null) ? inner : new YamlAttributeOverridesInspector(inner, overrides.Clone())); typeInspectorFactories.Add(typeof(ReadableAndWritablePropertiesTypeInspector), (ITypeInspector inner) => new ReadableAndWritablePropertiesTypeInspector(inner)); nodeDeserializerFactories = new LazyComponentRegistrationList<Nothing, INodeDeserializer> { { typeof(YamlConvertibleNodeDeserializer), (Nothing _) => new YamlConvertibleNodeDeserializer(objectFactory.Value) }, { typeof(YamlSerializableNodeDeserializer), (Nothing _) => new YamlSerializableNodeDeserializer(objectFactory.Value) }, { typeof(TypeConverterNodeDeserializer), (Nothing _) => new TypeConverterNodeDeserializer(BuildTypeConverters()) }, { typeof(NullNodeDeserializer), (Nothing _) => new NullNodeDeserializer() }, { typeof(ScalarNodeDeserializer), (Nothing _) => new ScalarNodeDeserializer() }, { typeof(ArrayNodeDeserializer), (Nothing _) => new ArrayNodeDeserializer() }, { typeof(DictionaryNodeDeserializer), (Nothing _) => new DictionaryNodeDeserializer(objectFactory.Value) }, { typeof(CollectionNodeDeserializer), (Nothing _) => new CollectionNodeDeserializer(objectFactory.Value) }, { typeof(EnumerableNodeDeserializer), (Nothing _) => new EnumerableNodeDeserializer() }, { typeof(ObjectNodeDeserializer), (Nothing _) => new ObjectNodeDeserializer(objectFactory.Value, BuildTypeInspector(), ignoreUnmatched) } }; nodeTypeResolverFactories = new LazyComponentRegistrationList<Nothing, INodeTypeResolver> { { typeof(MappingNodeTypeResolver), (Nothing _) => new MappingNodeTypeResolver(typeMappings) }, { typeof(YamlConvertibleTypeResolver), (Nothing _) => new YamlConvertibleTypeResolver() }, { typeof(YamlSerializableTypeResolver), (Nothing _) => new YamlSerializableTypeResolver() }, { typeof(TagNodeTypeResolver), (Nothing _) => new TagNodeTypeResolver(tagMappings) }, { typeof(PreventUnknownTagsNodeTypeResolver), (Nothing _) => new PreventUnknownTagsNodeTypeResolver() }, { typeof(DefaultContainersNodeTypeResolver), (Nothing _) => new DefaultContainersNodeTypeResolver() } }; } public DeserializerBuilder WithObjectFactory(IObjectFactory objectFactory) { if (objectFactory == null) { throw new ArgumentNullException("objectFactory"); } this.objectFactory = new Lazy<IObjectFactory>(() => objectFactory, isThreadSafe: true); return this; } public DeserializerBuilder WithObjectFactory(Func<Type, object> objectFactory) { if (objectFactory == null) { throw new ArgumentNullException("objectFactory"); } return WithObjectFactory(new LambdaObjectFactory(objectFactory)); } public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer) { return WithNodeDeserializer(nodeDeserializer, delegate(IRegistrationLocationSelectionSyntax<INodeDeserializer> w) { w.OnTop(); }); } public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer, Action<IRegistrationLocationSelectionSyntax<INodeDeserializer>> where) { if (nodeDeserializer == null) { throw new ArgumentNullException("nodeDeserializer"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateRegistrationLocationSelector(nodeDeserializer.GetType(), (Nothing _) => nodeDeserializer)); return this; } public DeserializerBuilder WithNodeDeserializer<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] TNodeDeserializer>(WrapperFactory<INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeDeserializer>> where) where TNodeDeserializer : INodeDeserializer { if (nodeDeserializerFactory == null) { throw new ArgumentNullException("nodeDeserializerFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeDeserializer), (INodeDeserializer wrapped, Nothing _) => nodeDeserializerFactory(wrapped))); return this; } public DeserializerBuilder WithoutNodeDeserializer<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] TNodeDeserializer>() where TNodeDeserializer : INodeDeserializer { return WithoutNodeDeserializer(typeof(TNodeDeserializer)); } public DeserializerBuilder WithoutNodeDeserializer(Type nodeDeserializerType) { if (nodeDeserializerType == null) { throw new ArgumentNullException("nodeDeserializerType"); } nodeDeserializerFactories.Remove(nodeDeserializerType); return this; } public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver) { return WithNodeTypeResolver(nodeTypeResolver, delegate(IRegistrationLocationSelectionSyntax<INodeTypeResolver> w) { w.OnTop(); }); } public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver, Action<IRegistrationLocationSelectionSyntax<INodeTypeResolver>> where) { if (nodeTypeResolver == null) { throw new ArgumentNullException("nodeTypeResolver"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeTypeResolverFactories.CreateRegistrationLocationSelector(nodeTypeResolver.GetType(), (Nothing _) => nodeTypeResolver)); return this; } public DeserializerBuilder WithNodeTypeResolver<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] TNodeTypeResolver>(WrapperFactory<INodeTypeResolver, TNodeTypeResolver> nodeTypeResolverFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeTypeResolver>> where) where TNodeTypeResolver : INodeTypeResolver { if (nodeTypeResolverFactory == null) { throw new ArgumentNullException("nodeTypeResolverFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeTypeResolverFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeTypeResolver), (INodeTypeResolver wrapped, Nothing _) => nodeTypeResolverFactory(wrapped))); return this; } public DeserializerBuilder WithoutNodeTypeResolver<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] TNodeTypeResolver>() where TNodeTypeResolver : INodeTypeResolver { return WithoutNodeTypeResolver(typeof(TNodeTypeResolver)); } public DeserializerBuilder WithoutNodeTypeResolver(Type nodeTypeResolverType) { if (nodeTypeResolverType == null) { throw new ArgumentNullException("nodeTypeResolverType"); } nodeTypeResolverFactories.Remove(nodeTypeResolverType); return this; } public override DeserializerBuilder WithTagMapping(TagName tag, Type type) { if (tag.IsEmpty) { throw new ArgumentException("Non-specific tags cannot be maped"); } if (type == null) { throw new ArgumentNullException("type"); } if (tagMappings.TryGetValue(tag, out var value)) { throw new ArgumentException($"Type already has a registered type '{value.FullName}' for tag '{tag}'", "tag"); } tagMappings.Add(tag, type); return this; } public DeserializerBuilder WithTypeMapping<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(2)] TInterface, [<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] TConcrete>() where TConcrete : TInterface { Type typeFromHandle = typeof(TInterface); Type typeFromHandle2 = typeof(TConcrete); if (!typeFromHandle.IsAssignableFrom(typeFromHandle2)) { throw new InvalidOperationException("The type '" + typeFromHandle2.Name + "' does not implement interface '" + typeFromHandle.Name + "'."); } if (typeMappings.ContainsKey(typeFromHandle)) { typeMappings[typeFromHandle] = typeFromHandle2; } else { typeMappings.Add(typeFromHandle, typeFromHandle2); } return this; } public DeserializerBuilder WithoutTagMapping(TagName tag) { if (tag.IsEmpty) { throw new ArgumentException("Non-specific tags cannot be maped"); } if (!tagMappings.Remove(tag)) { throw new KeyNotFoundException($"Tag '{tag}' is not registered"); } return this; } public DeserializerBuilder IgnoreUnmatchedProperties() { ignoreUnmatched = true; return this; } public IDeserializer Build() { return Deserializer.FromValueDeserializer(BuildValueDeserializer()); } public IValueDeserializer BuildValueDeserializer() { return new AliasValueDeserializer(new NodeValueDeserializer(nodeDeserializerFactories.BuildComponentList(), nodeTypeResolverFactories.BuildComponentList())); } } [<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] [<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(1)] internal sealed class EmissionPhaseObjectGraphVisitorArgs { private readonly IEnumerable<IObjectGraphVisitor<Nothing>> preProcessingPhaseVisitors; public IObjectGraphVisitor<IEmitter> InnerVisitor { get; private set; } public IEventEmitter EventEmitter { get; private set; } public ObjectSerializer NestedObjectSerializer { get; private set; } public IEnumerable<IYamlTypeConverter> TypeConverters { get; private set; } public EmissionPhaseObjectGraphVisitorArgs(IObjectGraphVisitor<IEmitter> innerVisitor, IEventEmitter eventEmitter, IEnumerable<IObjectGraphVisitor<Nothing>> preProcessingPhaseVisitors, IEnumerable<IYamlTypeConverter> typeConverters, ObjectSerializer nestedObjectSerializer) { InnerVisitor = innerVisitor ?? throw new ArgumentNullException("innerVisitor"); EventEmitter = eventEmitter ?? throw new ArgumentNullException("eventEmitter"); this.preProcessingPhaseVisitors = preProcessingPhaseVisitors ?? throw new ArgumentNullException("preProcessingPhaseVisitors"); TypeConverters = typeConverters ?? throw new ArgumentNullException("typeConverters"); NestedObjectSerializer = nestedObjectSerializer ?? throw new ArgumentNullException("nestedObjectSerializer"); } public T GetPreProcessingPhaseObjectGraphVisitor<[<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] T>() where T : IObjectGraphVisitor<Nothing> { return preProcessingPhaseVisitors.OfType<T>().Single(); } } [<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] [<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(1)] 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; } [<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(1)] 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; } [<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(1)] protected ObjectEventInfo(IObjectDescriptor source) : base(source) { } } [<bc71f7de-afef-4d40-a6bb-7d2fe813953f>Nullable(0)] [<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(1)] 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 source) : base(source) { Style = source.ScalarStyle; RenderedValue = string.Empty; } } internal sealed class MappingStartEventInfo : ObjectEventInfo { public bool IsImplicit { get; set; } public MappingStyle Style { get; set; } [<4a18eb94-4585-4427-bd06-310d110af9e4>NullableContext(1)] public MappingStartEventInfo(IObjectDescriptor source)