Decompiled source of GoodestBoy v0.3.6
GoodestBoy.dll
Decompiled 2 weeks 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.Reflection.Emit; 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 CreatureManager; using GoodestBoy.Patches; using HarmonyLib; using ItemManager; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.Serialization; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: Guid("D181CDA7-EF07-4BBC-B975-2B80FC6BBFAE")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyProduct("GoodestBoy")] [assembly: AssemblyCompany("")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("GoodestBoy")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyConfiguration("")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<7b3f5e94-2888-42a2-ad27-f56217650ded>Embedded] internal sealed class <7b3f5e94-2888-42a2-ad27-f56217650ded>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<7b3f5e94-2888-42a2-ad27-f56217650ded>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <1277a557-2f61-45b9-856f-fa8dcff5851f>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <1277a557-2f61-45b9-856f-fa8dcff5851f>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <1277a557-2f61-45b9-856f-fa8dcff5851f>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<7b3f5e94-2888-42a2-ad27-f56217650ded>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContextAttribute : Attribute { public readonly byte Flag; public <b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace GoodestBoy { [BepInPlugin("odinplus.plugins.goodestboy", "GoodestBoy", "0.3.6")] [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] public class GoodestBoy : BaseUnityPlugin { [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] private enum Toggle { On = 1, Off = 0 } private const string ModName = "GoodestBoy"; private const string ModVersion = "0.3.6"; private const string ModGUID = "odinplus.plugins.goodestboy"; private static readonly ConfigSync configSync = new ConfigSync("GoodestBoy") { DisplayName = "GoodestBoy", CurrentVersion = "0.3.6", MinimumRequiredVersion = "0.3.6" }; private static ConfigEntry<Toggle> serverConfigLocked = null; public static ConfigEntry<int> _goodestHealAmount = null; public static ConfigEntry<int> _goodestHealCooldown = null; public static ConfigEntry<int> _goodestDurabilityCost = null; internal static ConfigEntry<int> dogHealth = null; private static BestestBoy bestestDog = null; private static FileSystemWatcher configWatcher = null; internal static ConfigEntry<int> pupperHealth = null; internal static ConfigEntry<int> pupperOffspringGrowupTime = null; public static ConfigEntry<KeyboardShortcut> WaitKey; private ConfigEntry<T> config<[<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, description); SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry<T>(val); syncedConfigEntry.SynchronizedConfig = synchronizedSetting; return val; } private ConfigEntry<T> config<[<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting); } public void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_0627: Unknown result type (might be due to invalid IL or missing references) //IL_07a2: Unknown result type (might be due to invalid IL or missing references) //IL_07a9: Expected O, but got Unknown Localizer.Load(); dogHealth = config("Goodest Boy", "Health", 250, new ConfigDescription("Declare health points for BestestDog", (AcceptableValueBase)null, Array.Empty<object>())); pupperHealth = config("Bestest Pup", "Health", 50, new ConfigDescription("Declare health points for Pupper", (AcceptableValueBase)null, Array.Empty<object>())); pupperOffspringGrowupTime = config("Bestest Pup", "Grow-Up Time", 2000, new ConfigDescription("Declare growup time needed to convert offspring into GoodestBoy. Time in seconds.", (AcceptableValueBase)null, Array.Empty<object>())); bestestDog = Object.FindObjectsOfType<BestestBoy>().FirstOrDefault(); WaitKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "Wait Toggle Key", new KeyboardShortcut((KeyCode)104, Array.Empty<KeyCode>()), "Key to toggle GoodestBoy wait state"); SetupWatcher(); GameObject val = ItemManager.PrefabManager.RegisterPrefab("gsd", "fx_dogg_backstab"); GameObject val2 = ItemManager.PrefabManager.RegisterPrefab("gsd", "fx_doggo_crit"); GameObject val3 = ItemManager.PrefabManager.RegisterPrefab("gsd", "fx_doggo_footstep_jog"); GameObject val4 = ItemManager.PrefabManager.RegisterPrefab("gsd", "fx_doggo_footstep_snow_run"); GameObject val5 = ItemManager.PrefabManager.RegisterPrefab("gsd", "fx_doggo_footstep_water"); GameObject val6 = ItemManager.PrefabManager.RegisterPrefab("gsd", "fx_doggo_pet"); GameObject val7 = ItemManager.PrefabManager.RegisterPrefab("gsd", "fx_doggo_tamed"); GameObject val8 = ItemManager.PrefabManager.RegisterPrefab("gsd", "sfx_bestestball_hit"); GameObject val9 = ItemManager.PrefabManager.RegisterPrefab("gsd", "sfx_bestestball_throw"); GameObject val10 = ItemManager.PrefabManager.RegisterPrefab("gsd", "sfx_doggo_attack"); GameObject val11 = ItemManager.PrefabManager.RegisterPrefab("gsd", "sfx_doggo_attack_hit"); GameObject val12 = ItemManager.PrefabManager.RegisterPrefab("gsd", "sfx_doggo_bark"); GameObject val13 = ItemManager.PrefabManager.RegisterPrefab("gsd", "sfx_doggo_consume"); GameObject val14 = ItemManager.PrefabManager.RegisterPrefab("gsd", "sfx_doggo_death"); GameObject val15 = ItemManager.PrefabManager.RegisterPrefab("gsd", "sfx_doggo_hit"); GameObject val16 = ItemManager.PrefabManager.RegisterPrefab("gsd", "sfx_doggo_panting"); GameObject val17 = ItemManager.PrefabManager.RegisterPrefab("gsd", "sfx_doggo_swim"); GameObject val18 = ItemManager.PrefabManager.RegisterPrefab("gsd", "sfx_gb_whistle"); GameObject val19 = ItemManager.PrefabManager.RegisterPrefab("gsd", "vfx_doggo_birth"); GameObject val20 = ItemManager.PrefabManager.RegisterPrefab("gsd", "vfx_doggo_death"); GameObject val21 = ItemManager.PrefabManager.RegisterPrefab("gsd", "vfx_doggo_destruction"); GameObject val22 = ItemManager.PrefabManager.RegisterPrefab("gsd", "vfx_doggo_hit"); GameObject val23 = ItemManager.PrefabManager.RegisterPrefab("gsd", "vfx_doggo_love"); GameObject val24 = ItemManager.PrefabManager.RegisterPrefab("gsd", "vfx_doggo_soothed"); GameObject val25 = ItemManager.PrefabManager.RegisterPrefab("gsd", "vfx_dogwater_surface"); GameObject val26 = ItemManager.PrefabManager.RegisterPrefab("gsd", "GSD_Ragdoll"); Item item = new Item("gsd", "GSD_Dog_Attack1"); item.Configurable = Configurability.Stats; Item item2 = new Item("gsd", "GSD_Dog_Attack2"); item2.Configurable = Configurability.Stats; Item item3 = new Item("gsd", "GSD_Dog_Attack3"); item3.Configurable = Configurability.Stats; Item item4 = new Item("gsd", "BestestTreat"); item4.Crafting.Add(CraftingTable.Workbench, 1); item4.RequiredItems.Add("CookedMeat", 2); item4.CraftAmount = 1; Item item5 = new Item("gsd", "StoneGSDPup"); item5.Crafting.Add(CraftingTable.Workbench, 2); item5.RequiredItems.Add("Stone", 5); item5.RequiredItems.Add("BoneFragments", 5); item5.CraftAmount = 1; GameObject val27 = ItemManager.PrefabManager.RegisterPrefab("gsd", "StoneGSD_Projectile"); Item item6 = new Item("gsd", "BestestBall"); item6.Crafting.Add(CraftingTable.Workbench, 1); item6.RequiredItems.Add("LeatherScraps", 2); item6.CraftAmount = 1; GameObject val28 = ItemManager.PrefabManager.RegisterPrefab("gsd", "BestestBall_Projectile"); Item item7 = new Item("gsd", "GB_Whistle"); item7.Crafting.Add(CraftingTable.Workbench, 1); item7.RequiredItems.Add("FineWood", 1); item7.CraftAmount = 1; SharedData shared = item7.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared; Recall recall = ScriptableObject.CreateInstance<Recall>(); ((StatusEffect)recall).m_ttl = 0.25f; shared.m_consumeStatusEffect = (StatusEffect)(object)recall; Creature creature = new Creature("gsd", "Bestest_Pup") { Biome = (Biome)0, CanSpawn = true, SpawnChance = 100f, GroupSize = new CreatureManager.Range(1f, 2f), Maximum = 1, CreatureFaction = (Faction)0 }; creature.Drops["BoneFragments"].Amount = new CreatureManager.Range(1f, 2f); creature.Drops["BoneFragments"].DropChance = 50f; ((Character)creature.Prefab.GetComponent<Humanoid>()).m_health = pupperHealth.Value; creature.Prefab.GetComponent<Growup>().m_growTime = pupperOffspringGrowupTime.Value; Creature creature2 = new Creature("gsd", "BestestDog") { Biome = (Biome)8, CanBeTamed = true, CanHaveStars = true, FoodItems = "RawMeat, BestestTreat, CookedMeat, BoarJerky, NeckTail, DeerStew, NeckTailGrilled, DeerMeat, CookedDeerMeat, MinceMeatSauce, Sausages, Entrails, SerpentMeatCooked, SerpentStew, SerpentMeat, CookedWolfMeat, WolfMeat, Wolfjerky, LoxMeat, CookedLoxMeat, LoxPie,", SpawnChance = 10f, RequiredWeather = Weather.BlackForestFog, GroupSize = new CreatureManager.Range(1f, 2f), CheckSpawnInterval = 300, SpecificSpawnTime = SpawnTime.Always, Maximum = 1, CreatureFaction = (Faction)0, FedDuration = 300f, TamingTime = 800f, SpawnsTamed = false }; creature2.Drops["BoneFragments"].Amount = new CreatureManager.Range(1f, 2f); creature2.Drops["BoneFragments"].DropChance = 15f; creature2.Drops["WolfMeat"].Amount = new CreatureManager.Range(1f, 2f); creature2.Drops["WolfMeat"].DropChance = 50f; creature2.Drops["StoneGSDPup"].Amount = new CreatureManager.Range(1f, 1f); creature2.Drops["StoneGSDPup"].DropChance = 1f; ((Character)creature2.Prefab.GetComponent<Humanoid>()).m_health = dogHealth.Value; _goodestHealAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Treat Healing", "Amount", 100, "How much health the treat heals."); _goodestHealCooldown = ((BaseUnityPlugin)this).Config.Bind<int>("Treat Cooldown", "Cooldown", 60, "How long the cooldown is in seconds."); _goodestDurabilityCost = ((BaseUnityPlugin)this).Config.Bind<int>("Treat Durability", "Durability", 1, "How much durability the treat loses when used."); creature2.Prefab.AddComponent<GoodestBoyWait>(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); Harmony val29 = new Harmony("odinplus.plugins.goodestboy"); val29.PatchAll(executingAssembly); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void SetupWatcher() { string filter = "odinplus.plugins.goodestboy.cfg"; configWatcher = new FileSystemWatcher(Paths.ConfigPath, filter); configWatcher.Changed += ReadConfigValues; configWatcher.Created += ReadConfigValues; configWatcher.Renamed += ReadConfigValues; configWatcher.IncludeSubdirectories = true; configWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; configWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { string path = Path.Combine(Paths.ConfigPath, "odinplus.plugins.goodestboy.cfg"); if (!File.Exists(path)) { return; } try { ((BaseUnityPlugin)this).Logger.LogDebug((object)"ReadConfigValues called"); ((BaseUnityPlugin)this).Config.Reload(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("There was an issue loading your odinplus.plugins.goodestboy.cfg: " + ex.Message)); ((BaseUnityPlugin)this).Logger.LogError((object)"Please check your config entries for spelling and format!"); } } } public class BestestBoy : MonoBehaviour { public void UpdateTamingTime(float newTamingTime) { } } } namespace GoodestBoy.Patches { public class BestestTreat { [HarmonyPatch(typeof(Tameable), "GetHoverText")] private static class Tameable_transform_Patch { [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] private static void Postfix(Tameable __instance, ref string __result) { if (__instance.m_character.IsTamed() && !((Object)(object)Player.m_localPlayer == (Object)null)) { ItemData currentWeapon = ((Humanoid)Player.m_localPlayer).GetCurrentWeapon(); if (currentWeapon != null && !((Object)(object)currentWeapon.m_dropPrefab == (Object)null) && !(((Object)currentWeapon.m_dropPrefab).name != "BestestTreat")) { __result += $"\n[<color=yellow><b>L-Ctrl + E</b></color>] Heal: {GoodestBoy._goodestHealAmount.Value} HP"; } } } } [HarmonyPatch(typeof(Tameable), "Interact")] private static class Tameable_Interact_Patch { [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] private static bool Prefix(Tameable __instance) { if (!Input.GetKey((KeyCode)306)) { return true; } if ((Object)(object)Player.m_localPlayer == (Object)null) { return true; } ItemData currentWeapon = ((Humanoid)Player.m_localPlayer).GetCurrentWeapon(); if (currentWeapon == null || (Object)(object)currentWeapon.m_dropPrefab == (Object)null) { return true; } if (((Object)currentWeapon.m_dropPrefab).name != "BestestTreat") { return true; } if (!__instance.m_character.IsTamed()) { return true; } if (!Object.op_Implicit((Object)(object)__instance.m_nview) || !__instance.m_nview.IsValid()) { return true; } int @int = __instance.m_nview.m_zdo.GetInt("LastHealTime", 0); if ((double)(@int + GoodestBoy._goodestHealCooldown.Value) > EnvMan.instance.m_totalSeconds) { MessageHud.instance.ShowMessage((MessageType)2, "Cooldown not ready", 0, (Sprite)null, false); return false; } currentWeapon.m_durability -= (float)GoodestBoy._goodestDurabilityCost.Value; if (currentWeapon.m_durability <= 0f) { ((Humanoid)Player.m_localPlayer).UnequipItem(currentWeapon, false); ((Humanoid)Player.m_localPlayer).m_inventory.RemoveItem(currentWeapon); } ((Character)Player.m_localPlayer).m_zanim.SetTrigger("interact"); __instance.m_nview.InvokeRPC("GoodestHealTameable", Array.Empty<object>()); return false; } } [HarmonyPatch(typeof(Tameable), "Awake")] private static class Tameable_Awake_Patch { [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] private static void Postfix(Tameable __instance) { if (!Object.op_Implicit((Object)(object)__instance.m_nview) || !__instance.m_nview.IsValid()) { return; } __instance.m_nview.Register("GoodestHealTameable", (Action<long>)delegate { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) if (__instance.m_nview.IsValid()) { int @int = __instance.m_nview.m_zdo.GetInt("LastHealTime", 0); if (!((double)(@int + GoodestBoy._goodestHealCooldown.Value) > EnvMan.instance.m_totalSeconds) && __instance.m_nview.IsOwner()) { __instance.m_nview.m_zdo.Set("LastHealTime", (int)EnvMan.instance.m_totalSeconds); __instance.m_character.Heal((float)GoodestBoy._goodestHealAmount.Value, true); GameObject prefab = ZNetScene.instance.GetPrefab("fx_creature_tamed"); if ((Object)(object)prefab != (Object)null) { Object.Instantiate<GameObject>(prefab, ((Component)__instance).transform.position, Quaternion.identity); } } } }); } } [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] internal static AssetBundle GetAssetBundle(string filename) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename)); using Stream stream = executingAssembly.GetManifestResourceStream(name); return AssetBundle.LoadFromStream(stream); } } [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] public class GoodestBoyWait : MonoBehaviour { private Tameable m_tameable; private ZNetView m_nview; private Animator m_animator; private static readonly int s_isWaitingHash = StringExtensionMethods.GetStableHashCode("gb_waiting"); private void Awake() { m_tameable = ((Component)this).GetComponent<Tameable>(); m_nview = ((Component)this).GetComponent<ZNetView>(); m_animator = ((Component)this).GetComponentInChildren<Animator>(); if ((Object)(object)m_nview != (Object)null && m_nview.IsValid()) { m_nview.Register<bool>("RPC_SetWait", (Action<long, bool>)RPC_SetWait); } } private void Update() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)m_tameable) && m_tameable.IsTamed() && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { KeyboardShortcut value = GoodestBoy.WaitKey.Value; if (((KeyboardShortcut)(ref value)).IsDown() && !((Object)(object)((Humanoid)Player.m_localPlayer).GetHoverObject() != (Object)(object)((Component)this).gameObject)) { ToggleWait(); ((Character)Player.m_localPlayer).Message((MessageType)2, IsWaiting() ? "I'll wait here." : "Let's go.", 0, (Sprite)null); } } } public bool IsWaiting() { if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid() || m_nview.GetZDO() == null) { return false; } return m_nview.GetZDO().GetBool(s_isWaitingHash, false); } public void ToggleWait() { if (!((Object)(object)m_nview == (Object)null) && m_nview.IsValid()) { bool flag = !IsWaiting(); m_nview.InvokeRPC(ZNetView.Everybody, "RPC_SetWait", new object[1] { flag }); } } private void RPC_SetWait(long sender, bool state) { if (m_nview.IsOwner()) { m_nview.GetZDO().Set(s_isWaitingHash, state); } SetWaitAnimation(state); } private void SetWaitAnimation(bool waiting) { if ((Object)(object)m_animator != (Object)null) { m_animator.SetBool("wait", waiting); } } } [HarmonyPatch(typeof(MonsterAI), "UpdateAI")] internal class MonsterAI_UpdateAI_GoodestBoyWaitPatch { [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] private static bool Prefix(MonsterAI __instance, ref bool __result) { if ((Object)(object)__instance == (Object)null) { return true; } GoodestBoyWait component = ((Component)__instance).GetComponent<GoodestBoyWait>(); if ((Object)(object)component == (Object)null) { return true; } if (!component.IsWaiting()) { return true; } ((BaseAI)__instance).StopMoving(); __result = true; return false; } } [HarmonyPatch(typeof(Tameable), "Interact")] internal class Tameable_Interact_GoodestBoyWaitPatch { [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] private static bool Prefix(Tameable __instance, Humanoid user, bool hold, bool alt, ref bool __result) { return true; } } [HarmonyPatch(typeof(Tameable), "GetHoverText")] internal class Tameable_HoverText_GoodestBoyWaitPatch { [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] private static void Postfix(Tameable __instance, ref string __result) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) GoodestBoyWait component = ((Component)__instance).GetComponent<GoodestBoyWait>(); if (!((Object)(object)component == (Object)null) && __instance.IsTamed()) { KeyboardShortcut value = GoodestBoy.WaitKey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value)).MainKey; string text = ((object)(KeyCode)(ref mainKey)).ToString(); __result += (component.IsWaiting() ? ("\n[" + text + "] Follow Me") : ("\n[" + text + "] Wait Here")); } } } [HarmonyPatch(typeof(Character), "Damage")] internal class Character_Damage_GoodestBoyWaitPatch { [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] private static void Postfix(Character __instance, HitData hit) { if (hit != null && !(hit.GetTotalDamage() <= 0f)) { GoodestBoyWait component = ((Component)__instance).GetComponent<GoodestBoyWait>(); if (!((Object)(object)component == (Object)null) && component.IsWaiting()) { component.ToggleWait(); } } } } [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] public class FetchAI : MonoBehaviour { [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] public enum AIStates { BaseAI, Idle, GettingBall, ReturningBall, Wait, DropBall } [CompilerGenerated] private sealed class <PickupBall>d__26 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] private object <>2__current; [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] public FetchAI <>4__this; [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] private Transform <petTransform>5__1; private Vector3 <vector>5__2; object IEnumerator<object>.Current { [DebuggerHidden] [return: <1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public <PickupBall>d__26(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <petTransform>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.48f); <>1__state = 1; return true; case 1: <>1__state = -1; if (!<>4__this.ValidBallToGet || ((BaseAI)<>4__this.m_monsterAI).IsAlerted()) { <>4__this.m_animator.CrossFadeInFixedTime("New State 0", 0.4f, 0); <>4__this.m_AiState = AIStates.Idle; <>4__this.m_stateTime = 0f; return false; } Traverse.Create((object)((Component)<>4__this.m_targetItem).GetComponent<ZSyncTransform>()).Field("m_useGravity").SetValue((object)false); <>4__this.m_targetItem.collisionDetectionMode = (CollisionDetectionMode)3; <>4__this.m_targetItem.isKinematic = true; ((Component)<>4__this.m_targetItem).GetComponent<ItemDrop>().m_autoPickup = false; <petTransform>5__1 = Utils.FindChild(((Component)<>4__this).transform, "Head", (IterativeSearchType)0); <vector>5__2 = ((Component)<>4__this.m_targetItem).transform.rotation * <>4__this.m_boneOffset; ((Component)<>4__this.m_targetItem).transform.SetParent(<petTransform>5__1, true); ((Component)<>4__this.m_targetItem).transform.position = <petTransform>5__1.position + <vector>5__2 + <petTransform>5__1.rotation * <>4__this.m_mouthOffset; <>4__this.m_hasABall = true; ((Renderer)((Component)<>4__this.m_targetItem).gameObject.GetComponentInChildren<MeshRenderer>()).enabled = false; <>2__current = (object)new WaitForSeconds(0.52f); <>1__state = 2; return true; case 2: <>1__state = -1; <>4__this.m_animator.CrossFadeInFixedTime("New State 0", 0.6f, 0); <>2__current = (object)new WaitForSeconds(Random.Range(0.2f, 1.5f)); <>1__state = 3; return true; case 3: <>1__state = -1; <>4__this.m_AiState = AIStates.ReturningBall; <>4__this.m_stateTime = 10f; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static readonly List<FetchAI> _fetchAiList = new List<FetchAI>(); public AIStates m_AiState; public Animator m_animator; public MonsterAI m_monsterAI; public float m_updateTimer; public float m_distanceFromPlayer = 2.25f; public float m_distanceFromItem = 1f; public bool m_pausing; [FormerlySerializedAs("m_targetBall")] public Rigidbody m_targetItem; public float m_stateTime; public bool m_hasABall; private readonly Vector3 m_boneOffset = new Vector3(-0.001f, -0.147f, -0.023f); private readonly Vector3 m_mouthOffset = new Vector3(1f, 0.56f, 0f); private bool ValidBallToGet => (Object)(object)m_targetItem != (Object)null && m_targetItem.useGravity; private bool ValidBall => (Object)(object)m_targetItem != (Object)null && !m_targetItem.useGravity; public void Awake() { m_monsterAI = ((Component)this).GetComponent<MonsterAI>(); ((Behaviour)m_monsterAI).enabled = false; _fetchAiList.Add(this); m_animator = ((Component)this).GetComponentInChildren<Animator>(); } public void Start() { m_monsterAI.Start(); } private void OnDestroy() { _fetchAiList.Remove(this); } private Rigidbody GetBall(float range) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) m_targetItem = FetchSystem.FindBall(((Component)this).transform.position, range); return (!Object.op_Implicit((Object)(object)m_targetItem)) ? null : m_targetItem; } public void GetBall(ItemDrop ball) { m_targetItem = ((Component)ball).GetComponent<Rigidbody>(); if (Object.op_Implicit((Object)(object)m_targetItem)) { m_AiState = AIStates.GettingBall; m_stateTime = 10f; } } public void FixedUpdate() { try { if (((BaseAI)m_monsterAI).m_nview.IsValid()) { m_updateTimer += Time.fixedDeltaTime; if (!(m_updateTimer < 0.05f)) { UpdateAI(0.05f); m_updateTimer -= 0.05f; } } } catch { } } public void UpdateAI(float dt) { //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: 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_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) if (!((BaseAI)m_monsterAI).m_nview.IsOwner()) { return; } GoodestBoyWait component = ((Component)this).GetComponent<GoodestBoyWait>(); if ((Object)(object)component != (Object)null && component.IsWaiting()) { ((BaseAI)m_monsterAI).StopMoving(); return; } m_stateTime -= dt; if (((BaseAI)m_monsterAI).IsAlerted()) { m_stateTime = 3f; m_AiState = AIStates.BaseAI; DropBall(); } if (m_stateTime <= 0f && m_pausing) { m_pausing = false; } else if (m_stateTime <= 0f && m_AiState != 0) { NewAction(); } else if (m_pausing) { return; } switch (m_AiState) { case AIStates.BaseAI: ((BaseAI)m_monsterAI).UpdateAI(dt); if (m_stateTime <= 0f) { if (((BaseAI)m_monsterAI).m_randomMoveUpdateTimer <= 0f) { NewAction(); } else { m_stateTime = 3f; } } break; case AIStates.GettingBall: { if (!ValidBallToGet) { m_stateTime = 0f; break; } Vector3 position = ((Component)m_targetItem).transform.position; if (((BaseAI)m_monsterAI).MoveTo(dt, position, m_distanceFromItem, true) && Utils.DistanceXZ(((Component)this).transform.position, position) <= m_distanceFromItem) { ((BaseAI)m_monsterAI).LookAt(position); if (((BaseAI)m_monsterAI).IsLookingAt(position, 20f, false) && ValidBallToGet) { m_animator.Play("consume"); ((MonoBehaviour)this).StartCoroutine(PickupBall()); m_AiState = AIStates.Wait; m_stateTime = 5f; } } break; } case AIStates.ReturningBall: { if (!ValidBall) { m_hasABall = false; m_stateTime = 0f; break; } if ((Object)(object)Player.m_localPlayer == (Object)null) { DropBall(); m_stateTime = 0f; break; } Transform transform = ((Component)Player.m_localPlayer).transform; if (((BaseAI)m_monsterAI).MoveTo(dt, transform.position + transform.forward * m_distanceFromPlayer, 0f, true)) { ((BaseAI)m_monsterAI).LookAt(transform.position); if (((BaseAI)m_monsterAI).IsLookingAt(transform.position, 15f, false)) { m_pausing = true; m_AiState = AIStates.DropBall; m_stateTime = Random.Range(0.4f, 1.3f); } } break; } case AIStates.DropBall: DropBall(); m_AiState = AIStates.Wait; m_stateTime = Random.Range(2f, 4f); break; case AIStates.Idle: case AIStates.Wait: break; } } private void DropBall() { if (m_hasABall) { m_hasABall = false; if (ValidBall) { ((Renderer)((Component)m_targetItem).gameObject.GetComponentInChildren<MeshRenderer>()).enabled = true; m_targetItem.isKinematic = false; m_targetItem.collisionDetectionMode = (CollisionDetectionMode)1; Traverse.Create((object)((Component)m_targetItem).GetComponent<ZSyncTransform>()).Field("m_useGravity").SetValue((object)true); ((Component)m_targetItem).transform.SetParent((Transform)null, true); } } } [IteratorStateMachine(typeof(<PickupBall>d__26))] private IEnumerator PickupBall() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <PickupBall>d__26(0) { <>4__this = this }; } private void NewAction() { //IL_002b: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (Random.Range(0, 3) == 0) { if (!m_hasABall && !((Object)(object)Player.m_localPlayer == (Object)null)) { Vector3 val = ((Component)this).transform.position - ((Component)Player.m_localPlayer).transform.position; if (((Vector3)(ref val)).sqrMagnitude <= 36f && !((Object)(object)GetBall(50f) == (Object)null)) { m_AiState = AIStates.GettingBall; m_stateTime = 10f; } } } else { m_AiState = AIStates.BaseAI; m_stateTime = Random.Range(2f, 4f); } } } [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] [HarmonyPatch] [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] public class FetchSystem { private static readonly Collider[] _sphereResults = (Collider[])(object)new Collider[32]; private static ItemDrop _lastDroppedItem; [HarmonyPatch(typeof(ItemDrop), "OnPlayerDrop")] [HarmonyPostfix] public static void OnPlayerDrop_Postfix(ItemDrop __instance) { _lastDroppedItem = __instance; } [HarmonyPostfix] [HarmonyPatch(typeof(Humanoid), "DropItem")] public static void DropItem_Postfix(Inventory inventory, ItemData item, int amount, Humanoid __instance, bool __result) { if (!__result || !((Character)__instance).IsPlayer() || !Object.op_Implicit((Object)(object)_lastDroppedItem) || item.m_shared.m_name != "$bestestball") { return; } foreach (FetchAI item2 in FetchAI._fetchAiList.Where([<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (FetchAI p) => { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) int result; if ((Object)(object)p != (Object)null && (Object)(object)((Component)p).gameObject != (Object)null && (Object)(object)p.m_monsterAI != (Object)null) { Vector3 val = ((Component)p).gameObject.transform.position - ((Component)Player.m_localPlayer).transform.position; result = ((!(((Vector3)(ref val)).sqrMagnitude > 80f)) ? 1 : 0); } else { result = 0; } return (byte)result != 0; })) { Character component = ((Component)item2).GetComponent<Character>(); if ((Object)(object)component == (Object)null || !component.IsTamed()) { continue; } Growup component2 = ((Component)item2).GetComponent<Growup>(); if (!((Object)(object)component2 != (Object)null) && !((BaseAI)item2.m_monsterAI).IsAlerted() && item2.m_AiState == FetchAI.AIStates.BaseAI) { GoodestBoyWait component3 = ((Component)item2).GetComponent<GoodestBoyWait>(); if ((Object)(object)component3 != (Object)null && component3.IsWaiting()) { component3.ToggleWait(); } item2.GetBall(_lastDroppedItem); } } } [HarmonyPostfix] [HarmonyPatch(typeof(MonsterAI), "MakeTame")] public static void MakeTame_Postfix(MonsterAI __instance) { if (!(((Object)((Component)__instance).gameObject).name.Replace("(Clone)", "") != "BestestDog")) { Character component = ((Component)__instance).GetComponent<Character>(); if ((Object)(object)component != (Object)null && component.IsTamed()) { NewTame(((Component)__instance).gameObject); } } } [HarmonyPostfix] [HarmonyPatch(typeof(Procreation), "Awake")] public static void Awake_Postfix(Procreation __instance) { if (!(((Object)((Component)__instance).gameObject).name.Replace("(Clone)", "") != "BestestDog")) { Character component = ((Component)__instance).GetComponent<Character>(); if ((Object)(object)component != (Object)null && component.IsTamed()) { NewTame(((Component)__instance).gameObject); } } } [HarmonyPatch(typeof(Character), "Awake")] [HarmonyPostfix] public static void Awake_Prefix(Character __instance) { if (!((Object)(object)__instance == (Object)null) && !__instance.IsPlayer() && !__instance.IsBoss() && __instance.m_nview.IsValid() && __instance.IsTamed() && !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<Growup>()) && !(((Object)__instance).name.Replace("(Clone)", "") != "BestestDog")) { NewTame(((Component)__instance).gameObject); } } public static Rigidbody FindBall(Vector3 pos, float range) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapSphereNonAlloc(pos, range, _sphereResults, LayerMask.GetMask(new string[1] { "item" })); Rigidbody result = null; float num2 = 999999f; for (int i = 0; i < num; i++) { Collider val = _sphereResults[i]; if (!Object.op_Implicit((Object)(object)val.attachedRigidbody)) { continue; } ItemDrop component = ((Component)val.attachedRigidbody).GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null || !((Component)component).GetComponent<ZNetView>().IsValid() || component.m_itemData.m_shared.m_name != "$bestestball") { continue; } Rigidbody component2 = ((Component)component).GetComponent<Rigidbody>(); if (Object.op_Implicit((Object)(object)component2) && component2.useGravity) { Vector3 val2 = ((Component)component).transform.position - pos; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num2) { result = component2; num2 = sqrMagnitude; } } } return result; } private static void NewTame(GameObject pet) { if (!Object.op_Implicit((Object)(object)pet.GetComponent<FetchAI>())) { ((Behaviour)pet.GetComponent<MonsterAI>()).enabled = false; pet.AddComponent<FetchAI>(); } } [HarmonyPostfix] [HarmonyPatch(typeof(ItemDrop), "DropItem")] public static void DropItem_Postfix(ItemDrop __result) { _lastDroppedItem = __result; } [HarmonyPostfix] [HarmonyPatch(typeof(Projectile), "SpawnOnHit")] public static void SpawnOnHit_Postfix(Projectile __instance, ref ItemData ___m_spawnItem) { if (__instance.m_spawnItem == null || !__instance.m_respawnItemOnHit || !Object.op_Implicit((Object)(object)_lastDroppedItem) || ___m_spawnItem.m_shared.m_name != "$bestestball") { return; } foreach (FetchAI item in FetchAI._fetchAiList.Where([<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (FetchAI p) => { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) int result; if ((Object)(object)p != (Object)null && (Object)(object)((Component)p).gameObject != (Object)null && (Object)(object)p.m_monsterAI != (Object)null) { Vector3 val = ((Component)p).gameObject.transform.position - ((Component)Player.m_localPlayer).transform.position; result = ((!(((Vector3)(ref val)).sqrMagnitude > 80f)) ? 1 : 0); } else { result = 0; } return (byte)result != 0; })) { Character component = ((Component)item).GetComponent<Character>(); if ((Object)(object)component == (Object)null || !component.IsTamed()) { continue; } Growup component2 = ((Component)item).GetComponent<Growup>(); if (!((Object)(object)component2 != (Object)null) && !((BaseAI)item.m_monsterAI).IsAlerted() && item.m_AiState == FetchAI.AIStates.BaseAI) { GoodestBoyWait component3 = ((Component)item).GetComponent<GoodestBoyWait>(); if ((Object)(object)component3 != (Object)null && component3.IsWaiting()) { component3.ToggleWait(); } item.GetBall(_lastDroppedItem); } } } } [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] public class Recall : StatusEffect { public float m_maxDistance = 200f; public List<Character> m_companions = new List<Character>(); private readonly float[] _offSets = new float[6] { -80f, 80f, -60f, 60f, -30f, 30f }; public override void Setup(Character character) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) ((StatusEffect)this).Setup(character); m_companions.Clear(); if ((Object)(object)character == (Object)null) { return; } List<Character> list = new List<Character>(); Character.GetCharactersInRange(((Component)character).transform.position, m_maxDistance, list); foreach (Character item in list) { if (m_companions.Count >= _offSets.Length) { break; } if (!((Object)(object)item == (Object)null) && item.IsTamed() && !(((Object)item).name.Replace("(Clone)", "") != "BestestDog")) { MonsterAI component = ((Component)item).GetComponent<MonsterAI>(); if (Object.op_Implicit((Object)(object)component)) { m_companions.Add(item); } } } } public override void UpdateStatusEffect(float dt) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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) ((StatusEffect)this).UpdateStatusEffect(dt); if ((Object)(object)base.m_character == (Object)null || m_companions == null || m_companions.Count == 0) { return; } int num = 0; for (int num2 = m_companions.Count - 1; num2 >= 0; num2--) { Character val = m_companions[num2]; if ((Object)(object)val == (Object)null || val.IsDead() || !val.m_nview.IsValid()) { m_companions.RemoveAt(num2); } else { if (num >= _offSets.Length) { break; } Vector3 val2 = Quaternion.AngleAxis(_offSets[num], Vector3.up) * ((Component)base.m_character).transform.forward; Vector3 val3 = ((Component)base.m_character).transform.position + val2 * 0.6f; ((Component)val).transform.SetPositionAndRotation(val3, ((Component)base.m_character).transform.rotation); val.SetLookDir(((Component)base.m_character).transform.forward, 0f); GoodestBoyWait component = ((Component)val).GetComponent<GoodestBoyWait>(); if ((Object)(object)component != (Object)null && component.IsWaiting()) { component.ToggleWait(); } num++; } } } public override void OnDestroy() { m_companions.Clear(); ((StatusEffect)this).OnDestroy(); } } } namespace CreatureManager { public enum Toggle { On, Off } [PublicAPI] public enum GlobalKey { [InternalName("")] None, [InternalName("defeated_bonemass")] KilledBonemass, [InternalName("defeated_gdking")] KilledElder, [InternalName("defeated_goblinking")] KilledYagluth, [InternalName("defeated_dragon")] KilledModer, [InternalName("defeated_eikthyr")] KilledEikthyr, [InternalName("KilledTroll")] KilledTroll, [InternalName("killed_surtling")] KilledSurtling } [Flags] [PublicAPI] public enum Weather { [InternalName("")] None = 0, [InternalName("Clear")] ClearSkies = 1, [InternalName("Heath clear")] MeadowsClearSkies = 4, [InternalName("LightRain")] LightRain = 8, [InternalName("Rain")] Rain = 0x10, [InternalName("ThunderStorm")] ThunderStorm = 0x20, [InternalName("nofogts")] ClearThunderStorm = 0x40, [InternalName("SwampRain")] SwampRain = 0x80, [InternalName("Darklands_dark")] MistlandsDark = 0x100, [InternalName("Ashrain")] AshlandsAshrain = 0x200, [InternalName("Snow")] MountainSnow = 0x400, [InternalName("SnowStorm")] MountainBlizzard = 0x800, [InternalName("DeepForest Mist")] BlackForestFog = 0x1000, [InternalName("Misty")] Fog = 0x2000, [InternalName("Twilight_Snow")] DeepNorthSnow = 0x4000, [InternalName("Twilight_SnowStorm")] DeepNorthSnowStorm = 0x8000, [InternalName("Twilight_Clear")] DeepNorthClear = 0x10000, [InternalName("Eikthyr")] EikthyrsThunderstorm = 0x20000, [InternalName("GDKing")] EldersHaze = 0x40000, [InternalName("Bonemass")] BonemassDownpour = 0x80000, [InternalName("Moder")] ModersVortex = 0x100000, [InternalName("GoblinKing")] YagluthsMagicBlizzard = 0x200000, [InternalName("Crypt")] Crypt = 0x400000, [InternalName("SunkenCrypt")] SunkenCrypt = 0x800000 } [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] public class InternalName : Attribute { public readonly string internalName; public InternalName(string internalName) { this.internalName = internalName; } } public enum DropOption { Disabled, Default, Custom } public enum SpawnOption { Disabled, Default, Custom } public enum SpawnTime { Day, Night, Always } public enum SpawnArea { Center, Edge, Everywhere } public enum Forest { Yes, No, Both } [PublicAPI] public struct Range { public float min; public float max; public Range(float min, float max) { this.min = min; this.max = max; } } [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] [PublicAPI] public class Creature { [PublicAPI] [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] public class DropList { [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] internal class SerializedDrops { [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(new byte[] { 1, 0, 1, 1 })] public readonly List<KeyValuePair<string, Drop>> Drops; public SerializedDrops(DropList drops, Creature creature) { Drops = (drops.drops ?? creature.Prefab.GetComponent<CharacterDrop>()?.m_drops.ToDictionary([<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (Drop drop) => ((Object)drop.m_prefab).name, [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (Drop drop) => new Drop { Amount = new Range(drop.m_amountMin, drop.m_amountMax), DropChance = drop.m_chance, DropOnePerPlayer = drop.m_onePerPlayer, MultiplyDropByLevel = drop.m_levelMultiplier }) ?? new Dictionary<string, Drop>()).ToList(); } public SerializedDrops([<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(new byte[] { 1, 0, 1, 1 })] List<KeyValuePair<string, Drop>> drops) { Drops = drops; } public SerializedDrops(string reqs) { Drops = (from r in reqs.Split(new char[1] { ',' }) select r.Split(new char[1] { ':' })).ToDictionary([<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (string[] l) => l[0], [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (string[] parts) => { Range amount = new Range(1f, 1f); if (parts.Length > 1) { string[] array = parts[1].Split(new char[1] { '-' }); if (!int.TryParse(array[0], out var result)) { result = 1; } if (array.Length == 1 || !int.TryParse(array[0], out var result2)) { result2 = result; } amount = new Range(result, result2); } float result3; return new Drop { Amount = amount, DropChance = ((parts.Length > 2 && float.TryParse(parts[2], out result3)) ? result3 : 100f), DropOnePerPlayer = (parts.Length > 3 && parts[3] == "onePerPlayer"), MultiplyDropByLevel = (parts.Length > 4 && parts[4] == "multiplyByLevel") }; }).ToList(); } public override string ToString() { return string.Join(",", Drops.Select([<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (KeyValuePair<string, Drop> kv) => string.Format("{0}:{1}-{2}:{3}:{4}:{5}", kv.Key, kv.Value.Amount.min, kv.Value.Amount.max, kv.Value.DropChance, kv.Value.DropOnePerPlayer ? "onePerPlayer" : "unrestricted", kv.Value.MultiplyDropByLevel ? "multiplyByLevel" : "unaffectedByLevel"))); } } [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(new byte[] { 2, 1, 1 })] private Dictionary<string, Drop> drops = null; public Drop this[string prefabName] { get { Drop result; if (!(drops ?? (drops = new Dictionary<string, Drop>())).TryGetValue(prefabName, out var value)) { Drop drop2 = (drops[prefabName] = new Drop()); result = drop2; } else { result = value; } return result; } } public void None() { drops = new Dictionary<string, Drop>(); } [HarmonyPriority(700)] internal static void AddDropsToCreature() { foreach (Creature registeredCreature in registeredCreatures) { UpdateDrops(registeredCreature); } } internal static void UpdateDrops(Creature creature) { DropOption dropOption = creatureConfigs[creature].Drops.get(); if (dropOption == DropOption.Default && creature.Drops.drops == null) { return; } CharacterDrop val = creature.Prefab.GetComponent<CharacterDrop>() ?? creature.Prefab.AddComponent<CharacterDrop>(); DropOption dropOption2 = creatureConfigs[creature].Drops.get(); if (1 == 0) { } List<KeyValuePair<string, Drop>> source = dropOption2 switch { DropOption.Custom => new SerializedDrops(creatureConfigs[creature].CustomDrops.get()).Drops, DropOption.Disabled => new List<KeyValuePair<string, Drop>>(), _ => creature.Drops.drops.ToList(), }; if (1 == 0) { } val.m_drops = (from d in ((IEnumerable<KeyValuePair<string, Drop>>)source).Select((Func<KeyValuePair<string, Drop>, Drop>)([<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (KeyValuePair<string, Drop> kv) => { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown if (kv.Key == "" || ZNetScene.instance == null) { return null; } GameObject prefab = ZNetScene.instance.GetPrefab(kv.Key); if (prefab == null) { Debug.LogWarning((object)("Found invalid prefab name " + kv.Key + " for creature " + ((Object)creature.Prefab).name)); return null; } return new Drop { m_prefab = prefab, m_amountMin = (int)kv.Value.Amount.min, m_amountMax = (int)kv.Value.Amount.max, m_chance = kv.Value.DropChance / 100f, m_onePerPlayer = kv.Value.DropOnePerPlayer, m_levelMultiplier = kv.Value.MultiplyDropByLevel }; })) where d != null select d).ToList(); } } [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] [PublicAPI] public class Drop { public Range Amount = new Range(1f, 1f); public float DropChance = 100f; public bool DropOnePerPlayer = false; public bool MultiplyDropByLevel = true; } [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] private class CustomConfig<[<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(2)] T> { [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(1)] public Func<T> get = null; [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(new byte[] { 2, 1 })] public ConfigEntry<T> config = null; } [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] private class CreatureConfig { public readonly CustomConfig<SpawnOption> Spawn = new CustomConfig<SpawnOption>(); public readonly CustomConfig<Toggle> CanBeTamed = new CustomConfig<Toggle>(); public readonly CustomConfig<string> ConsumesItemName = new CustomConfig<string>(); public readonly CustomConfig<float> FedDuration = new CustomConfig<float>(); public readonly CustomConfig<float> TamingTime = new CustomConfig<float>(); public readonly CustomConfig<Toggle> SpawnsTamed = new CustomConfig<Toggle>(); public readonly CustomConfig<Faction> CreatureFaction = new CustomConfig<Faction>(); public readonly CustomConfig<SpawnTime> SpecificSpawnTime = new CustomConfig<SpawnTime>(); public readonly CustomConfig<Range> RequiredAltitude = new CustomConfig<Range>(); public readonly CustomConfig<Range> RequiredOceanDepth = new CustomConfig<Range>(); public readonly CustomConfig<GlobalKey> RequiredGlobalKey = new CustomConfig<GlobalKey>(); public readonly CustomConfig<Range> GroupSize = new CustomConfig<Range>(); public readonly CustomConfig<Biome> Biome = new CustomConfig<Biome>(); public readonly CustomConfig<SpawnArea> SpecificSpawnArea = new CustomConfig<SpawnArea>(); public readonly CustomConfig<Weather> RequiredWeather = new CustomConfig<Weather>(); public readonly CustomConfig<float> SpawnAltitude = new CustomConfig<float>(); public readonly CustomConfig<Toggle> CanHaveStars = new CustomConfig<Toggle>(); public readonly CustomConfig<Toggle> AttackImmediately = new CustomConfig<Toggle>(); public readonly CustomConfig<int> CheckSpawnInterval = new CustomConfig<int>(); public readonly CustomConfig<float> SpawnChance = new CustomConfig<float>(); public readonly CustomConfig<Forest> ForestSpawn = new CustomConfig<Forest>(); public readonly CustomConfig<int> Maximum = new CustomConfig<int>(); public readonly CustomConfig<DropOption> Drops = new CustomConfig<DropOption>(); public readonly CustomConfig<string> CustomDrops = new CustomConfig<string>(); } [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(2)] [UsedImplicitly] public string Category; [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(new byte[] { 2, 1 })] [UsedImplicitly] public Action<ConfigEntryBase> CustomDrawer; } [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] private class AcceptableEnumValues<[<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] T> : AcceptableValueBase where T : struct, IConvertible { [PublicAPI] [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(new byte[] { 1, 0 })] public virtual T[] AcceptableValues { [return: <1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(new byte[] { 1, 0 })] get; } public AcceptableEnumValues([<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(new byte[] { 1, 0 })] params T[] acceptableValues) : base(typeof(T)) { AcceptableValues = acceptableValues; } public override object Clamp(object value) { return ((AcceptableValueBase)this).IsValid(value) ? value : ((object)AcceptableValues[0]); } public override bool IsValid(object value) { return AcceptableValues.Contains((T)value); } public override string ToDescriptionString() { return string.Join(", ", AcceptableValues); } } public bool ConfigurationEnabled = true; public readonly GameObject Prefab; public DropList Drops = new DropList(); public bool CanSpawn = true; public bool CanBeTamed = false; [Description("List of items the creature consumes to get tame.\nFor multiple item names, separate them with a comma.")] public string FoodItems; [Description("How long the creature remains fed after eating.")] public float FedDuration; [Description("Time it takes to tame the creature.")] public float TamingTime; [Description("If the creature spawns tamed.")] public bool SpawnsTamed; [Description("The creature faction the creature belongs to.")] public Faction CreatureFaction; [Description("Sets the time of day the creature can spawn.")] public SpawnTime SpecificSpawnTime = SpawnTime.Always; [Description("Sets the minimum and maximum altitude for the creature to spawn.")] public Range RequiredAltitude = new Range(5f, 1000f); [Description("Sets the minimum and maximum depth of the ocean for the creature to spawn.")] public Range RequiredOceanDepth = new Range(0f, 0f); [Description("Sets a global key required for the creature to spawn.")] public GlobalKey RequiredGlobalKey = GlobalKey.None; [Description("Sets a range for the group size the creature spawns in.")] public Range GroupSize = new Range(1f, 1f); [Description("Sets the biome the creature spawns in.")] public Biome Biome = (Biome)1; [Description("Sets spawning area for the creature inside the biome.\nUse SpawnArea.Edge, to make the creature spawn more towards the edge of the biome.\nUse SpawnArea.Center, to make the creature spawn more towards the center of the biome.")] public SpawnArea SpecificSpawnArea = SpawnArea.Everywhere; [Description("Sets the weather condition for the creature to spawn.\nUse the Weather enum for easy configuration.")] public Weather RequiredWeather = Weather.None; [Description("Sets altitude relative to the current ground level for the creature to spawn.\nShould be a higher number for flying creatures, so they spawn in the sky.")] public float SpawnAltitude = 0.5f; public bool CanHaveStars = true; [Description("Controls the first AI command right after spawn.\nSet to true for the creature to immediately start to hunt down the player.")] public bool AttackImmediately = false; [Description("The time between attempts to spawn the creature in.")] public int CheckSpawnInterval = 600; [Description("The chance in percent for the creature to spawn, every time Valheim checks if it should spawn.")] public float SpawnChance = 100f; [Description("Can be used to make the creature spawn in forests or prevent it from spawning in forests.\nUse the Forest enum for easy configuration.")] public Forest ForestSpawn = Forest.Both; [Description("Sets the maximum number of the creature that can be near the player, before Valheim disables its spawn.")] public int Maximum = 1; private static readonly List<Creature> registeredCreatures = new List<Creature>(); private static Dictionary<Creature, CreatureConfig> creatureConfigs = new Dictionary<Creature, CreatureConfig>(); [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(2)] private static object configManager; private static List<SpawnData> lastRegisteredSpawns = new List<SpawnData>(); [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(2)] private static Localization _english; [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(2)] private static BaseUnityPlugin _plugin; private static bool hasConfigSync = true; [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(2)] private static object _configSync; private static Localization english => _english ?? (_english = LocalizationCache.ForLanguage("English")); private static BaseUnityPlugin plugin { get { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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([<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(2)] private static object configSync { [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(2)] get { if (_configSync == null && hasConfigSync) { Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync"); if ((object)type != null) { _configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " CreatureManager"); type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString()); type.GetProperty("IsLocked").SetValue(_configSync, true); } else { hasConfigSync = false; } } return _configSync; } } public Creature(string assetBundleFileName, string prefabName, string folderName = "assets") : this(PrefabManager.RegisterAssetBundle(assetBundleFileName, folderName), prefabName) { } public Creature(AssetBundle bundle, string prefabName) : this(PrefabManager.RegisterPrefab(bundle, prefabName)) { } public Creature(GameObject creature) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) Prefab = creature; registeredCreatures.Add(this); Tameable val = default(Tameable); if (creature.TryGetComponent<Tameable>(ref val)) { CanBeTamed = true; FedDuration = val.m_fedDuration; TamingTime = val.m_tamingTime; SpawnsTamed = val.m_startsTamed; } else { CanBeTamed = false; FedDuration = 0f; TamingTime = 0f; SpawnsTamed = false; } Character val2 = default(Character); if (creature.TryGetComponent<Character>(ref val2)) { CreatureFaction = val2.m_faction; } FoodItems = string.Join(",", (from i in creature.GetComponent<MonsterAI>()?.m_consumeItems where Object.op_Implicit((Object)(object)i.m_itemData.m_dropPrefab) select ((Object)i.m_itemData.m_dropPrefab).name) ?? Enumerable.Empty<string>()); } public LocalizeKey Localize() { return new LocalizeKey(Prefab.GetComponent<Character>().m_name); } internal static void Patch_FejdStartup() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Expected O, but got Unknown //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Expected O, but got Unknown //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Expected O, but got Unknown //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Expected O, but got Unknown //IL_07ba: Unknown result type (might be due to invalid IL or missing references) //IL_07c4: Expected O, but got Unknown Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager"); configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type)); if (!TomlTypeConverter.CanConvert(typeof(Range))) { TomlTypeConverter.AddConverter(typeof(Range), new TypeConverter { ConvertToObject = [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (string s, Type _) => { Match match = Regex.Match(s, "^(-?\\d+(?:\\.\\d*)?)\\s*-\\s*(-?\\d+(?:\\.\\d*)?)$"); return match.Success ? new Range(float.Parse(match.Groups[1].Value), float.Parse(match.Groups[2].Value)) : default(Range); }, ConvertToString = [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (object obj, Type _) => { Range range = (Range)obj; return $"{range.min} - {range.max}"; } }); } bool saveOnConfigSet = plugin.Config.SaveOnConfigSet; plugin.Config.SaveOnConfigSet = false; foreach (Creature registeredCreature in registeredCreatures) { Creature creature = registeredCreature; CreatureConfig creatureConfig2 = (creatureConfigs[creature] = new CreatureConfig()); CreatureConfig cfg = creatureConfig2; string name2 = creature.Prefab.GetComponent<Character>().m_name; string englishName = new Regex("['[\"\\]]").Replace(english.Localize(name2), "").Trim(); string localizedName = Localization.instance.Localize(name2).Trim(); int order = 0; ConfigurationManagerAttributes tameConfigVisibility = new ConfigurationManagerAttributes(); config<Toggle>(cfg.CanBeTamed, () => (!creature.CanBeTamed) ? Toggle.Off : Toggle.On, delegate { tameConfigVisibility.Browsable = cfg.CanBeTamed.get() == Toggle.On; reloadConfigDisplay(); updateAI(); }, "Can be tamed", "Decides, if the creature can be tamed."); tameConfigVisibility.Browsable = cfg.CanBeTamed.get() == Toggle.On; configWithDesc<string>(cfg.ConsumesItemName, [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] () => creature.FoodItems, updateAI, "Food items", new ConfigDescription("The items the creature consumes to get tame.", (AcceptableValueBase)null, new object[1] { tameConfigVisibility })); configWithDesc<float>(cfg.FedDuration, () => creature.FedDuration, updateAI, "Fed Duration", new ConfigDescription("How long the creature stays fed after eating, in seconds.", (AcceptableValueBase)null, new object[1] { tameConfigVisibility })); configWithDesc<float>(cfg.TamingTime, () => creature.TamingTime, updateAI, "Time to Tame", new ConfigDescription("The time it takes to tame the creature.", (AcceptableValueBase)null, new object[1] { tameConfigVisibility })); configWithDesc<Toggle>(cfg.SpawnsTamed, () => (!creature.SpawnsTamed) ? Toggle.Off : Toggle.On, updateAI, "Spawns Tamed", new ConfigDescription("If on, the creature spawns tamed.", (AcceptableValueBase)null, new object[1] { tameConfigVisibility })); ConfigurationManagerAttributes spawnConfigVisibility = new ConfigurationManagerAttributes(); ConfigurationManagerAttributes dropConfigVisibility = new ConfigurationManagerAttributes(); config<SpawnOption>(cfg.Spawn, () => creature.CanSpawn ? SpawnOption.Default : SpawnOption.Disabled, delegate { spawnConfigVisibility.Browsable = cfg.Spawn.get() == SpawnOption.Custom; reloadConfigDisplay(); updateAllSpawnConfigs(); }, "Spawn", "Configures the spawn for the creature."); spawnConfigVisibility.Browsable = cfg.Spawn.get() == SpawnOption.Custom; spawnConfig<SpawnTime>(cfg.SpecificSpawnTime, () => creature.SpecificSpawnTime, "Spawn time", "Configures the time of day for the creature to spawn."); spawnConfig<Range>(cfg.RequiredAltitude, () => creature.RequiredAltitude, "Required altitude", "Configures the altitude required for the creature to spawn."); spawnConfig<Range>(cfg.RequiredOceanDepth, () => creature.RequiredOceanDepth, "Required ocean depth", "Configures the ocean depth required for the creature to spawn."); spawnConfig<GlobalKey>(cfg.RequiredGlobalKey, () => creature.RequiredGlobalKey, "Required global key", "Configures the global key required for the creature to spawn."); spawnConfig<Range>(cfg.GroupSize, () => creature.GroupSize, "Group size", "Configures the size of the groups in which the creature spawns."); spawnConfig<Biome>(cfg.Biome, () => creature.Biome, "Biome", "Configures the biome required for the creature to spawn."); spawnConfig<SpawnArea>(cfg.SpecificSpawnArea, () => creature.SpecificSpawnArea, "Spawn area", "Configures if the creature spawns more towards the center or the edge of the biome."); spawnConfig<Weather>(cfg.RequiredWeather, () => creature.RequiredWeather, "Required weather", "Configures the weather required for the creature to spawn."); spawnConfig<float>(cfg.SpawnAltitude, () => creature.SpawnAltitude, "Spawn altitude", "Configures the height from the ground in which the creature will spawn."); spawnConfig<Toggle>(cfg.CanHaveStars, () => (!creature.CanHaveStars) ? Toggle.Off : Toggle.On, "Can have stars", "If the creature can have stars."); spawnConfig<Toggle>(cfg.AttackImmediately, () => (!creature.AttackImmediately) ? Toggle.Off : Toggle.On, "Hunt player", "Makes the creature immediately hunt down the player after it spawns."); spawnConfig<int>(cfg.CheckSpawnInterval, () => creature.CheckSpawnInterval, "Maximum spawn interval", "Configures the timespan that Valheim has to make the creature spawn."); spawnConfig<float>(cfg.SpawnChance, () => creature.SpawnChance, "Spawn chance", "Sets the chance for the creature to be spawned, every time Valheim checks the spawn."); spawnConfig<Forest>(cfg.ForestSpawn, () => creature.ForestSpawn, "Forest condition", "If the creature can spawn in forests or cannot spawn in forests. Or both."); spawnConfig<int>(cfg.Maximum, () => creature.Maximum, "Maximum creature count", "The maximum number of this creature near the player, before Valheim stops spawning it in. Setting this lower than the upper limit of the group size does not make sense."); config<DropOption>(cfg.Drops, () => DropOption.Default, delegate { dropConfigVisibility.Browsable = cfg.Drops.get() == DropOption.Custom; reloadConfigDisplay(); DropList.UpdateDrops(creature); }, "Drops", "Configures the drops for the creature."); dropConfigVisibility.Browsable = cfg.Drops.get() == DropOption.Custom; configWithDesc<string>(cfg.CustomDrops, [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] () => new DropList.SerializedDrops(creature.Drops, creature).ToString(), delegate { DropList.UpdateDrops(creature); }, "Drop config", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { dropConfigVisibility })); config<Faction>(cfg.CreatureFaction, () => creature.CreatureFaction, updateCharacterAttributes, "Creature Faction", "The creature faction the creature belongs to."); void config<T>([<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(new byte[] { 1, 0 })] CustomConfig<T> customConfig, [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(new byte[] { 1, 0 })] Func<T> getter, Action configChanged, string name, string desc) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown configWithDesc<T>(customConfig, getter, configChanged, name, new ConfigDescription(desc, (AcceptableValueBase)null, Array.Empty<object>())); } void configWithDesc<T>([<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(new byte[] { 1, 0 })] CustomConfig<T> customConfig, [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(new byte[] { 1, 0 })] Func<T> getter, Action configChanged, string name, ConfigDescription desc) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown if (creature.ConfigurationEnabled) { customConfig.config = pluginConfig(englishName, name, getter(), new ConfigDescription(desc.Description, desc.AcceptableValues, desc.Tags.Concat(new ConfigurationManagerAttributes[1] { new ConfigurationManagerAttributes { Order = (order -= 1), CustomDrawer = ((customConfig == cfg.CustomDrops) ? new Action<ConfigEntryBase>(drawConfigTable) : ((typeof(T) == typeof(Range)) ? new Action<ConfigEntryBase>(drawRange) : null)), Category = localizedName } }).ToArray())); customConfig.config.SettingChanged += [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (object _, EventArgs _) => { configChanged(); }; customConfig.get = [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] () => customConfig.config.Value; } else { customConfig.get = getter; } } void spawnConfig<T>([<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(new byte[] { 1, 0 })] CustomConfig<T> customConfig, [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(new byte[] { 1, 0 })] Func<T> getter, string name, string desc, [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(2)] AcceptableValueBase acceptableValues = null) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown configWithDesc<T>(customConfig, getter, updateAllSpawnConfigs, name, new ConfigDescription(desc, acceptableValues, new object[1] { spawnConfigVisibility })); } void updateAI() { if (Object.op_Implicit((Object)(object)ObjectDB.instance)) { BaseAI[] array2 = Object.FindObjectsOfType<BaseAI>(); foreach (BaseAI ai in array2) { creature.updateAi(ai); } creature.updateAi(creature.Prefab.GetComponent<BaseAI>()); } } void updateAllSpawnConfigs() { SpawnSystem[] array = Object.FindObjectsOfType<SpawnSystem>(); foreach (SpawnSystem val in array) { foreach (SpawnSystemList spawnList in val.m_spawnLists) { foreach (SpawnData spawner in spawnList.m_spawners) { if ((Object)(object)creature.Prefab == (Object)(object)spawner.m_prefab) { creature.updateSpawnData(spawner); } } } } } void updateCharacterAttributes() { if (Object.op_Implicit((Object)(object)ObjectDB.instance)) { creature.updateCharacterAttributes(creature.Prefab.GetComponent<Character>()); } } } if (saveOnConfigSet) { plugin.Config.SaveOnConfigSet = true; plugin.Config.Save(); } static void reloadConfigDisplay() { object obj2 = configManager?.GetType().GetProperty("DisplayingWindow").GetValue(configManager); if (obj2 is bool && (bool)obj2) { configManager.GetType().GetMethod("BuildSettingList").Invoke(configManager, Array.Empty<object>()); } } } private static void drawRange(ConfigEntryBase cfg) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown bool valueOrDefault = cfg.Description.Tags.Select([<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault(); ConfigEntry<Range> val = (ConfigEntry<Range>)(object)cfg; GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); float.TryParse(GUILayout.TextField(val.Value.min.ToString(CultureInfo.InvariantCulture), Array.Empty<GUILayoutOption>()), out var result); GUILayout.Label(" - ", new GUIStyle(GUI.skin.label) { fixedWidth = 14f }, Array.Empty<GUILayoutOption>()); float.TryParse(GUILayout.TextField(val.Value.max.ToString(CultureInfo.InvariantCulture), Array.Empty<GUILayoutOption>()), out var result2); GUILayout.EndHorizontal(); if (!valueOrDefault && (Math.Abs(val.Value.min - result) > 1E-05f || Math.Abs(val.Value.max - result2) > 1E-05f)) { val.Value = new Range(result, result2); } } private static void drawConfigTable(ConfigEntryBase cfg) { //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown //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_0213: Expected O, but got Unknown //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Expected O, but got Unknown //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Expected O, but got Unknown //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Expected O, but got Unknown //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Expected O, but got Unknown //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Expected O, but got Unknown //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Expected O, but got Unknown bool valueOrDefault = cfg.Description.Tags.Select([<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault(); List<KeyValuePair<string, Drop>> list = new List<KeyValuePair<string, Drop>>(); bool flag = false; int num = (int)(configManager?.GetType().GetProperty("RightColumnWidth", BindingFlags.Instance | BindingFlags.NonPublic).GetGetMethod(nonPublic: true) .Invoke(configManager, Array.Empty<object>()) ?? ((object)130)); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); foreach (KeyValuePair<string, Drop> drop in new DropList.SerializedDrops((string)cfg.BoxedValue).Drops) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); int num2 = Mathf.RoundToInt(drop.Value.Amount.min); if (int.TryParse(GUILayout.TextField(num2.ToString(), new GUIStyle(GUI.skin.textField) { fixedWidth = 35f }, Array.Empty<GUILayoutOption>()), out var result) && result != num2 && !valueOrDefault) { num2 = result; flag = true; } GUILayout.Label(" - ", new GUIStyle(GUI.skin.label) { fixedWidth = 14f }, Array.Empty<GUILayoutOption>()); int num3 = Mathf.RoundToInt(drop.Value.Amount.max); if (int.TryParse(GUILayout.TextField(num3.ToString(), new GUIStyle(GUI.skin.textField) { fixedWidth = 35f }, Array.Empty<GUILayoutOption>()), out var result2) && result2 != num3 && !valueOrDefault) { num3 = result2; flag = true; } GUILayout.Label(" ", new GUIStyle(GUI.skin.label) { fixedWidth = 10f }, Array.Empty<GUILayoutOption>()); string text = GUILayout.TextField(drop.Key, new GUIStyle(GUI.skin.textField) { fixedWidth = num - 35 - 14 - 35 - 10 - 21 - 18 }, Array.Empty<GUILayoutOption>()); string text2 = (valueOrDefault ? drop.Key : text); flag = flag || text2 != drop.Key; bool flag2 = GUILayout.Button("x", new GUIStyle(GUI.skin.button) { fixedWidth = 21f }, Array.Empty<GUILayoutOption>()) && !valueOrDefault; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); float num4 = drop.Value.DropChance; if (float.TryParse(GUILayout.TextField(num4.ToString(CultureInfo.InvariantCulture), new GUIStyle(GUI.skin.textField) { fixedWidth = 45f }, Array.Empty<GUILayoutOption>()), out var result3) && Math.Abs(result3 - num4) > 1E-05f && !valueOrDefault) { num4 = result3; flag = true; } GUILayout.Label("% ", Array.Empty<GUILayoutOption>()); string tooltip = GUI.tooltip; bool flag3 = drop.Value.MultiplyDropByLevel; bool flag4 = GUILayout.Toggle(flag3, new GUIContent(flag3 ? "per level" : "fixed", "Loot is multiplied by the creature's level."), Array.Empty<GUILayoutOption>()); if (flag4 != flag3 && !valueOrDefault) { flag3 = flag4; flag = true; } bool flag5 = drop.Value.DropOnePerPlayer; bool flag6 = GUILayout.Toggle(flag5, new GUIContent(flag5 ? "per player" : "independent", "Drops one per player."), Array.Empty<GUILayoutOption>()); if (flag6 != flag5 && !valueOrDefault) { flag5 = flag6; flag = true; } if (GUI.tooltip != tooltip) { Vector3 mousePosition = Input.mousePosition; GUI.Label(new Rect(mousePosition.x, mousePosition.y, 100f, 35f), GUI.tooltip); } if (flag2) { flag = true; } else { Drop value = new Drop { Amount = new Range(num2, num3), DropChance = num4, MultiplyDropByLevel = flag3, DropOnePerPlayer = flag5 }; list.Add(new KeyValuePair<string, Drop>(text2, value)); } if (GUILayout.Button("+", new GUIStyle(GUI.skin.button) { fixedWidth = 21f }, Array.Empty<GUILayoutOption>()) && !valueOrDefault) { flag = true; list.Add(new KeyValuePair<string, Drop>("", new Drop())); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (flag) { cfg.BoxedValue = new DropList.SerializedDrops(list).ToString(); } } private void updateAi(BaseAI ai) { CreatureConfig creatureConfig = creatureConfigs[this]; if (Object.op_Implicit((Object)(object)((Component)ai).GetComponent<Tameable>()) != (creatureConfig.CanBeTamed.get() == Toggle.On)) { if (creatureConfig.CanBeTamed.get() == Toggle.On) { ai.m_tamable = ((Component)ai).gameObject.AddComponent<Tameable>(); } else { Object.Destroy((Object)(object)ai.m_tamable); ai.m_tamable = null; } } Tameable tamable = ai.m_tamable; if (tamable != null) { tamable.m_fedDuration = creatureConfig.FedDuration.get(); tamable.m_tamingTime = creatureConfig.TamingTime.get(); tamable.m_startsTamed = creatureConfig.SpawnsTamed.get() == Toggle.On; } MonsterAI val = (MonsterAI)(object)((ai is MonsterAI) ? ai : null); if (val == null) { return; } val.m_consumeItems.Clear(); string[] array = creatureConfig.ConsumesItemName.get().Split(new char[1] { ',' }); string[] array2 = array; foreach (string text in array2) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text.Trim()); ItemDrop val2 = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null); if (val2 != null) { val.m_consumeItems.Add(val2); } } } private void updateCharacterAttributes(Character character) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) CreatureConfig creatureConfig = creatureConfigs[this]; character.m_faction = creatureConfig.CreatureFaction.get(); } internal static void UpdateCreatureAis(ObjectDB __instance) { foreach (Creature registeredCreature in registeredCreatures) { registeredCreature.updateAi(registeredCreature.Prefab.GetComponent<BaseAI>()); registeredCreature.updateCharacterAttributes(registeredCreature.Prefab.GetComponent<Character>()); } } private void updateSpawnData(SpawnData spawnData) { //IL_0047: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) CreatureConfig cfg = creatureConfigs[this]; spawnData.m_enabled = cfg.Spawn.get() != SpawnOption.Disabled; spawnData.m_biome = cfg.Biome.get(); SpawnArea spawnArea = cfg.SpecificSpawnArea.get(); if (1 == 0) { } BiomeArea biomeArea = (BiomeArea)(spawnArea switch { SpawnArea.Center => 2, SpawnArea.Edge => 1, _ => 3, }); if (1 == 0) { } spawnData.m_biomeArea = biomeArea; spawnData.m_maxSpawned = cfg.Maximum.get(); spawnData.m_spawnInterval = cfg.CheckSpawnInterval.get(); spawnData.m_spawnChance = cfg.SpawnChance.get(); spawnData.m_requiredGlobalKey = ((InternalName)typeof(GlobalKey).GetMember(cfg.RequiredGlobalKey.get().ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName; spawnData.m_requiredEnvironments = (from Weather w in Enum.GetValues(typeof(Weather)) where (w & cfg.RequiredWeather.get()) != 0 select ((InternalName)typeof(Weather).GetMember(w.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).ToList(); spawnData.m_groupSizeMin = (int)cfg.GroupSize.get().min; spawnData.m_groupSizeMax = (int)cfg.GroupSize.get().max; SpawnTime spawnTime = cfg.SpecificSpawnTime.get(); bool spawnAtNight = (uint)(spawnTime - 1) <= 1u; spawnData.m_spawnAtNight = spawnAtNight; spawnTime = cfg.SpecificSpawnTime.get(); spawnAtNight = ((spawnTime == SpawnTime.Day || spawnTime == SpawnTime.Always) ? true : false); spawnData.m_spawnAtDay = spawnAtNight; spawnData.m_minAltitude = cfg.RequiredAltitude.get().min; spawnData.m_maxAltitude = cfg.RequiredAltitude.get().max; Forest forest = cfg.ForestSpawn.get(); spawnAtNight = ((forest == Forest.Yes || forest == Forest.Both) ? true : false); spawnData.m_inForest = spawnAtNight; forest = cfg.ForestSpawn.get(); spawnAtNight = (uint)(forest - 1) <= 1u; spawnData.m_outsideForest = spawnAtNight; spawnData.m_minOceanDepth = cfg.RequiredOceanDepth.get().min; spawnData.m_maxOceanDepth = cfg.RequiredOceanDepth.get().max; spawnData.m_huntPlayer = cfg.AttackImmediately.get() == Toggle.On; spawnData.m_groundOffset = cfg.SpawnAltitude.get(); spawnData.m_maxLevel = ((cfg.CanHaveStars.get() != 0) ? 1 : 3); } [HarmonyPriority(700)] internal static void AddToSpawnSystem(SpawnSystem __instance) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown SpawnSystemList val = __instance.m_spawnLists.First(); foreach (SpawnData lastRegisteredSpawn in lastRegisteredSpawns) { val.m_spawners.Remove(lastRegisteredSpawn); } lastRegisteredSpawns.Clear(); foreach (Creature registeredCreature in registeredCreatures) { SpawnData val2 = new SpawnData { m_name = ((Object)registeredCreature.Prefab).name, m_prefab = registeredCreature.Prefab }; registeredCreature.updateSpawnData(val2); lastRegisteredSpawns.Add(val2); val.m_spawners.Add(val2); } } private static ConfigEntry<T> pluginConfig<[<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(2)] T>(string group, string name, T value, ConfigDescription description) { ConfigEntry<T> val = plugin.Config.Bind<T>(group, name, value, description); configSync?.GetType().GetMethod("AddConfigEntry").MakeGenericMethod(typeof(T)) .Invoke(configSync, new object[1] { val }); return val; } private static ConfigEntry<T> pluginConfig<[<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(2)] T>(string group, string name, T value, string description) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown return pluginConfig(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())); } } [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] [PublicAPI] public class LocalizeKey { private static readonly List<LocalizeKey> keys = new List<LocalizeKey>(); public readonly string Key; public readonly Dictionary<string, string> Localizations = new Dictionary<string, string>(); public LocalizeKey(string key) { Key = key.Replace("$", ""); keys.Add(this); } public void Alias(string alias) { Localizations.Clear(); if (!alias.Contains("$")) { alias = "$" + alias; } Localizations["alias"] = alias; if (Localization.m_instance != null) { Localization.instance.AddWord(Key, Localization.instance.Localize(alias)); } } public LocalizeKey English(string key) { return addForLang("English", key); } public LocalizeKey Swedish(string key) { return addForLang("Swedish", key); } public LocalizeKey French(string key) { return addForLang("French", key); } public LocalizeKey Italian(string key) { return addForLang("Italian", key); } public LocalizeKey German(string key) { return addForLang("German", key); } public LocalizeKey Spanish(string key) { return addForLang("Spanish", key); } public LocalizeKey Russian(string key) { return addForLang("Russian", key); } public LocalizeKey Romanian(string key) { return addForLang("Romanian", key); } public LocalizeKey Bulgarian(string key) { return addForLang("Bulgarian", key); } public LocalizeKey Macedonian(string key) { return addForLang("Macedonian", key); } public LocalizeKey Finnish(string key) { return addForLang("Finnish", key); } public LocalizeKey Danish(string key) { return addForLang("Danish", key); } public LocalizeKey Norwegian(string key) { return addForLang("Norwegian", key); } public LocalizeKey Icelandic(string key) { return addForLang("Icelandic", key); } public LocalizeKey Turkish(string key) { return addForLang("Turkish", key); } public LocalizeKey Lithuanian(string key) { return addForLang("Lithuanian", key); } public LocalizeKey Czech(string key) { return addForLang("Czech", key); } public LocalizeKey Hungarian(string key) { return addForLang("Hungarian", key); } public LocalizeKey Slovak(string key) { return addForLang("Slovak", key); } public LocalizeKey Polish(string key) { return addForLang("Polish", key); } public LocalizeKey Dutch(string key) { return addForLang("Dutch", key); } public LocalizeKey Portuguese_European(string key) { return addForLang("Portuguese_European", key); } public LocalizeKey Portuguese_Brazilian(string key) { return addForLang("Portuguese_Brazilian", key); } public LocalizeKey Chinese(string key) { return addForLang("Chinese", key); } public LocalizeKey Japanese(string key) { return addForLang("Japanese", key); } public LocalizeKey Korean(string key) { return addForLang("Korean", key); } public LocalizeKey Hindi(string key) { return addForLang("Hindi", key); } public LocalizeKey Thai(string key) { return addForLang("Thai", key); } public LocalizeKey Abenaki(string key) { return addForLang("Abenaki", key); } public LocalizeKey Croatian(string key) { return addForLang("Croatian", key); } public LocalizeKey Georgian(string key) { return addForLang("Georgian", key); } public LocalizeKey Greek(string key) { return addForLang("Greek", key); } public LocalizeKey Serbian(string key) { return addForLang("Serbian", key); } public LocalizeKey Ukrainian(string key) { return addForLang("Ukrainian", key); } private LocalizeKey addForLang(string lang, string value) { Localizations[lang] = value; if (Localization.m_instance != null) { if (Localization.instance.GetSelectedLanguage() == lang) { Localization.instance.AddWord(Key, value); } else if (lang == "English" && !Localization.instance.m_translations.ContainsKey(Key)) { Localization.instance.AddWord(Key, value); } } return this; } [HarmonyPriority(300)] internal static void AddLocalizedKeys(Localization __instance, string language) { foreach (LocalizeKey key in keys) { string value2; if (key.Localizations.TryGetValue(language, out var value) || key.Localizations.TryGetValue("English", out value)) { __instance.AddWord(key.Key, value); } else if (key.Localizations.TryGetValue("alias", out value2)) { __instance.AddWord(key.Key, Localization.instance.Localize(value2)); } } } } [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] public static class LocalizationCache { private static readonly Dictionary<string, Localization> localizations = new Dictionary<string, Localization>(); internal static void LocalizationPostfix(Localization __instance, string language) { string key = localizations.FirstOrDefault([<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(0)] (KeyValuePair<string, Localization> l) => l.Value == __instance).Key; if (key != null) { localizations.Remove(key); } if (!localizations.ContainsKey(language)) { localizations.Add(language, __instance); } } public static Localization ForLanguage([<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(2)] string language = null) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (localizations.TryGetValue(language ?? PlayerPrefs.GetString("language", "English"), out var value)) { return value; } value = new Localization(); if (language != null) { value.SetupLanguage(language); } return value; } } [<b06a9c6b-2be5-4c87-a545-7b5bc92fe11e>NullableContext(1)] [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] public static class PrefabManager { [<1277a557-2f61-45b9-856f-fa8dcff5851f>Nullable(0)] private struct BundleId { [UsedImplicitly] public string assetBundleFileName; [UsedImplicitly] public string folderName; } private static readonly Dictionary<BundleId, AssetBundle> bundleCache; private static readonly List<GameObject> prefabs; static PrefabManager() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown bundleCache = new Dictionary<BundleId, AssetBundle>(); prefabs = new List<GameObject>(); Harmony val = new Harmony("org.bepinex.helpers.CreatureManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PrefabManager), "Patch_ZNetSceneAwake", (Type[])null, (Type[])null)), (Harmony