Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of VikingsDoSwim v1.4.1
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.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: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("blacks7ar")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.4.1")] [assembly: AssemblyInformationalVersion("1.4.1")] [assembly: AssemblyProduct("VikingsDoSwim")] [assembly: AssemblyTitle("VikingsDoSwim")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace VikingsDoSwim { [BepInPlugin("blacks7ar.VikingsDoSwim", "VikingsDoSwim", "1.4.1")] 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.4.1"; 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.4.1", MinimumRequiredVersion = "1.4.1" }; 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 _Instance = this; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; Localizer.Load(); _serverConfigLocked = config("1- ServerSync", "Lock Configuration", Toggle.On, new ConfigDescription("If On, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, Array.Empty<object>())); _configSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked); _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(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; ((BaseUnityPlugin)this).Config.Save(); } 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.linearVelocity; 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 linearVelocity = ((Character)val).m_body.linearVelocity; linearVelocity.y = Mathf.MoveTowards(linearVelocity.y, num5, 50f * dt); ((Character)val).m_body.linearVelocity = linearVelocity; } else { float num6 = Mathf.Clamp01((0f - (num3 - ((Component)val).transform.position.y)) / 1f); float num7 = Mathf.Lerp(0f, 10f, num6); Vector3 linearVelocity2 = ((Character)val).m_body.linearVelocity; linearVelocity2.y = Mathf.MoveTowards(linearVelocity2.y, 0f - num7, 30f * dt); ((Character)val).m_body.linearVelocity = linearVelocity2; } 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.linearVelocity, 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 Color32 ChangeColorBrightness(Color32 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_0015: 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) int num = color.r; int num2 = color.g; int num3 = color.b; int a = color.a; if (correctionFactor < 0f) { correctionFactor *= -1f; num -= (int)((float)num * correctionFactor); num2 -= (int)((float)num2 * correctionFactor); num3 -= (int)((float)num3 * correctionFactor); } num = Mathf.Clamp(num, 0, 255); num2 = Mathf.Clamp(num2, 0, 255); num3 = Mathf.Clamp(num3, 0, 255); return new Color32((byte)num, (byte)num2, (byte)num3, (byte)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_024e: 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_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_0187: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: 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; } ((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_0007: 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) //IL_0021: 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) color = Color32.op_Implicit(ChangeColorBrightness(Color32.op_Implicit(color), Plugin._CharacterSwimDepth * Plugin._colorBrightnessFactor.Value)); }; color = Color32.op_Implicit(ChangeColorBrightness(Color32.op_Implicit(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; return; } if (((Component)___m_camera).gameObject.transform.position.y > Plugin._WaterLevelCamera) { if (!Plugin._RenderSettingsUpdateCamera) { if (Plugin._MaxDistance != 0f) { __instance.m_maxDistance = Plugin._MaxDistance; } 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 { [HarmonyPriority(700)] [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "Awake")] public static void Awake_Postfix(ObjectDB __instance) { ItemSetup.RegisterToObjectDB(); ItemSetup.RegisterRecipeToObjectDB(); __instance.UpdateRegisters(); } [HarmonyPriority(700)] [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] 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_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Expected O, but got Unknown //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_0455: 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).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("__SE_Krump_OxygenBubble30")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("__SE_Krump_OxygenBubble20")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("__SE_Krump_OxygenBubble10"))) && !((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")) && !((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("__SE_Krump_OxygenBubble30")) && !((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("__SE_Krump_OxygenBubble20")) && !((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("__SE_Krump_OxygenBubble10"))) { 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"; } } } [HarmonyPostfix] [HarmonyPatch(typeof(Player), "Awake")] 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; public static void Init() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown string group = "Atlantean 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>(); ((Object)sE_OxygenBuble).name = "vds_oxygenbuble"; ((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); SE_OxygenBuble sE_OxygenBuble2 = ScriptableObject.CreateInstance<SE_OxygenBuble>(); ((Object)sE_OxygenBuble2).name = "__SE_Krump_OxygenBubble30"; ((StatusEffect)sE_OxygenBuble2).m_icon = PrefabSetup._vdsBundle.LoadAsset<Sprite>("VDS_StatusEffect_Oxygen"); ((StatusEffect)sE_OxygenBuble2).m_ttl = 30f; RegisterStatusEffects((StatusEffect)(object)sE_OxygenBuble2); SE_OxygenBuble sE_OxygenBuble3 = ScriptableObject.CreateInstance<SE_OxygenBuble>(); ((Object)sE_OxygenBuble3).name = "__SE_Krump_OxygenBubble20"; ((StatusEffect)sE_OxygenBuble3).m_icon = PrefabSetup._vdsBundle.LoadAsset<Sprite>("VDS_StatusEffect_Oxygen"); ((StatusEffect)sE_OxygenBuble3).m_ttl = 20f; RegisterStatusEffects((StatusEffect)(object)sE_OxygenBuble3); SE_OxygenBuble sE_OxygenBuble4 = ScriptableObject.CreateInstance<SE_OxygenBuble>(); ((Object)sE_OxygenBuble4).name = "__SE_Krump_OxygenBubble10"; ((StatusEffect)sE_OxygenBuble4).m_icon = PrefabSetup._vdsBundle.LoadAsset<Sprite>("VDS_StatusEffect_Oxygen"); ((StatusEffect)sE_OxygenBuble4).m_ttl = 10f; RegisterStatusEffects((StatusEffect)(object)sE_OxygenBuble4); SE_OxygenBuble sE_OxygenBuble5 = ScriptableObject.CreateInstance<SE_OxygenBuble>(); ((Object)sE_OxygenBuble5).name = "__SE_Krump_OxygenBubble60"; ((StatusEffect)sE_OxygenBuble5).m_icon = PrefabSetup._vdsBundle.LoadAsset<Sprite>("VDS_StatusEffect_Oxygen"); ((StatusEffect)sE_OxygenBuble5).m_ttl = 60f; RegisterStatusEffects((StatusEffect)(object)sE_OxygenBuble5); SE_OxygenBuble sE_OxygenBuble6 = ScriptableObject.CreateInstance<SE_OxygenBuble>(); ((Object)sE_OxygenBuble6).name = "__SE_Krump_OxygenBubble120"; ((StatusEffect)sE_OxygenBuble6).m_icon = PrefabSetup._vdsBundle.LoadAsset<Sprite>("VDS_StatusEffect_Oxygen"); ((StatusEffect)sE_OxygenBuble6).m_ttl = 120f; RegisterStatusEffects((StatusEffect)(object)sE_OxygenBuble6); } } public static void RegisterToZNetScene() { if (Helper.ZNetSceneAwake()) { _zNetScene.AddClonedObject(PrefabSetup._diveCrown); _zNetScene.AddClonedObject(PrefabSetup._bubbleVFX); } } 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 { public static AssetBundle _vdsBundle; public static GameObject _diveCrown; public static GameObject _bubbleVFX; public static Shader _vdsShader; public static void Init() { _vdsBundle = GetAssetBundleFromResources("vdsbundle"); _diveCrown = _vdsBundle.LoadAsset<GameObject>("VDS_AtlantianCrown"); _bubbleVFX = _vdsBundle.LoadAsset<GameObject>("VDS_Krump_Bubbles_Small"); _vdsShader = _vdsBundle.LoadAsset<Shader>("SimpleDepthOfField"); } private static AssetBundle GetAssetBundleFromResources(string filename) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = Enumerable.Single(executingAssembly.GetManifestResourceNames(), (string x) => x.EndsWith(filename)); using Stream stream = executingAssembly.GetManifestResourceStream(name); return AssetBundle.LoadFromStream(stream); } } public class SE_OxygenBuble : StatusEffect { public void Awake() { base.m_name = "Oxygen Bubble"; 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 //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[2] { new EffectData { m_prefab = ZNetScene.instance.GetPrefab("vfx_StaffShield"), m_enabled = true, m_variant = -1, m_attach = true, m_scale = true }, new EffectData { m_prefab = PrefabSetup._vdsBundle.LoadAsset<GameObject>("VDS_Krump_Bubbles_Small"), m_enabled = true, m_variant = -1, m_attach = true } }; base.m_startEffects = val; ((StatusEffect)this).Setup(character); } } [RequireComponent(typeof(Camera))] public class SimpleDepthOfField : MonoBehaviour { private static readonly int BlurAmount = Shader.PropertyToID("_BlurAmount"); [Range(0f, 10f)] public float blurAmount; public float fadeSpeed = 2f; private float targetBlur; private Material _material; private void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown if ((Object)(object)_material == (Object)null && (Object)(object)PrefabSetup._vdsShader != (Object)null) { _material = new Material(PrefabSetup._vdsShader); } } private void Update() { blurAmount = Mathf.Lerp(blurAmount, targetBlur, Time.deltaTime * fadeSpeed); } public void SetTargetBlur(float target) { targetBlur = Mathf.Clamp(target, 0f, 10f); ((Behaviour)this).enabled = targetBlur > 0.01f || blurAmount > 0.01f; } private void OnRenderImage(RenderTexture src, RenderTexture dest) { if ((Object)(object)_material != (Object)null && blurAmount > 0.01f) { _material.SetFloat(BlurAmount, blurAmount); Graphics.Blit((Texture)(object)src, dest, _material); } else { Graphics.Blit((Texture)(object)src, dest); } } } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<112b52fc-385e-4422-8766-76e3d2c67965>Embedded] internal sealed class <112b52fc-385e-4422-8766-76e3d2c67965>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<112b52fc-385e-4422-8766-76e3d2c67965>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [<112b52fc-385e-4422-8766-76e3d2c67965>Embedded] internal sealed class <79594173-e941-4ad9-973e-713c0d41eb0b>NullableContextAttribute : Attribute { public readonly byte Flag; public <79594173-e941-4ad9-973e-713c0d41eb0b>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace LocalizationManager { [<1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>Nullable(0)] [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(1)] [PublicAPI] internal class Localizer { private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors; private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts; private static readonly ConditionalWeakTable<Localization, string> localizationLanguage; private static readonly List<WeakReference<Localization>> localizationObjects; [<1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>Nullable(2)] private static BaseUnityPlugin _plugin; private static readonly List<string> fileExtensions; private static BaseUnityPlugin plugin { get { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown if (_plugin == null) { IEnumerable<TypeInfo> source; try { source = Enumerable.ToList(Assembly.GetExecutingAssembly().DefinedTypes); } catch (ReflectionTypeLoadException ex) { source = Enumerable.Select(Enumerable.Where(ex.Types, [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(0)] (Type t) => t != null), [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(0)] (Type t) => t.GetTypeInfo()); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)Enumerable.First(source, [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } [<1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>Nullable(2)] [method: <79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(2)] [field: <1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>Nullable(2)] public static event Action OnLocalizationComplete; private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out var value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out var value2)) { text = Enumerable.Aggregate(value2, text, [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(0)] (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value())); } localization.AddWord(key, text); } public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, [<1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null) { if (convertConfigValue == null) { convertConfigValue = (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary<string, Func<string>>(); } config.SettingChanged += [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(0)] (object _, EventArgs _) => { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value); UpdatePlaceholderText(Localization.instance, key); } } public static void AddText(string key, string text) { List<WeakReference<Localization>> list = new List<WeakReference<Localization>>(); foreach (WeakReference<Localization> localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference<Localization> item in list) { localizationObjects.Remove(item); } } public static void Load() { _ = plugin; } public static void LoadLocalizationLater(Localization __instance) { LoadLocalization(Localization.instance, __instance.GetSelectedLanguage()); } public static void SafeCallLocalizeComplete() { Localizer.OnLocalizationComplete?.Invoke(); } private static void LoadLocalization(Localization __instance, string language) { if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference<Localization>(__instance)); } localizationLanguage.Add(__instance, language); Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (string item in Enumerable.Where(Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories), [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(0)] (string f) => fileExtensions.IndexOf(Path.GetExtension(f)) >= 0)) { string text = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' })[1]; if (dictionary.ContainsKey(text)) { Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped.")); } else { dictionary[text] = item; } } byte[] array = LoadTranslationFromAssembly("English"); if (array == null) { throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml."); } Dictionary<string, string> dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array)); if (dictionary2 == null) { throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text2 = null; if (language != "English") { if (dictionary.TryGetValue(language, out var value)) { text2 = File.ReadAllText(value); } else { byte[] array2 = LoadTranslationFromAssembly(language); if (array2 != null) { text2 = Encoding.UTF8.GetString(array2); } } } if (text2 == null && dictionary.TryGetValue("English", out var value2)) { text2 = File.ReadAllText(value2); } if (text2 != null) { foreach (KeyValuePair<string, string> item2 in new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>()) { dictionary2[item2.Key] = item2.Value; } } loadedTexts[language] = dictionary2; foreach (KeyValuePair<string, string> item3 in dictionary2) { UpdatePlaceholderText(__instance, item3.Key); } } static Localizer() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>(); loadedTexts = new Dictionary<string, Dictionary<string, string>>(); localizationLanguage = new ConditionalWeakTable<Localization, string>(); localizationObjects = new List<WeakReference<Localization>>(); fileExtensions = new List<string>(2) { ".json", ".yml" }; Harmony val = new Harmony("org.bepinex.helpers.LocalizationManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "SetupGui", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalizationLater", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "SafeCallLocalizeComplete", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } [return: <1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>Nullable(2)] private static byte[] LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension); if (array != null) { return array; } } return null; } [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(2)] public static byte[] ReadEmbeddedFileBytes([<1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>Nullable(1)] string resourceFileName, Assembly containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = Enumerable.FirstOrDefault(containingAssembly.GetManifestResourceNames(), [<79594173-e941-4ad9-973e-713c0d41eb0b>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } internal static class LocalizationManagerVersion { [<1bfc4759-c5a6-4eb1-bee9-a1d0c5c59449>Nullable(1)] public const string Version = "1.4.0"; } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] internal sealed class AllowNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] internal sealed class DisallowNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Method, Inherited = false)] internal sealed class DoesNotReturnAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] internal sealed class DoesNotReturnIfAttribute : Attribute { public bool ParameterValue { get; } public DoesNotReturnIfAttribute(bool parameterValue) { ParameterValue = parameterValue; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)] internal sealed class MaybeNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] internal sealed class MaybeNullWhenAttribute : Attribute { public bool ReturnValue { get; } public MaybeNullWhenAttribute(bool returnValue) { ReturnValue = returnValue; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)] internal sealed class NotNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] internal sealed class NotNullIfNotNullAttribute : Attribute { public string ParameterName { get; } public NotNullIfNotNullAttribute(string parameterName) { ParameterName = parameterName; } } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] internal sealed class NotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public NotNullWhenAttribute(bool returnValue) { ReturnValue = returnValue; } } } namespace System.Collections.Generic { internal static class DeconstructionExtensions { public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> pair, out TKey key, out TValue value) { key = pair.Key; value = pair.Value; } } } namespace YamlDotNet { internal sealed class CultureInfoAdapter : CultureInfo { private readonly IFormatProvider provider; public CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider) : base(baseCulture.LCID) { this.provider = provider; } public override object? GetFormat(Type? formatType) { return provider.GetFormat(formatType); } } internal static class ReflectionExtensions { private static readonly FieldInfo? RemoteStackTraceField = typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic); public static Type? BaseType(this Type type) { return type.BaseType; } public static bool IsValueType(this Type type) { return type.IsValueType; } public static bool IsGenericType(this Type type) { return type.IsGenericType; } public static bool IsGenericTypeDefinition(this Type type) { return type.IsGenericTypeDefinition; } public static bool IsInterface(this Type type) { return type.IsInterface; } public static bool IsEnum(this Type type) { return type.IsEnum; } public static bool IsDbNull(this object value) { return value is DBNull; } public static bool HasDefaultConstructor(this Type type) { if (!type.IsValueType) { return type.GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, Type.EmptyTypes, null) != null; } return true; } public static TypeCode GetTypeCode(this Type type) { return Type.GetTypeCode(type); } public static PropertyInfo? GetPublicProperty(this Type type, string name) { return type.GetProperty(name); } public static FieldInfo? GetPublicStaticField(this Type type, string name) { return type.GetField(name, BindingFlags.Static | BindingFlags.Public); } public static IEnumerable<PropertyInfo> GetProperties(this Type type, bool includeNonPublic) { BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public; if (includeNonPublic) { bindingFlags |= BindingFlags.NonPublic; } if (!type.IsInterface) { return type.GetProperties(bindingFlags); } return Enumerable.SelectMany(Enumerable.Concat(new Type[1] { type }, type.GetInterfaces()), (Type i) => i.GetProperties(bindingFlags)); } public static IEnumerable<PropertyInfo> GetPublicProperties(this Type type) { return type.GetProperties(includeNonPublic: false); } public static IEnumerable<FieldInfo> GetPublicFields(this Type type) { return type.GetFields(BindingFlags.Instance | BindingFlags.Public); } public static IEnumerable<MethodInfo> GetPublicStaticMethods(this Type type) { return type.GetMethods(BindingFlags.Static | BindingFlags.Public); } public static MethodInfo GetPrivateStaticMethod(this Type type, string name) { return type.GetMethod(name, BindingFlags.Static | BindingFlags.NonPublic) ?? throw new MissingMethodException("Expected to find a method named '" + name + "' in '" + type.FullName + "'."); } public static MethodInfo? GetPublicStaticMethod(this Type type, string name, params Type[] parameterTypes) { return type.GetMethod(name, BindingFlags.Static | BindingFlags.Public, null, parameterTypes, null); } public static MethodInfo? GetPublicInstanceMethod(this Type type, string name) { return type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public); } public static Exception Unwrap(this TargetInvocationException ex) { Exception innerException = ex.InnerException; if (innerException == null) { return ex; } if (RemoteStackTraceField != null) { RemoteStackTraceField.SetValue(innerException, innerException.StackTrace + "\r\n"); } return innerException; } public static bool IsInstanceOf(this Type type, object o) { return type.IsInstanceOfType(o); } public static Attribute[] GetAllCustomAttributes<TAttribute>(this PropertyInfo property) { return Attribute.GetCustomAttributes(property, typeof(TAttribute)); } } internal static class PropertyInfoExtensions { public static object? ReadValue(this PropertyInfo property, object target) { return property.GetValue(target, null); } } internal static class StandardRegexOptions { public const RegexOptions Compiled = RegexOptions.Compiled; } } namespace YamlDotNet.Serialization { internal abstract class BuilderSkeleton<TBuilder> where TBuilder : BuilderSkeleton<TBuilder> { internal INamingConvention namingConvention = NullNamingConvention.Instance; internal ITypeResolver typeResolver; internal readonly YamlAttributeOverrides overrides; internal readonly LazyComponentRegistrationList<Nothing, IYamlTypeConverter> typeConverterFactories; internal readonly LazyComponentRegistrationList<ITypeInspector, ITypeInspector> typeInspectorFactories; private bool ignoreFields; private bool includeNonPublicProperties; protected abstract TBuilder Self { get; } internal BuilderSkeleton(ITypeResolver typeResolver) { overrides = new YamlAttributeOverrides(); typeConverterFactories = new LazyComponentRegistrationList<Nothing, IYamlTypeConverter> { { typeof(YamlDotNet.Serialization.Converters.GuidConverter), (Nothing _) => new YamlDotNet.Serialization.Converters.GuidConverter(jsonCompatible: false) }, { typeof(SystemTypeConverter), (Nothing _) => new SystemTypeConverter() } }; typeInspectorFactories = new LazyComponentRegistrationList<ITypeInspector, ITypeInspector>(); this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver"); } internal ITypeInspector BuildTypeInspector() { ITypeInspector typeInspector = new ReadablePropertiesTypeInspector(typeResolver, includeNonPublicProperties); if (!ignoreFields) { typeInspector = new CompositeTypeInspector(new ReadableFieldsTypeInspector(typeResolver), typeInspector); } return typeInspectorFactories.BuildComponentChain(typeInspector); } public TBuilder IgnoreFields() { ignoreFields = true; return Self; } public TBuilder IncludeNonPublicProperties() { includeNonPublicProperties = true; return Self; } public TBuilder WithNamingConvention(INamingConvention namingConvention) { this.namingConvention = namingConvention ?? throw new ArgumentNullException("namingConvention"); return Self; } public TBuilder WithTypeResolver(ITypeResolver typeResolver) { this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver"); return Self; } public abstract TBuilder WithTagMapping(TagName tag, Type type); public TBuilder WithAttributeOverride<TClass>(Expression<Func<TClass, object>> propertyAccessor, Attribute attribute) { overrides.Add(propertyAccessor, attribute); return Self; } public TBuilder WithAttributeOverride(Type type, string member, Attribute attribute) { overrides.Add(type, member, attribute); return Self; } public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter) { return WithTypeConverter(typeConverter, delegate(IRegistrationLocationSelectionSyntax<IYamlTypeConverter> w) { w.OnTop(); }); } public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter, Action<IRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) { IYamlTypeConverter typeConverter2 = typeConverter; if (typeConverter2 == null) { throw new ArgumentNullException("typeConverter"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateRegistrationLocationSelector(typeConverter2.GetType(), (Nothing _) => typeConverter2)); return Self; } public TBuilder WithTypeConverter<TYamlTypeConverter>(WrapperFactory<IYamlTypeConverter, IYamlTypeConverter> typeConverterFactory, Action<ITrackingRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) where TYamlTypeConverter : IYamlTypeConverter { WrapperFactory<IYamlTypeConverter, IYamlTypeConverter> typeConverterFactory2 = typeConverterFactory; if (typeConverterFactory2 == null) { throw new ArgumentNullException("typeConverterFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeConverterFactories.CreateTrackingRegistrationLocationSelector(typeof(TYamlTypeConverter), (IYamlTypeConverter wrapped, Nothing _) => typeConverterFactory2(wrapped))); return Self; } public TBuilder WithoutTypeConverter<TYamlTypeConverter>() where TYamlTypeConverter : IYamlTypeConverter { return WithoutTypeConverter(typeof(TYamlTypeConverter)); } public TBuilder WithoutTypeConverter(Type converterType) { if (converterType == null) { throw new ArgumentNullException("converterType"); } typeConverterFactories.Remove(converterType); return Self; } public TBuilder WithTypeInspector<TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory) where TTypeInspector : ITypeInspector { return WithTypeInspector(typeInspectorFactory, delegate(IRegistrationLocationSelectionSyntax<ITypeInspector> w) { w.OnTop(); }); } public TBuilder WithTypeInspector<TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory, Action<IRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector { Func<ITypeInspector, TTypeInspector> typeInspectorFactory2 = typeInspectorFactory; if (typeInspectorFactory2 == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector inner) => typeInspectorFactory2(inner))); return Self; } public TBuilder WithTypeInspector<TTypeInspector>(WrapperFactory<ITypeInspector, ITypeInspector, TTypeInspector> typeInspectorFactory, Action<ITrackingRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector { WrapperFactory<ITypeInspector, ITypeInspector, TTypeInspector> typeInspectorFactory2 = typeInspectorFactory; if (typeInspectorFactory2 == null) { throw new ArgumentNullException("typeInspectorFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(typeInspectorFactories.CreateTrackingRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector wrapped, ITypeInspector inner) => typeInspectorFactory2(wrapped, inner))); return Self; } public TBuilder WithoutTypeInspector<TTypeInspector>() where TTypeInspector : ITypeInspector { return WithoutTypeInspector(typeof(TTypeInspector)); } public TBuilder WithoutTypeInspector(Type inspectorType) { if (inspectorType == null) { throw new ArgumentNullException("inspectorType"); } typeInspectorFactories.Remove(inspectorType); return Self; } protected IEnumerable<IYamlTypeConverter> BuildTypeConverters() { return typeConverterFactories.BuildComponentList(); } } internal delegate TComponent WrapperFactory<TComponentBase, TComponent>(TComponentBase wrapped) where TComponent : TComponentBase; internal delegate TComponent WrapperFactory<TArgument, TComponentBase, TComponent>(TComponentBase wrapped, TArgument argument) where TComponent : TComponentBase; [Flags] internal enum DefaultValuesHandling { Preserve = 0, OmitNull = 1, OmitDefaults = 2, OmitEmptyCollections = 4 } internal sealed class Deserializer : IDeserializer { private readonly IValueDeserializer valueDeserializer; public Deserializer() : this(new DeserializerBuilder().BuildValueDeserializer()) { } private Deserializer(IValueDeserializer valueDeserializer) { this.valueDeserializer = valueDeserializer ?? throw new ArgumentNullException("valueDeserializer"); } public static Deserializer FromValueDeserializer(IValueDeserializer valueDeserializer) { return new Deserializer(valueDeserializer); } public T Deserialize<T>(string input) { using StringReader input2 = new StringReader(input); return Deserialize<T>(input2); } public T Deserialize<T>(TextReader input) { return Deserialize<T>(new Parser(input)); } public object? Deserialize(TextReader input) { return Deserialize(input, typeof(object)); } public object? Deserialize(string input, Type type) { using StringReader input2 = new StringReader(input); return Deserialize(input2, type); } public object? Deserialize(TextReader input, Type type) { return Deserialize(new Parser(input), type); } public T Deserialize<T>(IParser parser) { return (T)Deserialize(parser, typeof(T)); } public object? Deserialize(IParser parser) { return Deserialize(parser, typeof(object)); } public object? Deserialize(IParser parser, Type type) { if (parser == null) { throw new ArgumentNullException("parser"); } if (type == null) { throw new ArgumentNullException("type"); } YamlDotNet.Core.Events.StreamStart @event; bool flag = parser.TryConsume<YamlDotNet.Core.Events.StreamStart>(out @event); YamlDotNet.Core.Events.DocumentStart event2; bool flag2 = parser.TryConsume<YamlDotNet.Core.Events.DocumentStart>(out event2); object result = null; if (!parser.Accept<YamlDotNet.Core.Events.DocumentEnd>(out var _) && !parser.Accept<YamlDotNet.Core.Events.StreamEnd>(out var _)) { using SerializerState serializerState = new SerializerState(); result = valueDeserializer.DeserializeValue(parser, type, serializerState, valueDeserializer); serializerState.OnDeserialization(); } if (flag2) { parser.Consume<YamlDotNet.Core.Events.DocumentEnd>(); } if (flag) { parser.Consume<YamlDotNet.Core.Events.StreamEnd>(); } return result; } } internal sealed class DeserializerBuilder : BuilderSkeleton<DeserializerBuilder> { private Lazy<IObjectFactory> objectFactory; private readonly LazyComponentRegistrationList<Nothing, INodeDeserializer> nodeDeserializerFactories; private readonly LazyComponentRegistrationList<Nothing, INodeTypeResolver> nodeTypeResolverFactories; private readonly Dictionary<TagName, Type> tagMappings; private readonly Dictionary<Type, Type> typeMappings; private bool ignoreUnmatched; protected override DeserializerBuilder Self => this; public DeserializerBuilder() : base((ITypeResolver)new StaticTypeResolver()) { typeMappings = new Dictionary<Type, Type>(); objectFactory = new Lazy<IObjectFactory>(() => new DefaultObjectFactory(typeMappings), isThreadSafe: true); tagMappings = new Dictionary<TagName, Type> { { FailsafeSchema.Tags.Map, typeof(Dictionary<object, object>) }, { FailsafeSchema.Tags.Str, typeof(string) }, { JsonSchema.Tags.Bool, typeof(bool) }, { JsonSchema.Tags.Float, typeof(double) }, { JsonSchema.Tags.Int, typeof(int) }, { DefaultSchema.Tags.Timestamp, typeof(DateTime) } }; typeInspectorFactories.Add(typeof(CachedTypeInspector), (ITypeInspector inner) => new CachedTypeInspector(inner)); typeInspectorFactories.Add(typeof(NamingConventionTypeInspector), (ITypeInspector inner) => (!(namingConvention is NullNamingConvention)) ? new NamingConventionTypeInspector(inner, namingConvention) : inner); typeInspectorFactories.Add(typeof(YamlAttributesTypeInspector), (ITypeInspector inner) => new YamlAttributesTypeInspector(inner)); typeInspectorFactories.Add(typeof(YamlAttributeOverridesInspector), (ITypeInspector inner) => (overrides == null) ? inner : new YamlAttributeOverridesInspector(inner, overrides.Clone())); typeInspectorFactories.Add(typeof(ReadableAndWritablePropertiesTypeInspector), (ITypeInspector inner) => new ReadableAndWritablePropertiesTypeInspector(inner)); nodeDeserializerFactories = new LazyComponentRegistrationList<Nothing, INodeDeserializer> { { typeof(YamlConvertibleNodeDeserializer), (Nothing _) => new YamlConvertibleNodeDeserializer(objectFactory.Value) }, { typeof(YamlSerializableNodeDeserializer), (Nothing _) => new YamlSerializableNodeDeserializer(objectFactory.Value) }, { typeof(TypeConverterNodeDeserializer), (Nothing _) => new TypeConverterNodeDeserializer(BuildTypeConverters()) }, { typeof(NullNodeDeserializer), (Nothing _) => new NullNodeDeserializer() }, { typeof(ScalarNodeDeserializer), (Nothing _) => new ScalarNodeDeserializer() }, { typeof(ArrayNodeDeserializer), (Nothing _) => new ArrayNodeDeserializer() }, { typeof(DictionaryNodeDeserializer), (Nothing _) => new DictionaryNodeDeserializer(objectFactory.Value) }, { typeof(CollectionNodeDeserializer), (Nothing _) => new CollectionNodeDeserializer(objectFactory.Value) }, { typeof(EnumerableNodeDeserializer), (Nothing _) => new EnumerableNodeDeserializer() }, { typeof(ObjectNodeDeserializer), (Nothing _) => new ObjectNodeDeserializer(objectFactory.Value, BuildTypeInspector(), ignoreUnmatched) } }; nodeTypeResolverFactories = new LazyComponentRegistrationList<Nothing, INodeTypeResolver> { { typeof(MappingNodeTypeResolver), (Nothing _) => new MappingNodeTypeResolver(typeMappings) }, { typeof(YamlConvertibleTypeResolver), (Nothing _) => new YamlConvertibleTypeResolver() }, { typeof(YamlSerializableTypeResolver), (Nothing _) => new YamlSerializableTypeResolver() }, { typeof(TagNodeTypeResolver), (Nothing _) => new TagNodeTypeResolver(tagMappings) }, { typeof(PreventUnknownTagsNodeTypeResolver), (Nothing _) => new PreventUnknownTagsNodeTypeResolver() }, { typeof(DefaultContainersNodeTypeResolver), (Nothing _) => new DefaultContainersNodeTypeResolver() } }; } public DeserializerBuilder WithObjectFactory(IObjectFactory objectFactory) { IObjectFactory objectFactory2 = objectFactory; if (objectFactory2 == null) { throw new ArgumentNullException("objectFactory"); } this.objectFactory = new Lazy<IObjectFactory>(() => objectFactory2, isThreadSafe: true); return this; } public DeserializerBuilder WithObjectFactory(Func<Type, object> objectFactory) { if (objectFactory == null) { throw new ArgumentNullException("objectFactory"); } return WithObjectFactory(new LambdaObjectFactory(objectFactory)); } public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer) { return WithNodeDeserializer(nodeDeserializer, delegate(IRegistrationLocationSelectionSyntax<INodeDeserializer> w) { w.OnTop(); }); } public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer, Action<IRegistrationLocationSelectionSyntax<INodeDeserializer>> where) { INodeDeserializer nodeDeserializer2 = nodeDeserializer; if (nodeDeserializer2 == null) { throw new ArgumentNullException("nodeDeserializer"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateRegistrationLocationSelector(nodeDeserializer2.GetType(), (Nothing _) => nodeDeserializer2)); return this; } public DeserializerBuilder WithNodeDeserializer<TNodeDeserializer>(WrapperFactory<INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeDeserializer>> where) where TNodeDeserializer : INodeDeserializer { WrapperFactory<INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory2 = nodeDeserializerFactory; if (nodeDeserializerFactory2 == null) { throw new ArgumentNullException("nodeDeserializerFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeDeserializerFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeDeserializer), (INodeDeserializer wrapped, Nothing _) => nodeDeserializerFactory2(wrapped))); return this; } public DeserializerBuilder WithoutNodeDeserializer<TNodeDeserializer>() where TNodeDeserializer : INodeDeserializer { return WithoutNodeDeserializer(typeof(TNodeDeserializer)); } public DeserializerBuilder WithoutNodeDeserializer(Type nodeDeserializerType) { if (nodeDeserializerType == null) { throw new ArgumentNullException("nodeDeserializerType"); } nodeDeserializerFactories.Remove(nodeDeserializerType); return this; } public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver) { return WithNodeTypeResolver(nodeTypeResolver, delegate(IRegistrationLocationSelectionSyntax<INodeTypeResolver> w) { w.OnTop(); }); } public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver, Action<IRegistrationLocationSelectionSyntax<INodeTypeResolver>> where) { INodeTypeResolver nodeTypeResolver2 = nodeTypeResolver; if (nodeTypeResolver2 == null) { throw new ArgumentNullException("nodeTypeResolver"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeTypeResolverFactories.CreateRegistrationLocationSelector(nodeTypeResolver2.GetType(), (Nothing _) => nodeTypeResolver2)); return this; } public DeserializerBuilder WithNodeTypeResolver<TNodeTypeResolver>(WrapperFactory<INodeTypeResolver, TNodeTypeResolver> nodeTypeResolverFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeTypeResolver>> where) where TNodeTypeResolver : INodeTypeResolver { WrapperFactory<INodeTypeResolver, TNodeTypeResolver> nodeTypeResolverFactory2 = nodeTypeResolverFactory; if (nodeTypeResolverFactory2 == null) { throw new ArgumentNullException("nodeTypeResolverFactory"); } if (where == null) { throw new ArgumentNullException("where"); } where(nodeTypeResolverFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeTypeResolver), (INodeTypeResolver wrapped, Nothing _) => nodeTypeResolverFactory2(wrapped))); return this; } public DeserializerBuilder WithoutNodeTypeResolver<TNodeTypeResolver>() where TNodeTypeResolver : INodeTypeResolver { return WithoutNodeTypeResolver(typeof(TNodeTypeResolver)); } public DeserializerBuilder WithoutNodeTypeResolver(Type nodeTypeResolverType) { if (nodeTypeResolverType == null) { throw new ArgumentNullException("nodeTypeResolverType"); } nodeTypeResolverFactories.Remove(nodeTypeResolverType); return this; } public override DeserializerBuilder WithTagMapping(TagName tag, Type type) { if (tag.IsEmpty) { throw new ArgumentException("Non-specific tags cannot be maped"); } if (type == null) { throw new ArgumentNullException("type"); } if (tagMappings.TryGetValue(tag, out Type value)) { throw new ArgumentException($"Type already has a registered type '{value.FullName}' for tag '{tag}'", "tag"); } tagMappings.Add(tag, type); return this; } public DeserializerBuilder WithTypeMapping<TInterface, TConcrete>() where TConcrete : TInterface { Type typeFromHandle = typeof(TInterface); Type typeFromHandle2 = typeof(TConcrete); if (!typeFromHandle.IsAssignableFrom(typeFromHandle2)) { throw new InvalidOperationException("The type '" + typeFromHandle2.Name + "' does not implement interface '" + typeFromHandle.Name + "'."); } if (typeMappings.ContainsKey(typeFromHandle)) { typeMappings[typeFromHandle] = typeFromHandle2; } else { typeMappings.Add(typeFromHandle, typeFromHandle2); } return this; } public DeserializerBuilder WithoutTagMapping(TagName tag) { if (tag.IsEmpty) { throw new ArgumentException("Non-specific tags cannot be maped"); } if (!tagMappings.Remove(tag)) { throw new KeyNotFoundException($"Tag '{tag}' is not registered"); } return this; } public DeserializerBuilder IgnoreUnmatchedProperties() { ignoreUnmatched = true; return this; } public IDeserializer Build() { return Deserializer.FromValueDeserializer(BuildValueDeserializer()); } public IValueDeserializer BuildValueDeserializer() { return new AliasValueDeserializer(new NodeValueDeserializer(nodeDeserializerFactories.BuildComponentList(), nodeTypeResolverFactories.BuildComponentList())); } } internal sealed class EmissionPhaseObjectGraphVisitorArgs { private readonly IEnumerable<IObjectGraphVisitor<Nothing>> preProcessingPhaseVisitors; public IObjectGraphVisitor<IEmitter> InnerVisitor { get; private set; } public IEventEmitter EventEmitter { get; private set; } public ObjectSerializer N