Decompiled source of VillageNPCs v1.0.4
VillageNPCs.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using VillageNPCs.Functions; using VillageNPCs.NPCs; 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: AssemblyTitle("VillageNPCs")] [assembly: AssemblyDescription("https://valheim.thunderstore.io/package/blacks7ar/VillageNPCs/")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("blacks7ar")] [assembly: AssemblyProduct("VillageNPCs")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9BC0DC30-2202-4443-BDF8-80F1AEC9D24B")] [assembly: AssemblyFileVersion("1.0.4")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.4.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 VillageNPCs { [BepInPlugin("blacks7ar.VillageNPCs", "VillageNPCs", "1.0.4")] public class Plugin : BaseUnityPlugin { public enum Toggle { On = 1, Off = 0 } private const string modGUID = "blacks7ar.VillageNPCs"; public const string modName = "VillageNPCs"; public const string modAuthor = "blacks7ar"; public const string modVersion = "1.0.4"; public const string modLink = "https://valheim.thunderstore.io/package/blacks7ar/VillageNPCs/"; private static readonly Harmony _harmony = new Harmony("blacks7ar.VillageNPCs"); private static readonly ConfigSync _configSync = new ConfigSync("blacks7ar.VillageNPCs") { DisplayName = "VillageNPCs", CurrentVersion = "1.0.4", MinimumRequiredVersion = "1.0.4", ModRequired = true }; private static ConfigEntry<Toggle> _serverConfigLocked; public static GameObject _PrefabContainer; public static Plugin _Instance; public ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool synchronizedConfig = true) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown ConfigDescription val = new ConfigDescription(description.Description + (synchronizedConfig ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags); ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val); _configSync.AddConfigEntry<T>(val2).SynchronizedConfig = synchronizedConfig; return val2; } public void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown Localizer.Load(); _Instance = this; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; _serverConfigLocked = config("1- ServerSync", "Lock Configuration", Toggle.On, new ConfigDescription("If On, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, Array.Empty<object>())); _configSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked); PrefabContainerInit(); ConfigSetup.Init(); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; ((BaseUnityPlugin)this).Config.Save(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } public static void PrefabContainerInit() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown _PrefabContainer = new GameObject("BNpcPrefabs"); _PrefabContainer.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_PrefabContainer); } } } namespace VillageNPCs.Patches { [HarmonyPatch(typeof(Humanoid), "UseItem")] public class HumanoidPatch { private static bool Prefix(Humanoid __instance, Inventory inventory, ItemData item, bool fromInventoryGui) { //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: 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_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Invalid comparison between Unknown and I4 //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) if (inventory == null) { inventory = __instance.m_inventory; } if (!inventory.ContainsItem(item)) { return true; } GameObject hoverObject = __instance.GetHoverObject(); if ((Object.op_Implicit((Object)(object)hoverObject) ? hoverObject.GetComponentInParent<Hoverable>() : null) != null && !fromInventoryGui) { MonsterAI component = hoverObject.GetComponent<MonsterAI>(); if ((Object)(object)component != (Object)null && (((Object)((Component)component).gameObject).name.Replace("(Clone)", "") == "BVN_MaleNPC" || ((Object)((Component)component).gameObject).name.Replace("(Clone)", "") == "BVN_FemaleNPC") && component.CanConsume(item)) { Tameable component2 = hoverObject.GetComponent<Tameable>(); string text = ((((component2 != null) ? component2.GetText() : null) == "") ? ((Object)component2.m_character).name : component2.GetText()); if ((int)item.m_shared.m_itemType == 2) { if ((Object)(object)component2 != (Object)null && component2.IsHungry()) { __instance.DoInteractAnimation(hoverObject); component.m_onConsumedItem(item.m_dropPrefab.GetComponent<ItemDrop>()); Humanoid component3 = hoverObject.GetComponent<Humanoid>(); component3.m_consumeItemEffects.Create(((Component)component3).transform.position, Quaternion.identity, (Transform)null, 1f, -1); hoverObject.GetComponentInChildren<Animator>().SetTrigger("consume"); inventory.RemoveOneItem(item); ((Character)__instance).Message((MessageType)2, text + " is very happy!", 0, (Sprite)null); return false; } if (!component2.IsHungry()) { ((Character)__instance).Message((MessageType)2, text + " is not yet hungry!", 0, (Sprite)null); return false; } return false; } } } string name = ((Object)item.m_dropPrefab).name; if (!(name == "BVN_OrbOfLife1")) { if (name == "BVN_OrbOfLife2") { Object.Instantiate<GameObject>(ZNetScene.instance.GetPrefab("BVN_FemaleNPC"), ((Component)__instance).transform.position + ((Component)__instance).transform.forward + ((Component)__instance).transform.forward, Quaternion.identity); Object.Instantiate<GameObject>(ZNetScene.instance.GetPrefab("sfx_dverger_vo_idle"), ((Component)__instance).transform.position + ((Component)__instance).transform.forward + ((Component)__instance).transform.forward, Quaternion.identity); inventory.RemoveOneItem(item); ((Character)__instance).Message((MessageType)2, "A new villager has joined your village!", 0, (Sprite)null); } } else { Object.Instantiate<GameObject>(ZNetScene.instance.GetPrefab("BVN_MaleNPC"), ((Component)__instance).transform.position + ((Component)__instance).transform.forward + ((Component)__instance).transform.forward, Quaternion.identity); Object.Instantiate<GameObject>(ZNetScene.instance.GetPrefab("sfx_dverger_vo_idle"), ((Component)__instance).transform.position + ((Component)__instance).transform.forward + ((Component)__instance).transform.forward, Quaternion.identity); inventory.RemoveOneItem(item); ((Character)__instance).Message((MessageType)2, "A new villager has joined your village!", 0, (Sprite)null); } return true; } } [HarmonyPatch] public class ObjectDBPatch { [HarmonyPriority(700)] [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "Awake")] private static void Awake_Postfix(ObjectDB __instance) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (!(((Scene)(ref activeScene)).name != "main") && !((Object)(object)__instance == (Object)null) && __instance.m_items.Count > 0) { Orb.InitOrb1(__instance); Orb.InitOrb2(__instance); __instance.UpdateRegisters(); } } [HarmonyPriority(700)] [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] private static void CopyOtherDB_Postfix(ObjectDB __instance) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (!(((Scene)(ref activeScene)).name != "main") && !((Object)(object)__instance == (Object)null) && __instance.m_items.Count > 0) { Orb.InitOrb1(__instance); Orb.InitOrb2(__instance); __instance.UpdateRegisters(); } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] public class ZNetScenePatch { private static void Postfix(ZNetScene __instance) { if (!((Object)(object)__instance == (Object)null) && __instance.m_prefabs.Count > 0) { Plugin.PrefabContainerInit(); Male.Init(__instance); Female.Init(__instance); } } } } namespace VillageNPCs.NPCs { public static class Female { public static void Init(ZNetScene zNetScene) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown GameObject val = zNetScene.GetPrefab("Player").Clone("BVN_FemaleNPC"); val.transform.SetParent(Plugin._PrefabContainer.transform, false); val.RemoveComponent(typeof(PlayerController)); val.RemoveComponent(typeof(Player)); val.RemoveComponent(typeof(Talker)); val.RemoveComponent(typeof(Skills)); Humanoid val2 = val.AddComponent<Humanoid>(); SetHumanoid(val2, zNetScene); SetMonsterAI(val.AddComponent<MonsterAI>(), zNetScene); ZNetView component = val.GetComponent<ZNetView>(); component.m_persistent = true; component.m_distant = false; component.m_type = (ObjectType)0; component.m_syncInitialScale = false; ZSyncTransform component2 = val.GetComponent<ZSyncTransform>(); component2.m_syncPosition = true; component2.m_syncRotation = true; component2.m_syncScale = false; component2.m_syncBodyVelocity = false; component2.m_characterParentSync = false; val.GetComponent<ZSyncAnimation>().m_smoothCharacterSpeeds = true; val.AddComponent<FemaleNPC>(); SetTameable(val.AddComponent<Tameable>(), zNetScene); SetNpcTalk(val.AddComponent<NpcTalk>(), (Character)(object)val2); val.AddComponent<RandomAnimation>().m_values = new List<RandomValue>(1) { new RandomValue { m_name = "idle", m_values = 5, m_interval = 3f, m_floatValue = false, m_floatTransition = 1f } }; zNetScene.AddClonedObject(val); } private static void SetHumanoid(Humanoid humanoid, ZNetScene zNetScene) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: 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_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Expected O, but got Unknown //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: 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_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: 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_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Expected O, but got Unknown ((Character)humanoid).m_group = "VillageNpc_Female"; ((Character)humanoid).m_name = "$bvn_villagerfemale"; ((Character)humanoid).m_faction = (Faction)0; ((Character)humanoid).m_crouchSpeed = 2f; ((Character)humanoid).m_walkSpeed = 1.6f; ((Character)humanoid).m_speed = 4f; ((Character)humanoid).m_turnSpeed = 300f; ((Character)humanoid).m_runSpeed = 7f; ((Character)humanoid).m_runTurnSpeed = 300f; ((Character)humanoid).m_acceleration = 0.8f; ((Character)humanoid).m_jumpForce = 8f; ((Character)humanoid).m_jumpForceForward = 2f; ((Character)humanoid).m_jumpForceTiredFactor = 0.6f; ((Character)humanoid).m_canSwim = true; ((Character)humanoid).m_swimDepth = 1.5f; ((Character)humanoid).m_swimSpeed = 2f; ((Character)humanoid).m_swimTurnSpeed = 100f; ((Character)humanoid).m_swimAcceleration = 0.05f; ((Character)humanoid).m_groundTilt = (GroundTiltType)0; ((Character)humanoid).m_groundTiltSpeed = 50f; ((Character)humanoid).m_eye = Utils.FindChild(((Component)humanoid).gameObject.transform, "EyePos", (IterativeSearchType)0); ((Character)humanoid).m_hitEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[2] { new EffectData { m_prefab = zNetScene.GetPrefab("vfx_player_hit"), m_enabled = true, m_variant = -1 }, new EffectData { m_prefab = zNetScene.GetPrefab("sfx_hit"), m_enabled = true, m_variant = -1 } }; ((Character)humanoid).m_critHitEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("fx_crit"), m_enabled = true, m_variant = -1 } }; ((Character)humanoid).m_backstabHitEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("fx_backstab"), m_enabled = true, m_variant = -1 } }; ((Character)humanoid).m_deathEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[2] { new EffectData { m_prefab = zNetScene.GetPrefab("vfx_ghost_death"), m_enabled = true, m_variant = -1 }, new EffectData { m_prefab = zNetScene.GetPrefab("sfx_ghost_death"), m_enabled = true, m_variant = -1 } }; ((Character)humanoid).m_tolerateWater = true; ((Character)humanoid).m_health = 100f; ((Character)humanoid).m_damageModifiers = new DamageModifiers { m_blunt = (DamageModifier)0, m_slash = (DamageModifier)0, m_pierce = (DamageModifier)0, m_chop = (DamageModifier)3, m_pickaxe = (DamageModifier)3, m_fire = (DamageModifier)0, m_frost = (DamageModifier)0, m_lightning = (DamageModifier)0, m_spirit = (DamageModifier)3 }; ((Character)humanoid).m_staggerWhenBlocked = true; ((Character)humanoid).m_staggerDamageFactor = 0.4f; humanoid.m_consumeItemEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("sfx_creature_consume"), m_enabled = true, m_variant = -1 } }; } private static void SetMonsterAI(MonsterAI monsterAI, ZNetScene zNetScene) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) ((BaseAI)monsterAI).m_viewRange = 40f; ((BaseAI)monsterAI).m_viewAngle = 90f; ((BaseAI)monsterAI).m_hearRange = 9999f; ((BaseAI)monsterAI).m_mistVision = false; ((BaseAI)monsterAI).m_alertedEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("sfx_dverger_vo_alerted"), m_enabled = true, m_variant = -1 } }; ((BaseAI)monsterAI).m_idleSound.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("sfx_dverger_vo_idle"), m_enabled = true, m_variant = 0 } }; ((BaseAI)monsterAI).m_idleSoundInterval = 10f; ((BaseAI)monsterAI).m_idleSoundChance = 0.5f; ((BaseAI)monsterAI).m_pathAgentType = (AgentType)1; ((BaseAI)monsterAI).m_moveMinAngle = 90f; ((BaseAI)monsterAI).m_smoothMovement = true; ((BaseAI)monsterAI).m_serpentMovement = false; ((BaseAI)monsterAI).m_jumpInterval = 0f; ((BaseAI)monsterAI).m_randomCircleInterval = 2f; ((BaseAI)monsterAI).m_randomMoveInterval = 20f; ((BaseAI)monsterAI).m_randomMoveRange = 30f; ((BaseAI)monsterAI).m_avoidFire = false; ((BaseAI)monsterAI).m_afraidOfFire = false; ((BaseAI)monsterAI).m_avoidWater = true; ((BaseAI)monsterAI).m_aggravatable = false; monsterAI.m_alertRange = 5f; monsterAI.m_fleeIfHurtWhenTargetCantBeReached = true; monsterAI.m_fleeIfNotAlerted = false; monsterAI.m_fleeIfLowHealth = 0f; monsterAI.m_circulateWhileCharging = false; monsterAI.m_circulateWhileChargingFlying = false; monsterAI.m_enableHuntPlayer = false; monsterAI.m_attackPlayerObjects = false; monsterAI.m_privateAreaTriggerTreshold = 5; monsterAI.m_interceptTimeMax = 2f; monsterAI.m_interceptTimeMin = 0f; monsterAI.m_maxChaseDistance = 0f; monsterAI.m_minAttackInterval = 0f; monsterAI.m_circleTargetInterval = 5f; monsterAI.m_circleTargetDuration = 2f; monsterAI.m_circleTargetDistance = 5f; monsterAI.m_consumeItems = new List<ItemDrop>(8) { ObjectDB.instance.GetItemPrefab("CookedMeat").GetComponent<ItemDrop>(), ObjectDB.instance.GetItemPrefab("CookedWolfMeat").GetComponent<ItemDrop>(), ObjectDB.instance.GetItemPrefab("CookedLoxMeat").GetComponent<ItemDrop>(), ObjectDB.instance.GetItemPrefab("CookedDeerMeat").GetComponent<ItemDrop>(), ObjectDB.instance.GetItemPrefab("CookedChickenMeat").GetComponent<ItemDrop>(), ObjectDB.instance.GetItemPrefab("CookedEgg").GetComponent<ItemDrop>(), ObjectDB.instance.GetItemPrefab("CookedHareMeat").GetComponent<ItemDrop>(), ObjectDB.instance.GetItemPrefab("FishCooked").GetComponent<ItemDrop>() }; monsterAI.m_consumeRange = 1.4f; monsterAI.m_consumeSearchRange = 20f; monsterAI.m_consumeSearchInterval = 10f; } private static void SetTameable(Tameable tameable, ZNetScene zNetScene) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown tameable.m_fedDuration = 600f; tameable.m_tamingTime = 1800f; tameable.m_tamedEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("fx_creature_tamed"), m_enabled = true, m_variant = -1 } }; tameable.m_sootheEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("vfx_creature_soothed"), m_enabled = true, m_variant = -1 } }; tameable.m_petEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("sfx_dverger_vo_idle"), m_enabled = true, m_variant = 0 } }; tameable.m_commandable = true; } private static void SetNpcTalk(NpcTalk npcTalk, Character character) { List<string> randomTalk = new List<string> { "$bvn_randomtalk1", "$bvn_randomtalk2", "$bvn_randomtalk3", "$bvn_randomtalk4", "$bvn_randomtalk5", "$bvn_randomtalk6", "$bvn_randomtalk7", "$bvn_randomtalk8", "$bvn_randomtalk9", "$bvn_randomtalk10" }; List<string> randomGreets = new List<string> { "$bvn_randomgreet1", "$bvn_randomgreet2", "$bvn_randomgreet3", "$bvn_randomgreet4", "$bvn_randomgreet5", "$bvn_randomgreet6" }; List<string> randomGoodbye = new List<string> { "$bvn_randombye1", "$bvn_randombye2", "$bvn_randombye3", "$bvn_randombye4", "$bvn_randombye5" }; npcTalk.m_name = character.m_name; npcTalk.m_maxRange = 20f; npcTalk.m_greetRange = 10f; npcTalk.m_byeRange = 15f; npcTalk.m_offset = 2.2f; npcTalk.m_minTalkInterval = 3f; npcTalk.m_hideDialogDelay = 9f; npcTalk.m_randomTalkInterval = 30f; npcTalk.m_randomTalkChance = 0.75f; npcTalk.m_randomTalk = randomTalk; npcTalk.m_randomGreets = randomGreets; npcTalk.m_randomGoodbye = randomGoodbye; } } public static class Male { public static void Init(ZNetScene zNetScene) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown GameObject val = zNetScene.GetPrefab("Player").Clone("BVN_MaleNPC"); val.transform.SetParent(Plugin._PrefabContainer.transform, false); val.RemoveComponent(typeof(PlayerController)); val.RemoveComponent(typeof(Player)); val.RemoveComponent(typeof(Talker)); val.RemoveComponent(typeof(Skills)); Humanoid val2 = val.AddComponent<Humanoid>(); SetHumanoid(val2, zNetScene); SetMonsterAI(val.AddComponent<MonsterAI>(), zNetScene); ZNetView component = val.GetComponent<ZNetView>(); component.m_persistent = true; component.m_distant = false; component.m_type = (ObjectType)0; component.m_syncInitialScale = false; ZSyncTransform component2 = val.GetComponent<ZSyncTransform>(); component2.m_syncPosition = true; component2.m_syncRotation = true; component2.m_syncScale = false; component2.m_syncBodyVelocity = false; component2.m_characterParentSync = false; val.GetComponent<ZSyncAnimation>().m_smoothCharacterSpeeds = true; val.AddComponent<MaleNPC>(); SetTameable(val.AddComponent<Tameable>(), zNetScene); SetNpcTalk(val.AddComponent<NpcTalk>(), (Character)(object)val2); val.AddComponent<RandomAnimation>().m_values = new List<RandomValue>(1) { new RandomValue { m_name = "idle", m_values = 5, m_interval = 3f, m_floatValue = false, m_floatTransition = 1f } }; zNetScene.AddClonedObject(val); } private static void SetHumanoid(Humanoid humanoid, ZNetScene zNetScene) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: 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_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Expected O, but got Unknown //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: 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_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: 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_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Expected O, but got Unknown ((Character)humanoid).m_group = "VillageNpc_Male"; ((Character)humanoid).m_name = "$bvn_villagermale"; ((Character)humanoid).m_faction = (Faction)0; ((Character)humanoid).m_crouchSpeed = 2f; ((Character)humanoid).m_walkSpeed = 1.6f; ((Character)humanoid).m_speed = 4f; ((Character)humanoid).m_turnSpeed = 300f; ((Character)humanoid).m_runSpeed = 7f; ((Character)humanoid).m_runTurnSpeed = 300f; ((Character)humanoid).m_acceleration = 0.8f; ((Character)humanoid).m_jumpForce = 8f; ((Character)humanoid).m_jumpForceForward = 2f; ((Character)humanoid).m_jumpForceTiredFactor = 0.6f; ((Character)humanoid).m_canSwim = true; ((Character)humanoid).m_swimDepth = 1.5f; ((Character)humanoid).m_swimSpeed = 2f; ((Character)humanoid).m_swimTurnSpeed = 100f; ((Character)humanoid).m_swimAcceleration = 0.05f; ((Character)humanoid).m_groundTilt = (GroundTiltType)0; ((Character)humanoid).m_groundTiltSpeed = 50f; ((Character)humanoid).m_eye = Utils.FindChild(((Component)humanoid).gameObject.transform, "EyePos", (IterativeSearchType)0); ((Character)humanoid).m_hitEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[2] { new EffectData { m_prefab = zNetScene.GetPrefab("vfx_player_hit"), m_enabled = true, m_variant = -1 }, new EffectData { m_prefab = zNetScene.GetPrefab("sfx_hit"), m_enabled = true, m_variant = -1 } }; ((Character)humanoid).m_critHitEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("fx_crit"), m_enabled = true, m_variant = -1 } }; ((Character)humanoid).m_backstabHitEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("fx_backstab"), m_enabled = true, m_variant = -1 } }; ((Character)humanoid).m_deathEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[2] { new EffectData { m_prefab = zNetScene.GetPrefab("vfx_ghost_death"), m_enabled = true, m_variant = -1 }, new EffectData { m_prefab = zNetScene.GetPrefab("sfx_ghost_death"), m_enabled = true, m_variant = -1 } }; ((Character)humanoid).m_tolerateWater = true; ((Character)humanoid).m_health = 100f; ((Character)humanoid).m_damageModifiers = new DamageModifiers { m_blunt = (DamageModifier)0, m_slash = (DamageModifier)0, m_pierce = (DamageModifier)0, m_chop = (DamageModifier)3, m_pickaxe = (DamageModifier)3, m_fire = (DamageModifier)0, m_frost = (DamageModifier)0, m_lightning = (DamageModifier)0, m_spirit = (DamageModifier)3 }; ((Character)humanoid).m_staggerWhenBlocked = true; ((Character)humanoid).m_staggerDamageFactor = 0.4f; humanoid.m_consumeItemEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("sfx_creature_consume"), m_enabled = true, m_variant = -1 } }; } private static void SetMonsterAI(MonsterAI monsterAI, ZNetScene zNetScene) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) ((BaseAI)monsterAI).m_viewRange = 40f; ((BaseAI)monsterAI).m_viewAngle = 90f; ((BaseAI)monsterAI).m_hearRange = 9999f; ((BaseAI)monsterAI).m_mistVision = false; ((BaseAI)monsterAI).m_alertedEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("sfx_dverger_vo_alerted"), m_enabled = true, m_variant = -1 } }; ((BaseAI)monsterAI).m_idleSound.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("sfx_dverger_vo_idle"), m_enabled = true, m_variant = 0 } }; ((BaseAI)monsterAI).m_idleSoundInterval = 10f; ((BaseAI)monsterAI).m_idleSoundChance = 0.5f; ((BaseAI)monsterAI).m_pathAgentType = (AgentType)1; ((BaseAI)monsterAI).m_moveMinAngle = 90f; ((BaseAI)monsterAI).m_smoothMovement = true; ((BaseAI)monsterAI).m_serpentMovement = false; ((BaseAI)monsterAI).m_jumpInterval = 0f; ((BaseAI)monsterAI).m_randomCircleInterval = 2f; ((BaseAI)monsterAI).m_randomMoveInterval = 20f; ((BaseAI)monsterAI).m_randomMoveRange = 30f; ((BaseAI)monsterAI).m_avoidFire = false; ((BaseAI)monsterAI).m_afraidOfFire = false; ((BaseAI)monsterAI).m_avoidWater = true; ((BaseAI)monsterAI).m_aggravatable = false; monsterAI.m_alertRange = 5f; monsterAI.m_fleeIfHurtWhenTargetCantBeReached = true; monsterAI.m_fleeIfNotAlerted = false; monsterAI.m_fleeIfLowHealth = 0f; monsterAI.m_circulateWhileCharging = false; monsterAI.m_circulateWhileChargingFlying = false; monsterAI.m_enableHuntPlayer = false; monsterAI.m_attackPlayerObjects = false; monsterAI.m_privateAreaTriggerTreshold = 5; monsterAI.m_interceptTimeMax = 2f; monsterAI.m_interceptTimeMin = 0f; monsterAI.m_maxChaseDistance = 0f; monsterAI.m_minAttackInterval = 0f; monsterAI.m_circleTargetInterval = 5f; monsterAI.m_circleTargetDuration = 2f; monsterAI.m_circleTargetDistance = 5f; monsterAI.m_consumeItems = new List<ItemDrop>(8) { ObjectDB.instance.GetItemPrefab("CookedMeat").GetComponent<ItemDrop>(), ObjectDB.instance.GetItemPrefab("CookedWolfMeat").GetComponent<ItemDrop>(), ObjectDB.instance.GetItemPrefab("CookedLoxMeat").GetComponent<ItemDrop>(), ObjectDB.instance.GetItemPrefab("CookedDeerMeat").GetComponent<ItemDrop>(), ObjectDB.instance.GetItemPrefab("CookedChickenMeat").GetComponent<ItemDrop>(), ObjectDB.instance.GetItemPrefab("CookedEgg").GetComponent<ItemDrop>(), ObjectDB.instance.GetItemPrefab("CookedHareMeat").GetComponent<ItemDrop>(), ObjectDB.instance.GetItemPrefab("FishCooked").GetComponent<ItemDrop>() }; monsterAI.m_consumeRange = 1.4f; monsterAI.m_consumeSearchRange = 20f; monsterAI.m_consumeSearchInterval = 10f; } private static void SetTameable(Tameable tameable, ZNetScene zNetScene) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown tameable.m_fedDuration = 600f; tameable.m_tamingTime = 1800f; tameable.m_tamedEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("fx_creature_tamed"), m_enabled = true, m_variant = -1 } }; tameable.m_sootheEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("vfx_creature_soothed"), m_enabled = true, m_variant = -1 } }; tameable.m_petEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = zNetScene.GetPrefab("sfx_dverger_vo_idle"), m_enabled = true, m_variant = 0 } }; tameable.m_commandable = true; } private static void SetNpcTalk(NpcTalk npcTalk, Character character) { List<string> randomTalk = new List<string> { "$bvn_randomtalk1", "$bvn_randomtalk2", "$bvn_randomtalk3", "$bvn_randomtalk4", "$bvn_randomtalk5", "$bvn_randomtalk6", "$bvn_randomtalk7", "$bvn_randomtalk8", "$bvn_randomtalk9", "$bvn_randomtalk10" }; List<string> randomGreets = new List<string> { "$bvn_randomgreet1", "$bvn_randomgreet2", "$bvn_randomgreet3", "$bvn_randomgreet4", "$bvn_randomgreet5", "$bvn_randomgreet6" }; List<string> randomGoodbye = new List<string> { "$bvn_randombye1", "$bvn_randombye2", "$bvn_randombye3", "$bvn_randombye4", "$bvn_randombye5" }; npcTalk.m_name = character.m_name; npcTalk.m_maxRange = 20f; npcTalk.m_greetRange = 10f; npcTalk.m_byeRange = 15f; npcTalk.m_offset = 2.2f; npcTalk.m_minTalkInterval = 3f; npcTalk.m_hideDialogDelay = 9f; npcTalk.m_randomTalkInterval = 30f; npcTalk.m_randomTalkChance = 0.75f; npcTalk.m_randomTalk = randomTalk; npcTalk.m_randomGreets = randomGreets; npcTalk.m_randomGoodbye = randomGoodbye; } } public static class Orb { public static void InitOrb1(ObjectDB objectDB) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Expected O, but got Unknown //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_023d: 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_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Expected O, but got Unknown //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: 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_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: 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_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Expected O, but got Unknown GameObject val = objectDB.GetItemPrefab("Eitr").CloneItem("BVN_OrbOfLife1"); val.transform.localScale = new Vector3(1.75f, 1.75f, 1.75f); ((Component)Utils.FindChild(val.transform, "Radiator", (IterativeSearchType)0)).gameObject.SetActive(false); ItemDrop component = val.GetComponent<ItemDrop>(); component.m_itemData.m_shared.m_name = "$bvn_orboflife1"; component.m_itemData.m_shared.m_itemType = (ItemType)2; component.m_itemData.m_shared.m_description = "$bvn_orboflife1_description"; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_teleportable = false; objectDB.AddClonedObject(val); ZNetScene instance = ZNetScene.instance; if (Object.op_Implicit((Object)(object)instance)) { instance.AddClonedObject(val); } Recipe val2 = ScriptableObject.CreateInstance<Recipe>(); ((Object)val2).name = "Recipe_" + ((Object)val).name; val2.m_item = component; val2.m_amount = 1; val2.m_enabled = ConfigSetup._enableOrb1.Value == Plugin.Toggle.On; val2.m_qualityResultAmountMultiplier = 1f; val2.m_craftingStation = instance.GetPrefab("piece_workbench").GetComponent<CraftingStation>(); val2.m_repairStation = null; val2.m_minStationLevel = 1; val2.m_requireOnlyOneIngredient = false; string[] array = ConfigSetup._orb1Mat1.Value.Split(':', ' '); string[] array2 = ConfigSetup._orb1Mat2.Value.Split(':', ' '); string[] array3 = ConfigSetup._orb1Mat3.Value.Split(':', ' '); string[] array4 = ConfigSetup._orb1Mat4.Value.Split(':', ' '); val2.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 = 0, m_recover = true } }; objectDB.AddRecipe(val2); } public static void InitOrb2(ObjectDB objectDB) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Expected O, but got Unknown //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_023d: 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_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Expected O, but got Unknown //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: 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_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: 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_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Expected O, but got Unknown GameObject val = objectDB.GetItemPrefab("Eitr").CloneItem("BVN_OrbOfLife2"); val.transform.localScale = new Vector3(1.75f, 1.75f, 1.75f); ((Component)Utils.FindChild(val.transform, "Radiator", (IterativeSearchType)0)).gameObject.SetActive(false); ItemDrop component = val.GetComponent<ItemDrop>(); component.m_itemData.m_shared.m_name = "$bvn_orboflife2"; component.m_itemData.m_shared.m_itemType = (ItemType)2; component.m_itemData.m_shared.m_description = "$bvn_orboflife2_description"; component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_teleportable = false; objectDB.AddClonedObject(val); ZNetScene instance = ZNetScene.instance; if (Object.op_Implicit((Object)(object)instance)) { instance.AddClonedObject(val); } Recipe val2 = ScriptableObject.CreateInstance<Recipe>(); ((Object)val2).name = "Recipe_" + ((Object)val).name; val2.m_item = component; val2.m_amount = 1; val2.m_enabled = ConfigSetup._enableOrb2.Value == Plugin.Toggle.On; val2.m_qualityResultAmountMultiplier = 1f; val2.m_craftingStation = instance.GetPrefab("piece_workbench").GetComponent<CraftingStation>(); val2.m_repairStation = null; val2.m_minStationLevel = 1; val2.m_requireOnlyOneIngredient = false; string[] array = ConfigSetup._orb2Mat1.Value.Split(':', ' '); string[] array2 = ConfigSetup._orb2Mat2.Value.Split(':', ' '); string[] array3 = ConfigSetup._orb2Mat3.Value.Split(':', ' '); string[] array4 = ConfigSetup._orb2Mat4.Value.Split(':', ' '); val2.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 = 0, m_recover = true } }; objectDB.AddRecipe(val2); } } } namespace VillageNPCs.Functions { public static class ConfigSetup { public static ConfigEntry<Plugin.Toggle> _enableOrb1; public static ConfigEntry<string> _orb1Mat1; public static ConfigEntry<string> _orb1Mat2; public static ConfigEntry<string> _orb1Mat3; public static ConfigEntry<string> _orb1Mat4; public static ConfigEntry<Plugin.Toggle> _enableOrb2; public static ConfigEntry<string> _orb2Mat1; public static ConfigEntry<string> _orb2Mat2; public static ConfigEntry<string> _orb2Mat3; public static ConfigEntry<string> _orb2Mat4; private const string _enableDesc = "Enable/Disables recipe. (Needs logout)"; private const string _amountDesc = "Craft amount (Needs logout)"; private const string _matDesc = "Item name : amount (Needs logout)"; private static Localization english; public static void Init() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown english = new Localization(); english.SetupLanguage("English"); string group = english.Localize("$bvn_orboflife1"); _enableOrb1 = Plugin._Instance.config(group, "Recipe", Plugin.Toggle.On, new ConfigDescription("Enable/Disables recipe. (Needs logout)", (AcceptableValueBase)null, Array.Empty<object>())); _orb1Mat1 = Plugin._Instance.config(group, "Required Material 1", "TrophyTheElder:1", new ConfigDescription("Item name : amount (Needs logout)", (AcceptableValueBase)null, Array.Empty<object>())); _orb1Mat2 = Plugin._Instance.config(group, "Required Material 2", "HardAntler:1", new ConfigDescription("Item name : amount (Needs logout)", (AcceptableValueBase)null, Array.Empty<object>())); _orb1Mat3 = Plugin._Instance.config(group, "Required Material 3", "AncientSeed:1", new ConfigDescription("Item name : amount (Needs logout)", (AcceptableValueBase)null, Array.Empty<object>())); _orb1Mat4 = Plugin._Instance.config(group, "Required Material 4", "Bloodbag:1", new ConfigDescription("Item name : amount (Needs logout)", (AcceptableValueBase)null, Array.Empty<object>())); string group2 = english.Localize("$bvn_orboflife2"); _enableOrb2 = Plugin._Instance.config(group2, "Recipe", Plugin.Toggle.On, new ConfigDescription("Enable/Disables recipe. (Needs logout)", (AcceptableValueBase)null, Array.Empty<object>())); _orb2Mat1 = Plugin._Instance.config(group2, "Required Material 1", "TrophyTheElder:1", new ConfigDescription("Item name : amount (Needs logout)", (AcceptableValueBase)null, Array.Empty<object>())); _orb2Mat2 = Plugin._Instance.config(group2, "Required Material 2", "HardAntler:1", new ConfigDescription("Item name : amount (Needs logout)", (AcceptableValueBase)null, Array.Empty<object>())); _orb2Mat3 = Plugin._Instance.config(group2, "Required Material 3", "AncientSeed:1", new ConfigDescription("Item name : amount (Needs logout)", (AcceptableValueBase)null, Array.Empty<object>())); _orb2Mat4 = Plugin._Instance.config(group2, "Required Material 4", "Bloodbag:1", new ConfigDescription("Item name : amount (Needs logout)", (AcceptableValueBase)null, Array.Empty<object>())); } } public class FemaleNPC : MonoBehaviour { public string[] m_hairItem = new string[31] { "Hair1", "Hair2", "Hair3", "Hair4", "Hair5", "Hair6", "Hair7", "Hair8", "Hair9", "Hair10", "Hair11", "Hair12", "Hair13", "Hair14", "Hair15", "Hair16", "Hair17", "Hair18", "Hair19", "Hair20", "Hair21", "Hair22", "Hair23", "Hair24", "Hair25", "Hair26", "Hair27", "Hair28", "Hair29", "Hair30", "Hair31" }; public string[] m_helmetItem = new string[13] { "HelmetFishingHat", "HelmetHat1", "HelmetHat2", "HelmetHat3", "HelmetHat4", "HelmetHat5", "HelmetHat6", "HelmetHat7", "HelmetHat8", "HelmetHat9", "HelmetHat10", "HelmetMidsummerCrown", "HelmetYule" }; public string[] m_chestItem = new string[10] { "ArmorDress1", "ArmorDress2", "ArmorDress3", "ArmorDress4", "ArmorDress5", "ArmorDress6", "ArmorDress7", "ArmorDress8", "ArmorDress9", "ArmorDress10" }; public string[] m_legItem = new string[10] { "ArmorBronzeLegs", "ArmorCarapaceLegs", "ArmorFenringLegs", "ArmorIronLegs", "ArmorLeatherLegs", "ArmorMageLegs", "ArmorPaddedGreaves", "ArmorRagsLegs", "ArmorRootLegs", "ArmorTrollLeatherLegs" }; private ZNetView m_nview; private VisEquipment m_visEquipment; private Humanoid m_humanoid; private readonly int m_npcInitialized = StringExtensionMethods.GetStableHashCode("NpcInitialized"); private void Awake() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) m_nview = ((Component)this).GetComponent<ZNetView>(); m_visEquipment = ((Component)this).GetComponent<VisEquipment>(); m_humanoid = ((Component)this).GetComponent<Humanoid>(); Vector3 position = ((Component)this).gameObject.transform.position; Helper._baseNumber += (int)((position.x + position.y) * 1000f); SetupVisuals(); SetupEquipment(); m_visEquipment.UpdateEquipmentVisuals(); m_nview.GetZDO().Set(m_npcInitialized, true); if ((Object)(object)m_nview != (Object)null && m_nview.IsValid()) { ((Character)m_humanoid).SetTamed(true); _ = m_humanoid.m_inventory; } } private void SetItem(string slot, string[] name) { ZNetView nview = m_nview; if (nview != null) { nview.GetZDO().Set(slot, StringExtensionMethods.GetStableHashCode(name.GetRandomElement())); } } private void SetupVisuals() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) if (!m_nview.GetZDO().GetBool(m_npcInitialized, false)) { m_visEquipment.m_nview = m_nview; float num = 0.2f + 0.8f.RandomValue(); Color val = Color.HSVToRGB(0.13f + 0.03f.RandomValue(), 1f.RandomValue(), 1f.RandomValue()); m_visEquipment.SetModel(1); SetItem("HairItem", m_hairItem); VisEquipment visEquipment = m_visEquipment; if (visEquipment != null) { visEquipment.SetHairItem(""); } VisEquipment visEquipment2 = m_visEquipment; if (visEquipment2 != null) { visEquipment2.SetHairItem(m_hairItem.GetRandomElement()); } VisEquipment visEquipment3 = m_visEquipment; if (visEquipment3 != null) { visEquipment3.SetHairColor(new Vector3(val.r, val.g, val.b)); } VisEquipment visEquipment4 = m_visEquipment; if (visEquipment4 != null) { visEquipment4.SetSkinColor(new Vector3(num, num, num)); } } } private void SetupEquipment() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if (!m_nview.GetZDO().GetBool(m_npcInitialized, false)) { ItemSet[] array = new ItemSet[1]; ItemSet val = new ItemSet(); val.m_items = (GameObject[])(object)new GameObject[3] { ObjectDB.instance.GetItemPrefab(m_helmetItem.GetRandomElement()), ObjectDB.instance.GetItemPrefab(m_chestItem.GetRandomElement()), ObjectDB.instance.GetItemPrefab(m_legItem.GetRandomElement()) }; array[0] = val; ItemSet[] randomSets = (ItemSet[])(object)array; m_humanoid.m_randomSets = randomSets; } } } public static class Helper { public static int _baseNumber; public static GameObject Clone(this GameObject gameObject, string name) { GameObject obj = Object.Instantiate<GameObject>(gameObject, Plugin._PrefabContainer.transform, false); ((Object)obj).name = name; obj.transform.SetParent(Plugin._PrefabContainer.transform, false); return obj; } public static GameObject CloneItem(this GameObject gameObject, string name) { GameObject obj = Object.Instantiate<GameObject>(gameObject, Plugin._PrefabContainer.transform, false); ((Object)obj).name = name; return obj; } public static void AddClonedObject(this ZNetScene zNetScene, GameObject gameObject, bool overWrite = true) { GameObject prefab; if ((Object)(object)(prefab = zNetScene.GetPrefab(((Object)gameObject).name)) != (Object)null) { if (!overWrite) { return; } zNetScene.m_prefabs.Remove(prefab); zNetScene.m_namedPrefabs.Remove(StringExtensionMethods.GetStableHashCode(((Object)gameObject).name)); } zNetScene.m_prefabs.Add(gameObject); zNetScene.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)gameObject).name), gameObject); } public static void AddClonedObject(this ObjectDB objectDB, GameObject gameObject, bool overWrite = true) { GameObject itemPrefab; if ((Object)(object)(itemPrefab = objectDB.GetItemPrefab(((Object)gameObject).name)) != (Object)null) { if (!overWrite) { return; } objectDB.m_items.Remove(itemPrefab); objectDB.m_itemByHash.Remove(StringExtensionMethods.GetStableHashCode(((Object)gameObject).name)); } objectDB.m_items.Add(gameObject); objectDB.m_itemByHash.Add(StringExtensionMethods.GetStableHashCode(((Object)gameObject).name), gameObject); } public static 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 float RandomValue(this float value) { _baseNumber++; Random.InitState((int)((Time.time + value) * 1000f) + _baseNumber); return value * Random.value; } private static int RandomValue(this int value) { _baseNumber++; Random.InitState((int)((Time.time + (float)value) * 1000f) + _baseNumber); return Mathf.FloorToInt(Random.Range(0f, (float)value - 0.0001f)); } public static string GetRandomElement(this string[] array) { return array[array.Length.RandomValue()]; } public static void RemoveComponent(this GameObject gameObject, Type type) { Component component = gameObject.GetComponent(type); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } } } public class MaleNPC : MonoBehaviour { public string[] m_beardItem = new string[20] { "Beard2", "Beard3", "Beard4", "Beard5", "Beard6", "Beard7", "Beard8", "Beard9", "Beard10", "Beard11", "Beard12", "Beard13", "Beard14", "Beard15", "Beard16", "Beard17", "Beard18", "Beard19", "Beard20", "Beard21" }; public string[] m_hairItem = new string[31] { "Hair1", "Hair2", "Hair3", "Hair4", "Hair5", "Hair6", "Hair7", "Hair8", "Hair9", "Hair10", "Hair11", "Hair12", "Hair13", "Hair14", "Hair15", "Hair16", "Hair17", "Hair18", "Hair19", "Hair20", "Hair21", "Hair22", "Hair23", "Hair24", "Hair25", "Hair26", "Hair27", "Hair28", "Hair29", "Hair30", "Hair31" }; public string[] m_helmetItem = new string[13] { "HelmetFishingHat", "HelmetHat1", "HelmetHat2", "HelmetHat3", "HelmetHat4", "HelmetHat5", "HelmetHat6", "HelmetHat7", "HelmetHat8", "HelmetHat9", "HelmetHat10", "HelmetMidsummerCrown", "HelmetYule" }; public string[] m_chestItem = new string[10] { "ArmorTunic1", "ArmorTunic2", "ArmorTunic3", "ArmorTunic4", "ArmorTunic5", "ArmorTunic6", "ArmorTunic7", "ArmorTunic8", "ArmorTunic9", "ArmorTunic10" }; public string[] m_legItem = new string[10] { "ArmorBronzeLegs", "ArmorCarapaceLegs", "ArmorFenringLegs", "ArmorIronLegs", "ArmorLeatherLegs", "ArmorMageLegs", "ArmorPaddedGreaves", "ArmorRagsLegs", "ArmorRootLegs", "ArmorTrollLeatherLegs" }; private ZNetView m_nview; private VisEquipment m_visEquipment; private Humanoid m_humanoid; private readonly int m_npcInitialized = StringExtensionMethods.GetStableHashCode("NpcInitialized"); private void Awake() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) m_nview = ((Component)this).GetComponent<ZNetView>(); m_visEquipment = ((Component)this).GetComponent<VisEquipment>(); m_humanoid = ((Component)this).GetComponent<Humanoid>(); Vector3 position = ((Component)this).gameObject.transform.position; Helper._baseNumber += (int)((position.x + position.y) * 1000f); SetupVisuals(); SetupEquipment(); m_visEquipment.UpdateEquipmentVisuals(); m_nview.GetZDO().Set(m_npcInitialized, true); if ((Object)(object)m_nview != (Object)null && m_nview.IsValid()) { ((Character)m_humanoid).SetTamed(true); } } private void SetItem(string slot, string[] name) { ZNetView nview = m_nview; if (nview != null) { nview.GetZDO().Set(slot, StringExtensionMethods.GetStableHashCode(name.GetRandomElement())); } } private void SetupVisuals() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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) if (!m_nview.GetZDO().GetBool(m_npcInitialized, false)) { m_visEquipment.m_nview = m_nview; float num = 0.2f + 0.8f.RandomValue(); Color val = Color.HSVToRGB(0.13f + 0.03f.RandomValue(), 1f.RandomValue(), 1f.RandomValue()); m_visEquipment.SetModel(0); SetItem("HairItem", m_hairItem); VisEquipment visEquipment = m_visEquipment; if (visEquipment != null) { visEquipment.SetHairItem(""); } VisEquipment visEquipment2 = m_visEquipment; if (visEquipment2 != null) { visEquipment2.SetHairItem(m_hairItem.GetRandomElement()); } SetItem("BeardItem", m_beardItem); VisEquipment visEquipment3 = m_visEquipment; if (visEquipment3 != null) { visEquipment3.SetBeardItem(""); } VisEquipment visEquipment4 = m_visEquipment; if (visEquipment4 != null) { visEquipment4.SetBeardItem(m_beardItem.GetRandomElement()); } VisEquipment visEquipment5 = m_visEquipment; if (visEquipment5 != null) { visEquipment5.SetHairColor(new Vector3(val.r, val.g, val.b)); } VisEquipment visEquipment6 = m_visEquipment; if (visEquipment6 != null) { visEquipment6.SetSkinColor(new Vector3(num, num, num)); } } } private void SetupEquipment() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if (!m_nview.GetZDO().GetBool(m_npcInitialized, false)) { ItemSet[] array = new ItemSet[1]; ItemSet val = new ItemSet(); val.m_items = (GameObject[])(object)new GameObject[3] { ObjectDB.instance.GetItemPrefab(m_helmetItem.GetRandomElement()), ObjectDB.instance.GetItemPrefab(m_chestItem.GetRandomElement()), ObjectDB.instance.GetItemPrefab(m_legItem.GetRandomElement()) }; array[0] = val; ItemSet[] randomSets = (ItemSet[])(object)array; m_humanoid.m_randomSets = randomSets; } } } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded] internal sealed class <b89b921d-8954-4084-bd4d-1feb826a594e>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [<b89b921d-8954-4084-bd4d-1feb826a594e>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [CompilerGenerated] internal sealed class <bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContextAttribute : Attribute { public readonly byte Flag; public <bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace LocalizationManager { [<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(0)] [PublicAPI] [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(1)] internal class Localizer { private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors; private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts; private static readonly ConditionalWeakTable<Localization, string> localizationLanguage; private static readonly List<WeakReference<Localization>> localizationObjects; [<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(2)] private static BaseUnityPlugin _plugin; private static readonly List<string> fileExtensions; private static BaseUnityPlugin plugin { get { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown if (_plugin == null) { IEnumerable<TypeInfo> source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out var value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out var value2)) { text = value2.Aggregate(text, [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value())); } localization.AddWord(key, text); } public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, [<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null) { if (convertConfigValue == null) { convertConfigValue = [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] [return: <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(1)] (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary<string, Func<string>>(); } config.SettingChanged += [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] (object _, EventArgs _) => { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value); UpdatePlaceholderText(Localization.instance, key); } } public static void AddText(string key, string text) { List<WeakReference<Localization>> list = new List<WeakReference<Localization>>(); foreach (WeakReference<Localization> localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference<Localization> item in list) { localizationObjects.Remove(item); } } public static void Load() { LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage()); } private static void LoadLocalization(Localization __instance, string language) { if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference<Localization>(__instance)); } localizationLanguage.Add(__instance, language); Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories) where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0 select f) { string text = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' })[1]; if (dictionary.ContainsKey(text)) { Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped.")); } else { dictionary[text] = item; } } byte[] array = LoadTranslationFromAssembly("English"); if (array == null) { throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml."); } Dictionary<string, string> dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array)); if (dictionary2 == null) { throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text2 = null; if (language != "English") { if (dictionary.ContainsKey(language)) { text2 = File.ReadAllText(dictionary[language]); } else { byte[] array2 = LoadTranslationFromAssembly(language); if (array2 != null) { text2 = Encoding.UTF8.GetString(array2); } } } if (text2 == null && dictionary.ContainsKey("English")) { text2 = File.ReadAllText(dictionary["English"]); } if (text2 != null) { foreach (KeyValuePair<string, string> item2 in new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>()) { dictionary2[item2.Key] = item2.Value; } } loadedTexts[language] = dictionary2; foreach (KeyValuePair<string, string> item3 in dictionary2) { UpdatePlaceholderText(__instance, item3.Key); } } static Localizer() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>(); loadedTexts = new Dictionary<string, Dictionary<string, string>>(); localizationLanguage = new ConditionalWeakTable<Localization, string>(); localizationObjects = new List<WeakReference<Localization>>(); fileExtensions = new List<string> { ".json", ".yml" }; new Harmony("org.bepinex.helpers.LocalizationManager").Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } [return: <f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(2)] private static byte[] LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension); if (array != null) { return array; } } return null; } [<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(2)] public static byte[] ReadEmbeddedFileBytes([<f6f8ff5f-fa45-43ba-9489-b740a9e7c98b>Nullable(1)] string resourceFileName, Assembly containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<bb5e3e5e-5c47-485a-88ef-ea5afd7f01c7>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } } namespace 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 new Type[1] { type }.Concat(type.GetInterfaces()).SelectMany((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(YamlConvert