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 System.Threading; using AzuEPI; using AzuEPI.Core.Slots; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using ItemManager; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using PieceManager; using ServerSync; using Splatform; using StatusEffectManager; using TMPro; using UnityEngine; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.ObjectPool; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Callbacks; 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("E74EB49A-461D-48EA-85BC-F462D60C98C4")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyProduct("Vikings_Summoner")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("Vikings_Summoner")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyFileVersion("1.4.4")] [assembly: AssemblyCompany("Radamanto")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.4.0")] [module: <0f5dda22-adc4-4eb7-9dec-383820a7c9a5>RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<944d4903-c032-4390-9b7e-e5d8660b6277>Embedded] internal sealed class <944d4903-c032-4390-9b7e-e5d8660b6277>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<944d4903-c032-4390-9b7e-e5d8660b6277>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<944d4903-c032-4390-9b7e-e5d8660b6277>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [<944d4903-c032-4390-9b7e-e5d8660b6277>Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] [CompilerGenerated] internal sealed class <0f5dda22-adc4-4eb7-9dec-383820a7c9a5>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <0f5dda22-adc4-4eb7-9dec-383820a7c9a5>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Vikings_Summoner { internal static class Registrations_Grimories { public static void RegisterGrimories() { Item item = new Item("rd_armor", "RD_grimoire_01"); item.Configurable = Configurability.Recipe; item.Crafting.Add("RD_necromancer_table", 1); item.RequiredItems.Add("DeerHide", 20); item.RequiredItems.Add("LeatherScraps", 10); item.RequiredItems.Add("Feathers", 15); item.RequiredItems.Add("GreydwarfEye", 10); MaterialReplacer.RegisterGameObjectForShaderSwap(item.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item2 = new Item("rd_armor", "RD_grimoire_summons_01"); item2.Configurable = Configurability.Recipe; item2.Crafting.Add("RD_necromancer_table", 1); item2.RequiredItems.Add("TrophyAbomination", 1); item2.RequiredItems.Add("DeerHide", 20); item2.RequiredItems.Add("Iron", 2); item2.RequiredItems.Add("Guck", 15); MaterialReplacer.RegisterGameObjectForShaderSwap(item2.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item3 = new Item("rd_armor", "RD_grimoire_02"); item3.Configurable = Configurability.Recipe; item3.Crafting.Add("RD_necromancer_table", 1); item3.RequiredItems.Add("WolfPelt", 10); item3.RequiredItems.Add("WolfFang", 4); item3.RequiredItems.Add("Crystal", 5); item3.RequiredItems.Add("Resin", 15); MaterialReplacer.RegisterGameObjectForShaderSwap(item3.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item4 = new Item("rd_armor", "RD_grimoire_summons_02"); item4.Configurable = Configurability.Recipe; item4.Crafting.Add("RD_necromancer_table_02", 1); item4.RequiredItems.Add("TrophyGoblinShaman", 1); item4.RequiredItems.Add("LoxPelt", 20); item4.RequiredItems.Add("BlackMetal", 2); item4.RequiredItems.Add("Tar", 15); MaterialReplacer.RegisterGameObjectForShaderSwap(item4.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item5 = new Item("rd_armor", "RD_grimoire_03"); item5.Configurable = Configurability.Recipe; item5.Crafting.Add("RD_necromancer_table_02", 1); item5.RequiredItems.Add("YmirRemains", 10); item5.RequiredItems.Add("DeerHide", 20); item5.RequiredItems.Add("BlackCore", 5); item5.RequiredItems.Add("Eitr", 15); MaterialReplacer.RegisterGameObjectForShaderSwap(item5.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item6 = new Item("rd_armor", "RD_grimoire_summons_03"); item6.Configurable = Configurability.Recipe; item6.Crafting.Add("RD_necromancer_table_02", 1); item6.RequiredItems.Add("TrophyCharredMage", 1); item6.RequiredItems.Add("AskHide", 10); item6.RequiredItems.Add("FlametalNew", 2); item6.RequiredItems.Add("CelestialFeather", 5); MaterialReplacer.RegisterGameObjectForShaderSwap(item6.Prefab, MaterialReplacer.ShaderType.UseUnityShader); } } internal static class Registrations_Armors { public static void RegisterArmors() { Item item = new Item("rd_armor", "RD_inv_chest_meadows"); item.Configurable = Configurability.Recipe | Configurability.Stats; item.Crafting.Add("RD_necromancer_table", 1); item.RequiredItems.Add("DeerHide", 10); item.RequiredItems.Add("LeatherScraps", 10); item.RequiredUpgradeItems.Add("DeerHide", 2); item.RequiredUpgradeItems.Add("LeatherScraps", 2); item.RequiredUpgradeItems.Add("BoneFragments", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item2 = new Item("rd_armor", "RD_inv_helmet_meadows"); item2.Configurable = Configurability.Recipe | Configurability.Stats; item2.Crafting.Add("RD_necromancer_table", 1); item2.RequiredItems.Add("DeerHide", 4); item2.RequiredItems.Add("LeatherScraps", 4); item2.RequiredUpgradeItems.Add("DeerHide", 2); item2.RequiredUpgradeItems.Add("LeatherScraps", 2); item2.RequiredUpgradeItems.Add("BoneFragments", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item2.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item3 = new Item("rd_armor", "RD_inv_legs_meadows"); item3.Configurable = Configurability.Recipe | Configurability.Stats; item3.Crafting.Add("RD_necromancer_table", 1); item3.RequiredItems.Add("DeerHide", 8); item3.RequiredItems.Add("LeatherScraps", 8); item3.RequiredUpgradeItems.Add("DeerHide", 2); item3.RequiredUpgradeItems.Add("LeatherScraps", 2); item3.RequiredUpgradeItems.Add("BoneFragments", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item3.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item4 = new Item("rd_armor", "RD_inv_cape_meadows"); item4.Configurable = Configurability.Recipe | Configurability.Stats; item4.Crafting.Add("RD_necromancer_table", 1); item4.RequiredItems.Add("DeerHide", 6); item4.RequiredItems.Add("LeatherScraps", 6); item4.RequiredUpgradeItems.Add("DeerHide", 2); item4.RequiredUpgradeItems.Add("LeatherScraps", 2); item4.RequiredUpgradeItems.Add("BoneFragments", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item4.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item5 = new Item("rd_armor", "RD_inv_helmet_bforest"); item5.Configurable = Configurability.Recipe | Configurability.Stats; item5.Crafting.Add("RD_necromancer_table", 1); item5.RequiredItems.Add("TrollHide", 4); item5.RequiredItems.Add("BoneFragments", 6); item5.RequiredItems.Add("Bronze", 5); item5.RequiredUpgradeItems.Add("TrollHide", 1); item5.RequiredUpgradeItems.Add("BoneFragments", 2); item5.RequiredUpgradeItems.Add("Bronze", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item5.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item6 = new Item("rd_armor", "RD_inv_chest_bforest"); item6.Configurable = Configurability.Recipe | Configurability.Stats; item6.Crafting.Add("RD_necromancer_table", 1); item6.RequiredItems.Add("TrollHide", 4); item6.RequiredItems.Add("BoneFragments", 8); item6.RequiredItems.Add("Bronze", 5); item6.RequiredUpgradeItems.Add("TrollHide", 1); item6.RequiredUpgradeItems.Add("BoneFragments", 3); item6.RequiredUpgradeItems.Add("Bronze", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item6.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item7 = new Item("rd_armor", "RD_inv_legs_bforest"); item7.Configurable = Configurability.Recipe | Configurability.Stats; item7.Crafting.Add("RD_necromancer_table", 1); item7.RequiredItems.Add("TrollHide", 4); item7.RequiredItems.Add("BoneFragments", 6); item7.RequiredItems.Add("Bronze", 5); item7.RequiredUpgradeItems.Add("TrollHide", 1); item7.RequiredUpgradeItems.Add("BoneFragments", 4); item7.RequiredUpgradeItems.Add("Bronze", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item7.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item8 = new Item("rd_armor", "RD_inv_cape_bforest"); item8.Configurable = Configurability.Recipe | Configurability.Stats; item8.Crafting.Add("RD_necromancer_table", 1); item8.RequiredItems.Add("TrollHide", 2); item8.RequiredItems.Add("BoneFragments", 4); item8.RequiredItems.Add("Bronze", 2); item8.RequiredUpgradeItems.Add("TrollHide", 1); item8.RequiredUpgradeItems.Add("BoneFragments", 2); item8.RequiredUpgradeItems.Add("Bronze", 1); MaterialReplacer.RegisterGameObjectForShaderSwap(item8.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item9 = new Item("rd_armor", "RD_inv_helmet_swamp"); item9.Configurable = Configurability.Recipe | Configurability.Stats; item9.Crafting.Add("RD_necromancer_table", 2); item9.RequiredItems.Add("Iron", 10); item9.RequiredItems.Add("ElderBark", 10); item9.RequiredItems.Add("Entrails", 6); item9.RequiredUpgradeItems.Add("Iron", 2); item9.RequiredUpgradeItems.Add("ElderBark", 6); item9.RequiredUpgradeItems.Add("Entrails", 3); MaterialReplacer.RegisterGameObjectForShaderSwap(item9.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item10 = new Item("rd_armor", "RD_inv_chest_swamp"); item10.Configurable = Configurability.Recipe | Configurability.Stats; item10.Crafting.Add("RD_necromancer_table", 2); item10.RequiredItems.Add("Iron", 12); item10.RequiredItems.Add("ElderBark", 8); item10.RequiredItems.Add("Entrails", 8); item10.RequiredUpgradeItems.Add("Iron", 3); item10.RequiredUpgradeItems.Add("ElderBark", 4); item10.RequiredUpgradeItems.Add("Entrails", 4); MaterialReplacer.RegisterGameObjectForShaderSwap(item10.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item11 = new Item("rd_armor", "RD_inv_legs_swamp"); item11.Configurable = Configurability.Recipe | Configurability.Stats; item11.Crafting.Add("RD_necromancer_table", 2); item11.RequiredItems.Add("Iron", 12); item11.RequiredItems.Add("ElderBark", 8); item11.RequiredItems.Add("Entrails", 8); item11.RequiredUpgradeItems.Add("Iron", 3); item11.RequiredUpgradeItems.Add("ElderBark", 4); item11.RequiredUpgradeItems.Add("Entrails", 4); MaterialReplacer.RegisterGameObjectForShaderSwap(item11.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item12 = new Item("rd_armor", "RD_inv_cape_swamp"); item12.Configurable = Configurability.Recipe | Configurability.Stats; item12.Crafting.Add("RD_necromancer_table", 2); item12.RequiredItems.Add("ElderBark", 4); item12.RequiredItems.Add("Entrails", 6); item12.RequiredUpgradeItems.Add("ElderBark", 2); item12.RequiredUpgradeItems.Add("Entrails", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item12.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item13 = new Item("rd_armor", "RD_inv_helmet_mountain"); item13.Configurable = Configurability.Recipe | Configurability.Stats; item13.Crafting.Add("RD_necromancer_table", 2); item13.RequiredItems.Add("WolfFang", 3); item13.RequiredItems.Add("WolfPelt", 10); item13.RequiredItems.Add("FreezeGland", 6); item13.RequiredItems.Add("TrollHide", 6); item13.RequiredUpgradeItems.Add("WolfPelt", 6); item13.RequiredUpgradeItems.Add("FreezeGland", 2); item13.RequiredUpgradeItems.Add("TrollHide", 4); MaterialReplacer.RegisterGameObjectForShaderSwap(item13.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item14 = new Item("rd_armor", "RD_inv_chest_mountain"); item14.Configurable = Configurability.Recipe | Configurability.Stats; item14.Crafting.Add("RD_necromancer_table", 2); item14.RequiredItems.Add("WolfClaw", 3); item14.RequiredItems.Add("WolfPelt", 14); item14.RequiredItems.Add("Silver", 18); item14.RequiredItems.Add("DeerHide", 12); item14.RequiredUpgradeItems.Add("WolfPelt", 6); item14.RequiredUpgradeItems.Add("Silver", 8); item14.RequiredUpgradeItems.Add("DeerHide", 6); MaterialReplacer.RegisterGameObjectForShaderSwap(item14.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item15 = new Item("rd_armor", "RD_inv_legs_mountain"); item15.Configurable = Configurability.Recipe | Configurability.Stats; item15.Crafting.Add("RD_necromancer_table", 2); item15.RequiredItems.Add("WolfClaw", 3); item15.RequiredItems.Add("WolfPelt", 12); item15.RequiredItems.Add("Silver", 24); item15.RequiredItems.Add("DeerHide", 16); item15.RequiredUpgradeItems.Add("WolfPelt", 6); item15.RequiredUpgradeItems.Add("Silver", 12); item15.RequiredUpgradeItems.Add("DeerHide", 8); MaterialReplacer.RegisterGameObjectForShaderSwap(item15.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item16 = new Item("rd_armor", "RD_inv_cape_mountain"); item16.Configurable = Configurability.Recipe | Configurability.Stats; item16.Crafting.Add("RD_necromancer_table", 2); item16.RequiredItems.Add("WolfPelt", 12); item16.RequiredItems.Add("Silver", 6); item16.RequiredItems.Add("FreezeGland", 6); item16.RequiredUpgradeItems.Add("WolfPelt", 6); item16.RequiredUpgradeItems.Add("Silver", 4); item16.RequiredUpgradeItems.Add("FreezeGland", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item16.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item17 = new Item("rd_armor", "RD_inv_helmet_plains"); item17.Configurable = Configurability.Recipe | Configurability.Stats; item17.Crafting.Add("RD_necromancer_table_02", 1); item17.RequiredItems.Add("BlackMetal", 16); item17.RequiredItems.Add("LoxPelt", 8); item17.RequiredItems.Add("LinenThread", 6); item17.RequiredItems.Add("JuteRed", 4); item17.RequiredUpgradeItems.Add("BlackMetal", 8); item17.RequiredUpgradeItems.Add("LoxPelt", 4); item17.RequiredUpgradeItems.Add("LinenThread", 3); item17.RequiredUpgradeItems.Add("JuteRed", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item17.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item18 = new Item("rd_armor", "RD_inv_chest_plains"); item18.Configurable = Configurability.Recipe | Configurability.Stats; item18.Crafting.Add("RD_necromancer_table_02", 1); item18.RequiredItems.Add("BlackMetal", 24); item18.RequiredItems.Add("LoxPelt", 12); item18.RequiredItems.Add("LinenThread", 12); item18.RequiredItems.Add("JuteRed", 4); item18.RequiredUpgradeItems.Add("BlackMetal", 12); item18.RequiredUpgradeItems.Add("LoxPelt", 6); item18.RequiredUpgradeItems.Add("LinenThread", 6); item18.RequiredUpgradeItems.Add("JuteRed", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item18.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item19 = new Item("rd_armor", "RD_inv_legs_plains"); item19.Configurable = Configurability.Recipe | Configurability.Stats; item19.Crafting.Add("RD_necromancer_table_02", 1); item19.RequiredItems.Add("BlackMetal", 24); item19.RequiredItems.Add("LoxPelt", 12); item19.RequiredItems.Add("LinenThread", 12); item19.RequiredItems.Add("JuteRed", 4); item19.RequiredUpgradeItems.Add("BlackMetal", 12); item19.RequiredUpgradeItems.Add("LoxPelt", 6); item19.RequiredUpgradeItems.Add("LinenThread", 6); item19.RequiredUpgradeItems.Add("JuteRed", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item19.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item20 = new Item("rd_armor", "RD_inv_cape_plains"); item20.Configurable = Configurability.Recipe | Configurability.Stats; item20.Crafting.Add("RD_necromancer_table_02", 1); item20.RequiredItems.Add("BlackMetal", 8); item20.RequiredItems.Add("LoxPelt", 6); item20.RequiredItems.Add("LinenThread", 8); item20.RequiredItems.Add("JuteRed", 2); item20.RequiredUpgradeItems.Add("BlackMetal", 4); item20.RequiredUpgradeItems.Add("LoxPelt", 2); item20.RequiredUpgradeItems.Add("LinenThread", 4); item20.RequiredUpgradeItems.Add("JuteRed", 1); MaterialReplacer.RegisterGameObjectForShaderSwap(item20.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item21 = new Item("rd_armor", "RD_inv_helmet_mistlands"); item21.Configurable = Configurability.Recipe | Configurability.Stats; item21.Crafting.Add("RD_necromancer_table_02", 1); item21.RequiredItems.Add("LinenThread", 16); item21.RequiredItems.Add("ScaleHide", 12); item21.RequiredItems.Add("Carapace", 8); item21.RequiredItems.Add("Eitr", 14); item21.RequiredUpgradeItems.Add("ScaleHide", 6); item21.RequiredUpgradeItems.Add("Carapace", 4); item21.RequiredUpgradeItems.Add("Eitr", 8); MaterialReplacer.RegisterGameObjectForShaderSwap(item21.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item22 = new Item("rd_armor", "RD_inv_chest_mistlands"); item22.Configurable = Configurability.Recipe | Configurability.Stats; item22.Crafting.Add("RD_necromancer_table_02", 1); item22.RequiredItems.Add("Mandible", 8); item22.RequiredItems.Add("ScaleHide", 18); item22.RequiredItems.Add("Carapace", 16); item22.RequiredItems.Add("Eitr", 22); item22.RequiredUpgradeItems.Add("ScaleHide", 9); item22.RequiredUpgradeItems.Add("Carapace", 8); item22.RequiredUpgradeItems.Add("Eitr", 11); MaterialReplacer.RegisterGameObjectForShaderSwap(item22.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item23 = new Item("rd_armor", "RD_inv_legs_mistlands"); item23.Configurable = Configurability.Recipe | Configurability.Stats; item23.Crafting.Add("RD_necromancer_table_02", 1); item23.RequiredItems.Add("Mandible", 8); item23.RequiredItems.Add("ScaleHide", 18); item23.RequiredItems.Add("Carapace", 16); item23.RequiredItems.Add("Eitr", 22); item23.RequiredUpgradeItems.Add("ScaleHide", 9); item23.RequiredUpgradeItems.Add("Carapace", 8); item23.RequiredUpgradeItems.Add("Eitr", 11); MaterialReplacer.RegisterGameObjectForShaderSwap(item23.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item24 = new Item("rd_armor", "RD_inv_cape_mistlands"); item24.Configurable = Configurability.Recipe | Configurability.Stats; item24.Crafting.Add("RD_necromancer_table_02", 1); item24.RequiredItems.Add("Mandible", 2); item24.RequiredItems.Add("ScaleHide", 8); item24.RequiredItems.Add("Carapace", 8); item24.RequiredItems.Add("Eitr", 12); item24.RequiredUpgradeItems.Add("ScaleHide", 4); item24.RequiredUpgradeItems.Add("Carapace", 4); item24.RequiredUpgradeItems.Add("Eitr", 6); MaterialReplacer.RegisterGameObjectForShaderSwap(item24.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item25 = new Item("rd_armor", "RD_inv_helmet_ashlands"); item25.Configurable = Configurability.Recipe | Configurability.Stats; item25.Crafting.Add("RD_necromancer_table_02", 1); item25.RequiredItems.Add("GemstoneRed", 1); item25.RequiredItems.Add("AskHide", 8); item25.RequiredItems.Add("CelestialFeather", 4); item25.RequiredItems.Add("FlametalNew", 8); item25.RequiredUpgradeItems.Add("AskHide", 4); item25.RequiredUpgradeItems.Add("CelestialFeather", 2); item25.RequiredUpgradeItems.Add("FlametalNew", 4); MaterialReplacer.RegisterGameObjectForShaderSwap(item25.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item26 = new Item("rd_armor", "RD_inv_chest_ashlands"); item26.Configurable = Configurability.Recipe | Configurability.Stats; item26.Crafting.Add("RD_necromancer_table_02", 1); item26.RequiredItems.Add("GemstoneRed", 1); item26.RequiredItems.Add("AskHide", 28); item26.RequiredItems.Add("CharredBone", 16); item26.RequiredItems.Add("FlametalNew", 26); item26.RequiredUpgradeItems.Add("AskHide", 14); item26.RequiredUpgradeItems.Add("CharredBone", 8); item26.RequiredUpgradeItems.Add("FlametalNew", 14); MaterialReplacer.RegisterGameObjectForShaderSwap(item26.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item27 = new Item("rd_armor", "RD_inv_legs_ashlands"); item27.Configurable = Configurability.Recipe | Configurability.Stats; item27.Crafting.Add("RD_necromancer_table_02", 1); item27.RequiredItems.Add("GemstoneRed", 1); item27.RequiredItems.Add("AskHide", 28); item27.RequiredItems.Add("CharredBone", 16); item27.RequiredItems.Add("FlametalNew", 26); item27.RequiredUpgradeItems.Add("AskHide", 14); item27.RequiredUpgradeItems.Add("CharredBone", 8); item27.RequiredUpgradeItems.Add("FlametalNew", 14); MaterialReplacer.RegisterGameObjectForShaderSwap(item27.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item28 = new Item("rd_armor", "RD_inv_cape_ashlands"); item28.Configurable = Configurability.Recipe | Configurability.Stats; item28.Crafting.Add("RD_necromancer_table_02", 1); item28.RequiredItems.Add("GemstoneRed", 1); item28.RequiredItems.Add("AskHide", 6); item28.RequiredItems.Add("CelestialFeather", 6); item28.RequiredItems.Add("FlametalNew", 12); item28.RequiredUpgradeItems.Add("AskHide", 3); item28.RequiredUpgradeItems.Add("CelestialFeather", 4); item28.RequiredUpgradeItems.Add("FlametalNew", 6); MaterialReplacer.RegisterGameObjectForShaderSwap(item28.Prefab, MaterialReplacer.ShaderType.UseUnityShader); } } internal static class Registrations_Mobs_EnemyHudIcons { internal static void Register() { } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [HarmonyPatch(typeof(EnemyHud), "UpdateHuds")] [NullableContext(2)] [HarmonyPriority(0)] internal static class Patch_EnemyHud_UpdateHuds_SummonIcons { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] private const string CombatSpriteName = "ico_summon_combat"; private static readonly FieldInfo HudsField = AccessTools.Field(typeof(EnemyHud), "m_huds"); private static readonly Type HudDataType = AccessTools.Inner(typeof(EnemyHud), "HudData"); private static readonly FieldInfo CharacterField = ((HudDataType != null) ? AccessTools.Field(HudDataType, "m_character") : null); private static readonly FieldInfo AlertedField = ((HudDataType != null) ? AccessTools.Field(HudDataType, "m_alerted") : null); private static readonly FieldInfo AwareField = ((HudDataType != null) ? AccessTools.Field(HudDataType, "m_aware") : null); private static readonly FieldInfo TargetCreatureField = AccessTools.Field(typeof(MonsterAI), "m_targetCreature"); private static readonly FieldInfo TargetStaticField = AccessTools.Field(typeof(MonsterAI), "m_targetStatic"); private static Sprite _combatSprite; [NullableContext(1)] private static void Postfix(EnemyHud __instance) { if ((Object)(object)__instance == (Object)null || HudsField == null || CharacterField == null || AlertedField == null || AwareField == null || !(HudsField.GetValue(__instance) is IDictionary dictionary) || dictionary.Count == 0) { return; } EnsureSprites(); foreach (DictionaryEntry item in dictionary) { UpdateSummonHud(item.Value); } } private static void UpdateSummonHud(object hudData) { if (hudData == null) { return; } object? obj = CharacterField?.GetValue(hudData); Character val = (Character)((obj is Character) ? obj : null); VS_SummonMarker vS_SummonMarker = default(VS_SummonMarker); if ((Object)(object)val == (Object)null || !((Component)val).TryGetComponent(ref vS_SummonMarker)) { return; } object? obj2 = AlertedField?.GetValue(hudData); RectTransform val2 = (RectTransform)((obj2 is RectTransform) ? obj2 : null); object? obj3 = AwareField?.GetValue(hudData); RectTransform val3 = (RectTransform)((obj3 is RectTransform) ? obj3 : null); if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val3 == (Object)null)) { SetVisible(val2, visible: false); if (!HasRealCombatTarget(val)) { SetVisible(val3, visible: false); return; } ApplySprite(val3, _combatSprite); SetVisible(val3, (Object)(object)_combatSprite != (Object)null); } } [NullableContext(1)] private static bool HasRealCombatTarget(Character character) { BaseAI baseAI = character.GetBaseAI(); MonsterAI val = (MonsterAI)(object)((baseAI is MonsterAI) ? baseAI : null); if ((Object)(object)val == (Object)null) { return false; } object? obj = TargetCreatureField?.GetValue(val); Character val2 = (Character)((obj is Character) ? obj : null); if ((Object)(object)val2 != (Object)null && !val2.IsDead() && BaseAI.IsEnemy(character, val2)) { return true; } object? obj2 = TargetStaticField?.GetValue(val); StaticTarget val3 = (StaticTarget)((obj2 is StaticTarget) ? obj2 : null); return (Object)(object)val3 != (Object)null; } private static void EnsureSprites() { if (_combatSprite == null) { _combatSprite = Vikings_Summoner_AssetLoader.GetSprite("ico_summon_combat"); } } [NullableContext(1)] private static void ApplySprite(RectTransform rect, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] Sprite sprite) { if (!((Object)(object)sprite == (Object)null)) { Image val = ((Component)rect).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)rect).GetComponentInChildren(true); } if (!((Object)(object)val == (Object)null) && (Object)(object)val.sprite != (Object)(object)sprite) { val.sprite = sprite; } } } [NullableContext(1)] private static void SetVisible(RectTransform rect, bool visible) { if (((Component)rect).gameObject.activeSelf != visible) { ((Component)rect).gameObject.SetActive(visible); } } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] [HarmonyPatch(typeof(MonsterAI), "UpdateAI")] internal static class Patch_MonsterAI_UpdateAI_SummonOwnerFollow { internal static float GroundStopDistance = 6f; internal static float FlyingStopDistanceHorizontal = 10f; internal static float FlyingFollowHeightOffset = 2.5f; internal static float FlyingVerticalTolerance = 1.5f; internal static float FlyingVerticalDeadzone = 0.75f; private const float MinMoveSqrMagnitude = 0.0001f; private static void Postfix(MonsterAI __instance, float dt, bool __result) { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) VS_SummonMarker vS_SummonMarker = default(VS_SummonMarker); if ((Object)(object)__instance == (Object)null || !__result || !((Component)__instance).TryGetComponent(ref vS_SummonMarker)) { return; } ZNetView component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null || !component.IsValid() || !component.IsOwner()) { return; } ZDO zDO = component.GetZDO(); if (zDO == null) { return; } Player val = ResolveOwnerPlayer(zDO); if ((Object)(object)val == (Object)null) { return; } Character component2 = ((Component)__instance).GetComponent(); if ((Object)(object)component2 == (Object)null) { return; } Character targetCreature = ((BaseAI)__instance).GetTargetCreature(); StaticTarget staticTarget = __instance.GetStaticTarget(); if (!((Object)(object)staticTarget != (Object)null) && (!((Object)(object)targetCreature != (Object)null) || targetCreature.IsDead() || !((BaseAI)__instance).IsEnemy(targetCreature))) { Vector3 position = ((Component)val).transform.position; Vector3 position2 = ((Component)__instance).transform.position; if (!component2.m_flying) { MoveGround(__instance, position, position2); } else { MoveFlying(__instance, position, position2); } } } private static void MoveGround(MonsterAI ai, Vector3 ownerPos, Vector3 summonPos) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(ownerPos.x - summonPos.x, 0f, ownerPos.z - summonPos.z); float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < GroundStopDistance) { ((BaseAI)ai).StopMoving(); } else if (((Vector3)(ref val)).sqrMagnitude <= 0.0001f) { ((BaseAI)ai).StopMoving(); } else { ((BaseAI)ai).MoveTowards(((Vector3)(ref val)).normalized, true); } } private static void MoveFlying(MonsterAI ai, Vector3 ownerPos, Vector3 summonPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_00bb: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ownerPos + Vector3.up * FlyingFollowHeightOffset; Vector3 val2 = val - summonPos; Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(val2.x, 0f, val2.z); float magnitude = ((Vector3)(ref val3)).magnitude; float num = Mathf.Abs(val2.y); bool flag = magnitude < FlyingStopDistanceHorizontal; bool flag2 = num <= FlyingVerticalTolerance; if (flag && flag2) { ((BaseAI)ai).StopMoving(); return; } if (num <= FlyingVerticalDeadzone) { val2.y = 0f; } if (((Vector3)(ref val2)).sqrMagnitude <= 0.0001f) { ((BaseAI)ai).StopMoving(); } else { ((BaseAI)ai).MoveTowards(((Vector3)(ref val2)).normalized, true); } } [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static Player ResolveOwnerPlayer(ZDO zdo) { string text = zdo.GetString("VS_OwnerSteamID", string.Empty).Trim(); if (text.Length == 0) { return null; } List allPlayers = Player.GetAllPlayers(); if (allPlayers == null || allPlayers.Count == 0) { return null; } for (int i = 0; i < allPlayers.Count; i++) { Player val = allPlayers[i]; if (!((Object)(object)val == (Object)null) && VS_SteamOwnerIdentity.TryGetSteamIdentity(val, out var steamId, out var _) && string.Equals(text, steamId.Trim(), StringComparison.Ordinal)) { return val; } } return null; } } internal static class Registrations_Mobs_Hp { [NullableContext(1)] internal static float CalculateFinalHp(Mob_Registry.SummonDef def, int level) { float num = Mathf.Max(1f, def.BaseHpCE.Value); float num2 = Mathf.Max(0f, def.HpPercentPerStarCE.Value); int num3 = Mathf.Max(0, level - 1); return Mathf.Max(1f, num * (1f + (float)num3 * (num2 / 100f))); } } [HarmonyPatch(typeof(Character), "SetupMaxHealth")] internal static class Patch_Character_SetupMaxHealth_SummonHp { private readonly struct State { internal readonly float OldMaxHealth; internal readonly float OldHealth; internal State(float oldMaxHealth, float oldHealth) { OldMaxHealth = oldMaxHealth; OldHealth = oldHealth; } } [NullableContext(1)] private static void Prefix(Character __instance, out State __state) { __state = (((Object)(object)__instance == (Object)null) ? default(State) : new State(__instance.GetMaxHealth(), __instance.GetHealth())); } [NullableContext(1)] private static void Postfix(Character __instance, State __state) { VS_SummonMarker vS_SummonMarker = default(VS_SummonMarker); if (!((Object)(object)__instance == (Object)null) && ((Component)__instance).TryGetComponent(ref vS_SummonMarker)) { string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject); if (Mob_Registry.TryGet(prefabName, out var def) && def != null) { int level = Mathf.Max(1, __instance.GetLevel()); float num = Registrations_Mobs_Hp.CalculateFinalHp(def, level); float num2 = Mathf.Max(1f, __state.OldMaxHealth); float num3 = Mathf.Max(0f, __state.OldHealth); bool flag = num3 >= num2 - 0.01f; float num4 = Mathf.Clamp01(num3 / num2); __instance.SetMaxHealth(num); __instance.SetHealth(flag ? num : Mathf.Clamp(num * num4, 0f, num)); } } } } [HarmonyPatch(typeof(ZNet), "Awake")] internal static class Patch_ZNet_Awake_SummonOwnerCleanupRpc { [NullableContext(1)] private static void Postfix(ZNet __instance) { if (!((Object)(object)__instance == (Object)null) && !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent())) { ((Component)__instance).gameObject.AddComponent(); } } } internal sealed class VS_SummonOwnerCleanupRpcRegistrar : MonoBehaviour { private static bool _registered; private float _tick; private void Update() { if (_registered) { ((Behaviour)this).enabled = false; return; } _tick -= Time.deltaTime; if (!(_tick > 0f)) { _tick = 0.25f; if (ZRoutedRpc.instance != null) { _registered = true; ZRoutedRpc.instance.Register("VS_RPC_RemoveOwnedSummons", (Action)VS_SummonOwnerCleanup.RPC_RemoveOwnedSummons); ((Behaviour)this).enabled = false; } } } } [HarmonyPatch(typeof(Player), "OnDeath")] internal static class Patch_Player_OnDeath_RemoveOwnedSummons { [NullableContext(1)] private static void Postfix(Player __instance) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { VS_SummonOwnerCleanup.RequestRemoveOwnedSummons(__instance, VS_SummonRemovalReason.OwnerDeath); } } } [HarmonyPatch(typeof(Player), "TeleportTo", new Type[] { typeof(Vector3), typeof(Quaternion), typeof(bool) })] internal static class Patch_Player_TeleportTo_RemoveOwnedSummons { [NullableContext(1)] private static void Prefix(Player __instance) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { VS_SummonOwnerCleanup.RequestRemoveOwnedSummons(__instance, VS_SummonRemovalReason.OwnerTeleport); } } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal static class VS_SummonOwnerCleanup { internal static void RequestRemoveOwnedSummons(Player owner, VS_SummonRemovalReason reason) { if ((Object)(object)owner == (Object)null || !VS_SteamOwnerIdentity.TryGetSteamIdentity(owner, out var steamId, out var _)) { return; } steamId = VS_SteamOwnerIdentity.NormalizeOwnerId(steamId); if (!string.IsNullOrWhiteSpace(steamId)) { RemoveOwnedSummonsBySteamId(steamId, reason); if (!VS_SummonState.IsServer() && ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC("VS_RPC_RemoveOwnedSummons", new object[2] { steamId, (int)reason }); } } } internal static void RPC_RemoveOwnedSummons(long sender, string steamId, int reason) { if (VS_SummonState.IsServer()) { steamId = VS_SteamOwnerIdentity.NormalizeOwnerId(steamId); if (!string.IsNullOrWhiteSpace(steamId)) { VS_SummonRemovalReason reason2 = (Enum.IsDefined(typeof(VS_SummonRemovalReason), reason) ? ((VS_SummonRemovalReason)reason) : VS_SummonRemovalReason.OwnerDeath); RemoveOwnedSummonsBySteamId(steamId, reason2); } } } private static void RemoveOwnedSummonsBySteamId(string steamId, VS_SummonRemovalReason reason) { if (string.IsNullOrWhiteSpace(steamId)) { return; } List allCharacters = Character.GetAllCharacters(); if (allCharacters == null || allCharacters.Count == 0) { return; } VS_SummonMarker vS_SummonMarker = default(VS_SummonMarker); for (int num = allCharacters.Count - 1; num >= 0; num--) { Character val = allCharacters[num]; if (!((Object)(object)val == (Object)null) && Object.op_Implicit((Object)(object)val) && !val.IsDead() && ((Component)val).TryGetComponent(ref vS_SummonMarker)) { ZNetView component = ((Component)val).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { ZDO zDO = component.GetZDO(); if (zDO != null && VS_SteamOwnerIdentity.IsSameOwner(zDO, steamId)) { VS_SummonRemoval.TryRemove(((Component)val).gameObject, reason); } } } } } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(2)] internal static class Registrations_Mobs_Lifetime_UpgradeTotem { internal static ItemData ResolveWeapon(Character owner, ItemData weapon) { if (weapon != null && (Object)(object)weapon.m_dropPrefab != (Object)null) { return weapon; } Humanoid val = (Humanoid)(object)((owner is Humanoid) ? owner : null); if (val == null) { return null; } ItemData currentWeapon = val.GetCurrentWeapon(); if (currentWeapon != null && (Object)(object)currentWeapon.m_dropPrefab != (Object)null) { return currentWeapon; } return null; } internal static float GetBonusSeconds(Character owner, ItemData weapon) { ItemData val = ResolveWeapon(owner, weapon); if (val == null || (Object)(object)val.m_dropPrefab == (Object)null) { return 0f; } int num = Mathf.Max(val.m_quality, 1); if (num <= 1) { return 0f; } string prefabName = Utils.GetPrefabName(val.m_dropPrefab); if (string.IsNullOrEmpty(prefabName)) { return 0f; } float num2 = Mathf.Max(Vikings_SummonerPlugin.GetLifetimeUpgradeTotemCE(prefabName).Value, 0f); if (num2 <= 0f) { return 0f; } return (float)(num - 1) * num2; } internal static float GetFinalLifetimeSeconds([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] string summonPrefab, Character owner, ItemData weapon) { float num = Mathf.Max(Vikings_SummonerPlugin.GetLifetimeCE(summonPrefab).Value, 0.01f); float bonusSeconds = GetBonusSeconds(owner, weapon); return Mathf.Max(num + bonusSeconds, 0.01f); } } internal static class Registrations_Mobs_OwnerDebuff { internal static void Register() { } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal sealed class VS_SummonOwnerRegenDebuff : SE_Stats { internal const string EffectName = "SE_VS_SummonOwnerRegenDebuff"; public override string GetIconText() { Character character = ((StatusEffect)this).m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val == null) { return ""; } int num = VS_SummonOwnerDebuffRuntime.CountActiveSummons(val); return (num > 0) ? num.ToString() : ""; } public override string GetTooltipString() { int num = 0; Character character = ((StatusEffect)this).m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null) { num = VS_SummonOwnerDebuffRuntime.CountActiveSummons(val); } float num2 = Mathf.Max(0f, (1f - base.m_healthRegenMultiplier) * 100f); string text = ((StatusEffect)this).m_tooltip; if (Localization.instance != null && !string.IsNullOrWhiteSpace(text)) { text = Localization.instance.Localize(text); } if (string.IsNullOrWhiteSpace(text)) { return string.Empty; } return string.Format(text, num, num2.ToString("0.#")); } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] internal static class VS_SummonOwnerDebuffRuntime { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static VS_SummonOwnerRegenDebuff _template; private static readonly int EffectHash = StringExtensionMethods.GetStableHashCode("SE_VS_SummonOwnerRegenDebuff"); internal static void EnsureRegistered() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_template != (Object)null)) { _template = ScriptableObject.CreateInstance(); ((Object)_template).name = "SE_VS_SummonOwnerRegenDebuff"; ((StatusEffect)_template).m_name = "$vs_summon_regen_burden_name"; ((StatusEffect)_template).m_tooltip = "$vs_summon_regen_burden_tooltip"; ((StatusEffect)_template).m_category = "Equipment"; ((StatusEffect)_template).m_icon = Vikings_Summoner_AssetLoader.GetSprite("ico_debuff"); ((StatusEffect)_template).m_flashIcon = false; ((StatusEffect)_template).m_cooldownIcon = false; ((StatusEffect)_template).m_startMessageType = (MessageType)2; ((StatusEffect)_template).m_startMessage = ""; ((StatusEffect)_template).m_stopMessageType = (MessageType)2; ((StatusEffect)_template).m_stopMessage = ""; ((StatusEffect)_template).m_ttl = 0f; ((SE_Stats)_template).m_healthRegenMultiplier = 1f; } } internal static void EnsureInObjectDb() { EnsureRegistered(); if (!((Object)(object)ObjectDB.instance == (Object)null) && !((Object)(object)_template == (Object)null) && !ObjectDB.instance.m_StatusEffects.Contains((StatusEffect)(object)_template)) { ObjectDB.instance.m_StatusEffects.Add((StatusEffect)(object)_template); ObjectDB.instance.UpdateRegisters(); } } internal static int CountActiveSummons(Player owner) { if (!TryResolveOwner(owner, out var steamId, out var _)) { return 0; } int num = 0; List allCharacters = Character.GetAllCharacters(); if (allCharacters == null || allCharacters.Count == 0) { return 0; } VS_SummonMarker vS_SummonMarker = default(VS_SummonMarker); for (int i = 0; i < allCharacters.Count; i++) { Character val = allCharacters[i]; if (!Object.op_Implicit((Object)(object)val) || !((Component)val).TryGetComponent(ref vS_SummonMarker) || val.IsDead()) { continue; } ZNetView component = ((Component)val).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { ZDO zDO = component.GetZDO(); if (zDO != null && !zDO.GetBool("vs_summon_removing", false) && VS_SteamOwnerIdentity.IsSameOwner(zDO, steamId)) { num++; } } } return num; } internal static float CalculateHealthRegenMultiplier(int activeSummons) { float num = Mathf.Max(0f, Vikings_SummonerPlugin.CE_ActiveSummonHealthRegenPenaltyPerSummon.Value); return Mathf.Max(0f, 1f - (float)activeSummons * num); } internal static void UpdateDebuff(Player player) { if ((Object)(object)player == (Object)null) { return; } SEMan seman = ((Character)player).m_seman; if (seman == null) { return; } if (!Vikings_SummonerPlugin.CE_ActiveSummonHealthRegenDebuffEnabled.Value) { seman.RemoveStatusEffect(EffectHash, true); return; } if (!TryResolveOwner(player, out var _, out var _)) { seman.RemoveStatusEffect(EffectHash, true); return; } int num = CountActiveSummons(player); if (num <= 0) { seman.RemoveStatusEffect(EffectHash, true); return; } EnsureInObjectDb(); StatusEffect statusEffect = seman.GetStatusEffect(EffectHash); VS_SummonOwnerRegenDebuff vS_SummonOwnerRegenDebuff = statusEffect as VS_SummonOwnerRegenDebuff; if ((Object)(object)vS_SummonOwnerRegenDebuff == (Object)null) { statusEffect = seman.AddStatusEffect(EffectHash, true, 0, 0f); vS_SummonOwnerRegenDebuff = statusEffect as VS_SummonOwnerRegenDebuff; if ((Object)(object)vS_SummonOwnerRegenDebuff == (Object)null) { return; } } ((SE_Stats)vS_SummonOwnerRegenDebuff).m_healthRegenMultiplier = CalculateHealthRegenMultiplier(num); } [NullableContext(2)] internal static void EnsureUpdater(Player player) { VS_SummonOwnerDebuffUpdater vS_SummonOwnerDebuffUpdater = default(VS_SummonOwnerDebuffUpdater); if (!((Object)(object)player == (Object)null) && TryResolveOwner(player, out var _, out var _) && !((Component)player).TryGetComponent(ref vS_SummonOwnerDebuffUpdater)) { ((Component)player).gameObject.AddComponent(); } } internal static bool HasValidOwnerIdentity(Player player) { string steamId; string ownerName; return TryResolveOwner(player, out steamId, out ownerName); } private static bool TryResolveOwner(Player player, out string steamId, out string ownerName) { return VS_SteamOwnerIdentity.TryGetSteamIdentity(player, out steamId, out ownerName); } } internal sealed class VS_SummonOwnerDebuffUpdater : MonoBehaviour { private const float UpdateInterval = 1f; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private Player _player; private float _tick; private void Awake() { _player = ((Component)this).GetComponent(); _tick = 0f; } private void Update() { if (!((Object)(object)_player == (Object)null) && !((Character)_player).IsDead() && VS_SummonOwnerDebuffRuntime.HasValidOwnerIdentity(_player)) { _tick -= Time.deltaTime; if (!(_tick > 0f)) { _tick = 1f; VS_SummonOwnerDebuffRuntime.UpdateDebuff(_player); } } } private void OnDestroy() { if (((Character)(_player?)).m_seman != null) { ((Character)_player).m_seman.RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SE_VS_SummonOwnerRegenDebuff"), true); } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] internal static class Patch_ObjectDB_Awake_SummonOwnerDebuff { private static void Postfix() { VS_SummonOwnerDebuffRuntime.EnsureInObjectDb(); } } [HarmonyPatch(typeof(Player), "SetPlayerID", new Type[] { typeof(long), typeof(string) })] internal static class Patch_Player_SetPlayerID_SummonOwnerDebuff { [NullableContext(1)] private static void Postfix(Player __instance, long playerID, string name) { if (!((Object)(object)__instance == (Object)null)) { VS_SummonOwnerDebuffRuntime.EnsureUpdater(__instance); } } } [HarmonyPatch(typeof(Player), "Start")] internal static class Patch_Player_Start_SummonOwnerDebuff { [NullableContext(1)] private static void Postfix(Player __instance) { VS_SummonOwnerDebuffRuntime.EnsureUpdater(__instance); } } internal readonly struct VS_SummonProgressionEntry { internal readonly int MinSkill; internal readonly int MaxSkill; internal readonly int SummonLevel; internal readonly int MaxInstances; internal VS_SummonProgressionEntry(int minSkill, int maxSkill, int summonLevel, int maxInstances) { MinSkill = minSkill; MaxSkill = maxSkill; SummonLevel = ((summonLevel < 1) ? 1 : summonLevel); MaxInstances = ((maxInstances < 1) ? 1 : maxInstances); } } internal readonly struct VS_SummonProgressionResult { internal readonly int SummonLevel; internal readonly int MaxInstances; internal VS_SummonProgressionResult(int summonLevel, int maxInstances) { SummonLevel = ((summonLevel < 1) ? 1 : summonLevel); MaxInstances = ((maxInstances < 1) ? 1 : maxInstances); } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal static class VS_SummonProgression { internal static bool TryGetGateFromConfig(string prefab, out int minGate) { minGate = 0; if (!TryParse(prefab, out var result)) { return false; } if (result.Count == 0) { return false; } minGate = result[0].MinSkill; for (int i = 1; i < result.Count; i++) { if (result[i].MinSkill < minGate) { minGate = result[i].MinSkill; } } return true; } internal static bool TryResolve(string prefab, float bloodMagic, out VS_SummonProgressionResult result) { result = default(VS_SummonProgressionResult); if (!TryParse(prefab, out var result2)) { return false; } if (result2.Count == 0) { return false; } int num = Mathf.FloorToInt(bloodMagic); VS_SummonProgressionEntry? vS_SummonProgressionEntry = null; for (int i = 0; i < result2.Count; i++) { VS_SummonProgressionEntry value = result2[i]; if (num < value.MinSkill) { break; } vS_SummonProgressionEntry = value; } if (!vS_SummonProgressionEntry.HasValue) { return false; } result = new VS_SummonProgressionResult(vS_SummonProgressionEntry.Value.SummonLevel, vS_SummonProgressionEntry.Value.MaxInstances); return true; } internal static VS_SummonProgressionResult Resolve(string prefab, float bloodMagic) { if (TryResolve(prefab, bloodMagic, out var result)) { return result; } throw new InvalidOperationException($"Invalid summon progression config for prefab '{prefab}' or Blood Magic '{bloodMagic}'."); } private static bool TryParse(string prefab, out List result) { result = new List(); ConfigEntry progressionCE = Vikings_SummonerPlugin.GetProgressionCE(prefab); if (progressionCE == null) { return false; } string value = progressionCE.Value; if (string.IsNullOrWhiteSpace(value)) { return false; } string[] array = value.Split(new char[1] { ';' }); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length == 0) { return false; } string[] array2 = text.Split(new char[1] { ':' }); if (array2.Length != 3) { return false; } string[] array3 = array2[0].Split(new char[1] { '-' }); if (array3.Length != 2) { return false; } if (!int.TryParse(array3[0].Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out var result2)) { return false; } if (!int.TryParse(array3[1].Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out var result3)) { return false; } if (!int.TryParse(array2[1].Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out var result4)) { return false; } if (!int.TryParse(array2[2].Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out var result5)) { return false; } if (result2 < 0) { return false; } if (result3 < result2) { return false; } if (result4 < 1) { return false; } if (result5 < 1) { return false; } result.Add(new VS_SummonProgressionEntry(result2, result3, result4, result5)); } result.Sort(delegate(VS_SummonProgressionEntry a, VS_SummonProgressionEntry b) { int minSkill = a.MinSkill; return minSkill.CompareTo(b.MinSkill); }); return result.Count > 0; } internal static void EnforceMaxInstances(string prefab, Humanoid owner, int maxInstances) { maxInstances = Mathf.Max(0, maxInstances); Player val = (Player)(object)((owner is Player) ? owner : null); if (val == null || !TryResolveOwner(val, out var steamId, out var ownerName)) { return; } List list = new List(); foreach (Character allCharacter in Character.GetAllCharacters()) { if (!Object.op_Implicit((Object)(object)allCharacter) || !Object.op_Implicit((Object)(object)((Component)allCharacter).GetComponent())) { continue; } string basePrefab = VS_SummonState.GetBasePrefab(((Component)allCharacter).gameObject); if (!string.Equals(basePrefab, prefab, StringComparison.Ordinal)) { continue; } ZNetView component = ((Component)allCharacter).GetComponent(); if (!Object.op_Implicit((Object)(object)component) || !component.IsValid()) { continue; } ZDO zDO = component.GetZDO(); if (zDO != null && VS_SteamOwnerIdentity.IsSameOwner(zDO, steamId)) { VS_SteamOwnerIdentity.RepairOwnerZDO(component, zDO, steamId, ownerName); BaseAI component2 = ((Component)allCharacter).GetComponent(); if (!((Object)(object)component2 == (Object)null)) { list.Add(component2); } } } list.Sort((BaseAI a, BaseAI b) => b.GetTimeSinceSpawned().CompareTo(a.GetTimeSinceSpawned())); int num = list.Count - maxInstances; for (int i = 0; i < num; i++) { TryUnsummonNow(((Component)list[i]).gameObject); } if (num > 0) { ((Character)val).Message((MessageType)2, "$hud_maxsummonsreached", 0, (Sprite)null); } } internal static void EnforceAllSummonLimits(Humanoid owner) { Player val = (Player)(object)((owner is Player) ? owner : null); if (val == null || !TryResolveOwner(val, out var steamId, out var ownerName)) { return; } Skills skills = ((Character)owner).GetSkills(); if ((Object)(object)skills == (Object)null) { return; } float skillLevel = skills.GetSkillLevel((SkillType)10); HashSet hashSet = new HashSet(StringComparer.Ordinal); foreach (Character allCharacter in Character.GetAllCharacters()) { if (!Object.op_Implicit((Object)(object)allCharacter) || !Object.op_Implicit((Object)(object)((Component)allCharacter).GetComponent())) { continue; } ZNetView component = ((Component)allCharacter).GetComponent(); if (!Object.op_Implicit((Object)(object)component) || !component.IsValid()) { continue; } ZDO zDO = component.GetZDO(); if (zDO != null && VS_SteamOwnerIdentity.IsSameOwner(zDO, steamId)) { VS_SteamOwnerIdentity.RepairOwnerZDO(component, zDO, steamId, ownerName); string basePrefab = VS_SummonState.GetBasePrefab(((Component)allCharacter).gameObject); if (!string.IsNullOrEmpty(basePrefab) && Mob_Registry.All.ContainsKey(basePrefab)) { hashSet.Add(basePrefab); } } } foreach (string item in hashSet) { if (!TryResolve(item, skillLevel, out var result)) { EnforceMaxInstances(item, owner, 0); continue; } int maxInstances = SE_SummonExtra.ApplyExtraMaxSummons(owner, result.MaxInstances); EnforceMaxInstances(item, owner, maxInstances); } } private static bool TryResolveOwner(Player p, out string steamId, out string ownerName) { return VS_SteamOwnerIdentity.TryGetSteamIdentity(p, out steamId, out ownerName); } private static void TryUnsummonNow(GameObject go) { VS_SummonRemoval.TryRemove(go, VS_SummonRemovalReason.ProgressionLimit); } } internal enum VS_SummonRemovalReason { Manual, LifetimeExpired, OwnerDeath, OwnerTeleport, ProgressionLimit, DeathCleanup, OwnerIdentityFailed } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] internal static class VS_SummonRemoval { internal const string ZdoRemoving = "vs_summon_removing"; internal const string ZdoRemovingAtTicks = "vs_summon_removing_at"; internal static bool TryRemove(GameObject go, VS_SummonRemovalReason reason) { //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)go)) { return false; } VS_SummonMarker vS_SummonMarker = default(VS_SummonMarker); if (!go.TryGetComponent(ref vS_SummonMarker)) { return false; } ZNetView component = go.GetComponent(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return false; } ZDO zDO = component.GetZDO(); if (zDO == null) { return false; } if (zDO.GetBool("vs_summon_removing", false)) { return false; } if (!component.IsOwner() && (Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { component.ClaimOwnership(); } if (!component.IsOwner()) { return false; } zDO.Set("vs_summon_removing", true); zDO.Set("vs_summon_removing_at", VS_SummonTime.NowTicks()); VS_SummonVfxProfile component2 = go.GetComponent(); if (reason != VS_SummonRemovalReason.DeathCleanup && (Object)(object)component2 != (Object)null && component2.UnSummonEffect != null && component2.UnSummonEffect.HasEffects()) { component2.UnSummonEffect.Create(go.transform.position, go.transform.rotation, (Transform)null, 1f, -1); } if ((Object)(object)ZNetScene.instance != (Object)null) { ZNetScene.instance.Destroy(go); } else { component.Destroy(); } return true; } internal static bool TryRemove(Component c, VS_SummonRemovalReason reason) { return (Object)(object)c != (Object)null && TryRemove(c.gameObject, reason); } internal static bool TryForceDestroy(GameObject go) { if (!Object.op_Implicit((Object)(object)go)) { return false; } VS_SummonMarker vS_SummonMarker = default(VS_SummonMarker); if (!go.TryGetComponent(ref vS_SummonMarker)) { return false; } ZNetView component = go.GetComponent(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return false; } if (!component.IsOwner() && (Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { component.ClaimOwnership(); } if (!component.IsOwner()) { return false; } if ((Object)(object)ZNetScene.instance != (Object)null) { ZNetScene.instance.Destroy(go); } else { component.Destroy(); } return true; } } internal static class Registrations_Mobs_SpawnAbility { internal static void Register() { Mob_Registry.Init(); } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal static class VS_SpawnAbilityScope { [NullableContext(0)] private sealed class Marker { } private static readonly ConditionalWeakTable Marked = new ConditionalWeakTable(); internal static bool TryGetSummonPrefabs(SpawnAbility sa, out List prefabs) { prefabs = new List(); if ((Object)(object)sa == (Object)null || sa.m_spawnPrefab == null || sa.m_spawnPrefab.Length == 0) { return false; } for (int i = 0; i < sa.m_spawnPrefab.Length; i++) { GameObject val = sa.m_spawnPrefab[i]; if (!Object.op_Implicit((Object)(object)val)) { return false; } string prefabName = Utils.GetPrefabName(((Object)val).name); if (string.IsNullOrEmpty(prefabName)) { return false; } if (!Mob_Registry.All.ContainsKey(prefabName)) { return false; } prefabs.Add(val); } return prefabs.Count > 0; } internal static bool IsMarked(SpawnAbility sa) { Marker value; return (Object)(object)sa != (Object)null && Marked.TryGetValue(sa, out value); } internal static void Mark(SpawnAbility sa) { if (!((Object)(object)sa == (Object)null)) { Unmark(sa); Marked.Add(sa, new Marker()); } } internal static void Unmark(SpawnAbility sa) { if (!((Object)(object)sa == (Object)null)) { Marked.Remove(sa); } } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal static class VS_SpawnAbilityContextStore { [NullableContext(2)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private sealed class SpawnSetupContext { internal Character Owner; internal ItemData Weapon; } private static readonly ConditionalWeakTable Table = new ConditionalWeakTable(); [NullableContext(2)] internal static void Set([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] SpawnAbility ability, Character owner, ItemData weapon) { if (!((Object)(object)ability == (Object)null)) { Table.Remove(ability); Table.Add(ability, new SpawnSetupContext { Owner = owner, Weapon = weapon }); } } [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] internal static Character GetOwner(SpawnAbility ability) { SpawnSetupContext value; return ((Object)(object)ability != (Object)null && Table.TryGetValue(ability, out value)) ? value.Owner : null; } [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] internal static ItemData GetWeapon(SpawnAbility ability) { SpawnSetupContext value; return ((Object)(object)ability != (Object)null && Table.TryGetValue(ability, out value)) ? value.Weapon : null; } internal static void Clear(SpawnAbility ability) { if (!((Object)(object)ability == (Object)null)) { Table.Remove(ability); } } } [HarmonyPatch(typeof(SpawnAbility), "Setup")] internal static class Patch_SpawnAbility_Setup_SummonMark { [NullableContext(1)] private static bool Prefix(SpawnAbility __instance, Character owner, ItemData item) { VS_SpawnAbilityContextStore.Set(__instance, owner, item); if (VS_SummonSpawnAbility.ShouldBlockSetup(__instance, owner)) { VS_SpawnAbilityScope.Unmark(__instance); VS_SpawnAbilityContextStore.Clear(__instance); return false; } VS_SummonSpawnAbility.TryMarkFromSetup(__instance); return true; } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal static class VS_SummonSpawnAbility { [NullableContext(2)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private readonly struct SpawnContext { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] internal readonly SpawnAbility Ability; internal readonly Character Owner; internal readonly ItemData Weapon; internal readonly Skills Skills; internal readonly float BloodMagic; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] internal readonly List Prefabs; internal SpawnContext([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] SpawnAbility ability, Character owner, ItemData weapon, Skills skills, float bloodMagic, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] List prefabs) { Ability = ability; Owner = owner; Weapon = weapon; Skills = skills; BloodMagic = bloodMagic; Prefabs = prefabs; } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private readonly struct ValidSummonPrefab { internal readonly GameObject Prefab; internal readonly string Name; internal readonly VS_SummonProgressionResult Progression; internal ValidSummonPrefab(GameObject prefab, string name, VS_SummonProgressionResult progression) { Prefab = prefab; Name = name; Progression = progression; } } [CompilerGenerated] private sealed class d__10 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private object <>2__current; object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; 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(); } } [CompilerGenerated] private sealed class d__12 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private object <>2__current; public SpawnContext ctx; public int index; public int spawnCount; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private SpawnAbility 5__1; private Vector3 5__2; private Vector3 5__3; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private GameObject 5__4; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private string 5__5; private VS_SummonProgressionResult 5__6; private int 5__7; private float 5__8; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private GameObject 5__9; object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__4 = null; 5__5 = null; 5__9 = null; <>1__state = -2; } private bool MoveNext() { //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = ctx.Ability; if (!TryResolveSpawnPoint(ctx, index, spawnCount, out 5__2, out 5__3)) { return false; } if (!TrySelectSummonPrefab(ctx.Prefabs, ctx.BloodMagic, out 5__4, out 5__5, out 5__6)) { ShowBloodMagicGateMessageIfPossible(ctx); return false; } 5__7 = SE_SummonExtra.ApplyExtraMaxSummons(ctx.Owner, 5__6.MaxInstances); 5__8 = Registrations_Mobs_Lifetime_UpgradeTotem.GetFinalLifetimeSeconds(5__5, ctx.Owner, ctx.Weapon); 5__1.m_preSpawnEffects.Create(5__3, Quaternion.identity, (Transform)null, 1f, -1); if (5__1.m_preSpawnDelay > 0f) { <>2__current = (object)new WaitForSeconds(5__1.m_preSpawnDelay); <>1__state = 1; return true; } goto IL_0158; case 1: <>1__state = -1; goto IL_0158; case 2: { <>1__state = -1; break; } IL_0158: 5__9 = SpawnSummonInstance(5__4, 5__3); if (!Object.op_Implicit((Object)(object)5__9)) { return false; } ApplyLifetime(5__9, 5__8); ApplyRandomYRotation(5__1, 5__9); SetupSpawnedProjectile(5__1, ctx.Owner, 5__9, 5__2); ApplyCopiedSkillFactor(5__1, ctx.Skills, 5__9); ApplyProgression(5__9, new VS_SummonProgressionResult(5__6.SummonLevel, 5__7)); VS_SummonState.Begin(5__9, ctx.Owner, 5__5, 5__7); RegisterPlayerSummonStat(5__1, ctx.Owner); ApplyWakeupAnimation(5__1, 5__9); ApplyAiState(5__1, 5__9); SetupAoe(5__1, 5__9.GetComponent(), 5__3); 5__1.m_spawnEffects.Create(5__3, Quaternion.identity, (Transform)null, 1f, -1); if (5__1.m_spawnDelay > 0f) { <>2__current = (object)new WaitForSeconds(5__1.m_spawnDelay); <>1__state = 2; return true; } break; } 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(); } } [CompilerGenerated] private sealed class d__11 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private object <>2__current; public SpawnContext ctx; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private SpawnAbility 5__1; private int 5__2; private int 5__3; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private IEnumerator 5__4; object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 1u) { try { } finally { <>m__Finally1(); } } 5__1 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown try { int num; switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>1__state = -3; 5__1 = ctx.Ability; if (5__1.m_initialSpawnDelay > 0f) { <>2__current = (object)new WaitForSeconds(5__1.m_initialSpawnDelay); <>1__state = 1; return true; } goto IL_008f; case 1: <>1__state = -3; goto IL_008f; case 2: { <>1__state = -3; goto IL_00fd; } IL_008f: 5__2 = Random.Range(5__1.m_minToSpawn, 5__1.m_maxToSpawn); 5__3 = 0; goto IL_0126; IL_0126: if (5__3 < 5__2) { 5__4 = SpawnOne(ctx, 5__3, 5__2); goto IL_00fd; } DestroySpawnAbilityObjectIfNeeded(5__1); 5__1 = null; <>m__Finally1(); return false; IL_00fd: if (5__4.MoveNext()) { <>2__current = 5__4.Current; <>1__state = 2; return true; } 5__4 = null; num = 5__3 + 1; 5__3 = num; goto IL_0126; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; VS_SpawnAbilityScope.Unmark(ctx.Ability); VS_SpawnAbilityContextStore.Clear(ctx.Ability); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static void ShowInvalidProgressionMessage(Character owner) { Player val = (Player)(object)((owner is Player) ? owner : null); if (val != null) { ((Character)val).Message((MessageType)2, "Invalid summon progression config.", 0, (Sprite)null); } } internal static bool ShouldBlockSetup(SpawnAbility sa, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] Character owner) { if ((Object)(object)owner == (Object)null) { return false; } if (!VS_SpawnAbilityScope.TryGetSummonPrefabs(sa, out var prefabs)) { return false; } float num = ResolveRequiredBloodMagic(prefabs); if (num < 0f) { ShowInvalidProgressionMessage(owner); return true; } Skills skills = owner.GetSkills(); if ((Object)(object)skills == (Object)null) { return false; } float skillLevel = skills.GetSkillLevel((SkillType)10); if (skillLevel >= num) { return false; } ShowBloodMagicGateMessage(owner, skillLevel, num); return true; } internal static bool TryMarkFromSetup(SpawnAbility sa) { VS_SpawnAbilityScope.Unmark(sa); if (!VS_SpawnAbilityScope.TryGetSummonPrefabs(sa, out var _)) { return false; } VS_SpawnAbilityScope.Mark(sa); return true; } internal static bool TryBuildSpawnOverride(SpawnAbility sa, ref IEnumerator result) { if (!VS_SpawnAbilityScope.IsMarked(sa)) { return false; } if (!VS_SpawnAbilityScope.TryGetSummonPrefabs(sa, out var prefabs)) { VS_SpawnAbilityScope.Unmark(sa); VS_SpawnAbilityContextStore.Clear(sa); result = AbortSpawn(); return true; } result = SpawnOverride(BuildContext(sa, prefabs)); return true; } private static SpawnContext BuildContext(SpawnAbility sa, List prefabs) { Character owner = VS_SpawnAbilityContextStore.GetOwner(sa); ItemData weapon = VS_SpawnAbilityContextStore.GetWeapon(sa); Skills val = (Object.op_Implicit((Object)(object)owner) ? owner.GetSkills() : null); float bloodMagic = (((Object)(object)val != (Object)null) ? val.GetSkillLevel((SkillType)10) : 0f); return new SpawnContext(sa, owner, weapon, val, bloodMagic, prefabs); } private static float ResolveRequiredBloodMagic(List prefabs) { int num = int.MaxValue; bool flag = false; for (int i = 0; i < prefabs.Count; i++) { string prefabName = Utils.GetPrefabName(((Object)prefabs[i]).name); if (string.IsNullOrEmpty(prefabName)) { return -1f; } if (!VS_SummonProgression.TryGetGateFromConfig(prefabName, out var minGate)) { return -1f; } if (!flag || minGate < num) { num = minGate; flag = true; } } return flag ? ((float)num) : (-1f); } private static void ShowBloodMagicGateMessage(Character owner, float have, float required) { Player val = (Player)(object)((owner is Player) ? owner : null); if (val != null) { int num = Mathf.FloorToInt(have); int num2 = Mathf.FloorToInt(required); string arg = $"{num}"; string arg2 = $"{num2}"; string format = Localization.instance.Localize("$vs_bm_gate_msg"); string text = string.Format(format, arg, arg2); ((Character)val).Message((MessageType)2, text, 0, (Sprite)null); } } private static void ShowBloodMagicGateMessageIfPossible(SpawnContext ctx) { if (!((Object)(object)ctx.Owner == (Object)null)) { float num = ResolveRequiredBloodMagic(ctx.Prefabs); if (num < 0f) { ShowInvalidProgressionMessage(ctx.Owner); } else { ShowBloodMagicGateMessage(ctx.Owner, ctx.BloodMagic, num); } } } [IteratorStateMachine(typeof(d__10))] private static IEnumerator AbortSpawn() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__10(0); } [IteratorStateMachine(typeof(d__11))] private static IEnumerator SpawnOverride(SpawnContext ctx) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__11(0) { ctx = ctx }; } [IteratorStateMachine(typeof(d__12))] private static IEnumerator SpawnOne(SpawnContext ctx, int index, int spawnCount) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0) { ctx = ctx, index = index, spawnCount = spawnCount }; } private static bool TryResolveSpawnPoint(SpawnContext ctx, int index, int spawnCount, out Vector3 targetPosition, out Vector3 spawnPoint) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) SpawnAbility ability = ctx.Ability; targetPosition = ((Component)ability).transform.position; spawnPoint = targetPosition; if (!TryResolveTargetPosition(ctx, index, spawnCount, out targetPosition)) { return false; } return TryResolveFinalSpawnPoint(ability, targetPosition, index, spawnCount, out spawnPoint); } private static bool TryResolveTargetPosition(SpawnContext ctx, int index, int spawnCount, out Vector3 targetPosition) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) SpawnAbility ability = ctx.Ability; targetPosition = ((Component)ability).transform.position; bool result = false; int num = (((int)ability.m_targetType != 4) ? 1 : 5); for (int i = 0; i < num; i++) { if (result = FindTarget(ability, ctx.Owner, out targetPosition, index, spawnCount)) { break; } if ((int)ability.m_targetType == 4 && i == num - 1) { targetPosition = ((Component)ability).transform.position; result = true; } } return result; } private static bool TryResolveFinalSpawnPoint(SpawnAbility sa, Vector3 targetPosition, int index, int spawnCount, out Vector3 spawnPoint) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) spawnPoint = targetPosition; if ((int)sa.m_targetType == 4) { return true; } Vector3 val = (sa.m_spawnAtTarget ? targetPosition : ((Component)sa).transform.position); Vector2 val2 = (sa.m_circleSpawn ? (GetCirclePoint(index, spawnCount) * sa.m_spawnRadius) : (Random.insideUnitCircle * sa.m_spawnRadius)); spawnPoint = val + new Vector3(val2.x, 0f, val2.y); if (sa.m_snapToTerrain) { if ((Object)(object)ZoneSystem.instance == (Object)null) { return false; } float y = default(float); ZoneSystem.instance.GetSolidHeight(spawnPoint, ref y, sa.m_getSolidHeightMargin); spawnPoint.y = y; } spawnPoint.y += sa.m_spawnGroundOffset; return Mathf.Abs(spawnPoint.y - val.y) <= 100f; } private static bool TrySelectSummonPrefab(List summonPrefabs, float bloodMagic, out GameObject prefab, out string summonPrefab, out VS_SummonProgressionResult progression) { prefab = null; summonPrefab = string.Empty; progression = default(VS_SummonProgressionResult); if (summonPrefabs.Count == 0) { return false; } List list = new List(); for (int i = 0; i < summonPrefabs.Count; i++) { GameObject val = summonPrefabs[i]; if (Object.op_Implicit((Object)(object)val)) { string prefabName = Utils.GetPrefabName(((Object)val).name); if (!string.IsNullOrEmpty(prefabName) && VS_SummonProgression.TryResolve(prefabName, bloodMagic, out var result)) { list.Add(new ValidSummonPrefab(val, prefabName, result)); } } } if (list.Count == 0) { return false; } ValidSummonPrefab validSummonPrefab = list[Random.Range(0, list.Count)]; prefab = validSummonPrefab.Prefab; summonPrefab = validSummonPrefab.Name; progression = validSummonPrefab.Progression; return true; } private static GameObject SpawnSummonInstance(GameObject prefab, Vector3 spawnPoint) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.Euler(0f, Random.value * 360f, 0f); return Object.Instantiate(prefab, spawnPoint, val); } private static void ApplyLifetime(GameObject go, float finalLifetime) { VS_SummonLifetime.Apply(go, finalLifetime); } private static void ApplyRandomYRotation(SpawnAbility sa, GameObject go) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (sa.m_randomYRotation) { go.transform.Rotate(Vector3.up, (float)Random.Range(-180, 180)); } } private static void SetupSpawnedProjectile(SpawnAbility sa, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] Character owner, GameObject go, Vector3 targetPosition) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) Projectile component = go.GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)owner == (Object)null)) { SetupProjectile(sa, owner, component, targetPosition); } } private static void ApplyCopiedSkillFactor(SpawnAbility sa, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] Skills skills, GameObject go) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)skills == (Object)null) { return; } ZNetView component = go.GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { ZDO zDO = component.GetZDO(); if (zDO != null && (int)sa.m_copySkill != 0 && !(sa.m_copySkillToRandomFactor <= 0f)) { zDO.Set(ZDOVars.s_randomSkillFactor, 1f + skills.GetSkillLevel(sa.m_copySkill) * sa.m_copySkillToRandomFactor); } } } private static void ApplyProgression(GameObject go, VS_SummonProgressionResult progression) { Character component = go.GetComponent(); if ((Object)(object)component != (Object)null) { component.SetLevel(progression.SummonLevel); } } private static void RegisterPlayerSummonStat(SpawnAbility sa, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] Character owner) { if (sa.m_commandOnSpawn && (Object)(object)owner == (Object)(object)Player.m_localPlayer) { Game.instance.IncrementPlayerStat((PlayerStatType)50, 1f); } } private static void ApplyWakeupAnimation(SpawnAbility sa, GameObject go) { if (sa.m_wakeUpAnimation) { ZSyncAnimation component = go.GetComponent(); if (component != null) { component.SetBool("wakeup", true); } } } private static void ApplyAiState(SpawnAbility sa, GameObject go) { BaseAI component = go.GetComponent(); if (!((Object)(object)component == (Object)null) && sa.m_passiveAggressive) { component.m_passiveAggresive = true; } } private static void DestroySpawnAbilityObjectIfNeeded(SpawnAbility sa) { if (!sa.m_spawnOnAwake) { Object.Destroy((Object)(object)((Component)sa).gameObject); } } private static void SetupProjectile(SpawnAbility sa, Character owner, Projectile projectile, Vector3 targetPoint) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (sa.m_randomDirection ? GetRandomConeDirection(sa) : (targetPoint - ((Component)projectile).transform.position)); if (((Vector3)(ref val)).sqrMagnitude <= 0.0001f) { val = owner.GetLookDir(); } if (((Vector3)(ref val)).sqrMagnitude <= 0.0001f) { val = ((Component)projectile).transform.forward; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(val, Vector3.up); if (((Vector3)(ref val2)).sqrMagnitude <= 0.0001f) { val2 = Vector3.right; } Vector3 val3 = Quaternion.AngleAxis(Random.Range(0f - sa.m_projectileAccuracy, sa.m_projectileAccuracy), Vector3.up) * (Quaternion.AngleAxis(Random.Range(0f - sa.m_projectileAccuracy, sa.m_projectileAccuracy), ((Vector3)(ref val2)).normalized) * val); float num = ((sa.m_projectileVelocityMax > 0f) ? Random.Range(sa.m_projectileVelocity, sa.m_projectileVelocityMax) : sa.m_projectileVelocity); projectile.Setup(owner, val3 * num, -1f, (HitData)null, (ItemData)null, (ItemData)null); } private static Vector3 GetRandomConeDirection(SpawnAbility sa) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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 num = Random.Range(0, 360); float num2 = Random.Range(sa.m_randomAngleMin, sa.m_randomAngleMax); return Quaternion.AngleAxis((float)num, Vector3.up) * new Vector3(Mathf.Sin(num2), Mathf.Cos(num2), 0f); } private static void SetupAoe(SpawnAbility sa, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] Character owner, Vector3 targetPoint) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)sa.m_aoePrefab == (Object)null) && !((Object)(object)owner == (Object)null)) { Aoe component = Object.Instantiate(sa.m_aoePrefab, targetPoint, Quaternion.identity).GetComponent(); if (!((Object)(object)component == (Object)null)) { component.Setup(owner, Vector3.zero, -1f, (HitData)null, (ItemData)null, (ItemData)null); } } } private static bool FindTarget(SpawnAbility sa, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] Character owner, out Vector3 point, int i, int spawnCount) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected I4, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: 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_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) point = Vector3.zero; TargetType targetType = sa.m_targetType; TargetType val = targetType; switch ((int)val) { case 0: { if ((Object)(object)owner == (Object)null) { return false; } Character val3 = BaseAI.FindClosestEnemy(owner, ((Component)sa).transform.position, sa.m_maxTargetRange); if (!Object.op_Implicit((Object)(object)val3)) { return false; } point = ((Component)val3).transform.position; return true; } case 1: { if ((Object)(object)owner == (Object)null) { return false; } Character val4 = BaseAI.FindRandomEnemy(owner, ((Component)sa).transform.position, sa.m_maxTargetRange); if (!Object.op_Implicit((Object)(object)val4)) { return false; } point = ((Component)val4).transform.position; return true; } case 2: if ((Object)(object)owner == (Object)null) { return false; } point = ((Component)owner).transform.position; return true; case 3: point = ((Component)sa).transform.position; return true; case 4: { if ((Object)(object)owner == (Object)null) { return false; } if ((Object)(object)ZoneSystem.instance == (Object)null || (Object)(object)Pathfinding.instance == (Object)null) { return false; } List list = new List(); Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val2 = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(sa.m_spawnRadius / 2f, sa.m_spawnRadius); point = ((Component)sa).transform.position + new Vector3(val2.x, 2f, val2.y); float y = default(float); ZoneSystem.instance.GetSolidHeight(point, ref y, 2); point.y = y; if (!Pathfinding.instance.GetPath(((Component)owner).transform.position, point, list, sa.m_targetWhenPathfindingType, true, false, true)) { return false; } if (list.Count == 0) { return false; } point = list[list.Count - 1]; return true; } default: return false; } } private static Vector2 GetCirclePoint(int i, int spawnCount) { //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) //IL_0045: Unknown result type (might be due to invalid IL or missing references) double num = (double)i / (double)spawnCount; return new Vector2(Mathf.Sin((float)(num * Math.PI * 2.0)), Mathf.Cos((float)(num * Math.PI * 2.0))); } } [HarmonyPatch(typeof(SpawnAbility), "Spawn")] internal static class Patch_SpawnAbility_Spawn_SummonOverride { [NullableContext(1)] private static bool Prefix(SpawnAbility __instance, ref IEnumerator __result) { return !VS_SummonSpawnAbility.TryBuildSpawnOverride(__instance, ref __result); } } internal static class Registrations_Mobs_SpawnCost { internal static void Register() { } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] internal static class VS_SummonSpawnCost { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private readonly struct TooltipAttackState { internal readonly bool Active; internal readonly Attack Attack; internal readonly float Eitr; internal readonly float Health; internal readonly float HealthPercentage; internal TooltipAttackState(Attack attack) { Active = true; Attack = attack; Eitr = attack.m_attackEitr; Health = attack.m_attackHealth; HealthPercentage = attack.m_attackHealthPercentage; } } [NullableContext(0)] [HarmonyPatch(typeof(Attack), "Start", new Type[] { typeof(Humanoid), typeof(Rigidbody), typeof(ZSyncAnimation), typeof(CharacterAnimEvent), typeof(VisEquipment), typeof(ItemData), typeof(Attack), typeof(float), typeof(float) })] private static class Patch_Attack_Start_BlockSummonIfMissingHealth { [NullableContext(1)] private static bool Prefix(Humanoid character, ItemData weapon) { if ((Object)(object)character == (Object)null) { return true; } if (CanPaySummonHealthCost(weapon, (Character)(object)character)) { return true; } if (((Character)character).IsPlayer()) { if ((Object)(object)Hud.instance != (Object)null) { Hud.instance.FlashHealthBar(); } Player val = (Player)(object)((character is Player) ? character : null); if ((Object)(object)val != (Object)null) { ((Character)val).Message((MessageType)2, "$vs_summon_not_enough_health", 0, (Sprite)null); } } return false; } } [NullableContext(0)] [HarmonyPatch(typeof(Attack), "GetAttackHealth")] private static class Patch_Attack_GetAttackHealth_SummonSpawnCost { [NullableContext(1)] private static void Postfix(Attack __instance, ref float __result) { Character attackOwner = GetAttackOwner(__instance); if (!((Object)(object)attackOwner == (Object)null)) { __result = BuildHealthCost(__instance, attackOwner, __result); } } } [NullableContext(0)] [HarmonyPatch(typeof(Attack), "GetAttackEitr")] private static class Patch_Attack_GetAttackEitr_SummonSpawnCost { [NullableContext(1)] private static void Postfix(Attack __instance, ref float __result) { __result = BuildEitrCost(__instance, __result); } } [NullableContext(0)] [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int) })] private static class Patch_ItemData_GetTooltip_SummonSpawnCost { [NullableContext(1)] private static void Prefix(ItemData item, out TooltipAttackState __state) { __state = default(TooltipAttackState); if (item?.m_shared != null && TryGetSummonDef(item, out var def) && def != null) { Attack attack = item.m_shared.m_attack; __state = new TooltipAttackState(attack); Character localPlayer = (Character)(object)Player.m_localPlayer; attack.m_attackEitr = BuildEitrCost(item, attack.m_attackEitr); attack.m_attackHealth = 0f; attack.m_attackHealthPercentage = BuildHealthPercent(item, localPlayer, attack.m_attackHealthPercentage); } } private static void Finalizer(TooltipAttackState __state) { if (__state.Active) { __state.Attack.m_attackEitr = __state.Eitr; __state.Attack.m_attackHealth = __state.Health; __state.Attack.m_attackHealthPercentage = __state.HealthPercentage; } } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static readonly FieldInfo FI_AttackCharacter = AccessTools.Field(typeof(Attack), "m_character"); [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static readonly FieldInfo FI_AttackWeapon = AccessTools.Field(typeof(Attack), "m_weapon"); [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static Character GetAttackOwner(Attack attack) { if (attack == null || FI_AttackCharacter == null) { return null; } object? value = FI_AttackCharacter.GetValue(attack); return (Character)((value is Character) ? value : null); } [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static ItemData GetAttackWeapon(Attack attack) { if (attack == null || FI_AttackWeapon == null) { return null; } object? value = FI_AttackWeapon.GetValue(attack); return (ItemData)((value is ItemData) ? value : null); } private static bool TryGetSummonDef(Attack attack, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] out Mob_Registry.SummonDef def) { return TryGetSummonDef(GetAttackWeapon(attack), out def); } [NullableContext(2)] private static bool TryGetSummonDef(ItemData weapon, out Mob_Registry.SummonDef def) { def = null; if ((Object)(object)weapon?.m_dropPrefab == (Object)null) { return false; } string prefabName = Utils.GetPrefabName(((Object)weapon.m_dropPrefab).name); if (string.IsNullOrWhiteSpace(prefabName)) { return false; } return Mob_Registry.TryGetByTotemPrefab(prefabName, out def) && def != null; } private static float BuildHealthCost(Attack attack, Character owner, float originalCost) { return BuildHealthCost(GetAttackWeapon(attack), owner, originalCost); } private static float BuildHealthCost([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] ItemData weapon, Character owner, float originalCost) { if (!TryGetSummonDef(weapon, out var def) || def == null) { return originalCost; } float maxHealth = owner.GetMaxHealth(); float num = Mathf.Max(0f, def.SpawnHealthPercentCE.Value); float baseCost = maxHealth * (num / 100f); return SE_SummonExtra.ApplySummonHealthCostMultiplier(owner, baseCost); } [NullableContext(2)] private static float BuildHealthPercent(ItemData weapon, Character owner, float originalPercent) { if (!TryGetSummonDef(weapon, out var def) || def == null) { return originalPercent; } float num = Mathf.Max(0f, def.SpawnHealthPercentCE.Value); if ((Object)(object)owner == (Object)null) { return num; } float maxHealth = owner.GetMaxHealth(); if (maxHealth <= 0f) { return num; } float num2 = SE_SummonExtra.ApplySummonHealthCostMultiplier(owner, maxHealth * (num / 100f)); return Mathf.Max(0f, num2 / maxHealth * 100f); } private static float BuildEitrCost(Attack attack, float originalCost) { if (!TryGetSummonDef(attack, out var def) || def == null) { return originalCost; } return Mathf.Max(0f, def.SpawnEitrCE.Value); } [NullableContext(2)] private static float BuildEitrCost(ItemData weapon, float originalCost) { if (!TryGetSummonDef(weapon, out var def) || def == null) { return originalCost; } return Mathf.Max(0f, def.SpawnEitrCE.Value); } private static bool CanPaySummonHealthCost([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] ItemData weapon, Character owner) { if (!TryGetSummonDef(weapon, out var _)) { return true; } float num = BuildHealthCost(weapon, owner, 0f); if (num <= 0f) { return true; } return owner.HaveHealth(num + 0.1f); } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] public sealed class VS_SummonState : MonoBehaviour { internal const string KeyOwnerSteamId = "VS_OwnerSteamID"; internal const string KeyOwner = "VS_OwnerID"; internal const string KeyOwnerName = "VS_OwnerName"; internal const string KeyPrefab = "VS_SummonPrefab"; internal const string KeyReady = "VS_SummonReady"; private const float ServerTickSeconds = 0.25f; private const float InitTimeoutSeconds = 10f; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private ZNetView _nview; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private Character _character; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private MonsterAI _ai; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private Humanoid _pendingOwner; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private GameObject _pendingFollowTarget; private string _pendingOwnerSteamId = string.Empty; private long _pendingOwnerId; private string _pendingOwnerName = string.Empty; private string _pendingPrefab = string.Empty; private int _pendingMaxInstances; private float _retryTimer; private float _tick; private bool _pendingInit; private void Awake() { _nview = ((Component)this).GetComponent(); _character = ((Component)this).GetComponent(); _ai = ((Component)this).GetComponent(); ((Behaviour)this).enabled = false; } internal static VS_SummonState Ensure(GameObject go) { VS_SummonState vS_SummonState = go.GetComponent(); if (!Object.op_Implicit((Object)(object)vS_SummonState)) { vS_SummonState = go.AddComponent(); } return vS_SummonState; } internal static void Begin(GameObject go, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] Character owner, string summonPrefab, int maxInstances) { if (Object.op_Implicit((Object)(object)go)) { Humanoid val = (Humanoid)(object)((owner is Humanoid) ? owner : null); if (val != null) { Ensure(go).BeginInternal(val, summonPrefab, maxInstances); } } } internal static bool IsServer() { return (Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer(); } [NullableContext(2)] internal static bool TryGetZDO([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] GameObject go, out ZNetView nview, out ZDO zdo) { nview = (Object.op_Implicit((Object)(object)go) ? go.GetComponent() : null); zdo = (((Object)(object)nview != (Object)null && nview.IsValid()) ? nview.GetZDO() : null); return (Object)(object)nview != (Object)null && zdo != null; } internal static bool TryGetOwnerSteamId(GameObject go, out string ownerSteamId) { ownerSteamId = string.Empty; if (!TryGetZDO(go, out var _, out var zdo) || zdo == null) { return false; } ownerSteamId = VS_SteamOwnerIdentity.NormalizeOwnerId(zdo.GetString("VS_OwnerSteamID", string.Empty)); return !string.IsNullOrWhiteSpace(ownerSteamId); } internal static string GetBasePrefab(GameObject go) { if (!Object.op_Implicit((Object)(object)go)) { return string.Empty; } if (!TryGetZDO(go, out var _, out var zdo) || zdo == null) { return Utils.GetPrefabName(go); } string @string = zdo.GetString("VS_SummonPrefab", string.Empty); return (!string.IsNullOrWhiteSpace(@string)) ? @string : Utils.GetPrefabName(go); } internal static bool IsReady(GameObject go) { if (!TryGetZDO(go, out var _, out var zdo) || zdo == null) { return false; } return zdo.GetBool("VS_SummonReady", false); } private void BeginInternal(Humanoid owner, string summonPrefab, int maxInstances) { _nview = ((Component)this).GetComponent(); _character = ((Component)this).GetComponent(); _ai = ((Component)this).GetComponent(); if ((Object)(object)_character != (Object)null) { _character.SetTamed(true); } _pendingOwner = owner; _pendingFollowTarget = ((Component)owner).gameObject; _pendingPrefab = summonPrefab; _pendingMaxInstances = Mathf.Max(1, maxInstances); _pendingOwnerSteamId = string.Empty; _pendingOwnerId = 0L; _pendingOwnerName = ((Character)owner).GetHoverName(); _retryTimer = 0f; _tick = 0f; _pendingInit = true; Player val = (Player)(object)((owner is Player) ? owner : null); if (val != null) { ResolvePendingIdentity(val); } ((Behaviour)this).enabled = true; TryCommitInitialState(); } private void Update() { if ((Object)(object)_character != (Object)null && _character.IsDead()) { ClearFollowRuntime(); ((Behaviour)this).enabled = false; return; } if (_pendingInit) { _retryTimer += Time.deltaTime; if (_retryTimer > 10f) { _pendingInit = false; if (IsServer()) { VS_SummonRemoval.TryRemove(((Component)this).gameObject, VS_SummonRemovalReason.OwnerIdentityFailed); } ((Behaviour)this).enabled = false; return; } if (!TryCommitInitialState()) { return; } } if (IsServer() && !((Object)(object)_nview == (Object)null) && _nview.IsValid() && _nview.IsOwner()) { _tick -= Time.deltaTime; if (!(_tick > 0f)) { _tick = 0.25f; EnsureFollowOwner(); } } } private bool TryCommitInitialState() { if ((Object)(object)_nview == (Object)null) { _nview = ((Component)this).GetComponent(); } if ((Object)(object)_character == (Object)null) { _character = ((Component)this).GetComponent(); } if ((Object)(object)_ai == (Object)null) { _ai = ((Component)this).GetComponent(); } if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return false; } ZDO zDO = _nview.GetZDO(); if (zDO == null) { return false; } Humanoid pendingOwner = _pendingOwner; Player val = (Player)(object)((pendingOwner is Player) ? pendingOwner : null); if (val != null && string.IsNullOrWhiteSpace(_pendingOwnerSteamId)) { ResolvePendingIdentity(val); } _pendingOwnerSteamId = VS_SteamOwnerIdentity.NormalizeOwnerId(_pendingOwnerSteamId); if (string.IsNullOrWhiteSpace(_pendingOwnerSteamId)) { return false; } zDO.Set("VS_OwnerSteamID", _pendingOwnerSteamId); zDO.Set("VS_OwnerID", _pendingOwnerId); zDO.Set("VS_OwnerName", _pendingOwnerName); zDO.Set(ZDOVars.s_follow, _pendingOwnerName); zDO.Set("VS_SummonPrefab", _pendingPrefab); zDO.Set(ZDOVars.s_maxInstances, _pendingMaxInstances, false); zDO.Set("VS_SummonReady", true); ConfigureFollow(_pendingFollowTarget); _pendingInit = false; if ((Object)(object)_pendingOwner != (Object)null) { VS_SummonProgression.EnforceMaxInstances(_pendingPrefab, _pendingOwner, _pendingMaxInstances); } return true; } private void ResolvePendingIdentity(Player p) { _pendingOwnerId = p.GetPlayerID(); _pendingOwnerName = GetSafePlayerName(p); if (VS_SteamOwnerIdentity.TryGetSteamIdentity(p, out var steamId, out var playerName)) { _pendingOwnerSteamId = VS_SteamOwnerIdentity.NormalizeOwnerId(steamId); _pendingOwnerName = playerName; } else { _pendingOwnerSteamId = string.Empty; } } private void EnsureFollowOwner() { if ((Object)(object)_ai == (Object)null || (Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } ZDO zDO = _nview.GetZDO(); if (zDO != null) { if (!TryFindOwnerPlayer(zDO, out var owner) || (Object)(object)owner == (Object)null) { ClearFollowRuntime(); return; } if (!VS_SteamOwnerIdentity.TryGetSteamIdentity(owner, out var steamId, out var playerName)) { ClearFollowRuntime(); return; } VS_SteamOwnerIdentity.RepairOwnerZDO(_nview, zDO, steamId, playerName); ConfigureFollow(((Component)owner).gameObject); } } private bool TryFindOwnerPlayer(ZDO zdo, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] out Player owner) { owner = null; string text = VS_SteamOwnerIdentity.NormalizeOwnerId(zdo.GetString("VS_OwnerSteamID", string.Empty)); if (string.IsNullOrWhiteSpace(text)) { return false; } List allPlayers = Player.GetAllPlayers(); if (allPlayers == null || allPlayers.Count == 0) { return false; } for (int i = 0; i < allPlayers.Count; i++) { Player val = allPlayers[i]; if (!((Object)(object)val == (Object)null) && VS_SteamOwnerIdentity.TryGetSteamIdentity(val, out var steamId, out var _) && string.Equals(text, VS_SteamOwnerIdentity.NormalizeOwnerId(steamId), StringComparison.Ordinal)) { owner = val; return true; } } return false; } [NullableContext(2)] private void ConfigureFollow(GameObject target) { if (!((Object)(object)_ai == (Object)null) && !((Object)(object)target == (Object)null) && !((Object)(object)_ai.GetFollowTarget() == (Object)(object)target)) { ((BaseAI)_ai).ResetPatrolPoint(); _ai.SetFollowTarget(target); } } private void ClearFollowRuntime() { if (!((Object)(object)_ai == (Object)null)) { if ((Object)(object)_ai.GetFollowTarget() != (Object)null) { _ai.SetFollowTarget((GameObject)null); } ((BaseAI)_ai).StopMoving(); } } private static string GetSafePlayerName(Player player) { string text = player.GetPlayerName(); if (string.IsNullOrWhiteSpace(text) || text == "...") { text = ((Character)player).GetHoverName(); } return text; } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] internal static class VS_SteamOwnerIdentity { internal static bool TryGetSteamIdentity(Player player, out string steamId, out string playerName) { steamId = string.Empty; playerName = string.Empty; if ((Object)(object)player == (Object)null) { return false; } playerName = GetSafePlayerName(player); if (TryGetSteamIdByCharacterZdo(player, out steamId)) { steamId = NormalizeOwnerId(steamId); return !string.IsNullOrWhiteSpace(steamId); } if ((Object)(object)player == (Object)(object)Player.m_localPlayer) { UserInfo localUser = UserInfo.GetLocalUser(); steamId = NormalizeOwnerId(((object)(PlatformUserID)(ref localUser.UserId)).ToString()); if (!string.IsNullOrWhiteSpace(localUser.Name)) { playerName = localUser.Name; } return !string.IsNullOrWhiteSpace(steamId); } return false; } internal static bool IsSameOwner(ZDO zdo, string steamId) { if (zdo == null) { return false; } string text = NormalizeOwnerId(zdo.GetString("VS_OwnerSteamID", string.Empty)); string text2 = NormalizeOwnerId(steamId); return !string.IsNullOrWhiteSpace(text) && !string.IsNullOrWhiteSpace(text2) && string.Equals(text, text2, StringComparison.Ordinal); } internal static void RepairOwnerZDO(ZNetView nview, ZDO zdo, string steamId, string playerName) { if ((Object)(object)nview == (Object)null || zdo == null) { return; } steamId = NormalizeOwnerId(steamId); if (string.IsNullOrWhiteSpace(steamId)) { return; } if (!nview.IsOwner() && (Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { nview.ClaimOwnership(); } if (nview.IsOwner()) { if (!string.Equals(NormalizeOwnerId(zdo.GetString("VS_OwnerSteamID", string.Empty)), steamId, StringComparison.Ordinal)) { zdo.Set("VS_OwnerSteamID", steamId); } if (!string.IsNullOrWhiteSpace(playerName) && !string.Equals(zdo.GetString("VS_OwnerName", string.Empty), playerName, StringComparison.Ordinal)) { zdo.Set("VS_OwnerName", playerName); } if (!string.IsNullOrWhiteSpace(playerName) && !string.Equals(zdo.GetString(ZDOVars.s_follow, string.Empty), playerName, StringComparison.Ordinal)) { zdo.Set(ZDOVars.s_follow, playerName); } } } internal static string NormalizeOwnerId(string id) { return string.IsNullOrWhiteSpace(id) ? string.Empty : id.Trim(); } private static bool TryGetSteamIdByCharacterZdo(Player player, out string steamId) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) steamId = string.Empty; if ((Object)(object)player == (Object)null) { return false; } if ((Object)(object)ZNet.instance == (Object)null) { return false; } ZNetView component = ((Component)player).GetComponent(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return false; } ZDO zDO = component.GetZDO(); if (zDO == null) { return false; } ZDOID uid = zDO.m_uid; if (((ZDOID)(ref uid)).IsNone()) { return false; } List playerList = ZNet.instance.GetPlayerList(); if (playerList == null || playerList.Count == 0) { return false; } for (int i = 0; i < playerList.Count; i++) { PlayerInfo val = playerList[i]; if (!((ZDOID)(ref val.m_characterID)).IsNone() && val.m_characterID == uid) { steamId = NormalizeOwnerId(((object)(PlatformUserID)(ref val.m_userInfo.m_id)).ToString()); return !string.IsNullOrWhiteSpace(steamId); } } return false; } private static string GetSafePlayerName(Player player) { string text = player.GetPlayerName(); if (string.IsNullOrWhiteSpace(text) || text == "...") { text = ((Character)player).GetHoverName(); } return text; } } internal static class Registrations_MobsVoice { public static void RegisterMobsVoice() { Vikings_SummonerPlugin.SetupIdleVoiceRules(); } } internal enum VS_SfxLanguageMode { Portuguese_Brazilian, English } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [BepInPlugin("radamanto.Vikings_Summoner", "Vikings_Summoner", "1.4.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NullableContext(1)] public class Vikings_SummonerPlugin : BaseUnityPlugin { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal readonly struct VS_IdleVoiceRule { public readonly string MobPrefabName; public readonly string OriginalPrefabName; public readonly string EnglishPrefabName; public readonly string PortugueseBrazilianPrefabName; public VS_IdleVoiceRule(string mobPrefabName, string originalPrefabName, string englishPrefabName, string portugueseBrazilianPrefabName) { MobPrefabName = mobPrefabName; OriginalPrefabName = originalPrefabName; EnglishPrefabName = englishPrefabName; PortugueseBrazilianPrefabName = portugueseBrazilianPrefabName; } } [NullableContext(0)] private class ConfigurationManagerAttributes { public bool? Browsable = false; } [CompilerGenerated] private sealed class d__129 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private object <>2__current; public float quietSeconds; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public Vikings_SummonerPlugin <>4__this; object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public d__129(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if ((DateTime.UtcNow - <>4__this._lastCfgWriteUtc).TotalSeconds < (double)quietSeconds) { <>2__current = null; <>1__state = 1; return true; } try { if (<>4__this._configWatcher == null || !<>4__this._watcherReady) { return false; } <>4__this._configWatcher.EnableRaisingEvents = false; if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { ((BaseUnityPlugin)<>4__this).Config.Reload(); <>4__this._ignoreEventsUntilUtc = DateTime.UtcNow.AddSeconds(1.0); ((BaseUnityPlugin)<>4__this).Config.Save(); } } finally { if (<>4__this._configWatcher != null) { <>4__this._configWatcher.EnableRaisingEvents = true; } <>4__this._reloadScheduled = false; } 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(); } } private static bool _idleVoiceRulesValidated; internal static readonly Dictionary IdleVoiceRulesByMob = new Dictionary(StringComparer.Ordinal); internal const string ModName = "Vikings_Summoner"; internal const string ModVersion = "1.4.4"; internal const string Author = "radamanto"; private const string ModGUID = "radamanto.Vikings_Summoner"; internal static Vikings_SummonerPlugin Instance = null; private readonly Harmony _harmony = new Harmony("radamanto.Vikings_Summoner"); private static bool _bootstrapped; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] internal static ConfigEntry CE_SummonDecayFullHealthTimePercent; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] internal static ConfigEntry CE_SummonDecayTickInterval; internal static ConfigEntry CE_IdleSfxOverrideEnabled = null; internal static ConfigEntry CE_IdleSfxLanguageMode = null; internal static ConfigEntry CE_IdleSfxSoundInterval = null; internal static ConfigEntry CE_IdleSfxSoundChance = null; internal static ConfigEntry CE_Lifetime_RD_inv_skeleton_meadows = null; internal static ConfigEntry CE_Lifetime_RD_inv_skeleton_bforest = null; internal static ConfigEntry CE_Lifetime_RD_inv_ghost_bforest = null; internal static ConfigEntry CE_Lifetime_RD_inv_draugr_swamp = null; internal static ConfigEntry CE_Lifetime_RD_inv_draugr_mountain = null; internal static ConfigEntry CE_Lifetime_RD_inv_valkyrie_mountain = null; internal static ConfigEntry CE_Lifetime_RD_inv_skeleton_plains = null; internal static ConfigEntry CE_Lifetime_RD_inv_unbjorn_plains = null; internal static ConfigEntry CE_Lifetime_RD_inv_skeleton_mistlands = null; internal static ConfigEntry CE_Lifetime_RD_inv_skeleton_ashlands = null; internal static ConfigEntry CE_Lifetime_RD_inv_skeleton_mage_ashlands = null; internal static ConfigEntry CE_LifetimeUpgradeTotem_RD_totem_inv_meadows = null; internal static ConfigEntry CE_LifetimeUpgradeTotem_RD_totem_inv_bforest = null; internal static ConfigEntry CE_LifetimeUpgradeTotem_RD_totem_inv_bforest_ghost = null; internal static ConfigEntry CE_LifetimeUpgradeTotem_RD_totem_inv_swamp = null; internal static ConfigEntry CE_LifetimeUpgradeTotem_RD_totem_inv_mountain = null; internal static ConfigEntry CE_LifetimeUpgradeTotem_RD_totem_inv_mountain_valkyrie = null; internal static ConfigEntry CE_LifetimeUpgradeTotem_RD_totem_inv_plains = null; internal static ConfigEntry CE_LifetimeUpgradeTotem_RD_totem_inv_plains_bear = null; internal static ConfigEntry CE_LifetimeUpgradeTotem_RD_totem_inv_mistlands = null; internal static ConfigEntry CE_LifetimeUpgradeTotem_RD_totem_inv_ashlands = null; internal static ConfigEntry CE_LifetimeUpgradeTotem_RD_totem_inv_ashlands_mage = null; internal static ConfigEntry CE_BaseHp_RD_inv_skeleton_meadows = null; internal static ConfigEntry CE_BaseHp_RD_inv_skeleton_bforest = null; internal static ConfigEntry CE_BaseHp_RD_inv_ghost_bforest = null; internal static ConfigEntry CE_BaseHp_RD_inv_draugr_swamp = null; internal static ConfigEntry CE_BaseHp_RD_inv_draugr_mountain = null; internal static ConfigEntry CE_BaseHp_RD_inv_valkyrie_mountain = null; internal static ConfigEntry CE_BaseHp_RD_inv_skeleton_plains = null; internal static ConfigEntry CE_BaseHp_RD_inv_unbjorn_plains = null; internal static ConfigEntry CE_BaseHp_RD_inv_skeleton_mistlands = null; internal static ConfigEntry CE_BaseHp_RD_inv_skeleton_ashlands = null; internal static ConfigEntry CE_BaseHp_RD_inv_skeleton_mage_ashlands = null; internal static ConfigEntry CE_HpPercentPerStar_RD_inv_skeleton_meadows = null; internal static ConfigEntry CE_HpPercentPerStar_RD_inv_skeleton_bforest = null; internal static ConfigEntry CE_HpPercentPerStar_RD_inv_ghost_bforest = null; internal static ConfigEntry CE_HpPercentPerStar_RD_inv_draugr_swamp = null; internal static ConfigEntry CE_HpPercentPerStar_RD_inv_draugr_mountain = null; internal static ConfigEntry CE_HpPercentPerStar_RD_inv_valkyrie_mountain = null; internal static ConfigEntry CE_HpPercentPerStar_RD_inv_skeleton_plains = null; internal static ConfigEntry CE_HpPercentPerStar_RD_inv_unbjorn_plains = null; internal static ConfigEntry CE_HpPercentPerStar_RD_inv_skeleton_mistlands = null; internal static ConfigEntry CE_HpPercentPerStar_RD_inv_skeleton_ashlands = null; internal static ConfigEntry CE_HpPercentPerStar_RD_inv_skeleton_mage_ashlands = null; internal static ConfigEntry CE_Progression_RD_inv_skeleton_meadows = null; internal static ConfigEntry CE_Progression_RD_inv_skeleton_bforest = null; internal static ConfigEntry CE_Progression_RD_inv_ghost_bforest = null; internal static ConfigEntry CE_Progression_RD_inv_draugr_swamp = null; internal static ConfigEntry CE_Progression_RD_inv_draugr_mountain = null; internal static ConfigEntry CE_Progression_RD_inv_valkyrie_mountain = null; internal static ConfigEntry CE_Progression_RD_inv_skeleton_plains = null; internal static ConfigEntry CE_Progression_RD_inv_unbjorn_plains = null; internal static ConfigEntry CE_Progression_RD_inv_skeleton_mistlands = null; internal static ConfigEntry CE_Progression_RD_inv_skeleton_ashlands = null; internal static ConfigEntry CE_Progression_RD_inv_skeleton_mage_ashlands = null; internal static ConfigEntry CE_SpawnHealthPercent_RD_inv_skeleton_meadows = null; internal static ConfigEntry CE_SpawnHealthPercent_RD_inv_skeleton_bforest = null; internal static ConfigEntry CE_SpawnHealthPercent_RD_inv_ghost_bforest = null; internal static ConfigEntry CE_SpawnHealthPercent_RD_inv_draugr_swamp = null; internal static ConfigEntry CE_SpawnHealthPercent_RD_inv_draugr_mountain = null; internal static ConfigEntry CE_SpawnHealthPercent_RD_inv_valkyrie_mountain = null; internal static ConfigEntry CE_SpawnHealthPercent_RD_inv_skeleton_plains = null; internal static ConfigEntry CE_SpawnHealthPercent_RD_inv_unbjorn_plains = null; internal static ConfigEntry CE_SpawnHealthPercent_RD_inv_skeleton_mistlands = null; internal static ConfigEntry CE_SpawnHealthPercent_RD_inv_skeleton_ashlands = null; internal static ConfigEntry CE_SpawnHealthPercent_RD_inv_skeleton_mage_ashlands = null; internal static ConfigEntry CE_SpawnEitr_RD_inv_skeleton_meadows = null; internal static ConfigEntry CE_SpawnEitr_RD_inv_skeleton_bforest = null; internal static ConfigEntry CE_SpawnEitr_RD_inv_ghost_bforest = null; internal static ConfigEntry CE_SpawnEitr_RD_inv_draugr_swamp = null; internal static ConfigEntry CE_SpawnEitr_RD_inv_draugr_mountain = null; internal static ConfigEntry CE_SpawnEitr_RD_inv_valkyrie_mountain = null; internal static ConfigEntry CE_SpawnEitr_RD_inv_skeleton_plains = null; internal static ConfigEntry CE_SpawnEitr_RD_inv_unbjorn_plains = null; internal static ConfigEntry CE_SpawnEitr_RD_inv_skeleton_mistlands = null; internal static ConfigEntry CE_SpawnEitr_RD_inv_skeleton_ashlands = null; internal static ConfigEntry CE_SpawnEitr_RD_inv_skeleton_mage_ashlands = null; internal static ConfigEntry CE_GrimoireIExtraMaxSummons = null; internal static ConfigEntry CE_GrimoireIIExtraMaxSummons = null; internal static ConfigEntry CE_GrimoireIIIExtraMaxSummons = null; internal static ConfigEntry CE_GrimoireISummonHealthCostBonusPercent = null; internal static ConfigEntry CE_GrimoireIISummonHealthCostBonusPercent = null; internal static ConfigEntry CE_GrimoireIIISummonHealthCostBonusPercent = null; internal static ConfigEntry CE_GrimoireIPlayerMaxHealthPenaltyPercent = null; internal static ConfigEntry CE_GrimoireIIPlayerMaxHealthPenaltyPercent = null; internal static ConfigEntry CE_GrimoireIIIPlayerMaxHealthPenaltyPercent = null; internal static ConfigEntry CE_ActiveSummonHealthRegenDebuffEnabled = null; internal static ConfigEntry CE_ActiveSummonHealthRegenPenaltyPerSummon = null; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] internal static ConfigSync ConfigSync; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static ConfigEntry _serverConfigLocked; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private FileSystemWatcher _configWatcher; private DateTime _lastCfgWriteUtc = DateTime.MinValue; private bool _reloadScheduled; private bool _watcherReady; private DateTime _ignoreEventsUntilUtc = DateTime.MinValue; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] internal static ConfigEntry CE_TomeSlot_Enabled; internal static void SetupIdleVoiceRules() { IdleVoiceRulesByMob.Clear(); AddIdleVoiceRule("RD_inv_skeleton_bforest", "sfx_skeleton_bforest_idle_rd_armor", "sfx_skeleton_bforest_idle_rd_armor_en", "sfx_skeleton_bforest_idle_rd_armor_ptbr"); AddIdleVoiceRule("RD_inv_ghost_bforest", "sfx_ghosts_idle_rd_armor", "sfx_ghosts_idle_rd_armor_male_en", "sfx_ghosts_idle_rd_armor_male_ptbr"); AddIdleVoiceRule("RD_inv_draugr_swamp", "sfx_draugr_archer_idle_rd_armor", "sfx_draugr_archer_idle_rd_armor_en", "sfx_draugr_archer_idle_rd_armor_ptbr"); AddIdleVoiceRule("RD_inv_draugr_mountain", "sfx_draugr_idle_rd_armor", "sfx_draugr_idle_rd_armor_en", "sfx_draugr_idle_rd_armor_ptbr"); AddIdleVoiceRule("RD_inv_valkyrie_mountain", "sfx_fallenvalkyrie_idle_rd_armor", "sfx_fallenvalkyrie_idle_rd_armor_en", "sfx_fallenvalkyrie_idle_rd_armor_ptbr"); AddIdleVoiceRule("RD_inv_skeleton_plains", "sfx_skeleton_ildir_idle_rd_armor", "sfx_skeleton_ildir_idle_rd_armor_en", "sfx_skeleton_ildir_idle_rd_armor_ptbr"); AddIdleVoiceRule("RD_inv_skeleton_mistlands", "sfx_charred_archer_idle_rd_armor", "sfx_charred_archer_idle_rd_armor_female_en", "sfx_charred_archer_idle_rd_armor_female_ptbr"); AddIdleVoiceRule("RD_inv_skeleton_ashlands", "sfx_charred_idle_rd_armor", "sfx_charred_idle_rd_armor_male_en", "sfx_charred_idle_rd_armor_male_ptbr"); AddIdleVoiceRule("RD_inv_skeleton_mage_ashlands", "sfx_charred_mage_idle_rd_armor", "sfx_charred_mage_idle_rd_armor_en", "sfx_charred_mage_idle_rd_armor_ptbr"); } private static void AddIdleVoiceRule(string mobPrefabName, string originalPrefabName, string englishPrefabName, string portugueseBrazilianPrefabName) { if (!string.IsNullOrWhiteSpace(mobPrefabName) && !string.IsNullOrWhiteSpace(originalPrefabName) && !string.IsNullOrWhiteSpace(englishPrefabName) && !string.IsNullOrWhiteSpace(portugueseBrazilianPrefabName) && !IdleVoiceRulesByMob.ContainsKey(mobPrefabName)) { IdleVoiceRulesByMob.Add(mobPrefabName, new VS_IdleVoiceRule(mobPrefabName, originalPrefabName, englishPrefabName, portugueseBrazilianPrefabName)); } } internal static void ValidateIdleVoiceRules() { if (_idleVoiceRulesValidated || !CE_IdleSfxOverrideEnabled.Value || (Object)(object)ZNetScene.instance == (Object)null) { return; } foreach (KeyValuePair item in IdleVoiceRulesByMob) { VS_IdleVoiceRule value = item.Value; if (!VS_RuntimeLookup.TryGetPrefabByName(value.OriginalPrefabName, out var prefab) || !VS_RuntimeLookup.TryGetPrefabByName(value.EnglishPrefabName, out prefab) || !VS_RuntimeLookup.TryGetPrefabByName(value.PortugueseBrazilianPrefabName, out prefab)) { return; } } _idleVoiceRulesValidated = true; } internal static string ResolveIdleVoicePrefabName(in VS_IdleVoiceRule rule) { return (CE_IdleSfxLanguageMode.Value == VS_SfxLanguageMode.English) ? rule.EnglishPrefabName : rule.PortugueseBrazilianPrefabName; } private void Awake() { Localizer.Load(); Instance = this; if (!_bootstrapped) { _bootstrapped = true; SetupServerSyncAndWatcher(); SetupBinds(); Summoner_DynamicTooltips.Register(); Mob_Registry.Init(); Registrations_MobsPrefab.RegisterMobsPrefab(); Registrations_GameObjetcs.RegisterGameObjetcs(); Registrations_Staffs.RegisterStaffs(); Registrations_Armors.RegisterArmors(); Registrations_Totens.RegisterTotens(); Registrations_Bench.RegisterBench(); Registrations_SummonWeapons.RegisterSummonWeapons(); Registrations_Food.RegisterFoods(); Registrations_Grimories.RegisterGrimories(); Registrations_MobsVoice.RegisterMobsVoice(); Registrations_TomeSlot.RegisterTomeSlot(this); SE_Registry_Manager.RegisterStatusEffects(); Registrations_Mobs_SpawnCost.Register(); Registrations_Mobs_OwnerDebuff.Register(); Registrations_Mobs_Lifetime.Register(); _harmony.PatchAll(); } } private void OnDestroy() { _configWatcher?.Dispose(); _configWatcher = null; } private void SetupBinds() { CE_ActiveSummonHealthRegenDebuffEnabled = config("01 - General", "Health Regen Debuff", value: true, "If enabled, active summons reduce the owner's health regeneration."); CE_SummonDecayFullHealthTimePercent = config("01 - General", "Summon Decay Health", 80f, "Percentage of the summon lifetime during which the summon keeps full health. After this period, health decays gradually until death."); CE_SummonDecayTickInterval = config("01 - General", "Summon Decay Tick", 0.5f, "Interval, in seconds, between summon lifetime decay updates."); CE_ActiveSummonHealthRegenPenaltyPerSummon = config("01 - General", "Health Regen Debuff Penalty", 0.01f, "Health regeneration penalty per active summon. 0.01 = 1% per summon."); CE_IdleSfxOverrideEnabled = config("01 - General", "Voice Override", value: false, "Allows overriding voice sound effects for summoned creatures. If disabled, summons will use the default sound effects."); CE_IdleSfxLanguageMode = config("01 - General", "Voice Language", VS_SfxLanguageMode.English, "Portuguese_Brazilian: Uses PT-BR summon voice sounds. English: Uses EN summon voice sounds."); CE_IdleSfxSoundInterval = config("01 - General", "Voice Sound Interval", 45f, "Interval in seconds between mob voice lines."); CE_IdleSfxSoundChance = config("01 - General", "Voice Sound Chance", 0.7f, "Chance from 0 to 1 for a summon to play a voice line."); CE_GrimoireIExtraMaxSummons = config("Grimoire Summoning I", "Extra Summons", 1, "Extra maximum summons granted while Grimoire is equipped."); CE_GrimoireISummonHealthCostBonusPercent = config("Grimoire Summoning I", "Summon Health Cost", 5f, "Extra percentage added to the summon health cost multiplier while Grimoire is equipped. 10 = +10%."); CE_GrimoireIPlayerMaxHealthPenaltyPercent = config("Grimoire Summoning I", "Player Health Penalty", 5f, "Percentage reduction applied to the player's maximum health while Grimoire is equipped. 10 = -10%."); CE_GrimoireIIExtraMaxSummons = config("Grimoire Summoning II", "Extra Summons", 2, "Extra maximum summons granted while Grimoire is equipped."); CE_GrimoireIISummonHealthCostBonusPercent = config("Grimoire Summoning II", "Summon Health Cost", 10f, "Extra percentage added to the summon health cost multiplier while Grimoire is equipped. 10 = +10%."); CE_GrimoireIIPlayerMaxHealthPenaltyPercent = config("Grimoire Summoning II", "Player Health Penalty", 10f, "Percentage reduction applied to the player's maximum health while Grimoire is equipped. 10 = -10%."); CE_GrimoireIIIExtraMaxSummons = config("Grimoire Summoning III", "Extra Summons", 3, "Extra maximum summons granted while Grimoire is equipped."); CE_GrimoireIIISummonHealthCostBonusPercent = config("Grimoire Summoning III", "Summon Health Cost", 15f, "Extra percentage added to the summon health cost multiplier while Grimoire is equipped. 10 = +10%."); CE_GrimoireIIIPlayerMaxHealthPenaltyPercent = config("Grimoire Summoning III", "Player Health Penalty", 15f, "Percentage reduction applied to the player's maximum health while Grimoire is equipped. 10 = -10%."); CE_Lifetime_RD_inv_skeleton_meadows = config("Summon Meadows Skeleton", "Life Time", 50f, "Lifetime of a summon in seconds."); CE_LifetimeUpgradeTotem_RD_totem_inv_meadows = config("Summon Meadows Skeleton", "Extra Life Time", 10f, "Extra lifetime in seconds gained per totem level."); CE_BaseHp_RD_inv_skeleton_meadows = config("Summon Meadows Skeleton", "Summon Health", 50f, "Total summon health."); CE_HpPercentPerStar_RD_inv_skeleton_meadows = config("Summon Meadows Skeleton", "Summon Health Level", 25f, "Extra summon health percentage per star."); CE_Progression_RD_inv_skeleton_meadows = config("Summon Meadows Skeleton", "Summon Progression", "10-19:1:2;20-29:2:2;30-39:3:2;40-100:3:3", "Defines summon scaling by Blood Magic level. Values below the first range block the summon.\nFormat: MinBloodMagic-MaxBloodMagic:SummonStars:MaxSummons."); CE_SpawnHealthPercent_RD_inv_skeleton_meadows = config("Summon Meadows Skeleton", "Health Cost", 5f, "Percentage of the player's health used to summon."); CE_SpawnEitr_RD_inv_skeleton_meadows = config("Summon Meadows Skeleton", "Eitr Cost", 5f, "Absolute eitr used to summon."); CE_Lifetime_RD_inv_skeleton_bforest = config("Summon Black Forest Spiteful Carcass", "Life Time", 60f, "Lifetime of a summon in seconds."); CE_LifetimeUpgradeTotem_RD_totem_inv_bforest = config("Summon Black Forest Spiteful Carcass", "Extra Life Time", 10f, "Extra lifetime in seconds gained per totem level."); CE_BaseHp_RD_inv_skeleton_bforest = config("Summon Black Forest Spiteful Carcass", "Summon Health", 100f, "Total summon health."); CE_HpPercentPerStar_RD_inv_skeleton_bforest = config("Summon Black Forest Spiteful Carcass", "Summon Health Level", 25f, "Extra summon health percentage per star."); CE_Progression_RD_inv_skeleton_bforest = config("Summon Black Forest Spiteful Carcass", "Summon Progression", "20-29:1:2;30-39:2:2;40-49:3:2;50-100:3:3", "Defines summon scaling by Blood Magic level. Values below the first range block the summon.\nFormat: MinBloodMagic-MaxBloodMagic:SummonStars:MaxSummons."); CE_SpawnHealthPercent_RD_inv_skeleton_bforest = config("Summon Black Forest Spiteful Carcass", "Health Cost", 7f, "Percentage of the player's health used to summon."); CE_SpawnEitr_RD_inv_skeleton_bforest = config("Summon Black Forest Spiteful Carcass", "Eitr Cost", 7f, "Absolute eitr used to summon."); CE_Lifetime_RD_inv_ghost_bforest = config("Summon Black Forest Specter", "Life Time", 50f, "Lifetime of a summon in seconds."); CE_LifetimeUpgradeTotem_RD_totem_inv_bforest_ghost = config("Summon Black Forest Specter", "Extra Life Time", 10f, "Extra lifetime in seconds gained per totem level."); CE_BaseHp_RD_inv_ghost_bforest = config("Summon Black Forest Specter", "Summon Health", 80f, "Total summon health."); CE_HpPercentPerStar_RD_inv_ghost_bforest = config("Summon Black Forest Specter", "Summon Health Level", 25f, "Extra summon health percentage per star."); CE_Progression_RD_inv_ghost_bforest = config("Summon Black Forest Specter", "Summon Progression", "30-59:1:1;60-89:1:2;90-100:2:2", "Defines summon scaling by Blood Magic level. Values below the first range block the summon.\nFormat: MinBloodMagic-MaxBloodMagic:SummonStars:MaxSummons."); CE_SpawnHealthPercent_RD_inv_ghost_bforest = config("Summon Black Forest Specter", "Health Cost", 7f, "Percentage of the player's health used to summon."); CE_SpawnEitr_RD_inv_ghost_bforest = config("Summon Black Forest Specter", "Eitr Cost", 7f, "Absolute eitr used to summon."); CE_Lifetime_RD_inv_draugr_swamp = config("Summon Swamp Bloody Archer", "Life Time", 80f, "Lifetime of a summon in seconds."); CE_LifetimeUpgradeTotem_RD_totem_inv_swamp = config("Summon Swamp Bloody Archer", "Extra Life Time", 10f, "Extra lifetime in seconds gained per totem level."); CE_BaseHp_RD_inv_draugr_swamp = config("Summon Swamp Bloody Archer", "Summon Health", 200f, "Total summon health."); CE_HpPercentPerStar_RD_inv_draugr_swamp = config("Summon Swamp Bloody Archer", "Summon Health Level", 25f, "Extra summon health percentage per star."); CE_Progression_RD_inv_draugr_swamp = config("Summon Swamp Bloody Archer", "Summon Progression", "30-39:1:2;40-49:2:2;50-59:3:2;60-100:3:3", "Defines summon scaling by Blood Magic level. Values below the first range block the summon.\nFormat: MinBloodMagic-MaxBloodMagic:SummonStars:MaxSummons."); CE_SpawnHealthPercent_RD_inv_draugr_swamp = config("Summon Swamp Bloody Archer", "Health Cost", 10f, "Percentage of the player's health used to summon."); CE_SpawnEitr_RD_inv_draugr_swamp = config("Summon Swamp Bloody Archer", "Eitr Cost", 10f, "Absolute eitr used to summon."); CE_Lifetime_RD_inv_draugr_mountain = config("Summon Mountain Frozen Corpse", "Life Time", 100f, "Lifetime of a summon in seconds."); CE_LifetimeUpgradeTotem_RD_totem_inv_mountain = config("Summon Mountain Frozen Corpse", "Extra Life Time", 10f, "Extra lifetime in seconds gained per totem level."); CE_BaseHp_RD_inv_draugr_mountain = config("Summon Mountain Frozen Corpse", "Summon Health", 300f, "Total summon health."); CE_HpPercentPerStar_RD_inv_draugr_mountain = config("Summon Mountain Frozen Corpse", "Summon Health Level", 25f, "Extra summon health percentage per star."); CE_Progression_RD_inv_draugr_mountain = config("Summon Mountain Frozen Corpse", "Summon Progression", "40-49:1:2;50-59:2:2;60-100:3:2", "Defines summon scaling by Blood Magic level. Values below the first range block the summon.\nFormat: MinBloodMagic-MaxBloodMagic:SummonStars:MaxSummons."); CE_SpawnHealthPercent_RD_inv_draugr_mountain = config("Summon Mountain Frozen Corpse", "Health Cost", 12f, "Percentage of the player's health used to summon."); CE_SpawnEitr_RD_inv_draugr_mountain = config("Summon Mountain Frozen Corpse", "Eitr Cost", 12f, "Absolute eitr used to summon."); CE_Lifetime_RD_inv_valkyrie_mountain = config("Summon Mountain Corrupted Valkyrie", "Life Time", 120f, "Lifetime of a summon in seconds."); CE_LifetimeUpgradeTotem_RD_totem_inv_mountain_valkyrie = config("Summon Mountain Corrupted Valkyrie", "Extra Life Time", 10f, "Extra lifetime in seconds gained per totem level."); CE_BaseHp_RD_inv_valkyrie_mountain = config("Summon Mountain Corrupted Valkyrie", "Summon Health", 350f, "Total summon health."); CE_HpPercentPerStar_RD_inv_valkyrie_mountain = config("Summon Mountain Corrupted Valkyrie", "Summon Health Level", 25f, "Extra summon health percentage per star."); CE_Progression_RD_inv_valkyrie_mountain = config("Summon Mountain Corrupted Valkyrie", "Summon Progression", "40-49:1:1;50-59:2:1;60-100:3:1", "Defines summon scaling by Blood Magic level. Values below the first range block the summon.\nFormat: MinBloodMagic-MaxBloodMagic:SummonStars:MaxSummons."); CE_SpawnHealthPercent_RD_inv_valkyrie_mountain = config("Summon Mountain Corrupted Valkyrie", "Health Cost", 12f, "Percentage of the player's health used to summon."); CE_SpawnEitr_RD_inv_valkyrie_mountain = config("Summon Mountain Corrupted Valkyrie", "Eitr Cost", 12f, "Absolute eitr used to summon."); CE_Lifetime_RD_inv_skeleton_plains = config("Summon Plains Ancestral Skeleton", "Life Time", 140f, "Lifetime of a summon in seconds."); CE_LifetimeUpgradeTotem_RD_totem_inv_plains = config("Summon Plains Ancestral Skeleton", "Extra Life Time", 10f, "Extra lifetime in seconds gained per totem level."); CE_BaseHp_RD_inv_skeleton_plains = config("Summon Plains Ancestral Skeleton", "Summon Health", 400f, "Total summon health."); CE_HpPercentPerStar_RD_inv_skeleton_plains = config("Summon Plains Ancestral Skeleton", "Summon Health Level", 25f, "Extra summon health percentage per star."); CE_Progression_RD_inv_skeleton_plains = config("Summon Plains Ancestral Skeleton", "Summon Progression", "50-59:1:2;60-69:2:2;70-79:3:2;80-100:3:3", "Defines summon scaling by Blood Magic level. Values below the first range block the summon.\nFormat: MinBloodMagic-MaxBloodMagic:SummonStars:MaxSummons."); CE_SpawnHealthPercent_RD_inv_skeleton_plains = config("Summon Plains Ancestral Skeleton", "Health Cost", 15f, "Percentage of the player's health used to summon."); CE_SpawnEitr_RD_inv_skeleton_plains = config("Summon Plains Ancestral Skeleton", "Eitr Cost", 15f, "Absolute eitr used to summon."); CE_Lifetime_RD_inv_unbjorn_plains = config("Summon Plains Vile", "Life Time", 160f, "Lifetime of a summon in seconds."); CE_LifetimeUpgradeTotem_RD_totem_inv_plains_bear = config("Summon Plains Vile", "Extra Life Time", 10f, "Extra lifetime in seconds gained per totem level."); CE_BaseHp_RD_inv_unbjorn_plains = config("Summon Plains Vile", "Summon Health", 450f, "Total summon health."); CE_HpPercentPerStar_RD_inv_unbjorn_plains = config("Summon Plains Vile", "Summon Health Level", 25f, "Extra summon health percentage per star."); CE_Progression_RD_inv_unbjorn_plains = config("Summon Plains Vile", "Summon Progression", "50-69:1:1;70-89:2:1;90-100:2:2", "Defines summon scaling by Blood Magic level. Values below the first range block the summon.\nFormat: MinBloodMagic-MaxBloodMagic:SummonStars:MaxSummons."); CE_SpawnHealthPercent_RD_inv_unbjorn_plains = config("Summon Plains Vile", "Health Cost", 15f, "Percentage of the player's health used to summon."); CE_SpawnEitr_RD_inv_unbjorn_plains = config("Summon Plains Vile", "Eitr Cost", 15f, "Absolute eitr used to summon."); CE_Lifetime_RD_inv_skeleton_mistlands = config("Summon Mistlands Memorial Archer", "Life Time", 180f, "Lifetime of a summon in seconds."); CE_LifetimeUpgradeTotem_RD_totem_inv_mistlands = config("Summon Mistlands Memorial Archer", "Extra Life Time", 15f, "Extra lifetime in seconds gained per totem level."); CE_BaseHp_RD_inv_skeleton_mistlands = config("Summon Mistlands Memorial Archer", "Summon Health", 600f, "Total summon health."); CE_HpPercentPerStar_RD_inv_skeleton_mistlands = config("Summon Mistlands Memorial Archer", "Summon Health Level", 25f, "Extra summon health percentage per star."); CE_Progression_RD_inv_skeleton_mistlands = config("Summon Mistlands Memorial Archer", "Summon Progression", "60-79:2:1;80-100:2:2", "Defines summon scaling by Blood Magic level. Values below the first range block the summon.\nFormat: MinBloodMagic-MaxBloodMagic:SummonStars:MaxSummons."); CE_SpawnHealthPercent_RD_inv_skeleton_mistlands = config("Summon Mistlands Memorial Archer", "Health Cost", 18f, "Percentage of the player's health used to summon."); CE_SpawnEitr_RD_inv_skeleton_mistlands = config("Summon Mistlands Memorial Archer", "Eitr Cost", 18f, "Absolute eitr used to summon."); CE_Lifetime_RD_inv_skeleton_ashlands = config("Summon Ashlands Memorial Warrior", "Life Time", 200f, "Lifetime of a summon in seconds."); CE_LifetimeUpgradeTotem_RD_totem_inv_ashlands = config("Summon Ashlands Memorial Warrior", "Extra Life Time", 15f, "Extra lifetime in seconds gained per totem level."); CE_BaseHp_RD_inv_skeleton_ashlands = config("Summon Ashlands Memorial Warrior", "Summon Health", 800f, "Total summon health."); CE_HpPercentPerStar_RD_inv_skeleton_ashlands = config("Summon Ashlands Memorial Warrior", "Summon Health Level", 25f, "Extra summon health percentage per star."); CE_Progression_RD_inv_skeleton_ashlands = config("Summon Ashlands Memorial Warrior", "Summon Progression", "70-89:2:1;90-100:2:2", "Defines summon scaling by Blood Magic level. Values below the first range block the summon.\nFormat: MinBloodMagic-MaxBloodMagic:SummonStars:MaxSummons."); CE_SpawnHealthPercent_RD_inv_skeleton_ashlands = config("Summon Ashlands Memorial Warrior", "Health Cost", 20f, "Percentage of the player's health used to summon."); CE_SpawnEitr_RD_inv_skeleton_ashlands = config("Summon Ashlands Memorial Warrior", "Eitr Cost", 20f, "Absolute eitr used to summon."); CE_Lifetime_RD_inv_skeleton_mage_ashlands = config("Summon Ashlands Memorial Mage", "Life Time", 200f, "Lifetime of a summon in seconds."); CE_LifetimeUpgradeTotem_RD_totem_inv_ashlands_mage = config("Summon Ashlands Memorial Mage", "Extra Life Time", 15f, "Extra lifetime in seconds gained per totem level."); CE_BaseHp_RD_inv_skeleton_mage_ashlands = config("Summon Ashlands Memorial Mage", "Summon Health", 500f, "Total summon health."); CE_HpPercentPerStar_RD_inv_skeleton_mage_ashlands = config("Summon Ashlands Memorial Mage", "Summon Health Level", 25f, "Extra summon health percentage per star."); CE_Progression_RD_inv_skeleton_mage_ashlands = config("Summon Ashlands Memorial Mage", "Summon Progression", "70-89:2:1;90-100:2:2", "Defines summon scaling by Blood Magic level. Values below the first range block the summon.\nFormat: MinBloodMagic-MaxBloodMagic:SummonStars:MaxSummons."); CE_SpawnHealthPercent_RD_inv_skeleton_mage_ashlands = config("Summon Ashlands Memorial Mage", "Health Cost", 20f, "Percentage of the player's health used to summon."); CE_SpawnEitr_RD_inv_skeleton_mage_ashlands = config("Summon Ashlands Memorial Mage", "Eitr Cost", 20f, "Absolute eitr used to summon."); } internal static ConfigEntry GetLifetimeCE(string prefab) { return Mob_Registry.Get(prefab).LifetimeCE; } internal static ConfigEntry GetLifetimeUpgradeTotemCE(string prefab) { return Mob_Registry.GetByTotemPrefab(prefab).LifetimeUpgradeTotemCE; } internal static ConfigEntry GetBaseHpCE(string prefab) { return Mob_Registry.Get(prefab).BaseHpCE; } internal static ConfigEntry GetHpPercentPerStarCE(string prefab) { return Mob_Registry.Get(prefab).HpPercentPerStarCE; } internal static ConfigEntry GetProgressionCE(string prefab) { return Mob_Registry.Get(prefab).ProgressionCE; } internal static bool HasLifetimeUpgradeTotem(string prefab) { Mob_Registry.SummonDef def; return Mob_Registry.TryGetByTotemPrefab(prefab, out def); } public void SetupServerSyncAndWatcher() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown bool flag = false; try { ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; ConfigSync = new ConfigSync(((BaseUnityPlugin)this).Info.Metadata.GUID) { DisplayName = ((BaseUnityPlugin)this).Info.Metadata.Name, CurrentVersion = ((BaseUnityPlugin)this).Info.Metadata.Version.ToString(), MinimumRequiredVersion = ((BaseUnityPlugin)this).Info.Metadata.Version.ToString() }; _serverConfigLocked = ((BaseUnityPlugin)this).Config.Bind("01 - General", "Lock Configuration", true, new ConfigDescription("If true, the server locks synchronized configs.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = false } })); ConfigSync.AddLockingConfigEntry(_serverConfigLocked); SetupConfigWatcher(); flag = true; } finally { ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; if (flag && (Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { ((BaseUnityPlugin)this).Config.Save(); } } } internal ConfigEntry config<[<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags); ConfigEntry val2 = ((BaseUnityPlugin)this).Config.Bind(group, name, value, val); SyncedConfigEntry syncedConfigEntry = ConfigSync?.AddConfigEntry(val2); if (syncedConfigEntry != null) { syncedConfigEntry.SynchronizedConfig = synchronizedSetting; } return val2; } internal ConfigEntry config<[<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>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()), synchronizedSetting); } private void SetupConfigWatcher() { _configWatcher?.Dispose(); string configPath = Paths.ConfigPath; string fileName = Path.GetFileName(((BaseUnityPlugin)this).Config.ConfigFilePath); _configWatcher = new FileSystemWatcher(configPath, fileName) { IncludeSubdirectories = false, NotifyFilter = (NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite | NotifyFilters.CreationTime) }; FileSystemEventHandler onChanged = [NullableContext(0)] (object _, FileSystemEventArgs __) => { if (!(DateTime.UtcNow < _ignoreEventsUntilUtc)) { _lastCfgWriteUtc = DateTime.UtcNow; if (!_reloadScheduled) { _reloadScheduled = true; ((MonoBehaviour)this).StartCoroutine(ReloadConfigAfterQuietPeriod(0.75f)); } } }; _configWatcher.Changed += onChanged; _configWatcher.Created += onChanged; _configWatcher.Renamed += [NullableContext(0)] (object _, RenamedEventArgs __) => { onChanged(_, __); }; _configWatcher.EnableRaisingEvents = true; _watcherReady = true; } [IteratorStateMachine(typeof(d__129))] private IEnumerator ReloadConfigAfterQuietPeriod(float quietSeconds) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__129(0) { <>4__this = this, quietSeconds = quietSeconds }; } internal void InitializeTomeSlot() { CE_TomeSlot_Enabled = config("01 - General", "Tome Slot", value: true, "Enable custom Tome slot. Requires AzuExtendedPlayerInventory."); if (CE_TomeSlot_Enabled.Value && AzuEpiCompat.IsLoaded()) { AzuEpiCompat.AddSlot("Tome", (Player player) => TomeCustomSlotManager.GetEquippedTome(player) ?? null, (ItemData item) => TomeCustomSlotManager.IsTomeItem(item)); } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class VS_IdleVoice_ZNetScene_Awake_Patch { private static void Postfix() { Vikings_SummonerPlugin.ValidateIdleVoiceRules(); } } internal static class VS_SummonVoicePrefabResolver { [NullableContext(1)] internal static bool TryGetMobPrefabName([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] BaseAI ai, out string mobPrefabName) { mobPrefabName = string.Empty; if (!Object.op_Implicit((Object)(object)ai)) { return false; } return VS_RuntimeLookup.TryGetPrefabNameFromZdo((Component)(object)ai, out mobPrefabName); } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(2)] internal static class VS_SummonIdleVoiceScheduler { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] private const string IdleMethodName = "DoIdleSound"; private static readonly MethodInfo CancelInvokeStringMethod = AccessTools.Method(typeof(MonoBehaviour), "CancelInvoke", new Type[1] { typeof(string) }, (Type[])null); private static readonly MethodInfo InvokeRepeatingMethod = AccessTools.Method(typeof(MonoBehaviour), "InvokeRepeating", new Type[3] { typeof(string), typeof(float), typeof(float) }, (Type[])null); internal static bool Rebind(BaseAI ai, float interval, float chance) { if (!Object.op_Implicit((Object)(object)ai)) { return false; } if (CancelInvokeStringMethod == null || InvokeRepeatingMethod == null) { return false; } float num = Mathf.Max(0.01f, interval); float idleSoundChance = Mathf.Clamp01(chance); ai.m_idleSoundInterval = num; ai.m_idleSoundChance = idleSoundChance; CancelInvokeStringMethod.Invoke(ai, new object[1] { "DoIdleSound" }); InvokeRepeatingMethod.Invoke(ai, new object[3] { "DoIdleSound", num, num }); return true; } } [HarmonyPatch(typeof(BaseAI), "Awake")] internal static class VS_SummonIdleVoice_BaseAI_Awake_Patch { [NullableContext(1)] private static void Postfix(BaseAI __instance) { VS_SummonMarker vS_SummonMarker = default(VS_SummonMarker); if (!Object.op_Implicit((Object)(object)__instance) || !((Component)__instance).TryGetComponent(ref vS_SummonMarker)) { return; } VS_SummonIdleVoiceScheduler.Rebind(__instance, Vikings_SummonerPlugin.CE_IdleSfxSoundInterval.Value, Vikings_SummonerPlugin.CE_IdleSfxSoundChance.Value); if (!Vikings_SummonerPlugin.CE_IdleSfxOverrideEnabled.Value || !VS_SummonVoicePrefabResolver.TryGetMobPrefabName(__instance, out var mobPrefabName) || !Vikings_SummonerPlugin.IdleVoiceRulesByMob.TryGetValue(mobPrefabName, out var value)) { return; } string prefabName = Vikings_SummonerPlugin.ResolveIdleVoicePrefabName(in value); if (!VS_RuntimeLookup.TryGetPrefabByName(prefabName, out var prefab)) { return; } EffectList idleSound = __instance.m_idleSound; EffectData[] effectPrefabs = idleSound.m_effectPrefabs; if (effectPrefabs == null || effectPrefabs.Length == 0) { return; } bool flag = false; EffectData[] array = (EffectData[])(object)new EffectData[effectPrefabs.Length]; for (int i = 0; i < effectPrefabs.Length; i++) { EffectData val = effectPrefabs[i]; GameObject prefab2 = val.m_prefab; if (Object.op_Implicit((Object)(object)prefab2)) { string a = ((Object)prefab2).name ?? string.Empty; if (string.Equals(a, value.OriginalPrefabName, StringComparison.Ordinal)) { val.m_prefab = prefab; flag = true; } } array[i] = val; } if (flag) { idleSound.m_effectPrefabs = array; __instance.m_idleSound = idleSound; } } } internal static class Registrations_Bench { public static void RegisterBench() { BuildPiece buildPiece = new BuildPiece("rd_armor", "RD_necromancer_table"); buildPiece.Crafting.Set(PieceManager.CraftingTable.Workbench); buildPiece.Category.Set("Vikings Mastery"); buildPiece.SpecialProperties.AdminOnly = false; buildPiece.RequiredItems.Add("Resin", 10, recover: true); buildPiece.RequiredItems.Add("Wood", 20, recover: true); buildPiece.RequiredItems.Add("DeerHide", 10, recover: true); MaterialReplacer.RegisterGameObjectForShaderSwap(buildPiece.Prefab, MaterialReplacer.ShaderType.UseUnityShader); BuildPiece buildPiece2 = new BuildPiece("rd_armor", "RD_necromancer_table_ext_01"); buildPiece2.Crafting.Set(PieceManager.CraftingTable.Workbench); buildPiece2.Category.Set("Vikings Mastery"); buildPiece2.SpecialProperties.AdminOnly = false; buildPiece2.RequiredItems.Add("GreydwarfEye", 10, recover: true); buildPiece2.RequiredItems.Add("Wood", 10, recover: true); buildPiece2.RequiredItems.Add("DeerHide", 5, recover: true); MaterialReplacer.RegisterGameObjectForShaderSwap(buildPiece2.Prefab, MaterialReplacer.ShaderType.UseUnityShader); BuildPiece buildPiece3 = new BuildPiece("rd_armor", "RD_necromancer_table_ext_02"); buildPiece3.Crafting.Set(PieceManager.CraftingTable.Workbench); buildPiece3.Category.Set("Vikings Mastery"); buildPiece3.SpecialProperties.AdminOnly = false; buildPiece3.RequiredItems.Add("Bronze", 10, recover: true); buildPiece3.RequiredItems.Add("FineWood", 10, recover: true); buildPiece3.RequiredItems.Add("Feathers", 5, recover: true); MaterialReplacer.RegisterGameObjectForShaderSwap(buildPiece3.Prefab, MaterialReplacer.ShaderType.UseUnityShader); BuildPiece buildPiece4 = new BuildPiece("rd_armor", "RD_necromancer_table_ext_03"); buildPiece4.Crafting.Set(PieceManager.CraftingTable.Workbench); buildPiece4.Category.Set("Vikings Mastery"); buildPiece4.SpecialProperties.AdminOnly = false; buildPiece4.RequiredItems.Add("Iron", 10, recover: true); buildPiece4.RequiredItems.Add("ElderBark", 15, recover: true); buildPiece4.RequiredItems.Add("Entrails", 10, recover: true); MaterialReplacer.RegisterGameObjectForShaderSwap(buildPiece4.Prefab, MaterialReplacer.ShaderType.UseUnityShader); BuildPiece buildPiece5 = new BuildPiece("rd_armor", "RD_necromancer_table_ext_04"); buildPiece5.Crafting.Set(PieceManager.CraftingTable.Workbench); buildPiece5.Category.Set("Vikings Mastery"); buildPiece5.SpecialProperties.AdminOnly = false; buildPiece5.RequiredItems.Add("Silver", 10, recover: true); buildPiece5.RequiredItems.Add("FineWood", 10, recover: true); buildPiece5.RequiredItems.Add("FreezeGland", 6, recover: true); MaterialReplacer.RegisterGameObjectForShaderSwap(buildPiece5.Prefab, MaterialReplacer.ShaderType.UseUnityShader); BuildPiece buildPiece6 = new BuildPiece("rd_armor", "RD_necromancer_table_02"); buildPiece6.Crafting.Set(PieceManager.CraftingTable.Workbench); buildPiece6.Category.Set("Vikings Mastery"); buildPiece6.SpecialProperties.AdminOnly = false; buildPiece6.RequiredItems.Add("BlackMetal", 20, recover: true); buildPiece6.RequiredItems.Add("FineWood", 20, recover: true); buildPiece6.RequiredItems.Add("GoblinTotem", 2, recover: true); MaterialReplacer.RegisterGameObjectForShaderSwap(buildPiece6.Prefab, MaterialReplacer.ShaderType.UseUnityShader); BuildPiece buildPiece7 = new BuildPiece("rd_armor", "RD_necromancer_table_02_ext_01"); buildPiece7.Crafting.Set(PieceManager.CraftingTable.Workbench); buildPiece7.Category.Set("Vikings Mastery"); buildPiece7.SpecialProperties.AdminOnly = false; buildPiece7.RequiredItems.Add("BlackMetal", 10, recover: true); buildPiece7.RequiredItems.Add("FineWood", 10, recover: true); buildPiece7.RequiredItems.Add("GoblinTotem", 1, recover: true); MaterialReplacer.RegisterGameObjectForShaderSwap(buildPiece7.Prefab, MaterialReplacer.ShaderType.UseUnityShader); BuildPiece buildPiece8 = new BuildPiece("rd_armor", "RD_necromancer_table_02_ext_02"); buildPiece8.Crafting.Set(PieceManager.CraftingTable.Workbench); buildPiece8.Category.Set("Vikings Mastery"); buildPiece8.SpecialProperties.AdminOnly = false; buildPiece8.RequiredItems.Add("Eitr", 10, recover: true); buildPiece8.RequiredItems.Add("FineWood", 10, recover: true); buildPiece8.RequiredItems.Add("BlackCore", 1, recover: true); MaterialReplacer.RegisterGameObjectForShaderSwap(buildPiece8.Prefab, MaterialReplacer.ShaderType.UseUnityShader); BuildPiece buildPiece9 = new BuildPiece("rd_armor", "RD_necromancer_table_02_ext_03"); buildPiece9.Crafting.Set(PieceManager.CraftingTable.Workbench); buildPiece9.Category.Set("Vikings Mastery"); buildPiece9.SpecialProperties.AdminOnly = false; buildPiece9.RequiredItems.Add("Eitr", 8, recover: true); buildPiece9.RequiredItems.Add("Blackwood", 10, recover: true); buildPiece9.RequiredItems.Add("FlametalNew", 10, recover: true); MaterialReplacer.RegisterGameObjectForShaderSwap(buildPiece9.Prefab, MaterialReplacer.ShaderType.UseUnityShader); } } internal static class Registrations_GameObjetcs { public static void RegisterGameObjetcs() { GameObject val = PrefabManager.RegisterPrefab("rd_armor", "fx_backstab_rd_armor"); GameObject val2 = PrefabManager.RegisterPrefab("rd_armor", "fx_crit_rd_armor"); GameObject val3 = PrefabManager.RegisterPrefab("rd_armor", "fx_footstep_climb_rd_armor"); GameObject val4 = PrefabManager.RegisterPrefab("rd_armor", "fx_footstep_jog_rd_armor"); GameObject val5 = PrefabManager.RegisterPrefab("rd_armor", "fx_footstep_mud_jog_rd_armor"); GameObject val6 = PrefabManager.RegisterPrefab("rd_armor", "fx_footstep_mud_run_rd_armor"); GameObject val7 = PrefabManager.RegisterPrefab("rd_armor", "fx_footstep_run_rd_armor"); GameObject val8 = PrefabManager.RegisterPrefab("rd_armor", "fx_footstep_snow_jog_rd_armor"); GameObject val9 = PrefabManager.RegisterPrefab("rd_armor", "fx_footstep_snow_run_rd_armor"); GameObject val10 = PrefabManager.RegisterPrefab("rd_armor", "fx_footstep_water_rd_armor"); GameObject val11 = PrefabManager.RegisterPrefab("rd_armor", "fx_skeleton_pet_rd_armor"); GameObject val12 = PrefabManager.RegisterPrefab("rd_armor", "fx_block_camshake_rd_armor"); GameObject val13 = PrefabManager.RegisterPrefab("rd_armor", "fx_hit_camshake_rd_armor"); GameObject val14 = PrefabManager.RegisterPrefab("rd_armor", "fx_swing_camshake_rd_armor"); GameObject val15 = PrefabManager.RegisterPrefab("rd_armor", "fx_charred_death_rd_armor"); GameObject val16 = PrefabManager.RegisterPrefab("rd_armor", "fx_charred_hit_rd_armor"); GameObject val17 = PrefabManager.RegisterPrefab("rd_armor", "fx_fireskeleton_nova_rd_armor"); GameObject val18 = PrefabManager.RegisterPrefab("rd_armor", "fx_summon_spawn_efeito_mao"); GameObject val19 = PrefabManager.RegisterPrefab("rd_armor", "fx_summon_spawn_solo_ashlands"); GameObject val20 = PrefabManager.RegisterPrefab("rd_armor", "fx_summon_spawn_solo_bforest"); GameObject val21 = PrefabManager.RegisterPrefab("rd_armor", "fx_summon_spawn_solo_meadows"); GameObject val22 = PrefabManager.RegisterPrefab("rd_armor", "fx_summon_spawn_solo_mistlands"); GameObject val23 = PrefabManager.RegisterPrefab("rd_armor", "fx_summon_spawn_solo_mountain"); GameObject val24 = PrefabManager.RegisterPrefab("rd_armor", "fx_summon_spawn_solo_plains"); GameObject val25 = PrefabManager.RegisterPrefab("rd_armor", "fx_summon_spawn_solo_swamp"); GameObject val26 = PrefabManager.RegisterPrefab("rd_armor", "fx_inv_projectile_explosion_bflorest"); GameObject val27 = PrefabManager.RegisterPrefab("rd_armor", "fx_inv_projectile_explosion_pantano"); GameObject val28 = PrefabManager.RegisterPrefab("rd_armor", "fx_inv_projectile_explosion_meadows"); GameObject val29 = PrefabManager.RegisterPrefab("rd_armor", "fx_inv_projectile_hit_mountain"); GameObject val30 = PrefabManager.RegisterPrefab("rd_armor", "fx_inv_projectile_explosion_mistlands"); GameObject val31 = PrefabManager.RegisterPrefab("rd_armor", "fx_inv_launch_mountain_launch"); GameObject val32 = PrefabManager.RegisterPrefab("rd_armor", "fx_inv_launch_plains_launch"); GameObject val33 = PrefabManager.RegisterPrefab("rd_armor", "fx_inv_projectile_explosion_ashlands"); GameObject val34 = PrefabManager.RegisterPrefab("rd_armor", "fx_FeastSmall_rd_armor"); GameObject val35 = PrefabManager.RegisterPrefab("rd_armor", "fx_Eat_rd_armor"); GameObject val36 = PrefabManager.RegisterPrefab("rd_armor", "fx_bjorn_hit_rd_armor"); GameObject val37 = PrefabManager.RegisterPrefab("rd_armor", "fx_bjorn_death_rd_armor"); GameObject val38 = PrefabManager.RegisterPrefab("rd_armor", "fx_summon_spawn_solo_plains_unbjorn"); GameObject val39 = PrefabManager.RegisterPrefab("rd_armor", "fx_summon_spawn_solo_bforest_ghost"); GameObject val40 = PrefabManager.RegisterPrefab("rd_armor", "fx_bat_hit_rd_armor"); GameObject val41 = PrefabManager.RegisterPrefab("rd_armor", "fx_fallenvalkyrie_death_rd_armor"); GameObject val42 = PrefabManager.RegisterPrefab("rd_armor", "fx_FallenValkyrie_projectile_explosion_rd_armor"); GameObject val43 = PrefabManager.RegisterPrefab("rd_armor", "fx_fallenfalkyrie_spin_rd_armor"); GameObject val44 = PrefabManager.RegisterPrefab("rd_armor", "fx_charred_firestaff_chargeup_rd_armor"); GameObject val45 = PrefabManager.RegisterPrefab("rd_armor", "fx_fireball_staff_explosion_rd_armor"); GameObject val46 = PrefabManager.RegisterPrefab("rd_armor", "sfx_footstep_sneak_rd_armor"); GameObject val47 = PrefabManager.RegisterPrefab("rd_armor", "sfx_footstep_swim_rd_armor"); GameObject val48 = PrefabManager.RegisterPrefab("rd_armor", "sfx_skeleton_hit_rd_armor"); GameObject val49 = PrefabManager.RegisterPrefab("rd_armor", "sfx_metal_blocked_rd_armor"); GameObject val50 = PrefabManager.RegisterPrefab("rd_armor", "sfx_sword_hit_rd_armor"); GameObject val51 = PrefabManager.RegisterPrefab("rd_armor", "sfx_sword_swing_rd_armor"); GameObject val52 = PrefabManager.RegisterPrefab("rd_armor", "sfx_wood_blocked_rd_armor"); GameObject val53 = PrefabManager.RegisterPrefab("rd_armor", "sfx_skeleton_big_death_rd_armor"); GameObject val54 = PrefabManager.RegisterPrefab("rd_armor", "sfx_club_swing_rd_armor"); GameObject val55 = PrefabManager.RegisterPrefab("rd_armor", "sfx_axe_swing_rd_armor"); GameObject val56 = PrefabManager.RegisterPrefab("rd_armor", "sfx_skeleton_attack_rd_armor"); GameObject val57 = PrefabManager.RegisterPrefab("rd_armor", "sfx_skeleton_mace_hit_rd_armor"); GameObject val58 = PrefabManager.RegisterPrefab("rd_armor", "sfx_skeleton_alerted_rd_armor"); GameObject val59 = PrefabManager.RegisterPrefab("rd_armor", "sfx_skeleton_idle_rd_armor"); GameObject val60 = PrefabManager.RegisterPrefab("rd_armor", "sfx_draugr_death_rd_armor"); GameObject val61 = PrefabManager.RegisterPrefab("rd_armor", "sfx_arrow_hit_rd_armor"); GameObject val62 = PrefabManager.RegisterPrefab("rd_armor", "sfx_draugr_hit_rd_armor"); GameObject val63 = PrefabManager.RegisterPrefab("rd_armor", "sfx_bow_draw_rd_armor"); GameObject val64 = PrefabManager.RegisterPrefab("rd_armor", "sfx_bow_fire_rd_armor"); GameObject val65 = PrefabManager.RegisterPrefab("rd_armor", "sfx_draugr_alerted_rd_armor"); GameObject val66 = PrefabManager.RegisterPrefab("rd_armor", "sfx_firestaff_launch_rd_armor"); GameObject val67 = PrefabManager.RegisterPrefab("rd_armor", "sfx_bomb_throw_rd_armor"); GameObject val68 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_death_rd_armor"); GameObject val69 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_alert_rd_armor"); GameObject val70 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_archer_bow_draw_rd_armor"); GameObject val71 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_archer_bow_release_rd_armor"); GameObject val72 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_archer_volley_draw_rd_armor"); GameObject val73 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_archer_volley_release_rd_armor"); GameObject val74 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_hurt_rd_armor"); GameObject val75 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_melee_attack_lift_rd_armor"); GameObject val76 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_melee_attack_swing_rd_armor"); GameObject val77 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_melee_attack_stab_rd_armor"); GameObject val78 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_footstep_rd_armor"); GameObject val79 = PrefabManager.RegisterPrefab("rd_armor", "sfx_wood_destroyed_rd_armor"); GameObject val80 = PrefabManager.RegisterPrefab("rd_armor", "sfx_build_hammer_wood_rd_armor"); GameObject val81 = PrefabManager.RegisterPrefab("rd_armor", "sfx_gui_craftitem_workbench_rd_armor"); GameObject val82 = PrefabManager.RegisterPrefab("rd_armor", "sfx_gui_craftitem_workbench_end_rd_armor"); GameObject val83 = PrefabManager.RegisterPrefab("rd_armor", "sfx_gui_repairitem_workbench_rd_armor"); GameObject val84 = PrefabManager.RegisterPrefab("rd_armor", "sfx_club_hit_rd_armor"); GameObject val85 = PrefabManager.RegisterPrefab("rd_armor", "sfx_inv_launch_meadows"); GameObject val86 = PrefabManager.RegisterPrefab("rd_armor", "sfx_inv_launch_bflorest"); GameObject val87 = PrefabManager.RegisterPrefab("rd_armor", "sfx_inv_launch_swamp"); GameObject val88 = PrefabManager.RegisterPrefab("rd_armor", "sfx_inv_launch_mountain_start"); GameObject val89 = PrefabManager.RegisterPrefab("rd_armor", "sfx_inv_launch_plains"); GameObject val90 = PrefabManager.RegisterPrefab("rd_armor", "sfx_inv_launch_mistlands"); GameObject val91 = PrefabManager.RegisterPrefab("rd_armor", "sfx_inv_launch_ashlands"); GameObject val92 = PrefabManager.RegisterPrefab("rd_armor", "sfx_unarmed_hit_rd_armor"); GameObject val93 = PrefabManager.RegisterPrefab("rd_armor", "sfx_eat_rd_armor"); GameObject val94 = PrefabManager.RegisterPrefab("rd_armor", "sfx_unbjorn_hurt_rd_armor"); GameObject val95 = PrefabManager.RegisterPrefab("rd_armor", "sfx_unbjorn_idle_rd_armor"); GameObject val96 = PrefabManager.RegisterPrefab("rd_armor", "sfx_troll_rock_destroyed_rd_armor"); GameObject val97 = PrefabManager.RegisterPrefab("rd_armor", "sfx_unbjorn_claw_attack_rd_armor"); GameObject val98 = PrefabManager.RegisterPrefab("rd_armor", "sfx_unbjorn_claw_attack_slash_rd_armor"); GameObject val99 = PrefabManager.RegisterPrefab("rd_armor", "sfx_unbjorn_bite_attack_impact_rd_armor"); GameObject val100 = PrefabManager.RegisterPrefab("rd_armor", "sfx_unbjorn_bite_attack_rd_armor"); GameObject val101 = PrefabManager.RegisterPrefab("rd_armor", "sfx_unspawn_rd_armor"); GameObject val102 = PrefabManager.RegisterPrefab("rd_armor", "sfx_ghost_death_rd_armor"); GameObject val103 = PrefabManager.RegisterPrefab("rd_armor", "sfx_ghost_hurt_rd_armor"); GameObject val104 = PrefabManager.RegisterPrefab("rd_armor", "sfx_ghosts_melee_attack_impact_rd_armor"); GameObject val105 = PrefabManager.RegisterPrefab("rd_armor", "sfx_ghosts_melee_attack_rd_armor"); GameObject val106 = PrefabManager.RegisterPrefab("rd_armor", "sfx_fallenvalkyrie_death_rd_armor"); GameObject val107 = PrefabManager.RegisterPrefab("rd_armor", "sfx_fallenvalkyrie_alert_rd_armor"); GameObject val108 = PrefabManager.RegisterPrefab("rd_armor", "sfx_wraith_attack_hit_rd_armor"); GameObject val109 = PrefabManager.RegisterPrefab("rd_armor", "sfx_fallenvalkyrie_attack_spit_projectile_impact_rd_armor"); GameObject val110 = PrefabManager.RegisterPrefab("rd_armor", "sfx_greydwarf_attack_hit_rd_armor"); GameObject val111 = PrefabManager.RegisterPrefab("rd_armor", "sfx_fallenvalkyrie_attack_spit_charge_rd_armor"); GameObject val112 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_mage_attack_shoot_rd_armor"); GameObject val113 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_mage_attack_charge_rd_armor"); GameObject val114 = PrefabManager.RegisterPrefab("rd_armor", "vfx_creature_soothed_rd_armor"); GameObject val115 = PrefabManager.RegisterPrefab("rd_armor", "vfx_skeleton_death_rd_armor"); GameObject val116 = PrefabManager.RegisterPrefab("rd_armor", "vfx_skeleton_hit_rd_armor"); GameObject val117 = PrefabManager.RegisterPrefab("rd_armor", "vfx_water_surface_rd_armor"); GameObject val118 = PrefabManager.RegisterPrefab("rd_armor", "vfx_blocked_rd_armor"); GameObject val119 = PrefabManager.RegisterPrefab("rd_armor", "vfx_HitSparks_rd_armor"); GameObject val120 = PrefabManager.RegisterPrefab("rd_armor", "vfx_skeleton_big_death_rd_armor"); GameObject val121 = PrefabManager.RegisterPrefab("rd_armor", "vfx_clubhit_rd_armor"); GameObject val122 = PrefabManager.RegisterPrefab("rd_armor", "vfx_skeleton_mace_hit_rd_armor"); GameObject val123 = PrefabManager.RegisterPrefab("rd_armor", "vfx_arrowhit_rd_armor"); GameObject val124 = PrefabManager.RegisterPrefab("rd_armor", "vfx_corpse_destruction_small_rd_armor"); GameObject val125 = PrefabManager.RegisterPrefab("rd_armor", "vfx_skeleton_fire_death_rd_armor"); GameObject val126 = PrefabManager.RegisterPrefab("rd_armor", "vfx_draugr_hit_rd_armor"); GameObject val127 = PrefabManager.RegisterPrefab("rd_armor", "vfx_draugr_death_rd_armor"); GameObject val128 = PrefabManager.RegisterPrefab("rd_armor", "vfx_SawDust_rd_armor"); GameObject val129 = PrefabManager.RegisterPrefab("rd_armor", "vfx_Place_workbench_rd_armor"); GameObject val130 = PrefabManager.RegisterPrefab("rd_armor", "vfx_ExtensionConnection_rd_armor"); GameObject val131 = PrefabManager.RegisterPrefab("rd_armor", "vfx_Place_wood_pole_rd_armor"); GameObject val132 = PrefabManager.RegisterPrefab("rd_armor", "vfx_corpse_destruction_medium_rd_armor"); GameObject val133 = PrefabManager.RegisterPrefab("rd_armor", "vfx_bjorn_groundslam_rd_armor"); GameObject val134 = PrefabManager.RegisterPrefab("rd_armor", "vfx_unspawn_rd_armor"); GameObject val135 = PrefabManager.RegisterPrefab("rd_armor", "vfx_unspawn_big_rd_armor"); GameObject val136 = PrefabManager.RegisterPrefab("rd_armor", "vfx_ghost_death_rd_armor"); GameObject val137 = PrefabManager.RegisterPrefab("rd_armor", "vfx_ghost_hit_rd_armor"); GameObject val138 = PrefabManager.RegisterPrefab("rd_armor", "vfx_FlameBall_launch_valkyrie"); GameObject val139 = PrefabManager.RegisterPrefab("rd_armor", "valkyrie_spit_projectile"); GameObject val140 = PrefabManager.RegisterPrefab("rd_armor", "charred_mage_fireball_projectile"); GameObject val141 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_draugr_mountain_menu"); GameObject val142 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_draugr_swamp_menu"); GameObject val143 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_ghost_bforest_menu"); GameObject val144 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_skeleton_ashlands_menu"); GameObject val145 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_skeleton_bforest_menu"); GameObject val146 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_skeleton_mage_ashlands_menu"); GameObject val147 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_skeleton_meadows_menu"); GameObject val148 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_skeleton_mistlands_menu"); GameObject val149 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_skeleton_plains_menu"); GameObject val150 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_unbjorn_plains_menu"); GameObject val151 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_valkyrie_mountain_menu"); GameObject val152 = PrefabManager.RegisterPrefab("rd_armor", "sfx_skeleton_bforest_idle_rd_armor"); GameObject val153 = PrefabManager.RegisterPrefab("rd_armor", "sfx_skeleton_bforest_idle_rd_armor_en"); GameObject val154 = PrefabManager.RegisterPrefab("rd_armor", "sfx_skeleton_bforest_idle_rd_armor_ptbr"); GameObject val155 = PrefabManager.RegisterPrefab("rd_armor", "sfx_draugr_archer_idle_rd_armor"); GameObject val156 = PrefabManager.RegisterPrefab("rd_armor", "sfx_draugr_archer_idle_rd_armor_en"); GameObject val157 = PrefabManager.RegisterPrefab("rd_armor", "sfx_draugr_archer_idle_rd_armor_ptbr"); GameObject val158 = PrefabManager.RegisterPrefab("rd_armor", "sfx_draugr_idle_rd_armor"); GameObject val159 = PrefabManager.RegisterPrefab("rd_armor", "sfx_draugr_idle_rd_armor_en"); GameObject val160 = PrefabManager.RegisterPrefab("rd_armor", "sfx_draugr_idle_rd_armor_ptbr"); GameObject val161 = PrefabManager.RegisterPrefab("rd_armor", "sfx_skeleton_ildir_idle_rd_armor"); GameObject val162 = PrefabManager.RegisterPrefab("rd_armor", "sfx_skeleton_ildir_idle_rd_armor_en"); GameObject val163 = PrefabManager.RegisterPrefab("rd_armor", "sfx_skeleton_ildir_idle_rd_armor_ptbr"); GameObject val164 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_archer_idle_rd_armor"); GameObject val165 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_archer_idle_rd_armor_female_en"); GameObject val166 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_archer_idle_rd_armor_female_ptbr"); GameObject val167 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_idle_rd_armor"); GameObject val168 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_idle_rd_armor_male_en"); GameObject val169 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_idle_rd_armor_male_ptbr"); GameObject val170 = PrefabManager.RegisterPrefab("rd_armor", "sfx_ghosts_idle_rd_armor"); GameObject val171 = PrefabManager.RegisterPrefab("rd_armor", "sfx_ghosts_idle_rd_armor_male_en"); GameObject val172 = PrefabManager.RegisterPrefab("rd_armor", "sfx_ghosts_idle_rd_armor_male_ptbr"); GameObject val173 = PrefabManager.RegisterPrefab("rd_armor", "sfx_fallenvalkyrie_idle_rd_armor"); GameObject val174 = PrefabManager.RegisterPrefab("rd_armor", "sfx_fallenvalkyrie_idle_rd_armor_en"); GameObject val175 = PrefabManager.RegisterPrefab("rd_armor", "sfx_fallenvalkyrie_idle_rd_armor_ptbr"); GameObject val176 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_mage_idle_rd_armor"); GameObject val177 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_mage_idle_rd_armor_en"); GameObject val178 = PrefabManager.RegisterPrefab("rd_armor", "sfx_charred_mage_idle_rd_armor_ptbr"); GameObject val179 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_projectile_meadows"); GameObject val180 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_projectile_bflorest"); GameObject val181 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_projectile_swamp"); GameObject val182 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_projectile_mountain"); GameObject val183 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_projectile_plains"); GameObject val184 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_projectile_mistlands"); GameObject val185 = PrefabManager.RegisterPrefab("rd_armor", "RD_inv_projectile_ashlands"); GameObject val186 = PrefabManager.RegisterPrefab("rd_armor", "ataque_totem_inv_meadows"); GameObject val187 = PrefabManager.RegisterPrefab("rd_armor", "ataque_totem_inv_bforest"); GameObject val188 = PrefabManager.RegisterPrefab("rd_armor", "ataque_totem_inv_bforest_ghost"); GameObject val189 = PrefabManager.RegisterPrefab("rd_armor", "ataque_totem_inv_swamp"); GameObject val190 = PrefabManager.RegisterPrefab("rd_armor", "ataque_totem_inv_mountain"); GameObject val191 = PrefabManager.RegisterPrefab("rd_armor", "ataque_totem_inv_mountain_valkyrie"); GameObject val192 = PrefabManager.RegisterPrefab("rd_armor", "ataque_totem_inv_plains"); GameObject val193 = PrefabManager.RegisterPrefab("rd_armor", "ataque_totem_inv_plains_unbjorn"); GameObject val194 = PrefabManager.RegisterPrefab("rd_armor", "ataque_totem_inv_mistlands"); GameObject val195 = PrefabManager.RegisterPrefab("rd_armor", "ataque_totem_inv_ashlands"); GameObject val196 = PrefabManager.RegisterPrefab("rd_armor", "ataque_totem_inv_ashlands_mage"); } } internal static class Registrations_Food { public static void RegisterFoods() { Item item = new Item("rd_armor", "RD_meat_patty"); item.Configurable = Configurability.Recipe | Configurability.Stats; item.Crafting.Add(ItemManager.CraftingTable.Inventory, 1); item.CraftAmount = 5; item.RequiredItems.Add("RawMeat", 2); item.RequiredItems.Add("Dandelion", 4); MaterialReplacer.RegisterGameObjectForShaderSwap(item.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item2 = new Item("rd_armor", "RD_fruit_mead"); item2.Configurable = Configurability.Recipe | Configurability.Stats; item2.Crafting.Add(ItemManager.CraftingTable.Inventory, 1); item2.CraftAmount = 5; item2.RequiredItems.Add("Blueberries", 4); item2.RequiredItems.Add("Raspberry", 4); item2.RequiredItems.Add("Mushroom", 4); MaterialReplacer.RegisterGameObjectForShaderSwap(item2.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item3 = new Item("rd_armor", "RD_roast_meat"); item3.Configurable = Configurability.Recipe | Configurability.Stats; item3.Crafting.Add(ItemManager.CraftingTable.Cauldron, 1); item3.CraftAmount = 5; item3.RequiredItems.Add("DeerMeat", 2); item3.RequiredItems.Add("Dandelion", 4); item3.RequiredItems.Add("Thistle", 4); MaterialReplacer.RegisterGameObjectForShaderSwap(item3.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item4 = new Item("rd_armor", "RD_blood_sausage"); item4.Configurable = Configurability.Recipe | Configurability.Stats; item4.Crafting.Add(ItemManager.CraftingTable.Cauldron, 1); item4.CraftAmount = 5; item4.RequiredItems.Add("Entrails", 4); item4.RequiredItems.Add("RawMeat", 1); item4.RequiredItems.Add("Bloodbag", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item4.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item5 = new Item("rd_armor", "RD_meat_stew"); item5.Configurable = Configurability.Recipe | Configurability.Stats; item5.Crafting.Add(ItemManager.CraftingTable.Cauldron, 1); item5.CraftAmount = 5; item5.RequiredItems.Add("WolfMeat", 6); item5.RequiredItems.Add("Onion", 4); item5.RequiredItems.Add("Carrot", 4); item5.RequiredItems.Add("MushroomYellow", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item5.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item6 = new Item("rd_armor", "RD_meatball"); item6.Configurable = Configurability.Recipe | Configurability.Stats; item6.Crafting.Add(ItemManager.CraftingTable.Cauldron, 1); item6.CraftAmount = 5; item6.RequiredItems.Add("LoxMeat", 2); item6.RequiredItems.Add("BarleyFlour", 4); item6.RequiredItems.Add("Cloudberry", 2); item6.RequiredItems.Add("Raspberry", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item6.Prefab, MaterialReplacer.ShaderType.UseUnityShader); } } internal static class Registrations_MobsPrefab { public static void RegisterMobsPrefab() { Mob_Registry.Init(); foreach (Mob_Registry.SummonDef value in Mob_Registry.All.Values) { RegisterSummon(value); } } private static void RegisterSummon(Mob_Registry.SummonDef def) { GameObject val = PrefabManager.RegisterPrefab("rd_armor", def.Prefab); if (!((Object)(object)val == (Object)null)) { } } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] internal static class Mob_Registry { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal sealed class SummonDef { public string Prefab = null; public string TotemPrefab = null; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] public string UnspawnVfxPrefab; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] public string UnspawnSfxPrefab; public ConfigEntry LifetimeCE = null; public ConfigEntry LifetimeUpgradeTotemCE = null; public ConfigEntry BaseHpCE = null; public ConfigEntry HpPercentPerStarCE = null; public ConfigEntry ProgressionCE = null; public ConfigEntry SpawnHealthPercentCE = null; public ConfigEntry SpawnEitrCE = null; public ConfigEntry Lifetime => LifetimeCE; public int BloodMagicGate { get { if (!VS_SummonProgression.TryGetGateFromConfig(Prefab, out var minGate)) { throw new InvalidOperationException("Invalid summon progression config for prefab '" + Prefab + "'."); } return minGate; } } } internal static readonly Dictionary All = new Dictionary(StringComparer.Ordinal); internal static readonly Dictionary ByTotemPrefab = new Dictionary(StringComparer.Ordinal); internal static void Init(Vikings_SummonerPlugin plugin) { Init(); } internal static void Init() { if (All.Count <= 0) { Add("RD_inv_skeleton_meadows", "RD_totem_inv_meadows", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_skeleton_meadows, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_meadows, Vikings_SummonerPlugin.CE_BaseHp_RD_inv_skeleton_meadows, Vikings_SummonerPlugin.CE_HpPercentPerStar_RD_inv_skeleton_meadows, Vikings_SummonerPlugin.CE_Progression_RD_inv_skeleton_meadows, Vikings_SummonerPlugin.CE_SpawnHealthPercent_RD_inv_skeleton_meadows, Vikings_SummonerPlugin.CE_SpawnEitr_RD_inv_skeleton_meadows, "vfx_unspawn_rd_armor", "sfx_unspawn_rd_armor"); Add("RD_inv_skeleton_bforest", "RD_totem_inv_bforest", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_skeleton_bforest, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_bforest, Vikings_SummonerPlugin.CE_BaseHp_RD_inv_skeleton_bforest, Vikings_SummonerPlugin.CE_HpPercentPerStar_RD_inv_skeleton_bforest, Vikings_SummonerPlugin.CE_Progression_RD_inv_skeleton_bforest, Vikings_SummonerPlugin.CE_SpawnHealthPercent_RD_inv_skeleton_bforest, Vikings_SummonerPlugin.CE_SpawnEitr_RD_inv_skeleton_bforest, "vfx_unspawn_rd_armor", "sfx_unspawn_rd_armor"); Add("RD_inv_ghost_bforest", "RD_totem_inv_bforest_ghost", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_ghost_bforest, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_bforest_ghost, Vikings_SummonerPlugin.CE_BaseHp_RD_inv_ghost_bforest, Vikings_SummonerPlugin.CE_HpPercentPerStar_RD_inv_ghost_bforest, Vikings_SummonerPlugin.CE_Progression_RD_inv_ghost_bforest, Vikings_SummonerPlugin.CE_SpawnHealthPercent_RD_inv_ghost_bforest, Vikings_SummonerPlugin.CE_SpawnEitr_RD_inv_ghost_bforest, "vfx_unspawn_rd_armor", "sfx_unspawn_rd_armor"); Add("RD_inv_draugr_swamp", "RD_totem_inv_swamp", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_draugr_swamp, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_swamp, Vikings_SummonerPlugin.CE_BaseHp_RD_inv_draugr_swamp, Vikings_SummonerPlugin.CE_HpPercentPerStar_RD_inv_draugr_swamp, Vikings_SummonerPlugin.CE_Progression_RD_inv_draugr_swamp, Vikings_SummonerPlugin.CE_SpawnHealthPercent_RD_inv_draugr_swamp, Vikings_SummonerPlugin.CE_SpawnEitr_RD_inv_draugr_swamp, "vfx_unspawn_rd_armor", "sfx_unspawn_rd_armor"); Add("RD_inv_draugr_mountain", "RD_totem_inv_mountain", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_draugr_mountain, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_mountain, Vikings_SummonerPlugin.CE_BaseHp_RD_inv_draugr_mountain, Vikings_SummonerPlugin.CE_HpPercentPerStar_RD_inv_draugr_mountain, Vikings_SummonerPlugin.CE_Progression_RD_inv_draugr_mountain, Vikings_SummonerPlugin.CE_SpawnHealthPercent_RD_inv_draugr_mountain, Vikings_SummonerPlugin.CE_SpawnEitr_RD_inv_draugr_mountain, "vfx_unspawn_rd_armor", "sfx_unspawn_rd_armor"); Add("RD_inv_valkyrie_mountain", "RD_totem_inv_mountain_valkyrie", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_valkyrie_mountain, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_mountain_valkyrie, Vikings_SummonerPlugin.CE_BaseHp_RD_inv_valkyrie_mountain, Vikings_SummonerPlugin.CE_HpPercentPerStar_RD_inv_valkyrie_mountain, Vikings_SummonerPlugin.CE_Progression_RD_inv_valkyrie_mountain, Vikings_SummonerPlugin.CE_SpawnHealthPercent_RD_inv_valkyrie_mountain, Vikings_SummonerPlugin.CE_SpawnEitr_RD_inv_valkyrie_mountain, "vfx_unspawn_big_rd_armor", "sfx_unspawn_rd_armor"); Add("RD_inv_skeleton_plains", "RD_totem_inv_plains", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_skeleton_plains, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_plains, Vikings_SummonerPlugin.CE_BaseHp_RD_inv_skeleton_plains, Vikings_SummonerPlugin.CE_HpPercentPerStar_RD_inv_skeleton_plains, Vikings_SummonerPlugin.CE_Progression_RD_inv_skeleton_plains, Vikings_SummonerPlugin.CE_SpawnHealthPercent_RD_inv_skeleton_plains, Vikings_SummonerPlugin.CE_SpawnEitr_RD_inv_skeleton_plains, "vfx_unspawn_rd_armor", "sfx_unspawn_rd_armor"); Add("RD_inv_unbjorn_plains", "RD_totem_inv_plains_bear", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_unbjorn_plains, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_plains_bear, Vikings_SummonerPlugin.CE_BaseHp_RD_inv_unbjorn_plains, Vikings_SummonerPlugin.CE_HpPercentPerStar_RD_inv_unbjorn_plains, Vikings_SummonerPlugin.CE_Progression_RD_inv_unbjorn_plains, Vikings_SummonerPlugin.CE_SpawnHealthPercent_RD_inv_unbjorn_plains, Vikings_SummonerPlugin.CE_SpawnEitr_RD_inv_unbjorn_plains, "vfx_unspawn_big_rd_armor", "sfx_unspawn_rd_armor"); Add("RD_inv_skeleton_mistlands", "RD_totem_inv_mistlands", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_skeleton_mistlands, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_mistlands, Vikings_SummonerPlugin.CE_BaseHp_RD_inv_skeleton_mistlands, Vikings_SummonerPlugin.CE_HpPercentPerStar_RD_inv_skeleton_mistlands, Vikings_SummonerPlugin.CE_Progression_RD_inv_skeleton_mistlands, Vikings_SummonerPlugin.CE_SpawnHealthPercent_RD_inv_skeleton_mistlands, Vikings_SummonerPlugin.CE_SpawnEitr_RD_inv_skeleton_mistlands, "vfx_unspawn_rd_armor", "sfx_unspawn_rd_armor"); Add("RD_inv_skeleton_ashlands", "RD_totem_inv_ashlands", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_skeleton_ashlands, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_ashlands, Vikings_SummonerPlugin.CE_BaseHp_RD_inv_skeleton_ashlands, Vikings_SummonerPlugin.CE_HpPercentPerStar_RD_inv_skeleton_ashlands, Vikings_SummonerPlugin.CE_Progression_RD_inv_skeleton_ashlands, Vikings_SummonerPlugin.CE_SpawnHealthPercent_RD_inv_skeleton_ashlands, Vikings_SummonerPlugin.CE_SpawnEitr_RD_inv_skeleton_ashlands, "vfx_unspawn_rd_armor", "sfx_unspawn_rd_armor"); Add("RD_inv_skeleton_mage_ashlands", "RD_totem_inv_ashlands_mage", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_skeleton_mage_ashlands, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_ashlands_mage, Vikings_SummonerPlugin.CE_BaseHp_RD_inv_skeleton_mage_ashlands, Vikings_SummonerPlugin.CE_HpPercentPerStar_RD_inv_skeleton_mage_ashlands, Vikings_SummonerPlugin.CE_Progression_RD_inv_skeleton_mage_ashlands, Vikings_SummonerPlugin.CE_SpawnHealthPercent_RD_inv_skeleton_mage_ashlands, Vikings_SummonerPlugin.CE_SpawnEitr_RD_inv_skeleton_mage_ashlands, "vfx_unspawn_rd_armor", "sfx_unspawn_rd_armor"); } } private static void Add(string prefab, string totemPrefab, ConfigEntry lifetimeCE, ConfigEntry lifetimeUpgradeTotemCE, ConfigEntry baseHpCE, ConfigEntry hpPercentPerStarCE, ConfigEntry progressionCE, ConfigEntry spawnHealthPercentCE, ConfigEntry spawnEitrCE, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] string unspawnVfxPrefab = null, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] string unspawnSfxPrefab = null) { if (string.IsNullOrWhiteSpace(prefab)) { throw new ArgumentException("Invalid summon prefab.", "prefab"); } if (string.IsNullOrWhiteSpace(totemPrefab)) { throw new ArgumentException("Invalid summon totem prefab.", "totemPrefab"); } if (All.ContainsKey(prefab)) { throw new InvalidOperationException("Duplicate summon prefab '" + prefab + "'."); } if (ByTotemPrefab.ContainsKey(totemPrefab)) { throw new InvalidOperationException("Duplicate summon totem prefab '" + totemPrefab + "'."); } if (lifetimeCE == null) { throw new InvalidOperationException("LifetimeCE is null for '" + prefab + "'."); } if (lifetimeUpgradeTotemCE == null) { throw new InvalidOperationException("LifetimeUpgradeTotemCE is null for '" + totemPrefab + "'."); } if (baseHpCE == null) { throw new InvalidOperationException("BaseHpCE is null for '" + prefab + "'."); } if (hpPercentPerStarCE == null) { throw new InvalidOperationException("HpPercentPerStarCE is null for '" + prefab + "'."); } if (progressionCE == null) { throw new InvalidOperationException("ProgressionCE is null for '" + prefab + "'."); } if (spawnHealthPercentCE == null) { throw new InvalidOperationException("SpawnHealthPercentCE is null for '" + prefab + "'."); } if (spawnEitrCE == null) { throw new InvalidOperationException("SpawnEitrCE is null for '" + prefab + "'."); } SummonDef value = new SummonDef { Prefab = prefab, TotemPrefab = totemPrefab, UnspawnVfxPrefab = unspawnVfxPrefab, UnspawnSfxPrefab = unspawnSfxPrefab, LifetimeCE = lifetimeCE, LifetimeUpgradeTotemCE = lifetimeUpgradeTotemCE, BaseHpCE = baseHpCE, HpPercentPerStarCE = hpPercentPerStarCE, ProgressionCE = progressionCE, SpawnHealthPercentCE = spawnHealthPercentCE, SpawnEitrCE = spawnEitrCE }; All.Add(prefab, value); ByTotemPrefab.Add(totemPrefab, value); } internal static SummonDef Get(string prefab) { Init(); if (All.TryGetValue(prefab, out var value)) { return value; } throw new ArgumentOutOfRangeException("prefab", prefab, "Unknown summon prefab."); } internal static bool TryGet(string prefab, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] out SummonDef def) { Init(); return All.TryGetValue(prefab, out def); } internal static SummonDef GetByTotemPrefab(string totemPrefab) { Init(); if (ByTotemPrefab.TryGetValue(totemPrefab, out var value)) { return value; } throw new ArgumentOutOfRangeException("totemPrefab", totemPrefab, "Unknown summon totem prefab."); } internal static bool TryGetByTotemPrefab(string totemPrefab, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] out SummonDef def) { Init(); return ByTotemPrefab.TryGetValue(totemPrefab, out def); } } public sealed class VS_SummonMarker : MonoBehaviour { } public sealed class VS_SummonVfxProfile : MonoBehaviour { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] public EffectList UnSummonEffect = new EffectList(); } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class Registrations_Mob_Summon { private static void Postfix(ZNetScene __instance) { Mob_Registry.Init(Vikings_SummonerPlugin.Instance); foreach (Mob_Registry.SummonDef value in Mob_Registry.All.Values) { GameObject prefab = __instance.GetPrefab(value.Prefab); if (Object.op_Implicit((Object)(object)prefab) && Object.op_Implicit((Object)(object)prefab.GetComponent()) && Object.op_Implicit((Object)(object)prefab.GetComponent()) && Object.op_Implicit((Object)(object)prefab.GetComponent())) { if (!Object.op_Implicit((Object)(object)prefab.GetComponent())) { prefab.AddComponent(); } if (!Object.op_Implicit((Object)(object)prefab.GetComponent())) { prefab.AddComponent(); } if (!Object.op_Implicit((Object)(object)prefab.GetComponent())) { prefab.AddComponent(); } if (!Object.op_Implicit((Object)(object)prefab.GetComponent())) { prefab.AddComponent(); } VS_SummonVfxProfile vS_SummonVfxProfile = prefab.GetComponent(); if (!Object.op_Implicit((Object)(object)vS_SummonVfxProfile)) { vS_SummonVfxProfile = prefab.AddComponent(); } vS_SummonVfxProfile.UnSummonEffect = BuildUnSummonEffect(__instance, value); } } } private static EffectList BuildUnSummonEffect(ZNetScene scene, Mob_Registry.SummonDef def) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown EffectList val = new EffectList(); List list = new List(); TryAddEffect(scene, list, def.UnspawnVfxPrefab); TryAddEffect(scene, list, def.UnspawnSfxPrefab); val.m_effectPrefabs = list.ToArray(); return val; } private static void TryAddEffect(ZNetScene scene, List data, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] string prefabName) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown if (!string.IsNullOrWhiteSpace(prefabName)) { GameObject prefab = scene.GetPrefab(prefabName); if (Object.op_Implicit((Object)(object)prefab)) { data.Add(new EffectData { m_prefab = prefab, m_enabled = true }); } } } } [HarmonyPatch(typeof(Tameable), "UpdateSummon")] internal static class Patch_Tameable_UpdateSummon_BlockVanillaUnsummon_ForVsSummons { [NullableContext(1)] private static bool Prefix(Tameable __instance) { if ((Object)(object)__instance == (Object)null) { return true; } VS_SummonMarker vS_SummonMarker = default(VS_SummonMarker); if (!((Component)__instance).TryGetComponent(ref vS_SummonMarker)) { return true; } return false; } } [HarmonyPatch(typeof(Character), "GetHoverName")] internal static class Patch_Character_GetHoverName_Summon { [NullableContext(1)] private static bool Prefix(Character __instance, ref string __result) { if (!Object.op_Implicit((Object)(object)__instance)) { return true; } if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent())) { return true; } string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject); if (!string.IsNullOrEmpty(prefabName)) { __result = Localization.instance.Localize("$enemy_" + prefabName); return false; } if (!string.IsNullOrEmpty(__instance.m_name)) { __result = Localization.instance.Localize(__instance.m_name); return false; } __result = Localization.instance.Localize(((Object)((Component)__instance).gameObject).name); return false; } } [HarmonyPatch(typeof(Character), "GetHoverText")] internal static class Patch_Character_GetHoverText_Summon { [NullableContext(1)] private static bool Prefix(Character __instance, ref string __result) { if (!Object.op_Implicit((Object)(object)__instance)) { return true; } VS_SummonMarker vS_SummonMarker = default(VS_SummonMarker); if (!((Component)__instance).TryGetComponent(ref vS_SummonMarker)) { return true; } VS_SummonInteract component = ((Component)__instance).GetComponent(); __result = (Object.op_Implicit((Object)(object)component) ? component.GetHoverText() : string.Empty); return false; } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public sealed class VS_SummonInteract : MonoBehaviour, Interactable { private const string RpcUnsummon = "VS_RPC_Unsummon"; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private ZNetView _nview; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private Character _character; private float _unsummonCd; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private string _lastHover; private float _hoverTTL; private void Awake() { _nview = ((Component)this).GetComponent(); _character = ((Component)this).GetComponent(); if ((Object)(object)_nview != (Object)null) { _nview.Register("VS_RPC_Unsummon", (Action)RPC_Unsummon); } } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold) { return false; } if (Time.time < _unsummonCd) { return false; } Player val = (Player)(object)((user is Player) ? user : null); if (val == null) { return false; } if (!CanUnsummon(val) && !((Character)val).IsDebugFlying()) { return false; } if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return false; } _unsummonCd = Time.time + 0.5f; if (_nview.IsOwner()) { RPC_Unsummon(0L); } else { _nview.InvokeRPC("VS_RPC_Unsummon", Array.Empty()); } return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverText() { _hoverTTL -= Time.deltaTime; if (_hoverTTL > 0f && !string.IsNullOrEmpty(_lastHover)) { return _lastHover; } string hoverName = GetHoverName(); Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return hoverName; } if (!CanUnsummon(localPlayer) && !((Character)localPlayer).IsDebugFlying()) { _lastHover = hoverName; _hoverTTL = 0.2f; return hoverName; } string text = Localization.instance.Localize("$KEY_Use"); string text2 = Localization.instance.Localize("$vs_summon_unsummon"); string result = (_lastHover = hoverName + "\n[" + text + "] " + text2); _hoverTTL = 0.35f; return result; } public string GetHoverName() { string prefabName = Utils.GetPrefabName(((Component)this).gameObject); if (!string.IsNullOrEmpty(prefabName)) { return Localization.instance.Localize("$enemy_" + prefabName); } if ((Object)(object)_character != (Object)null && !string.IsNullOrEmpty(_character.m_name)) { return Localization.instance.Localize(_character.m_name); } return Localization.instance.Localize(((Object)((Component)this).gameObject).name); } private void RPC_Unsummon(long sender) { VS_SummonRemoval.TryRemove(((Component)this).gameObject, VS_SummonRemovalReason.Manual); } private bool CanUnsummon(Player p) { if ((Object)(object)p == (Object)null) { return false; } if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return false; } ZDO zDO = _nview.GetZDO(); if (zDO == null) { return false; } if (!VS_SteamOwnerIdentity.TryGetSteamIdentity(p, out var steamId, out var _)) { return false; } return VS_SteamOwnerIdentity.IsSameOwner(zDO, steamId); } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(2)] public sealed class VS_SummonDeathCleanup : MonoBehaviour { private ZNetView _nview; private Character _character; private float _deadDelay = 0.2f; private bool _destroyQueued; private void Awake() { _nview = ((Component)this).GetComponent(); _character = ((Component)this).GetComponent(); } private void Update() { if (_destroyQueued || (Object)(object)_character == (Object)null || !_character.IsDead() || (Object)(object)_nview == (Object)null || !_nview.IsValid() || !_nview.IsOwner()) { return; } _deadDelay -= Time.deltaTime; if (!(_deadDelay > 0f) && _character.IsDead()) { _destroyQueued = true; if ((Object)(object)ZNetScene.instance != (Object)null) { ZNetScene.instance.Destroy(((Component)this).gameObject); } else { _nview.Destroy(); } ((Behaviour)this).enabled = false; } } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal static class VS_SummonHoverFilter { internal static string FilterHoverLines_NoSplit(string text) { if (string.IsNullOrEmpty(text)) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(text.Length); bool flag = true; int num = 0; int length = text.Length; while (num < length) { int num2 = num; int i; for (i = num; i < length && text[i] != '\n' && text[i] != '\r'; i++) { } int j; for (j = num2; j < i; j++) { char c = text[j]; if (c != ' ' && c != '\t') { break; } } if (!StartsWithIgnoreCase(text, j, i - j, "Follows") && !StartsWithIgnoreCase(text, j, i - j, "$hud_tame_followers")) { if (!flag) { stringBuilder.Append('\n'); } stringBuilder.Append(text, num2, i - num2); flag = false; } if (i < length && text[i] == '\r') { i++; } if (i < length && text[i] == '\n') { i++; } num = i; } return stringBuilder.ToString(); } private static bool StartsWithIgnoreCase(string s, int start, int availableLen, string prefix) { if (availableLen < prefix.Length) { return false; } for (int i = 0; i < prefix.Length; i++) { char c = s[start + i]; char c2 = prefix[i]; if (c != c2) { if (c >= 'A' && c <= 'Z') { c = (char)(c + 32); } if (c2 >= 'A' && c2 <= 'Z') { c2 = (char)(c2 + 32); } if (c != c2) { return false; } } } return true; } } [HarmonyPatch(typeof(Tameable), "Interact")] internal static class Patch_Tameable_Interact_Summon { [NullableContext(1)] private static bool Prefix(Tameable __instance, Humanoid user, bool hold, bool alt, ref bool __result) { if (!Object.op_Implicit((Object)(object)__instance)) { return true; } VS_SummonMarker vS_SummonMarker = default(VS_SummonMarker); if (!((Component)__instance).TryGetComponent(ref vS_SummonMarker)) { return true; } VS_SummonInteract component = ((Component)__instance).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { __result = false; return false; } __result = component.Interact(user, hold, alt); return false; } } [HarmonyPatch(typeof(Tameable), "UseItem")] internal static class Patch_Tameable_UseItem_Summon { [NullableContext(1)] private static bool Prefix(Tameable __instance, Humanoid user, ItemData item, ref bool __result) { if (!Object.op_Implicit((Object)(object)__instance)) { return true; } VS_SummonMarker vS_SummonMarker = default(VS_SummonMarker); if (!((Component)__instance).TryGetComponent(ref vS_SummonMarker)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Tameable), "GetHoverText")] internal static class Patch_Tameable_GetHoverText_Summon { [NullableContext(1)] private static bool Prefix(Tameable __instance, ref string __result) { if (!Object.op_Implicit((Object)(object)__instance)) { return true; } VS_SummonMarker vS_SummonMarker = default(VS_SummonMarker); if (!((Component)__instance).TryGetComponent(ref vS_SummonMarker)) { return true; } VS_SummonInteract component = ((Component)__instance).GetComponent(); __result = (Object.op_Implicit((Object)(object)component) ? component.GetHoverText() : string.Empty); return false; } } internal static class Registrations_Staffs { public static void RegisterStaffs() { Item item = new Item("rd_armor", "RD_inv_staff_meadows"); item.Configurable = Configurability.Recipe | Configurability.Stats; item.Crafting.Add("RD_necromancer_table", 1); item.RequiredItems.Add("TrophyBoar", 1); item.RequiredItems.Add("Wood", 16); item.RequiredItems.Add("GreydwarfEye", 10); item.RequiredItems.Add("Flint", 10); item.RequiredUpgradeItems.Add("Wood", 8); item.RequiredUpgradeItems.Add("GreydwarfEye", 4); item.RequiredUpgradeItems.Add("Flint", 4); MaterialReplacer.RegisterGameObjectForShaderSwap(item.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item2 = new Item("rd_armor", "RD_inv_staff_bforest"); item2.Configurable = Configurability.Recipe | Configurability.Stats; item2.Crafting.Add("RD_necromancer_table", 2); item2.RequiredItems.Add("TrophySkeleton", 1); item2.RequiredItems.Add("RoundLog", 12); item2.RequiredItems.Add("SurtlingCore", 5); item2.RequiredItems.Add("Bronze", 6); item2.RequiredUpgradeItems.Add("RoundLog", 8); item2.RequiredUpgradeItems.Add("SurtlingCore", 5); item2.RequiredUpgradeItems.Add("Bronze", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item2.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item3 = new Item("rd_armor", "RD_inv_staff_swamp"); item3.Configurable = Configurability.Recipe | Configurability.Stats; item3.Crafting.Add("RD_necromancer_table", 2); item3.RequiredItems.Add("YmirRemains", 5); item3.RequiredItems.Add("Guck", 16); item3.RequiredItems.Add("Iron", 20); item3.RequiredItems.Add("ElderBark", 14); item3.RequiredUpgradeItems.Add("Guck", 8); item3.RequiredUpgradeItems.Add("Iron", 10); item3.RequiredUpgradeItems.Add("TrophySkeleton", 6); MaterialReplacer.RegisterGameObjectForShaderSwap(item3.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item4 = new Item("rd_armor", "RD_inv_staff_mountain"); item4.Configurable = Configurability.Recipe | Configurability.Stats; item4.Crafting.Add("RD_necromancer_table", 2); item4.RequiredItems.Add("DragonEgg", 1); item4.RequiredItems.Add("ElderBark", 22); item4.RequiredItems.Add("FreezeGland", 16); item4.RequiredItems.Add("Silver", 14); item4.RequiredUpgradeItems.Add("ElderBark", 11); item4.RequiredUpgradeItems.Add("FreezeGland", 8); item4.RequiredUpgradeItems.Add("Silver", 8); MaterialReplacer.RegisterGameObjectForShaderSwap(item4.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item5 = new Item("rd_armor", "RD_inv_staff_plains"); item5.Configurable = Configurability.Recipe | Configurability.Stats; item5.Crafting.Add("RD_necromancer_table_02", 1); item5.RequiredItems.Add("GoblinTotem", 2); item5.RequiredItems.Add("LoxPelt", 22); item5.RequiredItems.Add("RoundLog", 16); item5.RequiredItems.Add("BlackMetal", 20); item5.RequiredUpgradeItems.Add("LoxPelt", 11); item5.RequiredUpgradeItems.Add("RoundLog", 8); item5.RequiredUpgradeItems.Add("BlackMetal", 8); MaterialReplacer.RegisterGameObjectForShaderSwap(item5.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item6 = new Item("rd_armor", "RD_inv_staff_mistlands"); item6.Configurable = Configurability.Recipe | Configurability.Stats; item6.Crafting.Add("RD_necromancer_table_02", 1); item6.RequiredItems.Add("BlackCore", 2); item6.RequiredItems.Add("YggdrasilWood", 22); item6.RequiredItems.Add("Eitr", 14); item6.RequiredItems.Add("GiantBloodSack", 4); item6.RequiredUpgradeItems.Add("YggdrasilWood", 11); item6.RequiredUpgradeItems.Add("Eitr", 6); item6.RequiredUpgradeItems.Add("GiantBloodSack", 1); MaterialReplacer.RegisterGameObjectForShaderSwap(item6.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item7 = new Item("rd_armor", "RD_inv_staff_ashlands"); item7.Configurable = Configurability.Recipe | Configurability.Stats; item7.Crafting.Add("RD_necromancer_table_02", 1); item7.RequiredItems.Add("ShieldCore", 2); item7.RequiredItems.Add("YggdrasilWood", 24); item7.RequiredItems.Add("FlametalNew", 12); item7.RequiredItems.Add("CharredBone", 12); item7.RequiredUpgradeItems.Add("YggdrasilWood", 11); item7.RequiredUpgradeItems.Add("FlametalNew", 6); item7.RequiredUpgradeItems.Add("CharredBone", 6); MaterialReplacer.RegisterGameObjectForShaderSwap(item7.Prefab, MaterialReplacer.ShaderType.UseUnityShader); } } internal static class Registrations_SummonWeapons { public static void RegisterSummonWeapons() { Item item = new Item("rd_armor", "RD_skeleton_bronze_mace_inv"); item.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item2 = new Item("rd_armor", "RD_skeleton_bronze_sword_inv"); item2.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item2.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item3 = new Item("rd_armor", "RD_skeleton_wood_shield_inv"); item3.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item3.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item4 = new Item("rd_armor", "RD_skeleton_iron_mace_inv"); item4.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item4.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item5 = new Item("rd_armor", "RD_skeleton_iron_sword_inv"); item5.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item5.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item6 = new Item("rd_armor", "Ghost_attack_bforest"); item6.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item6.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item7 = new Item("rd_armor", "RD_draugr_bow_inv"); item7.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item7.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item8 = new Item("rd_armor", "RD_draugrelite_sword_inv"); item8.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item8.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item9 = new Item("rd_armor", "RD_draugrelite_mace_inv"); item9.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item9.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item10 = new Item("rd_armor", "valkyrie_claws"); item10.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item10.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item11 = new Item("rd_armor", "valkyrie_spin"); item11.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item11.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item12 = new Item("rd_armor", "valkyrie_spit"); item12.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item12.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item13 = new Item("rd_armor", "RD_skeleton_hildir_firenova_rd_armor"); item13.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item13.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item14 = new Item("rd_armor", "RD_skeleton_hildir_sword_rd_armor"); item14.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item14.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item15 = new Item("rd_armor", "unbjorn_bite_plains"); item15.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item15.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item16 = new Item("rd_armor", "unbjorn_claws_plains"); item16.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item16.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item17 = new Item("rd_armor", "unbjorn_slam_plains"); item17.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item17.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item18 = new Item("rd_armor", "unbjorn_swipe_combo_plains"); item18.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item18.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item19 = new Item("rd_armor", "unbjorn_swipe_l_plains"); item19.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item19.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item20 = new Item("rd_armor", "unbjorn_swipe_r_plains"); item20.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item20.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item21 = new Item("rd_armor", "Charred_Breastplate_archer"); item21.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item21.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item22 = new Item("rd_armor", "Charred_Helmet_archer"); item22.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item22.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item23 = new Item("rd_armor", "Charred_HipCloth_archer"); item23.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item23.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item24 = new Item("rd_armor", "charred_bow_rd_armor"); item24.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item24.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item25 = new Item("rd_armor", "charred_bow_volley_rd_armor"); item25.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item25.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item26 = new Item("rd_armor", "Charred_Breastplate_melee"); item26.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item26.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item27 = new Item("rd_armor", "Charred_Helmet_melee"); item27.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item27.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item28 = new Item("rd_armor", "Charred_HipCloth_melee"); item28.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item28.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item29 = new Item("rd_armor", "charred_greatsword_feint_melee"); item29.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item29.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item30 = new Item("rd_armor", "charred_greatsword_swing_melee"); item30.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item30.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item31 = new Item("rd_armor", "charred_greatsword_thrust_melee"); item31.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item31.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item32 = new Item("rd_armor", "charred_greatsword_thrustfeint_melee"); item32.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item32.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item33 = new Item("rd_armor", "Charred_HipCloth_mage"); item33.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item33.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item34 = new Item("rd_armor", "Charred_MageCloths_mage"); item34.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item34.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item35 = new Item("rd_armor", "charred_magestaff_ashlands"); item35.Configurable = Configurability.Disabled; MaterialReplacer.RegisterGameObjectForShaderSwap(item35.Prefab, MaterialReplacer.ShaderType.UseUnityShader); } } internal static class Registrations_Totens { public static void RegisterTotens() { Item item = new Item("rd_armor", "RD_totem_inv_meadows"); item.Configurable = Configurability.Recipe; item.EnabledStatsConfigs.Add("Health Cost"); item.EnabledStatsConfigs.Add("Health Cost Percentage"); item.EnabledStatsConfigs.Add("Eitr Cost"); item.Crafting.Add("RD_necromancer_table", 1); item.RequiredItems.Add("TrophyDeer", 1); item.RequiredItems.Add("LeatherScraps", 20); item.RequiredItems.Add("BoneFragments", 20); item.RequiredUpgradeItems.Add("LeatherScraps", 5); item.RequiredUpgradeItems.Add("BoneFragments", 5); MaterialReplacer.RegisterGameObjectForShaderSwap(item.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item2 = new Item("rd_armor", "RD_totem_inv_bforest"); item2.Configurable = Configurability.Recipe; item2.EnabledStatsConfigs.Add("Health Cost"); item2.EnabledStatsConfigs.Add("Health Cost Percentage"); item2.EnabledStatsConfigs.Add("Eitr Cost"); item2.Crafting.Add("RD_necromancer_table", 2); item2.RequiredItems.Add("TrophySkeletonPoison", 1); item2.RequiredItems.Add("LeatherScraps", 25); item2.RequiredItems.Add("Bronze", 20); item2.RequiredItems.Add("BoneFragments", 20); item2.RequiredUpgradeItems.Add("LeatherScraps", 7); item2.RequiredUpgradeItems.Add("Bronze", 5); item2.RequiredUpgradeItems.Add("BoneFragments", 5); MaterialReplacer.RegisterGameObjectForShaderSwap(item2.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item3 = new Item("rd_armor", "RD_totem_inv_bforest_ghost"); item3.Configurable = Configurability.Recipe; item3.EnabledStatsConfigs.Add("Health Cost"); item3.EnabledStatsConfigs.Add("Health Cost Percentage"); item3.EnabledStatsConfigs.Add("Eitr Cost"); item3.Crafting.Add("RD_necromancer_table", 2); item3.RequiredItems.Add("TrophyGhost", 1); item3.RequiredItems.Add("DeerHide", 25); item3.RequiredItems.Add("Bronze", 20); item3.RequiredItems.Add("BoneFragments", 20); item3.RequiredUpgradeItems.Add("DeerHide", 7); item3.RequiredUpgradeItems.Add("Bronze", 5); item3.RequiredUpgradeItems.Add("BoneFragments", 5); MaterialReplacer.RegisterGameObjectForShaderSwap(item3.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item4 = new Item("rd_armor", "RD_totem_inv_swamp"); item4.Configurable = Configurability.Recipe; item4.EnabledStatsConfigs.Add("Health Cost"); item4.EnabledStatsConfigs.Add("Health Cost Percentage"); item4.EnabledStatsConfigs.Add("Eitr Cost"); item4.Crafting.Add("RD_necromancer_table", 2); item4.RequiredItems.Add("TrophyDraugr", 1); item4.RequiredItems.Add("Root", 6); item4.RequiredItems.Add("Iron", 20); item4.RequiredItems.Add("BoneFragments", 20); item4.RequiredUpgradeItems.Add("Root", 2); item4.RequiredUpgradeItems.Add("Iron", 5); item4.RequiredUpgradeItems.Add("BoneFragments", 5); MaterialReplacer.RegisterGameObjectForShaderSwap(item4.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item5 = new Item("rd_armor", "RD_totem_inv_mountain"); item5.Configurable = Configurability.Recipe; item5.EnabledStatsConfigs.Add("Health Cost"); item5.EnabledStatsConfigs.Add("Health Cost Percentage"); item5.EnabledStatsConfigs.Add("Eitr Cost"); item5.Crafting.Add("RD_necromancer_table", 2); item5.RequiredItems.Add("TrophyDraugrElite", 1); item5.RequiredItems.Add("FreezeGland", 8); item5.RequiredItems.Add("Silver", 20); item5.RequiredItems.Add("WolfFang", 10); item5.RequiredUpgradeItems.Add("FreezeGland", 2); item5.RequiredUpgradeItems.Add("Silver", 5); item5.RequiredUpgradeItems.Add("WolfFang", 4); MaterialReplacer.RegisterGameObjectForShaderSwap(item5.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item6 = new Item("rd_armor", "RD_totem_inv_mountain_valkyrie"); item6.Configurable = Configurability.Recipe; item6.EnabledStatsConfigs.Add("Health Cost"); item6.EnabledStatsConfigs.Add("Health Cost Percentage"); item6.EnabledStatsConfigs.Add("Eitr Cost"); item6.Crafting.Add("RD_necromancer_table", 2); item6.RequiredItems.Add("TrophySGolem", 1); item6.RequiredItems.Add("FreezeGland", 10); item6.RequiredItems.Add("Silver", 20); item6.RequiredItems.Add("Feathers", 50); item6.RequiredUpgradeItems.Add("FreezeGland", 2); item6.RequiredUpgradeItems.Add("Silver", 5); item6.RequiredUpgradeItems.Add("Feathers", 10); MaterialReplacer.RegisterGameObjectForShaderSwap(item6.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item7 = new Item("rd_armor", "RD_totem_inv_plains"); item7.Configurable = Configurability.Recipe; item7.EnabledStatsConfigs.Add("Health Cost"); item7.EnabledStatsConfigs.Add("Health Cost Percentage"); item7.EnabledStatsConfigs.Add("Eitr Cost"); item7.Crafting.Add("RD_necromancer_table_02", 1); item7.RequiredItems.Add("TrophySkeletonHildir", 1); item7.RequiredItems.Add("GoblinTotem", 4); item7.RequiredItems.Add("BlackMetal", 20); item7.RequiredItems.Add("BoneFragments", 20); item7.RequiredUpgradeItems.Add("GoblinTotem", 1); item7.RequiredUpgradeItems.Add("BlackMetal", 5); item7.RequiredUpgradeItems.Add("BoneFragments", 5); MaterialReplacer.RegisterGameObjectForShaderSwap(item7.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item8 = new Item("rd_armor", "RD_totem_inv_plains_bear"); item8.Configurable = Configurability.Recipe; item8.EnabledStatsConfigs.Add("Health Cost"); item8.EnabledStatsConfigs.Add("Health Cost Percentage"); item8.EnabledStatsConfigs.Add("Eitr Cost"); item8.Crafting.Add("RD_necromancer_table_02", 1); item8.RequiredItems.Add("TrophyBjornUndead", 1); item8.RequiredItems.Add("RottenMeat", 8); item8.RequiredItems.Add("BlackMetal", 20); item8.RequiredItems.Add("UndeadBjornRibcage", 6); item8.RequiredUpgradeItems.Add("RottenMeat", 2); item8.RequiredUpgradeItems.Add("BlackMetal", 5); item8.RequiredUpgradeItems.Add("UndeadBjornRibcage", 2); MaterialReplacer.RegisterGameObjectForShaderSwap(item8.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item9 = new Item("rd_armor", "RD_totem_inv_mistlands"); item9.Configurable = Configurability.Recipe; item9.EnabledStatsConfigs.Add("Health Cost"); item9.EnabledStatsConfigs.Add("Health Cost Percentage"); item9.EnabledStatsConfigs.Add("Eitr Cost"); item9.Crafting.Add("RD_necromancer_table_02", 1); item9.RequiredItems.Add("BlackCore", 2); item9.RequiredItems.Add("YggdrasilWood", 22); item9.RequiredItems.Add("Eitr", 14); item9.RequiredItems.Add("GiantBloodSack", 4); item9.RequiredUpgradeItems.Add("YggdrasilWood", 11); item9.RequiredUpgradeItems.Add("Eitr", 6); item9.RequiredUpgradeItems.Add("GiantBloodSack", 1); MaterialReplacer.RegisterGameObjectForShaderSwap(item9.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item10 = new Item("rd_armor", "RD_totem_inv_ashlands"); item10.Configurable = Configurability.Recipe; item10.EnabledStatsConfigs.Add("Health Cost"); item10.EnabledStatsConfigs.Add("Health Cost Percentage"); item10.EnabledStatsConfigs.Add("Eitr Cost"); item10.Crafting.Add("RD_necromancer_table_02", 1); item10.RequiredItems.Add("ShieldCore", 2); item10.RequiredItems.Add("YggdrasilWood", 24); item10.RequiredItems.Add("FlametalNew", 12); item10.RequiredItems.Add("CharredBone", 12); item10.RequiredUpgradeItems.Add("YggdrasilWood", 11); item10.RequiredUpgradeItems.Add("FlametalNew", 6); item10.RequiredUpgradeItems.Add("CharredBone", 6); MaterialReplacer.RegisterGameObjectForShaderSwap(item10.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Item item11 = new Item("rd_armor", "RD_totem_inv_ashlands_mage"); item11.Configurable = Configurability.Recipe; item11.EnabledStatsConfigs.Add("Health Cost"); item11.EnabledStatsConfigs.Add("Health Cost Percentage"); item11.EnabledStatsConfigs.Add("Eitr Cost"); item11.Crafting.Add("RD_necromancer_table_02", 1); item11.RequiredItems.Add("ShieldCore", 2); item11.RequiredItems.Add("YggdrasilWood", 24); item11.RequiredItems.Add("FlametalNew", 12); item11.RequiredItems.Add("CharredBone", 12); item11.RequiredUpgradeItems.Add("YggdrasilWood", 11); item11.RequiredUpgradeItems.Add("FlametalNew", 6); item11.RequiredUpgradeItems.Add("CharredBone", 6); MaterialReplacer.RegisterGameObjectForShaderSwap(item11.Prefab, MaterialReplacer.ShaderType.UseUnityShader); } } internal static class Registrations_Mobs_Lifetime { internal static void Register() { Mob_Registry.Init(); } } internal static class VS_SummonTime { internal static DateTime Now() { return ((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetTime() : DateTime.UtcNow; } internal static long NowTicks() { return Now().Ticks; } } [HarmonyPatch(typeof(ZNet), "Awake")] internal static class Patch_ZNet_Awake_SummonLifetimeServerCleanup { [NullableContext(1)] private static void Postfix(ZNet __instance) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer() && !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent())) { ((Component)__instance).gameObject.AddComponent(); } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class Patch_ZNetScene_Awake_SummonLifetimePrefabSetup { [NullableContext(1)] private static void Postfix(ZNetScene __instance) { if ((Object)(object)__instance == (Object)null) { return; } Mob_Registry.Init(); foreach (Mob_Registry.SummonDef value in Mob_Registry.All.Values) { if (value != null && !string.IsNullOrWhiteSpace(value.Prefab)) { GameObject prefab = __instance.GetPrefab(value.Prefab); if (Object.op_Implicit((Object)(object)prefab)) { VS_SummonLifetime.EnsurePrefab(prefab); } } } } } public sealed class VS_SummonExpiredServerCleanup : MonoBehaviour { private float _tick; private void Update() { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { ((Behaviour)this).enabled = false; return; } _tick -= Time.deltaTime; if (!(_tick > 0f)) { _tick = 2f; CleanupLoadedExpiredSummons(); } } private static void CleanupLoadedExpiredSummons() { List allCharacters = Character.GetAllCharacters(); if (allCharacters == null || allCharacters.Count == 0) { return; } VS_SummonMarker vS_SummonMarker = default(VS_SummonMarker); VS_SummonLifetime vS_SummonLifetime = default(VS_SummonLifetime); for (int num = allCharacters.Count - 1; num >= 0; num--) { Character val = allCharacters[num]; if (!((Object)(object)val == (Object)null) && Object.op_Implicit((Object)(object)val) && !val.IsDead() && ((Component)val).TryGetComponent(ref vS_SummonMarker) && ((Component)val).TryGetComponent(ref vS_SummonLifetime) && VS_SummonLifetime.IsExpiredOrMarked(((Component)val).gameObject)) { VS_SummonLifetime.TryRemoveExpired(((Component)val).gameObject); } } } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public sealed class VS_SummonLifetime : MonoBehaviour { [CompilerGenerated] private sealed class d__16 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private object <>2__current; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public VS_SummonLifetime <>4__this; private float 5__1; object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public d__16(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = 2f; break; case 1: <>1__state = -1; break; } if (5__1 > 0f) { if ((Object)(object)<>4__this._character == (Object)null) { <>4__this._character = ((Component)<>4__this).GetComponent(); } if ((Object)(object)<>4__this._nview == (Object)null) { <>4__this._nview = ((Component)<>4__this).GetComponent(); } if (!((Object)(object)<>4__this._character != (Object)null) || !((Object)(object)<>4__this._nview != (Object)null) || !<>4__this._nview.IsValid()) { 5__1 -= Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } } if ((Object)(object)<>4__this._character == (Object)null) { return false; } if ((Object)(object)<>4__this._nview == (Object)null || !<>4__this._nview.IsValid()) { return false; } <>4__this._loaded = true; <>4__this._tick = 0f; <>4__this.ApplyDecay(); 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(); } } internal const string ZdoStartTicks = "vs_decayStartTicks"; internal const string ZdoLifetimeSec = "vs_decayLifetimeSec"; internal const string ZdoExpired = "vs_decayExpired"; internal const string ZdoExpiredAtTicks = "vs_decayExpiredAtTicks"; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private Character _character; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private ZNetView _nview; private bool _stripped; private bool _loaded; private bool _removing; private float _tick; private void Awake() { _character = ((Component)this).GetComponent(); _nview = ((Component)this).GetComponent(); StripAffixesOnce(); ((MonoBehaviour)this).StartCoroutine(DelayedLoad()); } private void Update() { if (_loaded && !_removing && !((Object)(object)_character == (Object)null) && !_character.IsDead() && !((Object)(object)_nview == (Object)null) && _nview.IsValid()) { _tick -= Time.deltaTime; if (!(_tick > 0f)) { _tick = GetTickInterval(); ApplyDecay(); } } } internal static void EnsurePrefab(GameObject prefab) { if (Object.op_Implicit((Object)(object)prefab)) { CharacterTimedDestruction component = prefab.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_triggerOnAwake = false; ((MonoBehaviour)component).CancelInvoke(); } if (!Object.op_Implicit((Object)(object)prefab.GetComponent())) { prefab.AddComponent(); } } } internal static void Apply(GameObject go, float seconds) { if (Object.op_Implicit((Object)(object)go)) { seconds = Mathf.Max(seconds, 0.01f); CharacterTimedDestruction component = go.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_triggerOnAwake = false; ((MonoBehaviour)component).CancelInvoke(); } VS_SummonLifetime vS_SummonLifetime = go.GetComponent() ?? go.AddComponent(); vS_SummonLifetime._character = go.GetComponent(); vS_SummonLifetime._nview = go.GetComponent(); vS_SummonLifetime._loaded = true; vS_SummonLifetime._removing = false; vS_SummonLifetime._tick = GetTickInterval(); vS_SummonLifetime.WriteState(seconds); vS_SummonLifetime.StripAffixesOnce(); vS_SummonLifetime.ApplyDecay(); } } internal static bool IsExpiredOrMarked(GameObject go) { if (!TryGetZDO(go, out var _, out var zdo) || zdo == null) { return false; } if (zdo.GetBool("vs_decayExpired", false)) { return true; } long @long = zdo.GetLong("vs_decayStartTicks", 0L); float @float = zdo.GetFloat("vs_decayLifetimeSec", 0f); return @long > 0 && @float > 0f && GetElapsedSeconds(@long) >= @float; } internal static bool TryRemoveExpired(GameObject go) { if (!Object.op_Implicit((Object)(object)go)) { return false; } VS_SummonLifetime component = go.GetComponent(); if ((Object)(object)component != (Object)null) { return component.RemoveExpired(); } MarkExpired(go); return VS_SummonRemoval.TryRemove(go, VS_SummonRemovalReason.LifetimeExpired); } [IteratorStateMachine(typeof(d__16))] private IEnumerator DelayedLoad() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__16(0) { <>4__this = this }; } private void WriteState(float seconds) { if (!((Object)(object)_nview == (Object)null) && _nview.IsValid()) { ZDO zDO = _nview.GetZDO(); if (zDO != null) { zDO.Set("vs_decayStartTicks", VS_SummonTime.NowTicks()); zDO.Set("vs_decayLifetimeSec", Mathf.Max(seconds, 0.01f)); zDO.Set("vs_decayExpired", false); zDO.Set("vs_decayExpiredAtTicks", 0L); } } } private void ApplyDecay() { if (_removing || (Object)(object)_character == (Object)null || (Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } ZDO zDO = _nview.GetZDO(); if (zDO == null) { return; } if (zDO.GetBool("vs_decayExpired", false)) { RemoveExpired(); return; } long @long = zDO.GetLong("vs_decayStartTicks", 0L); float @float = zDO.GetFloat("vs_decayLifetimeSec", 0f); if (@long <= 0 || @float <= 0f) { return; } float num = GetElapsedSeconds(@long); if (num < 0f) { num = 0f; } if (num >= @float) { RemoveExpired(); } else { if (!EnsureOwner()) { return; } float fullHealthTimePercent = GetFullHealthTimePercent(); float num2 = @float * Mathf.Clamp(fullHealthTimePercent, 0f, 100f) / 100f; if (!(num <= num2)) { float num3 = Mathf.Max(@float - num2, 0.01f); float num4 = num - num2; float num5 = Mathf.Clamp01(1f - num4 / num3); float maxHealth = _character.GetMaxHealth(); float health = _character.GetHealth(); float num6 = Mathf.Max(maxHealth * num5, 0.01f); if (!(health <= num6 + 0.1f)) { Damage(health - num6); } } } } private bool EnsureOwner() { if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return false; } if (_nview.IsOwner()) { return true; } if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { _nview.ClaimOwnership(); } return _nview.IsOwner(); } private void Damage(float damage) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //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)(object)_character == (Object)null) && !(damage <= 0f)) { HitData val = new HitData(); val.m_damage.m_damage = damage; val.m_point = ((Component)this).transform.position; _character.ApplyDamage(val, false, true, (DamageModifier)0); } } private bool RemoveExpired() { if (_removing) { return true; } MarkExpired(); if (!VS_SummonRemoval.TryRemove(((Component)this).gameObject, VS_SummonRemovalReason.LifetimeExpired)) { return false; } _removing = true; ((Behaviour)this).enabled = false; return true; } private void MarkExpired() { MarkExpired(((Component)this).gameObject); } private static void MarkExpired(GameObject go) { if (TryGetZDO(go, out var nview, out var zdo) && !((Object)(object)nview == (Object)null) && zdo != null) { if (!nview.IsOwner() && (Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { nview.ClaimOwnership(); } if (nview.IsOwner()) { zdo.Set("vs_decayExpired", true); zdo.Set("vs_decayExpiredAtTicks", VS_SummonTime.NowTicks()); } } } [NullableContext(2)] private static bool TryGetZDO([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] GameObject go, out ZNetView nview, out ZDO zdo) { nview = (Object.op_Implicit((Object)(object)go) ? go.GetComponent() : null); zdo = (((Object)(object)nview != (Object)null && nview.IsValid()) ? nview.GetZDO() : null); return (Object)(object)nview != (Object)null && zdo != null; } private static float GetElapsedSeconds(long startTicks) { long num = VS_SummonTime.NowTicks() - startTicks; if (num <= 0) { return 0f; } double totalSeconds = new TimeSpan(num).TotalSeconds; return (totalSeconds > 0.0) ? ((float)totalSeconds) : 0f; } private static float GetFullHealthTimePercent() { if (Vikings_SummonerPlugin.CE_SummonDecayFullHealthTimePercent == null) { return 80f; } return Mathf.Clamp(Vikings_SummonerPlugin.CE_SummonDecayFullHealthTimePercent.Value, 0f, 100f); } private static float GetTickInterval() { if (Vikings_SummonerPlugin.CE_SummonDecayTickInterval == null) { return 1f; } return Mathf.Clamp(Vikings_SummonerPlugin.CE_SummonDecayTickInterval.Value, 0.1f, 10f); } private void StripAffixesOnce() { if (!_stripped) { if ((Object)(object)_character == (Object)null) { _character = ((Component)this).GetComponent(); } if (!((Object)(object)_character == (Object)null)) { _stripped = true; Registrations_CLLC_NoAffixesOnSummons.TryStrip(_character); } } } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] internal static class VS_MenuSummonPreview { [HarmonyPatch(typeof(FejdStartup), "SetupCharacterPreview")] [NullableContext(0)] private static class Patch_FejdStartup_SetupCharacterPreview { [NullableContext(1)] private static void Postfix(FejdStartup __instance) { RebuildPreview(__instance); } } [NullableContext(0)] [HarmonyPatch(typeof(FejdStartup), "ClearCharacterPreview")] private static class Patch_FejdStartup_ClearCharacterPreview { private static void Prefix() { DestroyPreview(); } } [NullableContext(0)] [HarmonyPatch(typeof(FejdStartup), "OnDestroy")] private static class Patch_FejdStartup_OnDestroy { private static void Prefix() { DestroyPreview(); } } private const string BundleName = "rd_armor"; private static readonly int PreviewLayer = 0; private static readonly Vector3 LocalOffset = new Vector3(2f, 0f, -2f); private static readonly Dictionary TotemToMenuPrefabMap = new Dictionary(StringComparer.OrdinalIgnoreCase) { { "RD_totem_inv_meadows", "RD_inv_skeleton_meadows_menu" }, { "RD_totem_inv_bforest", "RD_inv_skeleton_bforest_menu" }, { "RD_totem_inv_bforest_ghost", "RD_inv_ghost_bforest_menu" }, { "RD_totem_inv_swamp", "RD_inv_draugr_swamp_menu" }, { "RD_totem_inv_mountain", "RD_inv_draugr_mountain_menu" }, { "RD_totem_inv_mountain_valkyrie", "RD_inv_valkyrie_mountain_menu" }, { "RD_totem_inv_plains", "RD_inv_skeleton_plains_menu" }, { "RD_totem_inv_plains_bear", "RD_inv_unbjorn_plains_menu" }, { "RD_totem_inv_mistlands", "RD_inv_skeleton_mistlands_menu" }, { "RD_totem_inv_ashlands", "RD_inv_skeleton_ashlands_menu" }, { "RD_totem_inv_ashlands_mage", "RD_inv_skeleton_mage_ashlands_menu" } }; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static readonly FieldInfo FI_PlayerInstance = AccessTools.Field(typeof(FejdStartup), "m_playerInstance"); [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static readonly FieldInfo FI_RightItem = AccessTools.Field(typeof(Humanoid), "m_rightItem"); [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static readonly FieldInfo FI_LeftItem = AccessTools.Field(typeof(Humanoid), "m_leftItem"); [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static GameObject _previewSummon; internal static void Register(Harmony harmony) { harmony.PatchAll(typeof(VS_MenuSummonPreview)); } private static void RebuildPreview(FejdStartup fejd) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) DestroyPreview(); object? obj = FI_PlayerInstance?.GetValue(fejd); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if (!Object.op_Implicit((Object)(object)val)) { return; } Humanoid component = val.GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return; } string text = TryResolveMenuPrefabName(component); if (!string.IsNullOrWhiteSpace(text)) { GameObject val2 = ResolveMenuPreviewPrefab(text); if (Object.op_Implicit((Object)(object)val2)) { Transform transform = val.transform; Vector3 val3 = transform.TransformPoint(LocalOffset); Quaternion rotation = transform.rotation; _previewSummon = Object.Instantiate(val2, val3, rotation); ((Object)_previewSummon).name = ((Object)val2).name + "_MenuPreview"; SnapToGroundIfPossible(_previewSummon.transform, 2f, 3f); PrepareVisualOnlyClone(_previewSummon); } } } [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static string TryResolveMenuPrefabName(Humanoid humanoid) { object? obj = FI_RightItem?.GetValue(humanoid); ItemData val = (ItemData)((obj is ItemData) ? obj : null); object? obj2 = FI_LeftItem?.GetValue(humanoid); ItemData val2 = (ItemData)((obj2 is ItemData) ? obj2 : null); string text = (Object.op_Implicit((Object)(object)val?.m_dropPrefab) ? ((Object)val.m_dropPrefab).name : null); string text2 = (Object.op_Implicit((Object)(object)val2?.m_dropPrefab) ? ((Object)val2.m_dropPrefab).name : null); if (!string.IsNullOrWhiteSpace(text) && TotemToMenuPrefabMap.TryGetValue(text, out var value) && !string.IsNullOrWhiteSpace(value)) { return value; } if (!string.IsNullOrWhiteSpace(text2) && TotemToMenuPrefabMap.TryGetValue(text2, out var value2) && !string.IsNullOrWhiteSpace(value2)) { return value2; } return null; } [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static GameObject ResolveMenuPreviewPrefab(string prefabName) { AssetBundle val = FindLoadedBundle("rd_armor"); if (Object.op_Implicit((Object)(object)val)) { GameObject val2 = val.LoadAsset(prefabName); if (Object.op_Implicit((Object)(object)val2)) { return val2; } } foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if (Object.op_Implicit((Object)(object)allLoadedAssetBundle)) { GameObject val3 = allLoadedAssetBundle.LoadAsset(prefabName); if (Object.op_Implicit((Object)(object)val3)) { return val3; } } } return null; } [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static AssetBundle FindLoadedBundle(string bundleName) { foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if (Object.op_Implicit((Object)(object)allLoadedAssetBundle)) { string text = ((Object)allLoadedAssetBundle).name ?? string.Empty; if (text.Equals(bundleName, StringComparison.OrdinalIgnoreCase)) { return allLoadedAssetBundle; } if (text.EndsWith("/" + bundleName, StringComparison.OrdinalIgnoreCase)) { return allLoadedAssetBundle; } if (text.EndsWith("\\" + bundleName, StringComparison.OrdinalIgnoreCase)) { return allLoadedAssetBundle; } if (text.IndexOf(bundleName, StringComparison.OrdinalIgnoreCase) >= 0) { return allLoadedAssetBundle; } } } return null; } private static void PrepareVisualOnlyClone(GameObject root) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) Transform[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { ((Component)val).gameObject.layer = PreviewLayer; } Rigidbody[] componentsInChildren2 = root.GetComponentsInChildren(true); foreach (Rigidbody val2 in componentsInChildren2) { val2.linearVelocity = Vector3.zero; val2.angularVelocity = Vector3.zero; val2.isKinematic = true; val2.detectCollisions = false; } Collider[] componentsInChildren3 = root.GetComponentsInChildren(true); foreach (Collider val3 in componentsInChildren3) { val3.enabled = false; } Animator[] componentsInChildren4 = root.GetComponentsInChildren(true); foreach (Animator val4 in componentsInChildren4) { val4.updateMode = (AnimatorUpdateMode)0; } } private static void SnapToGroundIfPossible(Transform tr, float rayUp, float rayDown) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) Vector3 val = tr.position + Vector3.up * rayUp; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, Vector3.down, ref val2, rayUp + rayDown, -1, (QueryTriggerInteraction)1)) { tr.position = new Vector3(tr.position.x, ((RaycastHit)(ref val2)).point.y, tr.position.z); } } private static void DestroyPreview() { if (Object.op_Implicit((Object)(object)_previewSummon)) { Object.Destroy((Object)(object)_previewSummon); } _previewSummon = null; } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] internal static class Registrations_CLLC_NoAffixesOnSummons { private const string ZdoEffectKey = "CL&LC effect"; private const string ZdoInfusionKey = "CL&LC infusion"; [NullableContext(2)] internal static void TryStrip(Character ch) { try { if ((Object)(object)ch == (Object)null) { return; } ZNetView component = ((Component)ch).GetComponent(); if (Object.op_Implicit((Object)(object)component) && component.IsValid()) { ZDO zDO = component.GetZDO(); if (zDO != null) { zDO.Set("CL&LC effect", 0); zDO.Set("CL&LC infusion", 0); } } } catch { } } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] internal static class VS_SummonHealthCostFlashSuppressor { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static readonly FieldInfo FI_AttackCharacter = AccessTools.Field(typeof(Attack), "m_character"); [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static readonly FieldInfo FI_AttackWeapon = AccessTools.Field(typeof(Attack), "m_weapon"); private static int _suppressFrames; internal static bool ShouldSuppress => _suppressFrames > 0; internal static void Mark() { _suppressFrames = 2; } internal static void Tick() { if (_suppressFrames > 0) { _suppressFrames--; } } internal static bool IsSummonAttack(Attack attack) { if (attack == null) { return false; } if (FI_AttackCharacter == null || FI_AttackWeapon == null) { return false; } object? value = FI_AttackCharacter.GetValue(attack); Character val = (Character)((value is Character) ? value : null); if ((Object)(object)val == (Object)null || !val.IsPlayer()) { return false; } object? value2 = FI_AttackWeapon.GetValue(attack); ItemData item = (ItemData)((value2 is ItemData) ? value2 : null); if (!VS_RuntimeLookup.TryGetDropPrefabName(item, out var prefabName)) { return false; } return IsSummonCostWeaponPrefab(prefabName); } private static bool IsSummonCostWeaponPrefab(string prefab) { if (string.IsNullOrWhiteSpace(prefab)) { return false; } Mob_Registry.SummonDef def; return Mob_Registry.TryGetByTotemPrefab(prefab, out def) || prefab.StartsWith("RD_inv_staff", StringComparison.Ordinal) || prefab.StartsWith("RD_totem_inv", StringComparison.Ordinal); } } [HarmonyPatch(typeof(Attack), "Update")] internal static class Patch_Attack_Update_SuppressSummonHealthCostFlash { [NullableContext(1)] private static void Prefix(Attack __instance) { if (VS_SummonHealthCostFlashSuppressor.IsSummonAttack(__instance)) { VS_SummonHealthCostFlashSuppressor.Mark(); } } private static void Postfix() { VS_SummonHealthCostFlashSuppressor.Tick(); } } [HarmonyPatch(typeof(Hud), "DamageFlash")] internal static class Patch_Hud_DamageFlash_SummonHealthCost { private static bool Prefix() { return !VS_SummonHealthCostFlashSuppressor.ShouldSuppress; } } [NullableContext(2)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal static class SE_SummonExtra { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] internal const string EffectName01 = "SE_Summon_extra_01"; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] internal const string EffectName02 = "SE_Summon_extra_02"; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] internal const string EffectName03 = "SE_Summon_extra_03"; private static readonly int SummonExtraHash01 = StringExtensionMethods.GetStableHashCode("SE_Summon_extra_01"); private static readonly int SummonExtraHash02 = StringExtensionMethods.GetStableHashCode("SE_Summon_extra_02"); private static readonly int SummonExtraHash03 = StringExtensionMethods.GetStableHashCode("SE_Summon_extra_03"); internal static bool IsSummonExtraEffect(StatusEffect effect) { if ((Object)(object)effect == (Object)null) { return false; } int num = effect.NameHash(); return num == SummonExtraHash01 || num == SummonExtraHash02 || num == SummonExtraHash03; } internal static bool HasSummonExtraEffect(Character owner) { Humanoid val = (Humanoid)(object)((owner is Humanoid) ? owner : null); if (val == null) { return false; } return HasSummonExtraEffect(val); } internal static bool HasSummonExtraEffect(Humanoid owner) { if ((Object)(object)owner == (Object)null) { return false; } SEMan seman = ((Character)owner).m_seman; if (seman == null) { return false; } return seman.HaveStatusEffect(SummonExtraHash01) || seman.HaveStatusEffect(SummonExtraHash02) || seman.HaveStatusEffect(SummonExtraHash03); } internal static int GetExtraMaxSummons(Character owner) { Humanoid val = (Humanoid)(object)((owner is Humanoid) ? owner : null); if (val == null) { return 0; } return GetExtraMaxSummons(val); } internal static int GetExtraMaxSummons(Humanoid owner) { if ((Object)(object)owner == (Object)null) { return 0; } SEMan seman = ((Character)owner).m_seman; if (seman == null) { return 0; } if (seman.HaveStatusEffect(SummonExtraHash03)) { return Mathf.Max(0, Vikings_SummonerPlugin.CE_GrimoireIIIExtraMaxSummons.Value); } if (seman.HaveStatusEffect(SummonExtraHash02)) { return Mathf.Max(0, Vikings_SummonerPlugin.CE_GrimoireIIExtraMaxSummons.Value); } if (seman.HaveStatusEffect(SummonExtraHash01)) { return Mathf.Max(0, Vikings_SummonerPlugin.CE_GrimoireIExtraMaxSummons.Value); } return 0; } internal static int ApplyExtraMaxSummons(Character owner, int baseMaxInstances) { int num = Mathf.Max(1, baseMaxInstances); int extraMaxSummons = GetExtraMaxSummons(owner); return Mathf.Max(1, num + extraMaxSummons); } internal static int ApplyExtraMaxSummons(Humanoid owner, int baseMaxInstances) { int num = Mathf.Max(1, baseMaxInstances); int extraMaxSummons = GetExtraMaxSummons(owner); return Mathf.Max(1, num + extraMaxSummons); } internal static float GetSummonHealthCostPercentBonus(Character owner) { Humanoid val = (Humanoid)(object)((owner is Humanoid) ? owner : null); if (val == null) { return 0f; } return GetSummonHealthCostPercentBonus(val); } internal static float GetSummonHealthCostPercentBonus(Humanoid owner) { if ((Object)(object)owner == (Object)null) { return 0f; } SEMan seman = ((Character)owner).m_seman; if (seman == null) { return 0f; } if (seman.HaveStatusEffect(SummonExtraHash03)) { return Mathf.Max(0f, Vikings_SummonerPlugin.CE_GrimoireIIISummonHealthCostBonusPercent.Value); } if (seman.HaveStatusEffect(SummonExtraHash02)) { return Mathf.Max(0f, Vikings_SummonerPlugin.CE_GrimoireIISummonHealthCostBonusPercent.Value); } if (seman.HaveStatusEffect(SummonExtraHash01)) { return Mathf.Max(0f, Vikings_SummonerPlugin.CE_GrimoireISummonHealthCostBonusPercent.Value); } return 0f; } internal static float GetSummonHealthCostMultiplier(Character owner) { return 1f + GetSummonHealthCostPercentBonus(owner) / 100f; } internal static float GetSummonHealthCostMultiplier(Humanoid owner) { return 1f + GetSummonHealthCostPercentBonus(owner) / 100f; } internal static float ApplySummonHealthCostMultiplier(Character owner, float baseCost) { if (baseCost <= 0f) { return 0f; } return baseCost * GetSummonHealthCostMultiplier(owner); } internal static float ApplySummonHealthCostMultiplier(Humanoid owner, float baseCost) { if (baseCost <= 0f) { return 0f; } return baseCost * GetSummonHealthCostMultiplier(owner); } internal static float GetPlayerMaxHealthPenaltyPercent(Character owner) { Humanoid val = (Humanoid)(object)((owner is Humanoid) ? owner : null); if (val == null) { return 0f; } return GetPlayerMaxHealthPenaltyPercent(val); } internal static float GetPlayerMaxHealthPenaltyPercent(Humanoid owner) { if ((Object)(object)owner == (Object)null) { return 0f; } SEMan seman = ((Character)owner).m_seman; if (seman == null) { return 0f; } if (seman.HaveStatusEffect(SummonExtraHash03)) { return Mathf.Max(0f, Vikings_SummonerPlugin.CE_GrimoireIIIPlayerMaxHealthPenaltyPercent.Value); } if (seman.HaveStatusEffect(SummonExtraHash02)) { return Mathf.Max(0f, Vikings_SummonerPlugin.CE_GrimoireIIPlayerMaxHealthPenaltyPercent.Value); } if (seman.HaveStatusEffect(SummonExtraHash01)) { return Mathf.Max(0f, Vikings_SummonerPlugin.CE_GrimoireIPlayerMaxHealthPenaltyPercent.Value); } return 0f; } internal static float ApplyPlayerMaxHealthPenalty(Character owner, float baseMaxHealth) { if (baseMaxHealth <= 1f) { return baseMaxHealth; } float num = Mathf.Clamp(GetPlayerMaxHealthPenaltyPercent(owner), 0f, 90f); if (num <= 0f) { return baseMaxHealth; } return Mathf.Max(1f, baseMaxHealth * (1f - num / 100f)); } internal static void ClampPlayerHealthToPenaltyMax(Character owner) { if (!((Object)(object)owner == (Object)null) && owner.IsPlayer() && owner.IsOwner()) { float maxHealth = owner.GetMaxHealth(); float health = owner.GetHealth(); if (health > maxHealth) { owner.SetHealth(maxHealth); } } } } [HarmonyPatch(typeof(Character), "GetMaxHealth")] internal static class Patch_Character_GetMaxHealth_SummonExtraPenalty { [NullableContext(1)] private static void Postfix(Character __instance, ref float __result) { if (!((Object)(object)__instance == (Object)null) && __instance.IsPlayer()) { __result = SE_SummonExtra.ApplyPlayerMaxHealthPenalty(__instance, __result); } } } [HarmonyPatch(typeof(StatusEffect), "Setup")] internal static class Patch_StatusEffect_Setup_SummonExtraHealthClamp { [NullableContext(1)] private static void Postfix(StatusEffect __instance, Character character) { if (SE_SummonExtra.IsSummonExtraEffect(__instance)) { SE_SummonExtra.ClampPlayerHealthToPenaltyMax(character); } } } [HarmonyPatch(typeof(Hud), "FlashHealthBar")] internal static class Patch_Hud_FlashHealthBar_SummonExtra { private static bool Prefix() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return true; } return !SE_SummonExtra.HasSummonExtraEffect((Humanoid)(object)localPlayer); } } internal static class Summoner_DynamicTooltips { private static bool _handlerRegistered; private static bool _placeholdersRegistered; internal static void Register() { if (!_handlerRegistered) { _handlerRegistered = true; Localizer.OnLocalizationComplete += Setup; } } private static void Setup() { if (!_placeholdersRegistered) { _placeholdersRegistered = true; Localizer.AddPlaceholder("se_book_grimoire_extra_01_tooltip", "extra", Vikings_SummonerPlugin.CE_GrimoireIExtraMaxSummons); Localizer.AddPlaceholder("se_book_grimoire_extra_01_tooltip", "cost", Vikings_SummonerPlugin.CE_GrimoireISummonHealthCostBonusPercent, [NullableContext(1)] (float value) => value.ToString("0.#")); Localizer.AddPlaceholder("se_book_grimoire_extra_01_tooltip", "penalty", Vikings_SummonerPlugin.CE_GrimoireIPlayerMaxHealthPenaltyPercent, [NullableContext(1)] (float value) => value.ToString("0.#")); Localizer.AddPlaceholder("se_book_grimoire_extra_02_tooltip", "extra", Vikings_SummonerPlugin.CE_GrimoireIIExtraMaxSummons); Localizer.AddPlaceholder("se_book_grimoire_extra_02_tooltip", "cost", Vikings_SummonerPlugin.CE_GrimoireIISummonHealthCostBonusPercent, [NullableContext(1)] (float value) => value.ToString("0.#")); Localizer.AddPlaceholder("se_book_grimoire_extra_02_tooltip", "penalty", Vikings_SummonerPlugin.CE_GrimoireIIPlayerMaxHealthPenaltyPercent, [NullableContext(1)] (float value) => value.ToString("0.#")); Localizer.AddPlaceholder("se_book_grimoire_extra_03_tooltip", "extra", Vikings_SummonerPlugin.CE_GrimoireIIIExtraMaxSummons); Localizer.AddPlaceholder("se_book_grimoire_extra_03_tooltip", "cost", Vikings_SummonerPlugin.CE_GrimoireIIISummonHealthCostBonusPercent, [NullableContext(1)] (float value) => value.ToString("0.#")); Localizer.AddPlaceholder("se_book_grimoire_extra_03_tooltip", "penalty", Vikings_SummonerPlugin.CE_GrimoireIIIPlayerMaxHealthPenaltyPercent, [NullableContext(1)] (float value) => value.ToString("0.#")); AddTotemPlaceholders("item_RD_totem_inv_meadows_description", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_skeleton_meadows, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_meadows); AddTotemPlaceholders("item_RD_totem_inv_bforest_description", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_skeleton_bforest, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_bforest); AddTotemPlaceholders("item_RD_totem_inv_bforest_ghost_description", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_ghost_bforest, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_bforest_ghost); AddTotemPlaceholders("item_RD_totem_inv_swamp_description", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_draugr_swamp, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_swamp); AddTotemPlaceholders("item_RD_totem_inv_mountain_description", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_draugr_mountain, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_mountain); AddTotemPlaceholders("item_RD_totem_inv_mountain_valkyrie_description", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_valkyrie_mountain, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_mountain_valkyrie); AddTotemPlaceholders("item_RD_totem_inv_plains_description", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_skeleton_plains, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_plains); AddTotemPlaceholders("item_RD_totem_inv_plains_bear_description", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_unbjorn_plains, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_plains_bear); AddTotemPlaceholders("item_RD_totem_inv_mistlands_description", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_skeleton_mistlands, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_mistlands); AddTotemPlaceholders("item_RD_totem_inv_ashlands_description", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_skeleton_ashlands, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_ashlands); AddTotemPlaceholders("item_RD_totem_inv_ashlands_mage_description", Vikings_SummonerPlugin.CE_Lifetime_RD_inv_skeleton_mage_ashlands, Vikings_SummonerPlugin.CE_LifetimeUpgradeTotem_RD_totem_inv_ashlands_mage); } } [NullableContext(2)] private static void AddTotemPlaceholders([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] string token, ConfigEntry lifetime, ConfigEntry upgrade) { if (lifetime != null) { Localizer.AddPlaceholder(token, "lifetime", lifetime, [NullableContext(1)] (float value) => Mathf.Max(value, 0.01f).ToString("0.#")); } if (upgrade != null) { Localizer.AddPlaceholder(token, "upgrade", upgrade, [NullableContext(1)] (float value) => Mathf.Max(value, 0f).ToString("0.#")); } } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int) })] internal static class Patch_ItemData_GetTooltip_SummonHealthCostLabel { private const string VanillaToken = "$item_healthuse:"; private const string CustomToken = "$vs_summon_health_cost:"; private static readonly HashSet Prefabs = new HashSet { "RD_inv_staff_meadows", "RD_inv_staff_bforest", "RD_inv_staff_swamp", "RD_inv_staff_mountain", "RD_inv_staff_plains", "RD_inv_staff_mistlands", "RD_inv_staff_ashlands", "RD_totem_inv_meadows", "RD_totem_inv_bforest", "RD_totem_inv_bforest_ghost", "RD_totem_inv_swamp", "RD_totem_inv_mountain", "RD_totem_inv_mountain_valkyrie", "RD_totem_inv_plains", "RD_totem_inv_plains_bear", "RD_totem_inv_mistlands", "RD_totem_inv_ashlands", "RD_totem_inv_ashlands_mage" }; private static void Postfix(ItemData item, ref string __result) { if (item != null && !((Object)(object)item.m_dropPrefab == (Object)null) && !string.IsNullOrEmpty(__result)) { string prefabName = Utils.GetPrefabName(((Object)item.m_dropPrefab).name); if (Prefabs.Contains(prefabName)) { __result = __result.Replace("$item_healthuse:", "$vs_summon_health_cost:"); } } } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] internal static class Vikings_Summoner_AssetLoader { private const string BundleName = "rd_armor"; private const string ResourceName = "Vikings_Summoner.assets.rd_armor"; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static AssetBundle _bundle; internal static void Init() { LoadBundle(); } private static void LoadBundle() { if ((Object)(object)_bundle != (Object)null) { return; } foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if (!((Object)(object)allLoadedAssetBundle == (Object)null)) { string text = ((Object)allLoadedAssetBundle).name ?? string.Empty; if (text.Equals("rd_armor", StringComparison.OrdinalIgnoreCase)) { _bundle = allLoadedAssetBundle; return; } } } Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream stream = executingAssembly.GetManifestResourceStream("Vikings_Summoner.assets.rd_armor"); if (stream == null) { throw new FileNotFoundException("Embedded asset bundle 'Vikings_Summoner.assets.rd_armor' was not found."); } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); byte[] array = memoryStream.ToArray(); if (array.Length == 0) { throw new InvalidDataException("Embedded asset bundle 'Vikings_Summoner.assets.rd_armor' is empty."); } _bundle = AssetBundle.LoadFromMemory(array); if ((Object)(object)_bundle == (Object)null) { throw new InvalidDataException("Failed to load asset bundle 'rd_armor' from embedded resource 'Vikings_Summoner.assets.rd_armor'."); } } [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] internal static Sprite GetSprite(string name) { if (string.IsNullOrWhiteSpace(name)) { return null; } LoadBundle(); return ((Object)(object)_bundle != (Object)null) ? _bundle.LoadAsset(name) : null; } } internal static class SE_Registry_Manager { internal static void RegisterStatusEffects() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) CustomSE customSE = new CustomSE("SE_Summon_extra_01"); customSE.Type = EffectType.Equip; customSE.Effect.m_name = "$se_book_grimoire_extra_01"; customSE.Effect.m_tooltip = "$se_book_grimoire_extra_01_tooltip"; customSE.Effect.m_startMessageType = (MessageType)2; customSE.Effect.m_startMessage = ""; customSE.Effect.m_stopMessageType = (MessageType)2; customSE.Effect.m_stopMessage = ""; customSE.Effect.m_category = "Equipment"; customSE.Effect.m_ttl = 0f; customSE.Effect.m_flashIcon = false; customSE.Effect.m_cooldownIcon = false; customSE.Effect.m_icon = Vikings_Summoner_AssetLoader.GetSprite("extra_summon_ico_01"); customSE.AddSEToPrefab(customSE, "RD_grimoire_summons_01"); CustomSE customSE2 = new CustomSE("SE_Summon_extra_02"); customSE2.Type = EffectType.Equip; customSE2.Effect.m_name = "$se_book_grimoire_extra_02"; customSE2.Effect.m_tooltip = "$se_book_grimoire_extra_02_tooltip"; customSE2.Effect.m_startMessageType = (MessageType)2; customSE2.Effect.m_startMessage = ""; customSE2.Effect.m_stopMessageType = (MessageType)2; customSE2.Effect.m_stopMessage = ""; customSE2.Effect.m_category = "Equipment"; customSE2.Effect.m_ttl = 0f; customSE2.Effect.m_flashIcon = false; customSE2.Effect.m_cooldownIcon = false; customSE2.Effect.m_icon = Vikings_Summoner_AssetLoader.GetSprite("extra_summon_ico_02"); customSE2.AddSEToPrefab(customSE2, "RD_grimoire_summons_02"); CustomSE customSE3 = new CustomSE("SE_Summon_extra_03"); customSE3.Type = EffectType.Equip; customSE3.Effect.m_name = "$se_book_grimoire_extra_03"; customSE3.Effect.m_tooltip = "$se_book_grimoire_extra_03_tooltip"; customSE3.Effect.m_startMessageType = (MessageType)2; customSE3.Effect.m_startMessage = ""; customSE3.Effect.m_stopMessageType = (MessageType)2; customSE3.Effect.m_stopMessage = ""; customSE3.Effect.m_category = "Equipment"; customSE3.Effect.m_ttl = 0f; customSE3.Effect.m_flashIcon = false; customSE3.Effect.m_cooldownIcon = false; customSE3.Effect.m_icon = Vikings_Summoner_AssetLoader.GetSprite("extra_summon_ico_03"); customSE3.AddSEToPrefab(customSE3, "RD_grimoire_summons_03"); } } [NullableContext(2)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal static class AzuEpiCompat { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] private const string AssemblyName = "AzuExtendedPlayerInventory"; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] private const string ApiTypeName = "AzuExtendedPlayerInventory.API"; private static Type _apiType; private static MethodInfo _miIsLoaded; private static MethodInfo _miAddSlot; private static MethodInfo _miRemoveSlot; private static MethodInfo _miGetSlots; private static MethodInfo _miGetAddedRows; private static bool _resolved; private static void EnsureResolved() { if (_resolved) { return; } _resolved = true; try { _apiType = Type.GetType("AzuExtendedPlayerInventory.API, AzuExtendedPlayerInventory", throwOnError: false); if (_apiType == null) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (string.Equals(assembly.GetName().Name, "AzuExtendedPlayerInventory", StringComparison.Ordinal)) { _apiType = assembly.GetType("AzuExtendedPlayerInventory.API", throwOnError: false); if (_apiType != null) { break; } } } } if (!(_apiType == null)) { _miIsLoaded = _apiType.GetMethod("IsLoaded", BindingFlags.Static | BindingFlags.Public); _miAddSlot = _apiType.GetMethod("AddSlot", BindingFlags.Static | BindingFlags.Public); _miRemoveSlot = _apiType.GetMethod("RemoveSlot", BindingFlags.Static | BindingFlags.Public); _miGetSlots = _apiType.GetMethod("GetSlots", BindingFlags.Static | BindingFlags.Public); _miGetAddedRows = _apiType.GetMethod("GetAddedRows", BindingFlags.Static | BindingFlags.Public); } } catch { _apiType = null; _miIsLoaded = null; _miAddSlot = null; _miRemoveSlot = null; _miGetSlots = null; _miGetAddedRows = null; } } internal static bool IsLoaded() { try { EnsureResolved(); if (_apiType == null || _miIsLoaded == null) { return false; } object obj = _miIsLoaded.Invoke(null, Array.Empty()); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch { return false; } } [NullableContext(1)] internal static bool AddSlot(string slotName, Func getItem, Func isValid, int index = -1) { try { EnsureResolved(); if (_apiType == null || _miAddSlot == null) { return false; } object obj = _miAddSlot.Invoke(null, new object[4] { slotName, getItem, isValid, index }); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch { return false; } } [NullableContext(1)] internal static bool RemoveSlot(string slotName) { try { EnsureResolved(); if (_apiType == null || _miRemoveSlot == null) { return false; } object obj = _miRemoveSlot.Invoke(null, new object[1] { slotName }); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch { return false; } } internal static object GetSlots() { try { EnsureResolved(); if (_apiType == null || _miGetSlots == null) { return null; } return _miGetSlots.Invoke(null, Array.Empty()); } catch { return null; } } internal static int GetAddedRows(int width) { try { EnsureResolved(); if (_apiType == null || _miGetAddedRows == null) { return 0; } return (_miGetAddedRows.Invoke(null, new object[1] { width }) is int num) ? num : 0; } catch { return 0; } } } internal static class Registrations_TomeSlot { [NullableContext(1)] internal static void RegisterTomeSlot(Vikings_SummonerPlugin plugin) { plugin.InitializeTomeSlot(); } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal static class TomeCustomSlotManager { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 1, 1, 2 })] private static readonly Dictionary EquippedTomeByHumanoid = new Dictionary(); internal static bool IsSlotSystemEnabled() { return Vikings_SummonerPlugin.CE_TomeSlot_Enabled == null || Vikings_SummonerPlugin.CE_TomeSlot_Enabled.Value; } internal static void Register(Humanoid humanoid) { if (!((Object)(object)humanoid == (Object)null)) { if (!EquippedTomeByHumanoid.ContainsKey(humanoid)) { EquippedTomeByHumanoid[humanoid] = null; } ResyncEquippedTome(humanoid); } } internal static void Unregister(Humanoid humanoid) { if (!((Object)(object)humanoid == (Object)null)) { EquippedTomeByHumanoid.Remove(humanoid); } } [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] internal static ItemData GetEquippedTome(Humanoid humanoid) { if ((Object)(object)humanoid == (Object)null) { return null; } if (!IsSlotSystemEnabled()) { return null; } if (!EquippedTomeByHumanoid.TryGetValue(humanoid, out var value)) { Register(humanoid); EquippedTomeByHumanoid.TryGetValue(humanoid, out value); } if (IsValidEquippedTome(humanoid, value)) { return value; } ResyncEquippedTome(humanoid); EquippedTomeByHumanoid.TryGetValue(humanoid, out value); return IsValidEquippedTome(humanoid, value) ? value : null; } [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] internal static ItemData GetEquippedTome(Player player) { if ((Object)(object)player == (Object)null) { return null; } return GetEquippedTome((Humanoid)(object)player); } internal static void SetEquippedTome(Humanoid humanoid, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] ItemData item) { if (!((Object)(object)humanoid == (Object)null) && IsSlotSystemEnabled()) { if (!EquippedTomeByHumanoid.ContainsKey(humanoid)) { EquippedTomeByHumanoid[humanoid] = null; } if (item != null && !IsTomeItem(item)) { EquippedTomeByHumanoid[humanoid] = null; } else { EquippedTomeByHumanoid[humanoid] = item; } } } [NullableContext(2)] internal static bool IsTomeItem(ItemData item) { if (!IsSlotSystemEnabled()) { return false; } if (item == null) { return false; } GameObject dropPrefab = item.m_dropPrefab; if ((Object)(object)dropPrefab == (Object)null) { return false; } string prefabName = Utils.GetPrefabName(((Object)dropPrefab).name); if (string.IsNullOrWhiteSpace(prefabName)) { return false; } return prefabName.StartsWith("RD_grimoire_", StringComparison.Ordinal); } internal static bool IsAnyTomeEquipped(Humanoid humanoid, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] out ItemData equipped) { equipped = GetEquippedTome(humanoid); return equipped != null; } internal static void ClearIfMatches(Humanoid humanoid, ItemData item) { if (!((Object)(object)humanoid == (Object)null) && item != null && EquippedTomeByHumanoid.TryGetValue(humanoid, out var value) && value == item) { EquippedTomeByHumanoid[humanoid] = null; } } internal static bool ResyncEquippedTome(Humanoid humanoid) { if ((Object)(object)humanoid == (Object)null) { return false; } if (!IsSlotSystemEnabled()) { return false; } Inventory inventory = humanoid.GetInventory(); if (inventory == null) { EquippedTomeByHumanoid[humanoid] = null; return false; } List allItems = inventory.GetAllItems(); for (int i = 0; i < allItems.Count; i++) { ItemData val = allItems[i]; if (val != null && val.m_equipped && IsTomeItem(val)) { EquippedTomeByHumanoid[humanoid] = val; return true; } } EquippedTomeByHumanoid[humanoid] = null; return false; } private static bool IsValidEquippedTome(Humanoid humanoid, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] ItemData item) { if ((Object)(object)humanoid == (Object)null) { return false; } if (item == null) { return false; } if (!IsTomeItem(item)) { return false; } if (!item.m_equipped) { return false; } Inventory inventory = humanoid.GetInventory(); if (inventory == null) { return false; } return inventory.ContainsItem(item); } } [HarmonyPatch(typeof(Humanoid))] [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal static class TomeSlot_HumanoidPatches { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static readonly MethodInfo MI_SetupEquipment = AccessTools.Method(typeof(Humanoid), "SetupEquipment", Array.Empty(), (Type[])null); [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static readonly MethodInfo MI_TriggerEquipEffect = AccessTools.Method(typeof(Humanoid), "TriggerEquipEffect", new Type[1] { typeof(ItemData) }, (Type[])null); private static readonly Dictionary> LastAppliedTomeEffects = new Dictionary>(); private static bool CanApplyRuntimeEquipmentEffects(Humanoid humanoid) { if ((Object)(object)humanoid == (Object)null) { return false; } if ((Object)(object)Game.instance == (Object)null) { return false; } if ((Object)(object)ZNet.instance == (Object)null) { return false; } if (ZDOMan.instance == null) { return false; } if ((Object)(object)Player.m_localPlayer == (Object)null) { return false; } if ((Object)(object)humanoid != (Object)(object)Player.m_localPlayer) { return false; } return true; } private static void RefreshRuntimeEquipment(Humanoid humanoid, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] ItemData item, bool triggerEquipEffects) { if (CanApplyRuntimeEquipmentEffects(humanoid)) { MI_SetupEquipment?.Invoke(humanoid, Array.Empty()); if (triggerEquipEffects && item != null && MI_TriggerEquipEffect != null) { MI_TriggerEquipEffect.Invoke(humanoid, new object[1] { item }); } VS_SummonProgression.EnforceAllSummonLimits(humanoid); } } [HarmonyPostfix] [HarmonyPatch("Awake")] private static void Awake_Postfix(Humanoid __instance) { TomeCustomSlotManager.Register(__instance); } [HarmonyPostfix] [HarmonyPatch("Start")] private static void Start_Postfix(Humanoid __instance) { TomeCustomSlotManager.ResyncEquippedTome(__instance); } [HarmonyPostfix] [HarmonyPatch("OnDestroy")] private static void OnDestroy_Postfix(Humanoid __instance) { TomeCustomSlotManager.Unregister(__instance); LastAppliedTomeEffects.Remove(__instance); } [HarmonyPrefix] [HarmonyPatch("EquipItem")] private static bool EquipItem_Prefix(ref bool __result, Humanoid __instance, ItemData item, bool triggerEquipEffects) { if (!TomeCustomSlotManager.IsSlotSystemEnabled()) { return true; } if (item == null) { return true; } if (!TomeCustomSlotManager.IsTomeItem(item)) { return true; } ItemData equippedTome = TomeCustomSlotManager.GetEquippedTome(__instance); if (equippedTome == item) { item.m_equipped = true; __result = true; return false; } if (equippedTome != null && equippedTome != item) { equippedTome.m_equipped = false; TomeCustomSlotManager.SetEquippedTome(__instance, null); } TomeCustomSlotManager.SetEquippedTome(__instance, item); item.m_equipped = true; RefreshRuntimeEquipment(__instance, item, triggerEquipEffects); __result = true; return false; } [HarmonyPatch("UnequipItem")] [HarmonyPrefix] private static bool UnequipItem_Prefix(Humanoid __instance, ItemData item, bool triggerEquipEffects) { if (!TomeCustomSlotManager.IsSlotSystemEnabled()) { return true; } if (item == null) { return true; } if (!TomeCustomSlotManager.IsTomeItem(item)) { return true; } ItemData equippedTome = TomeCustomSlotManager.GetEquippedTome(__instance); if (equippedTome != item) { return true; } TomeCustomSlotManager.SetEquippedTome(__instance, null); item.m_equipped = false; RefreshRuntimeEquipment(__instance, item, triggerEquipEffects); return false; } [HarmonyPostfix] [HarmonyPatch("IsItemEquiped")] private static void IsItemEquipped_Postfix(ref bool __result, Humanoid __instance, ItemData item) { if (TomeCustomSlotManager.IsSlotSystemEnabled() && TomeCustomSlotManager.IsTomeItem(item)) { ItemData equippedTome = TomeCustomSlotManager.GetEquippedTome(__instance); if (equippedTome == item) { __result = true; } } } [HarmonyPostfix] [HarmonyPatch("GetEquipmentWeight")] private static void GetEquipmentWeight_Postfix(ref float __result, Humanoid __instance) { if (TomeCustomSlotManager.IsSlotSystemEnabled()) { ItemData equippedTome = TomeCustomSlotManager.GetEquippedTome(__instance); if (equippedTome != null) { __result += equippedTome.m_shared.m_weight; } } } [HarmonyPostfix] [HarmonyPatch("GetSetCount")] private static void GetSetCount_Postfix(ref int __result, Humanoid __instance, string setName) { if (TomeCustomSlotManager.IsSlotSystemEnabled()) { ItemData equippedTome = TomeCustomSlotManager.GetEquippedTome(__instance); if (equippedTome != null && equippedTome.m_shared.m_setName == setName) { __result++; } } } [HarmonyPatch("UnequipAllItems")] [HarmonyPrefix] private static void UnequipAllItems_Prefix(Humanoid __instance) { if (TomeCustomSlotManager.IsSlotSystemEnabled()) { ItemData equippedTome = TomeCustomSlotManager.GetEquippedTome(__instance); if (equippedTome != null) { __instance.UnequipItem(equippedTome, false); } } } [HarmonyPatch("DropItem")] [HarmonyPrefix] private static void DropItem_Prefix(Humanoid __instance, Inventory inventory, ItemData item, int amount) { if (TomeCustomSlotManager.IsSlotSystemEnabled() && item != null && TomeCustomSlotManager.IsTomeItem(item)) { TomeCustomSlotManager.ClearIfMatches(__instance, item); item.m_equipped = false; } } [HarmonyPostfix] [HarmonyPatch("UpdateEquipmentStatusEffects")] private static void UpdateEquipmentStatusEffects_Postfix(Humanoid __instance) { if (!TomeCustomSlotManager.IsSlotSystemEnabled() || !CanApplyRuntimeEquipmentEffects(__instance)) { return; } SEMan seman = ((Character)__instance).m_seman; if (seman == null) { return; } if (LastAppliedTomeEffects.TryGetValue(__instance, out var value) && value != null) { for (int i = 0; i < value.Count; i++) { seman.RemoveStatusEffect(value[i], false); } value.Clear(); } else { value = new List(); } ItemData equippedTome = TomeCustomSlotManager.GetEquippedTome(__instance); if (equippedTome != null) { SharedData shared = equippedTome.m_shared; if (shared != null) { StatusEffect equipStatusEffect = shared.m_equipStatusEffect; if ((Object)(object)equipStatusEffect != (Object)null) { int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)equipStatusEffect).name); seman.AddStatusEffect(stableHashCode, false, equippedTome.m_quality, 0f); value.Add(stableHashCode); } StatusEffect setStatusEffect = shared.m_setStatusEffect; if ((Object)(object)setStatusEffect != (Object)null && !string.IsNullOrEmpty(shared.m_setName) && __instance.GetSetCount(shared.m_setName) >= shared.m_setSize) { int stableHashCode2 = StringExtensionMethods.GetStableHashCode(((Object)setStatusEffect).name); seman.AddStatusEffect(stableHashCode2, false, equippedTome.m_quality, 0f); value.Add(stableHashCode2); } } } if (value.Count > 0) { LastAppliedTomeEffects[__instance] = value; } else { LastAppliedTomeEffects.Remove(__instance); } } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(2)] internal static class VS_RuntimeLookup { internal static bool TryGetPrefabByName(string prefabName, out GameObject prefab) { prefab = null; if (string.IsNullOrWhiteSpace(prefabName)) { return false; } if ((Object)(object)ZNetScene.instance == (Object)null) { return false; } prefab = ZNetScene.instance.GetPrefab(prefabName); return Object.op_Implicit((Object)(object)prefab); } internal static bool TryGetPrefabByHash(int prefabHash, out GameObject prefab) { prefab = null; if (prefabHash == 0) { return false; } if ((Object)(object)ZNetScene.instance == (Object)null) { return false; } prefab = ZNetScene.instance.GetPrefab(prefabHash); return Object.op_Implicit((Object)(object)prefab); } [NullableContext(1)] internal static bool TryGetPrefabName([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] GameObject go, out string prefabName) { prefabName = string.Empty; if (!Object.op_Implicit((Object)(object)go)) { return false; } prefabName = Utils.GetPrefabName(((Object)go).name); return !string.IsNullOrWhiteSpace(prefabName); } [NullableContext(1)] internal static bool TryGetDropPrefabName([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] ItemData item, out string prefabName) { prefabName = string.Empty; if (item == null) { return false; } GameObject dropPrefab = item.m_dropPrefab; if (!Object.op_Implicit((Object)(object)dropPrefab)) { return false; } return TryGetPrefabName(dropPrefab, out prefabName); } internal static bool TryGetZNetView(Component component, out ZNetView nview) { nview = null; if (!Object.op_Implicit((Object)(object)component)) { return false; } nview = component.GetComponent(); return (Object)(object)nview != (Object)null && nview.IsValid(); } internal static bool TryGetZdo(Component component, out ZDO zdo) { zdo = null; if (!TryGetZNetView(component, out var nview)) { return false; } zdo = nview.GetZDO(); return zdo != null; } [NullableContext(1)] internal static bool TryGetPrefabNameFromZdo([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] Component component, out string prefabName) { prefabName = string.Empty; if (!TryGetZdo(component, out var zdo)) { return false; } int prefab = zdo.GetPrefab(); if (!TryGetPrefabByHash(prefab, out var prefab2)) { return false; } prefabName = ((Object)prefab2).name; return !string.IsNullOrWhiteSpace(prefabName); } } } namespace StatusEffectManager { [PublicAPI] [Description("The ItemDrop effect to apply the status effect")] public enum EffectType { Equip, Attack, Consume, Set } public struct SE_Item { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] public StatusEffect Effect; public EffectType Type; } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [PublicAPI] public class CustomSE { private static readonly List RegisteredEffects = new List(); private static readonly Dictionary CustomEffectMap = new Dictionary(); internal static readonly List CustomSEs = new List(); internal static readonly Dictionary AddToPrefabs = new Dictionary(); [Description("Instance of the StatusEffect.")] public readonly StatusEffect Effect; public EffectType Type; private string _folderName = "icons"; private AssetBundle _assetBundle = null; [Description("Sets the icon for the StatusEffect. Must be 64x64")] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] public Sprite IconSprite = null; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private string IconName = null; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private LocalizeKey _name; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static Localization _english; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static BaseUnityPlugin _plugin; private static bool hasConfigSync = true; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static object _configSync; [Description("Sets the icon for the StatusEffect. Must be 64x64")] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] public string Icon { [NullableContext(2)] get { return IconName; } [NullableContext(2)] set { IconName = value; IconSprite = ((IconName == null) ? null : loadSprite(IconName)); Effect.m_icon = IconSprite; } } [Description("Sets the in-game name for the StatusEffect")] public LocalizeKey Name { get { LocalizeKey name = _name; if (name != null) { return name; } StatusEffect effect = Effect; if (effect.m_name.StartsWith("$")) { _name = new LocalizeKey(effect.m_name); } else { string text = "$statuseffect_" + ((Object)Effect).name.Replace(" ", "_"); _name = new LocalizeKey(text).English(effect.m_name); effect.m_name = text; } return _name; } } 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 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([NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static object configSync { [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 + " ItemManager"); type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString()); type.GetProperty("IsLocked").SetValue(_configSync, true); } else { hasConfigSync = false; } } return _configSync; } } public CustomSE(string assetBundleFileName, string customEffectName, string folderName = "assets") : this(EffectManager.RegisterAssetBundle(assetBundleFileName, folderName), customEffectName) { } public CustomSE(AssetBundle bundle, string customEffectName) { Effect = EffectManager.RegisterCustomSE(bundle, customEffectName); RegisteredEffects.Add(this); CustomEffectMap[Effect] = this; } public CustomSE(string customEffectName) { Effect = ScriptableObject.CreateInstance(); EffectManager.RegisterCustomSE(Effect, customEffectName); RegisteredEffects.Add(this); CustomEffectMap[Effect] = this; } private Sprite loadSprite(string name) { AssetBundle assetBundle = _assetBundle; Sprite val = ((assetBundle != null) ? assetBundle.LoadAsset(name) : null); if (val != null) { return val; } throw new FileNotFoundException("Could not find a file named " + name + " for the effect icon"); } public void AddSEToPrefab(CustomSE customSE, string prefabName) { SE_Item sE_Item = default(SE_Item); sE_Item.Effect = customSE.Effect; sE_Item.Type = customSE.Type; SE_Item key = sE_Item; AddToPrefabs.Add(key, prefabName); } private static ConfigEntry config<[<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] T>(string group, string name, T value, ConfigDescription description) { ConfigEntry val = plugin.Config.Bind(group, name, value, description); configSync?.GetType().GetMethod("AddConfigEntry").MakeGenericMethod(typeof(T)) .Invoke(configSync, new object[1] { val }); return val; } private static ConfigEntry config<[<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>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 config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty())); } } [PublicAPI] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] public class LocalizeKey { private static readonly List keys = new List(); public readonly string Key; public readonly Dictionary Localizations = new Dictionary(); 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)); } } } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public static class LocalizationCache { private static readonly Dictionary localizations = new Dictionary(); internal static void LocalizationPostfix(Localization __instance, string language) { string key = localizations.FirstOrDefault([NullableContext(0)] (KeyValuePair l) => l.Value == __instance).Key; if (key != null) { localizations.Remove(key); } if (!localizations.ContainsKey(language)) { localizations.Add(language, __instance); } } public static Localization ForLanguage([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>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; } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public static class EffectManager { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private struct BundleId { [UsedImplicitly] public string assetBundleFileName; [UsedImplicitly] public string folderName; } private static readonly Dictionary bundleCache; static EffectManager() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown bundleCache = new Dictionary(); Harmony val = new Harmony("org.bepinex.helpers.StatusEffectManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(EffectManager), "Patch_ObjectDBInit", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(EffectManager), "Patch_ZNetSceneAwake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(LocalizeKey), "AddLocalizedKeys", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(LocalizationCache), "LocalizationPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static AssetBundle RegisterAssetBundle(string assetBundleFileName, string folderName = "assets") { BundleId bundleId = default(BundleId); bundleId.assetBundleFileName = assetBundleFileName; bundleId.folderName = folderName; BundleId key = bundleId; if (!bundleCache.TryGetValue(key, out var value)) { Dictionary dictionary = bundleCache; AssetBundle? obj = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)([NullableContext(0)] (AssetBundle a) => ((Object)a).name == assetBundleFileName)) ?? AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + ((folderName == "") ? "" : ".") + folderName + "." + assetBundleFileName)); AssetBundle result = obj; dictionary[key] = obj; return result; } return value; } public static StatusEffect RegisterCustomSE(string assetBundleFileName, string customEffectName, string folderName = "assets") { return RegisterCustomSE(RegisterAssetBundle(assetBundleFileName, folderName), customEffectName); } public static StatusEffect RegisterCustomSE(AssetBundle assets, string customEffectName) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown StatusEffect val = (StatusEffect)assets.LoadAsset(customEffectName); CustomSE.CustomSEs.Add(val); return val; } public static StatusEffect RegisterCustomSE(StatusEffect customSE, string customEffectName) { ((Object)customSE).name = customEffectName; CustomSE.CustomSEs.Add(customSE); return customSE; } [HarmonyPriority(700)] private static void Patch_ObjectDBInit(ObjectDB __instance) { foreach (StatusEffect customSE in CustomSE.CustomSEs) { if (!__instance.m_StatusEffects.Contains(customSE)) { __instance.m_StatusEffects.Add(customSE); } } __instance.UpdateRegisters(); } [HarmonyPriority(700)] private static void Patch_ZNetSceneAwake(ZNetScene __instance) { foreach (KeyValuePair addToPrefab in CustomSE.AddToPrefabs) { try { GameObject prefab = __instance.GetPrefab(addToPrefab.Value); ItemDrop val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent() : prefab.GetComponentInChildren()); Aoe val2 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent() : prefab.GetComponentInChildren()); EffectArea val3 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent() : prefab.GetComponentInChildren()); if (Object.op_Implicit((Object)(object)val)) { switch (addToPrefab.Key.Type) { case EffectType.Equip: val.m_itemData.m_shared.m_equipStatusEffect = addToPrefab.Key.Effect; break; case EffectType.Attack: val.m_itemData.m_shared.m_attackStatusEffect = addToPrefab.Key.Effect; break; case EffectType.Consume: val.m_itemData.m_shared.m_consumeStatusEffect = addToPrefab.Key.Effect; break; case EffectType.Set: val.m_itemData.m_shared.m_setSize = 1; val.m_itemData.m_shared.m_setName = ((Object)addToPrefab.Key.Effect).name; val.m_itemData.m_shared.m_setStatusEffect = addToPrefab.Key.Effect; break; default: throw new ArgumentOutOfRangeException(); } } else if (Object.op_Implicit((Object)(object)val2)) { val2.m_statusEffect = ((Object)addToPrefab.Key.Effect).name; } else if (Object.op_Implicit((Object)(object)val3)) { val3.m_statusEffect = ((Object)addToPrefab.Key.Effect).name; } else { Debug.LogWarning((object)("The prefab '" + ((Object)prefab).name + "' does not have an ItemDrop, AOE, or EffectArea component. Cannot add the StatusEffect to the prefab.")); } } catch (Exception arg) { Debug.LogWarning((object)$"BROKE : {arg}"); } } } } public static class StatusEffectManagerVersion { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] public const string Version = "1.0.0"; } } namespace PieceManager { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [PublicAPI] [NullableContext(1)] public static class MaterialReplacer { [NullableContext(0)] public enum ShaderType { PieceShader, VegetationShader, RockShader, RugShader, GrassShader, CustomCreature, UseUnityShader } private static readonly Dictionary ObjectToSwap; private static readonly Dictionary OriginalMaterials; private static readonly Dictionary ObjectsForShaderReplace; private static readonly HashSet CachedShaders; private static bool hasRun; static MaterialReplacer() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown CachedShaders = new HashSet(); hasRun = false; OriginalMaterials = new Dictionary(); ObjectToSwap = new Dictionary(); ObjectsForShaderReplace = new Dictionary(); Harmony val = new Harmony("org.bepinex.helpers.PieceManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZoneSystem), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MaterialReplacer), "ReplaceAllMaterialsWithOriginal", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MaterialReplacer), "ReplaceAllMaterialsWithOriginal", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static void RegisterGameObjectForShaderSwap(GameObject go, ShaderType type) { if (!ObjectsForShaderReplace.ContainsKey(go)) { ObjectsForShaderReplace.Add(go, type); } } public static void RegisterGameObjectForMatSwap(GameObject go, bool isJotunnMock = false) { if (!ObjectToSwap.ContainsKey(go)) { ObjectToSwap.Add(go, isJotunnMock); } } private static void GetAllMaterials() { Material[] array = Resources.FindObjectsOfTypeAll(); foreach (Material val in array) { OriginalMaterials[((Object)val).name] = val; } } [HarmonyPriority(700)] private static void ReplaceAllMaterialsWithOriginal() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)SystemInfo.graphicsDeviceType == 4 || hasRun) { return; } if (OriginalMaterials.Count == 0) { GetAllMaterials(); } foreach (KeyValuePair item in ObjectToSwap) { GameObject key = item.Key; bool value = item.Value; ProcessGameObjectMaterials(key, value); } AssetBundle[] array = Resources.FindObjectsOfTypeAll(); AssetBundle[] array2 = array; foreach (AssetBundle val in array2) { IEnumerable enumerable3; try { IEnumerable enumerable2; if (!val.isStreamedSceneAssetBundle || !Object.op_Implicit((Object)(object)val)) { IEnumerable enumerable = val.LoadAllAssets(); enumerable2 = enumerable; } else { enumerable2 = from shader in ((IEnumerable)val.GetAllAssetNames()).Select((Func)val.LoadAsset) where (Object)(object)shader != (Object)null select shader; } enumerable3 = enumerable2; } catch (Exception) { continue; } if (enumerable3 == null) { continue; } foreach (Shader item2 in enumerable3) { CachedShaders.Add(item2); } } foreach (KeyValuePair item3 in ObjectsForShaderReplace) { GameObject key2 = item3.Key; ShaderType value2 = item3.Value; ProcessGameObjectShaders(key2, value2); } hasRun = true; } private static void ProcessGameObjectMaterials(GameObject go, bool isJotunnMock) { Renderer[] componentsInChildren = go.GetComponentsInChildren(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Material[] sharedMaterials = val.sharedMaterials.Select([NullableContext(0)] (Material material) => ReplaceMaterial(material, isJotunnMock)).ToArray(); val.sharedMaterials = sharedMaterials; } } private static Material ReplaceMaterial(Material originalMaterial, bool isJotunnMock) { string text = (isJotunnMock ? "JVLmock_" : "_REPLACE_"); if (!((Object)originalMaterial).name.StartsWith(text, StringComparison.Ordinal)) { return originalMaterial; } string text2 = ((Object)originalMaterial).name.Replace(" (Instance)", "").Replace(text, ""); if (OriginalMaterials.TryGetValue(text2, out var value)) { return value; } Debug.LogWarning((object)("No suitable material found to replace: " + text2)); return originalMaterial; } private static void ProcessGameObjectShaders(GameObject go, ShaderType shaderType) { Renderer[] componentsInChildren = go.GetComponentsInChildren(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 != (Object)null) { val2.shader = GetShaderForType(val2.shader, shaderType, ((Object)val2.shader).name); } } } } private static Shader GetShaderForType(Shader orig, ShaderType shaderType, string originalShaderName) { return (Shader)(shaderType switch { ShaderType.PieceShader => FindShaderWithName(orig, "Custom/Piece"), ShaderType.VegetationShader => FindShaderWithName(orig, "Custom/Vegetation"), ShaderType.RockShader => FindShaderWithName(orig, "Custom/StaticRock"), ShaderType.RugShader => FindShaderWithName(orig, "Custom/Rug"), ShaderType.GrassShader => FindShaderWithName(orig, "Custom/Grass"), ShaderType.CustomCreature => FindShaderWithName(orig, "Custom/Creature"), ShaderType.UseUnityShader => FindShaderWithName(orig, ((Object)(object)FindShaderWithName(orig, originalShaderName) != (Object)null) ? originalShaderName : "ToonDeferredShading2017"), _ => FindShaderWithName(orig, "Standard"), }); } public static Shader FindShaderWithName(Shader origShader, string name) { foreach (Shader cachedShader in CachedShaders) { if (((Object)cachedShader).name == name) { return cachedShader; } } return origShader; } } [PublicAPI] public enum CraftingTable { None, [InternalName("piece_workbench")] Workbench, [InternalName("piece_cauldron")] Cauldron, [InternalName("forge")] Forge, [InternalName("piece_artisanstation")] ArtisanTable, [InternalName("piece_stonecutter")] StoneCutter, [InternalName("piece_magetable")] MageTable, [InternalName("blackforge")] BlackForge, [InternalName("piece_preptable")] FoodPreparationTable, [InternalName("piece_MeadCauldron")] MeadKetill, Custom } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public class InternalName : Attribute { public readonly string internalName; public InternalName(string internalName) { this.internalName = internalName; } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [PublicAPI] public class ExtensionList { public readonly List ExtensionStations = new List(); public void Set(CraftingTable table, int maxStationDistance = 5) { ExtensionStations.Add(new ExtensionConfig { Table = table, maxStationDistance = maxStationDistance }); } public void Set(string customTable, int maxStationDistance = 5) { ExtensionStations.Add(new ExtensionConfig { Table = CraftingTable.Custom, custom = customTable, maxStationDistance = maxStationDistance }); } } public struct ExtensionConfig { public CraftingTable Table; public float maxStationDistance; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] public string custom; } [PublicAPI] [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public class CraftingStationList { public readonly List Stations = new List(); public void Set(CraftingTable table) { Stations.Add(new CraftingStationConfig { Table = table }); } public void Set(string customTable) { Stations.Add(new CraftingStationConfig { Table = CraftingTable.Custom, custom = customTable }); } } public struct CraftingStationConfig { public CraftingTable Table; public int level; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] public string custom; } [PublicAPI] public enum BuildPieceCategory { Misc = 0, Crafting = 1, BuildingWorkbench = 2, BuildingStonecutter = 3, Furniture = 4, All = 100, Custom = 99 } [NullableContext(1)] [PublicAPI] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public class RequiredResourcesList { public readonly List Requirements = new List(); public void Add(string item, int amount, bool recover) { Requirements.Add(new Requirement { itemName = item, amount = amount, recover = recover }); } } public struct Requirement { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] public string itemName; public int amount; public bool recover; } public struct SpecialProperties { [Description("Admins should be the only ones that can build this piece.")] public bool AdminOnly; [Description("Turns off generating a config for this build piece.")] public bool NoConfig; } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [PublicAPI] public class BuildingPieceCategory { public BuildPieceCategory Category; public string custom = ""; public void Set(BuildPieceCategory category) { Category = category; } public void Set(string customCategory) { Category = BuildPieceCategory.Custom; custom = customCategory; } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [PublicAPI] public class PieceTool { public readonly HashSet Tools = new HashSet(); public void Add(string tool) { Tools.Add(tool); } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [PublicAPI] public class BuildPiece { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal class PieceConfig { public ConfigEntry craft = null; public ConfigEntry category = null; public ConfigEntry customCategory = null; public ConfigEntry tools = null; public ConfigEntry extensionTable = null; public ConfigEntry customExtentionTable = null; public ConfigEntry maxStationDistance = null; public ConfigEntry table = null; public ConfigEntry customTable = null; } [NullableContext(0)] private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] [UsedImplicitly] public string Category; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 2, 1 })] [UsedImplicitly] public Action CustomDrawer; } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private class SerializedRequirements { public readonly List Reqs; public SerializedRequirements(List reqs) { Reqs = reqs; } public SerializedRequirements(string reqs) { Reqs = reqs.Split(new char[1] { ',' }).Select([NullableContext(0)] (string r) => { string[] array = r.Split(new char[1] { ':' }); Requirement result = default(Requirement); result.itemName = array[0]; result.amount = ((array.Length <= 1 || !int.TryParse(array[1], out var result2)) ? 1 : result2); bool result3 = default(bool); result.recover = array.Length <= 2 || !bool.TryParse(array[2], out result3) || result3; return result; }).ToList(); } public override string ToString() { return string.Join(",", Reqs.Select([NullableContext(0)] (Requirement r) => $"{r.itemName}:{r.amount}:{r.recover}")); } [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] public static ItemDrop fetchByName(ObjectDB objectDB, string name) { GameObject itemPrefab = objectDB.GetItemPrefab(name); ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent() : null); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)(((!string.IsNullOrWhiteSpace(((Object)plugin).name)) ? ("[" + ((Object)plugin).name + "]") : "") + " The required item '" + name + "' does not exist.")); } return val; } public static Requirement[] toPieceReqs(SerializedRequirements craft) { Dictionary dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func)([NullableContext(0)] (Requirement r) => r.itemName), (Func)([NullableContext(0)] (Requirement r) => { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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) //IL_0025: Unknown result type (might be due to invalid IL or missing references) ItemDrop val = ResItem(r); return (val == null) ? ((Requirement)null) : new Requirement { m_amount = r.amount, m_resItem = val, m_recover = r.recover }; })); return dictionary.Values.Where([NullableContext(0)] (Requirement v) => v != null).ToArray(); [NullableContext(2)] static ItemDrop ResItem(Requirement r) { return fetchByName(ObjectDB.instance, r.itemName); } } } internal static readonly List registeredPieces = new List(); private static readonly Dictionary pieceMap = new Dictionary(); internal static Dictionary pieceConfigs = new Dictionary(); internal List Conversions = new List(); internal List conversions = new List(); [Description("Disables generation of the configs for your pieces. This is global, this turns it off for all pieces in your mod.")] public static bool ConfigurationEnabled = true; public readonly GameObject Prefab; [Description("Specifies the resources needed to craft the piece.\nUse .Add to add resources with their internal ID and an amount.\nUse one .Add for each resource type the building piece should need.")] public readonly RequiredResourcesList RequiredItems = new RequiredResourcesList(); [Description("Sets the category for the building piece.")] public readonly BuildingPieceCategory Category = new BuildingPieceCategory(); [Description("Specifies the tool needed to build your piece.\nUse .Add to add a tool.")] public readonly PieceTool Tool = new PieceTool(); [Description("Specifies the crafting station needed to build your piece.\nUse .Add to add a crafting station, using the CraftingTable enum and a minimum level for the crafting station.")] public CraftingStationList Crafting = new CraftingStationList(); [Description("Makes this piece a station extension")] public ExtensionList Extension = new ExtensionList(); [Description("Change the extended/special properties of your build piece.")] public SpecialProperties SpecialProperties; [Description("Specifies a config entry which toggles whether a recipe is active.")] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] public ConfigEntryBase RecipeIsActive = null; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private LocalizeKey _name; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private LocalizeKey _description; internal string[] activeTools = null; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static object configManager; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static Localization _english; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] internal static BaseUnityPlugin _plugin = null; private static bool hasConfigSync = true; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static object _configSync; public LocalizeKey Name { get { LocalizeKey name = _name; if (name != null) { return name; } Piece component = Prefab.GetComponent(); if (component.m_name.StartsWith("$")) { _name = new LocalizeKey(component.m_name); } else { string text = "$piece_" + ((Object)Prefab).name.Replace(" ", "_"); _name = new LocalizeKey(text).English(component.m_name); component.m_name = text; } return _name; } } public LocalizeKey Description { get { LocalizeKey description = _description; if (description != null) { return description; } Piece component = Prefab.GetComponent(); if (component.m_description.StartsWith("$")) { _description = new LocalizeKey(component.m_description); } else { string text = "$piece_" + ((Object)Prefab).name.Replace(" ", "_") + "_description"; _description = new LocalizeKey(text).English(component.m_description); component.m_description = text; } return _description; } } private static Localization english => _english ?? (_english = LocalizationCache.ForLanguage("English")); internal static BaseUnityPlugin plugin { get { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown if (_plugin != null) { return _plugin; } IEnumerable 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([NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); return _plugin; } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static object configSync { [NullableContext(2)] get { if (_configSync != null || !hasConfigSync) { return _configSync; } Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync"); if ((object)type != null) { _configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " PieceManager"); type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString()); type.GetProperty("IsLocked").SetValue(_configSync, true); } else { hasConfigSync = false; } return _configSync; } } public BuildPiece(string assetBundleFileName, string prefabName, string folderName = "assets") : this(PiecePrefabManager.RegisterAssetBundle(assetBundleFileName, folderName), prefabName) { } public BuildPiece(AssetBundle bundle, string prefabName) { Prefab = PiecePrefabManager.RegisterPrefab(bundle, prefabName); registeredPieces.Add(this); } internal static void Patch_FejdStartup(FejdStartup __instance) { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Expected O, but got Unknown //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Expected O, but got Unknown //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Expected O, but got Unknown //IL_08ea: Unknown result type (might be due to invalid IL or missing references) //IL_08f4: Expected O, but got Unknown //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_0685: Expected O, but got Unknown //IL_0721: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Expected O, but got Unknown //IL_095f: Unknown result type (might be due to invalid IL or missing references) //IL_0969: Expected O, but got Unknown //IL_0b7e: Unknown result type (might be due to invalid IL or missing references) //IL_0b88: Expected O, but got Unknown //IL_0c18: Unknown result type (might be due to invalid IL or missing references) //IL_0c22: Expected O, but got Unknown Type configManagerType = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([NullableContext(0)] (Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager"); configManager = ((configManagerType == null) ? null : Chainloader.ManagerObject.GetComponent(configManagerType)); foreach (BuildPiece registeredPiece in registeredPieces) { registeredPiece.activeTools = registeredPiece.Tool.Tools.DefaultIfEmpty("Hammer").ToArray(); if (registeredPiece.Category.Category != BuildPieceCategory.Custom) { registeredPiece.Prefab.GetComponent().m_category = (PieceCategory)registeredPiece.Category.Category; } else { registeredPiece.Prefab.GetComponent().m_category = PiecePrefabManager.GetCategory(registeredPiece.Category.custom); } } if (!ConfigurationEnabled) { return; } bool saveOnConfigSet = plugin.Config.SaveOnConfigSet; plugin.Config.SaveOnConfigSet = false; foreach (BuildPiece registeredPiece2 in registeredPieces) { BuildPiece piece = registeredPiece2; if (piece.SpecialProperties.NoConfig) { continue; } PieceConfig pieceConfig2 = (pieceConfigs[piece] = new PieceConfig()); PieceConfig cfg = pieceConfig2; Piece piecePrefab2 = piece.Prefab.GetComponent(); string pieceName = piecePrefab2.m_name; string englishName = new Regex("[=\\n\\t\\\\\"\\'\\[\\]]*").Replace(english.Localize(pieceName), "").Trim(); string localizedName = Localization.instance.Localize(pieceName).Trim(); int order = 0; cfg.category = config(englishName, "Build Table Category", piece.Category.Category, new ConfigDescription("Build Category where " + localizedName + " is available.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Category = localizedName } })); ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), Browsable = (cfg.category.Value == BuildPieceCategory.Custom), Category = localizedName }; cfg.customCategory = config(englishName, "Custom Build Category", piece.Category.custom, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes })); cfg.category.SettingChanged += BuildTableConfigChanged; cfg.customCategory.SettingChanged += BuildTableConfigChanged; if (cfg.category.Value == BuildPieceCategory.Custom) { piecePrefab2.m_category = PiecePrefabManager.GetCategory(cfg.customCategory.Value); } else { piecePrefab2.m_category = (PieceCategory)cfg.category.Value; } cfg.tools = config(englishName, "Tools", string.Join(", ", piece.activeTools), new ConfigDescription("Comma separated list of tools where " + localizedName + " is available.", (AcceptableValueBase)null, new object[1] { customTableAttributes })); piece.activeTools = (from s in cfg.tools.Value.Split(new char[1] { ',' }) select s.Trim()).ToArray(); cfg.tools.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { Inventory[] source = (from c in Player.s_players.Select([NullableContext(0)] (Player p) => ((Humanoid)p).GetInventory()).Concat(from c in Object.FindObjectsOfType() select c.GetInventory()) where c != null select c).ToArray(); Dictionary> dictionary = (from kv in (from i in (from p in ObjectDB.instance.m_items select p.GetComponent() into c where Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)((Component)c).GetComponent()) select c).Concat(ItemDrop.s_instances) select new KeyValuePair(Utils.GetPrefabName(((Component)i).gameObject), i.m_itemData)).Concat(from i in source.SelectMany([NullableContext(0)] (Inventory i) => i.GetAllItems()) select new KeyValuePair(((Object)i.m_dropPrefab).name, i)) where Object.op_Implicit((Object)(object)kv.Value.m_shared.m_buildPieces) group kv by kv.Key).ToDictionary([NullableContext(0)] (IGrouping> g) => g.Key, [NullableContext(0)] (IGrouping> g) => g.Select([NullableContext(0)] (KeyValuePair kv) => kv.Value.m_shared.m_buildPieces).Distinct().ToList()); string[] array5 = piece.activeTools; foreach (string key in array5) { if (dictionary.TryGetValue(key, out var value3)) { foreach (PieceTable item3 in value3) { item3.m_pieces.Remove(piece.Prefab); } } } piece.activeTools = (from s in cfg.tools.Value.Split(new char[1] { ',' }) select s.Trim()).ToArray(); if (Object.op_Implicit((Object)(object)ObjectDB.instance)) { string[] array6 = piece.activeTools; foreach (string key2 in array6) { if (dictionary.TryGetValue(key2, out var value4)) { foreach (PieceTable item4 in value4) { if (!item4.m_pieces.Contains(piece.Prefab)) { item4.m_pieces.Add(piece.Prefab); } } } } if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)Player.m_localPlayer.m_buildPieces)) { PiecePrefabManager.CategoryRefreshNeeded = true; ((Humanoid)Player.m_localPlayer).SetPlaceMode(Player.m_localPlayer.m_buildPieces); } } }; StationExtension pieceExtensionComp; List hideWhenNoneAttributes2; if (piece.Extension.ExtensionStations.Count > 0) { pieceExtensionComp = piece.Prefab.GetOrAddComponent(); PieceConfig pieceConfig3 = cfg; string group = englishName; CraftingTable table = piece.Extension.ExtensionStations.First().Table; string text = "Crafting station that " + localizedName + " extends."; object[] array = new object[1]; ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes(); int num = order - 1; order = num; configurationManagerAttributes.Order = num; array[0] = configurationManagerAttributes; pieceConfig3.extensionTable = config(group, "Extends Station", table, new ConfigDescription(text, (AcceptableValueBase)null, array)); cfg.customExtentionTable = config(englishName, "Custom Extend Station", piece.Extension.ExtensionStations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes })); PieceConfig pieceConfig4 = cfg; string group2 = englishName; float maxStationDistance = piece.Extension.ExtensionStations.First().maxStationDistance; string text2 = "Distance from the station that " + localizedName + " can be placed."; object[] array2 = new object[1]; ConfigurationManagerAttributes configurationManagerAttributes2 = new ConfigurationManagerAttributes(); num = order - 1; order = num; configurationManagerAttributes2.Order = num; array2[0] = configurationManagerAttributes2; pieceConfig4.maxStationDistance = config(group2, "Max Station Distance", maxStationDistance, new ConfigDescription(text2, (AcceptableValueBase)null, array2)); hideWhenNoneAttributes2 = new List(); cfg.extensionTable.SettingChanged += ExtensionTableConfigChanged; cfg.customExtentionTable.SettingChanged += ExtensionTableConfigChanged; cfg.maxStationDistance.SettingChanged += ExtensionTableConfigChanged; ConfigurationManagerAttributes configurationManagerAttributes3 = new ConfigurationManagerAttributes(); num = order - 1; order = num; configurationManagerAttributes3.Order = num; configurationManagerAttributes3.Browsable = cfg.extensionTable.Value != CraftingTable.None; ConfigurationManagerAttributes item = configurationManagerAttributes3; hideWhenNoneAttributes2.Add(item); } List hideWhenNoneAttributes; if (piece.Crafting.Stations.Count > 0) { hideWhenNoneAttributes = new List(); PieceConfig pieceConfig5 = cfg; string group3 = englishName; CraftingTable table2 = piece.Crafting.Stations.First().Table; string text3 = "Crafting station where " + localizedName + " is available."; object[] array3 = new object[1]; ConfigurationManagerAttributes configurationManagerAttributes4 = new ConfigurationManagerAttributes(); int num = order - 1; order = num; configurationManagerAttributes4.Order = num; array3[0] = configurationManagerAttributes4; pieceConfig5.table = config(group3, "Crafting Station", table2, new ConfigDescription(text3, (AcceptableValueBase)null, array3)); cfg.customTable = config(englishName, "Custom Crafting Station", piece.Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes })); cfg.table.SettingChanged += TableConfigChanged; cfg.customTable.SettingChanged += TableConfigChanged; ConfigurationManagerAttributes configurationManagerAttributes5 = new ConfigurationManagerAttributes(); num = order - 1; order = num; configurationManagerAttributes5.Order = num; configurationManagerAttributes5.Browsable = cfg.table.Value != CraftingTable.None; ConfigurationManagerAttributes item2 = configurationManagerAttributes5; hideWhenNoneAttributes.Add(item2); } cfg.craft = itemConfig("Crafting Costs", new SerializedRequirements(piece.RequiredItems.Requirements).ToString(), "Item costs to craft " + localizedName); cfg.craft.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && (Object)(object)ObjectDB.instance.GetItemPrefab("YmirRemains") != (Object)null) { Requirement[] resources = SerializedRequirements.toPieceReqs(new SerializedRequirements(cfg.craft.Value)); piecePrefab2.m_resources = resources; Piece[] array4 = Object.FindObjectsOfType(); foreach (Piece val in array4) { if (val.m_name == pieceName) { val.m_resources = resources; } } } }; for (int j = 0; j < piece.Conversions.Count; j++) { string text4 = ((piece.Conversions.Count > 1) ? $"{j + 1}. " : ""); Conversion conversion = piece.Conversions[j]; conversion.config = new Conversion.ConversionConfig(); int index = j; conversion.config.input = config(englishName, text4 + "Conversion Input Item", conversion.Input, new ConfigDescription("Conversion input item within " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName } })); conversion.config.input.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { if (index < piece.conversions.Count) { ObjectDB instance2 = ObjectDB.instance; if (instance2 != null) { ItemDrop from = SerializedRequirements.fetchByName(instance2, conversion.config.input.Value); piece.conversions[index].m_from = from; } } }; conversion.config.output = config(englishName, text4 + "Conversion Output Item", conversion.Output, new ConfigDescription("Conversion output item within " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName } })); conversion.config.output.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { if (index < piece.conversions.Count) { ObjectDB instance = ObjectDB.instance; if (instance != null) { ItemDrop to = SerializedRequirements.fetchByName(instance, conversion.config.output.Value); piece.conversions[index].m_to = to; } } }; } void BuildTableConfigChanged(object o, EventArgs e) { //IL_0066: 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) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (registeredPieces.Count > 0) { if (cfg.category.Value == BuildPieceCategory.Custom) { piecePrefab2.m_category = PiecePrefabManager.GetCategory(cfg.customCategory.Value); } else { piecePrefab2.m_category = (PieceCategory)cfg.category.Value; } if (Object.op_Implicit((Object)(object)Hud.instance)) { PiecePrefabManager.CategoryRefreshNeeded = true; PiecePrefabManager.CreateCategoryTabs(); } } customTableAttributes.Browsable = cfg.category.Value == BuildPieceCategory.Custom; ReloadConfigDisplay(); } void ExtensionTableConfigChanged(object o, EventArgs e) { if (piece.RequiredItems.Requirements.Count > 0) { CraftingTable value2 = cfg.extensionTable.Value; CraftingTable craftingTable = value2; if (craftingTable == CraftingTable.Custom) { StationExtension obj2 = pieceExtensionComp; GameObject prefab2 = ZNetScene.instance.GetPrefab(cfg.customExtentionTable.Value); obj2.m_craftingStation = ((prefab2 != null) ? prefab2.GetComponent() : null); } else { pieceExtensionComp.m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(cfg.extensionTable.Value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent(); } pieceExtensionComp.m_maxStationDistance = cfg.maxStationDistance.Value; } customTableAttributes.Browsable = cfg.extensionTable.Value == CraftingTable.Custom; foreach (ConfigurationManagerAttributes item5 in hideWhenNoneAttributes2) { item5.Browsable = cfg.extensionTable.Value != CraftingTable.None; } ReloadConfigDisplay(); plugin.Config.Save(); } void TableConfigChanged(object o, EventArgs e) { if (piece.RequiredItems.Requirements.Count > 0) { switch (cfg.table.Value) { case CraftingTable.None: piecePrefab2.m_craftingStation = null; break; case CraftingTable.Custom: { Piece obj = piecePrefab2; GameObject prefab = ZNetScene.instance.GetPrefab(cfg.customTable.Value); obj.m_craftingStation = ((prefab != null) ? prefab.GetComponent() : null); break; } default: piecePrefab2.m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(cfg.table.Value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent(); break; } } customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom; foreach (ConfigurationManagerAttributes item6 in hideWhenNoneAttributes) { item6.Browsable = cfg.table.Value != CraftingTable.None; } ReloadConfigDisplay(); plugin.Config.Save(); } ConfigEntry itemConfig(string name, string value, string desc) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes6 = new ConfigurationManagerAttributes { CustomDrawer = DrawConfigTable, Order = (order -= 1), Category = localizedName }; return config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes6 })); } } foreach (BuildPiece registeredPiece3 in registeredPieces) { ConfigEntryBase enabledCfg = registeredPiece3.RecipeIsActive; Piece piecePrefab; if (enabledCfg != null) { piecePrefab = registeredPiece3.Prefab.GetComponent(); ConfigChanged(null, null); ((object)enabledCfg).GetType().GetEvent("SettingChanged").AddEventHandler(enabledCfg, new EventHandler(ConfigChanged)); } registeredPiece3.InitializeNewRegisteredPiece(registeredPiece3); [NullableContext(2)] void ConfigChanged(object o, EventArgs e) { piecePrefab.m_enabled = (int)enabledCfg.BoxedValue != 0; } } if (saveOnConfigSet) { plugin.Config.SaveOnConfigSet = true; plugin.Config.Save(); } void ReloadConfigDisplay() { object obj3 = configManagerType?.GetProperty("DisplayingWindow").GetValue(configManager); if (obj3 is bool && (bool)obj3) { configManagerType.GetMethod("BuildSettingList").Invoke(configManager, Array.Empty()); } } } private void InitializeNewRegisteredPiece(BuildPiece piece) { ConfigEntryBase recipeIsActive = piece.RecipeIsActive; PieceConfig cfg; Piece piecePrefab; string pieceName; if (recipeIsActive != null) { pieceConfigs.TryGetValue(piece, out cfg); piecePrefab = piece.Prefab.GetComponent(); pieceName = piecePrefab.m_name; ((object)recipeIsActive).GetType().GetEvent("SettingChanged").AddEventHandler(recipeIsActive, new EventHandler(ConfigChanged)); } void ConfigChanged(object o, EventArgs e) { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && (Object)(object)ObjectDB.instance.GetItemPrefab("YmirRemains") != (Object)null && cfg != null) { Requirement[] resources = SerializedRequirements.toPieceReqs(new SerializedRequirements(cfg.craft.Value)); piecePrefab.m_resources = resources; Piece[] array = Object.FindObjectsOfType(); foreach (Piece val in array) { if (val.m_name == pieceName) { val.m_resources = resources; } } } } } [HarmonyPriority(700)] internal static void Patch_ObjectDBInit(ObjectDB __instance) { //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Expected O, but got Unknown if ((Object)(object)__instance.GetItemPrefab("YmirRemains") == (Object)null) { return; } foreach (BuildPiece registeredPiece in registeredPieces) { pieceConfigs.TryGetValue(registeredPiece, out var value); registeredPiece.Prefab.GetComponent().m_resources = SerializedRequirements.toPieceReqs((value == null) ? new SerializedRequirements(registeredPiece.RequiredItems.Requirements) : new SerializedRequirements(value.craft.Value)); foreach (ExtensionConfig extensionStation in registeredPiece.Extension.ExtensionStations) { switch ((value == null || registeredPiece.Extension.ExtensionStations.Count > 1) ? extensionStation.Table : value.extensionTable.Value) { case CraftingTable.None: registeredPiece.Prefab.GetComponent().m_craftingStation = null; break; case CraftingTable.Custom: { GameObject prefab = ZNetScene.instance.GetPrefab((value == null || registeredPiece.Extension.ExtensionStations.Count > 0) ? extensionStation.custom : value.customExtentionTable.Value); if (prefab != null) { registeredPiece.Prefab.GetComponent().m_craftingStation = prefab.GetComponent(); } else { Debug.LogWarning((object)("Custom crafting station '" + ((value == null || registeredPiece.Extension.ExtensionStations.Count > 0) ? extensionStation.custom : value.customExtentionTable.Value) + "' does not exist")); } break; } default: if (value != null && value.table.Value == CraftingTable.None) { registeredPiece.Prefab.GetComponent().m_craftingStation = null; } else { registeredPiece.Prefab.GetComponent().m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(((value == null || registeredPiece.Extension.ExtensionStations.Count > 1) ? extensionStation.Table : value.extensionTable.Value).ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent(); } break; } } foreach (CraftingStationConfig station in registeredPiece.Crafting.Stations) { switch ((value == null || registeredPiece.Crafting.Stations.Count > 1) ? station.Table : value.table.Value) { case CraftingTable.None: registeredPiece.Prefab.GetComponent().m_craftingStation = null; break; case CraftingTable.Custom: { GameObject prefab2 = ZNetScene.instance.GetPrefab((value == null || registeredPiece.Crafting.Stations.Count > 0) ? station.custom : value.customTable.Value); if (prefab2 != null) { registeredPiece.Prefab.GetComponent().m_craftingStation = prefab2.GetComponent(); } else { Debug.LogWarning((object)("Custom crafting station '" + ((value == null || registeredPiece.Crafting.Stations.Count > 0) ? station.custom : value.customTable.Value) + "' does not exist")); } break; } default: if (value != null && value.table.Value == CraftingTable.None) { registeredPiece.Prefab.GetComponent().m_craftingStation = null; } else { registeredPiece.Prefab.GetComponent().m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(((value == null || registeredPiece.Crafting.Stations.Count > 1) ? station.Table : value.table.Value).ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent(); } break; } } registeredPiece.conversions = new List(); for (int i = 0; i < registeredPiece.Conversions.Count; i++) { Conversion conversion = registeredPiece.Conversions[i]; registeredPiece.conversions.Add(new ItemConversion { m_from = SerializedRequirements.fetchByName(ObjectDB.instance, conversion.config?.input.Value ?? conversion.Input), m_to = SerializedRequirements.fetchByName(ObjectDB.instance, conversion.config?.output.Value ?? conversion.Output) }); if (registeredPiece.conversions[i].m_from != null && registeredPiece.conversions[i].m_to != null) { registeredPiece.Prefab.GetComponent().m_conversion.Add(registeredPiece.conversions[i]); } } } } public void Snapshot(float lightIntensity = 1.3f, Quaternion? cameraRotation = null) { SnapshotPiece(Prefab, lightIntensity, cameraRotation); } internal void SnapshotPiece(GameObject prefab, float lightIntensity = 1.3f, Quaternion? cameraRotation = null) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Expected O, but got Unknown //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)prefab == (Object)null) && (prefab.GetComponentsInChildren().Any() || prefab.GetComponentsInChildren().Any())) { Camera component = new GameObject("CameraIcon", new Type[1] { typeof(Camera) }).GetComponent(); component.backgroundColor = Color.clear; component.clearFlags = (CameraClearFlags)2; ((Component)component).transform.position = new Vector3(10000f, 10000f, 10000f); ((Component)component).transform.rotation = (Quaternion)(((??)cameraRotation) ?? Quaternion.Euler(0f, 180f, 0f)); component.fieldOfView = 0.5f; component.farClipPlane = 100000f; component.cullingMask = 8; Light component2 = new GameObject("LightIcon", new Type[1] { typeof(Light) }).GetComponent(); ((Component)component2).transform.position = new Vector3(10000f, 10000f, 10000f); ((Component)component2).transform.rotation = Quaternion.Euler(5f, 180f, 5f); component2.type = (LightType)1; component2.cullingMask = 8; component2.intensity = lightIntensity; GameObject val = Object.Instantiate(prefab); Transform[] componentsInChildren = val.GetComponentsInChildren(); foreach (Transform val2 in componentsInChildren) { ((Component)val2).gameObject.layer = 3; } val.transform.position = Vector3.zero; val.transform.rotation = Quaternion.Euler(23f, 51f, 25.8f); ((Object)val).name = ((Object)prefab).name; MeshRenderer[] componentsInChildren2 = val.GetComponentsInChildren(); Vector3 val3 = componentsInChildren2.Aggregate(Vector3.positiveInfinity, [NullableContext(0)] (Vector3 cur, MeshRenderer renderer) => { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Bounds bounds2 = ((Renderer)renderer).bounds; return Vector3.Min(cur, ((Bounds)(ref bounds2)).min); }); Vector3 val4 = componentsInChildren2.Aggregate(Vector3.negativeInfinity, [NullableContext(0)] (Vector3 cur, MeshRenderer renderer) => { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = ((Renderer)renderer).bounds; return Vector3.Max(cur, ((Bounds)(ref bounds)).max); }); val.transform.position = new Vector3(10000f, 10000f, 10000f) - (val3 + val4) / 2f; Vector3 val5 = val4 - val3; TimedDestruction val6 = val.AddComponent(); val6.Trigger(1f); Rect val7 = default(Rect); ((Rect)(ref val7))..ctor(0f, 0f, 128f, 128f); component.targetTexture = RenderTexture.GetTemporary((int)((Rect)(ref val7)).width, (int)((Rect)(ref val7)).height); component.fieldOfView = 20f; float num = Mathf.Max(val5.x, val5.y) + 0.1f; float num2 = num / Mathf.Tan(component.fieldOfView * ((float)Math.PI / 180f)) * 1.1f; ((Component)component).transform.position = new Vector3(10000f, 10000f, 10000f) + new Vector3(0f, 0f, num2); component.Render(); RenderTexture active = RenderTexture.active; RenderTexture.active = component.targetTexture; Texture2D val8 = new Texture2D((int)((Rect)(ref val7)).width, (int)((Rect)(ref val7)).height, (TextureFormat)4, false); val8.ReadPixels(new Rect(0f, 0f, (float)(int)((Rect)(ref val7)).width, (float)(int)((Rect)(ref val7)).height), 0, 0); val8.Apply(); RenderTexture.active = active; prefab.GetComponent().m_icon = Sprite.Create(val8, new Rect(0f, 0f, (float)(int)((Rect)(ref val7)).width, (float)(int)((Rect)(ref val7)).height), Vector2.one / 2f); ((Component)component2).gameObject.SetActive(false); component.targetTexture.Release(); ((Component)component).gameObject.SetActive(false); val.SetActive(false); Object.DestroyImmediate((Object)(object)val); Object.Destroy((Object)(object)component); Object.Destroy((Object)(object)component2); Object.Destroy((Object)(object)((Component)component).gameObject); Object.Destroy((Object)(object)((Component)component2).gameObject); } } private static void DrawConfigTable(ConfigEntryBase cfg) { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //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_017f: Expected O, but got Unknown //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_01e0: Expected O, but got Unknown //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown bool valueOrDefault = cfg.Description.Tags.Select([NullableContext(0)] (object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault(); List list = new List(); bool flag = false; int num = (int)(configManager?.GetType().GetProperty("RightColumnWidth", BindingFlags.Instance | BindingFlags.NonPublic).GetGetMethod(nonPublic: true) .Invoke(configManager, Array.Empty()) ?? ((object)130)); GUILayout.BeginVertical(Array.Empty()); foreach (Requirement req in new SerializedRequirements((string)cfg.BoxedValue).Reqs) { GUILayout.BeginHorizontal(Array.Empty()); int num2 = req.amount; if (int.TryParse(GUILayout.TextField(num2.ToString(), new GUIStyle(GUI.skin.textField) { fixedWidth = 40f }, Array.Empty()), out var result) && result != num2 && !valueOrDefault) { num2 = result; flag = true; } string text = GUILayout.TextField(req.itemName, new GUIStyle(GUI.skin.textField) { fixedWidth = num - 40 - 67 - 21 - 21 - 12 }, Array.Empty()); string text2 = (valueOrDefault ? req.itemName : text); flag = flag || text2 != req.itemName; bool flag2 = req.recover; if (GUILayout.Toggle(req.recover, "Recover", new GUIStyle(GUI.skin.toggle) { fixedWidth = 67f }, Array.Empty()) != req.recover) { flag2 = !flag2; flag = true; } if (GUILayout.Button("x", new GUIStyle(GUI.skin.button) { fixedWidth = 21f }, Array.Empty()) && !valueOrDefault) { flag = true; } else { list.Add(new Requirement { amount = num2, itemName = text2, recover = flag2 }); } if (GUILayout.Button("+", new GUIStyle(GUI.skin.button) { fixedWidth = 21f }, Array.Empty()) && !valueOrDefault) { flag = true; list.Add(new Requirement { amount = 1, itemName = "", recover = false }); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (flag) { cfg.BoxedValue = new SerializedRequirements(list).ToString(); } } private static ConfigEntry config<[<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] T>(string group, string name, T value, ConfigDescription description) { ConfigEntry val = plugin.Config.Bind(group, name, value, description); configSync?.GetType().GetMethod("AddConfigEntry").MakeGenericMethod(typeof(T)) .Invoke(configSync, new object[1] { val }); return val; } private static ConfigEntry config<[<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>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 config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty())); } } public static class GoExtensions { [NullableContext(1)] public static T GetOrAddComponent<[<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] T>(this GameObject gameObject) where T : Component { return gameObject.GetComponent() ?? gameObject.AddComponent(); } } [PublicAPI] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] public class LocalizeKey { private static readonly List keys = new List(); public readonly string Key; public readonly Dictionary Localizations = new Dictionary(); 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)); } } } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] public static class LocalizationCache { private static readonly Dictionary localizations = new Dictionary(); internal static void LocalizationPostfix(Localization __instance, string language) { string key = localizations.FirstOrDefault([NullableContext(0)] (KeyValuePair l) => l.Value == __instance).Key; if (key != null) { localizations.Remove(key); } if (!localizations.ContainsKey(language)) { localizations.Add(language, __instance); } } public static Localization ForLanguage([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>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; } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public class AdminSyncing { [CompilerGenerated] private sealed class <g__WatchAdminListChanges|2_0>d : IEnumerator, IDisposable, IEnumerator { private int <>1__state; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private object <>2__current; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 0, 1 })] private List 5__1; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 0, 1 })] private List 5__2; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 0, 1 })] private List 5__3; object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public <g__WatchAdminListChanges|2_0>d(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; if (!ZNet.instance.m_adminList.GetList().SequenceEqual(5__1)) { 5__1 = new List(ZNet.instance.m_adminList.GetList()); 5__2 = (from p in ZNet.instance.GetPeers() where ZNet.instance.ListContainsId(ZNet.instance.m_adminList, p.m_rpc.GetSocket().GetHostName()) select p).ToList(); 5__3 = ZNet.instance.GetPeers().Except(5__2).ToList(); g__SendAdmin|2_2(5__3, isAdmin: false); g__SendAdmin|2_2(5__2, isAdmin: true); 5__2 = null; 5__3 = null; } } else { <>1__state = -1; 5__1 = new List(ZNet.instance.m_adminList.GetList()); } <>2__current = (object)new WaitForSeconds(30f); <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <>c__DisplayClass3_0 { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public ZPackage package; [NullableContext(0)] internal IEnumerator b__1(ZNetPeer p) { return TellPeerAdminStatus(p, package); } } [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct <>c__DisplayClass4_0 { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public ZNetPeer peer; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public ZRoutedRpc rpc; } [CompilerGenerated] private sealed class d__4 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private bool <>2__current; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public ZNetPeer peer; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public ZPackage package; private <>c__DisplayClass4_0 <>8__1; bool IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = default(<>c__DisplayClass4_0); <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; <>8__1.peer = peer; <>8__1.rpc = ZRoutedRpc.instance; if (<>8__1.rpc == null) { return false; } g__SendPackage|4_0(package, ref <>8__1); 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(); } } [CompilerGenerated] private sealed class d__3 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private object <>2__current; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 0, 1 })] public List peers; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public ZPackage package; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private <>c__DisplayClass3_0 <>8__1; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private byte[] 5__2; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 0, 1 })] private List> 5__3; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private ZPackage 5__4; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private MemoryStream 5__5; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private DeflateStream 5__6; object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; 5__5 = null; 5__6 = null; <>1__state = -2; } private bool MoveNext() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass3_0(); <>8__1.package = package; if (!Object.op_Implicit((Object)(object)ZNet.instance)) { return false; } 5__2 = <>8__1.package.GetArray(); if (5__2 != null && 5__2.LongLength > 10000) { 5__4 = new ZPackage(); 5__4.Write(4); 5__5 = new MemoryStream(); 5__6 = new DeflateStream(5__5, CompressionLevel.Optimal); try { 5__6.Write(5__2, 0, 5__2.Length); } finally { if (5__6 != null) { ((IDisposable)5__6).Dispose(); } } 5__6 = null; 5__4.Write(5__5.ToArray()); <>8__1.package = 5__4; 5__4 = null; 5__5 = null; } 5__3 = (from peer in peers where peer.IsReady() select peer into p select TellPeerAdminStatus(p, <>8__1.package)).ToList(); 5__3.RemoveAll((IEnumerator writer) => !writer.MoveNext()); break; case 1: <>1__state = -1; 5__3.RemoveAll((IEnumerator writer) => !writer.MoveNext()); break; } if (5__3.Count > 0) { <>2__current = null; <>1__state = 1; return true; } 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(); } } private static bool isServer; internal static bool registeredOnClient; [HarmonyPriority(700)] internal static void AdminStatusSync(ZNet __instance) { isServer = __instance.IsServer(); if (BuildPiece._plugin != null) { if (isServer) { ZRoutedRpc.instance.Register(BuildPiece._plugin.Info.Metadata.Name + " PMAdminStatusSync", (Action)RPC_AdminPieceAddRemove); } else if (!registeredOnClient) { ZRoutedRpc.instance.Register(BuildPiece._plugin.Info.Metadata.Name + " PMAdminStatusSync", (Action)RPC_AdminPieceAddRemove); registeredOnClient = true; } } if (isServer) { ((MonoBehaviour)ZNet.instance).StartCoroutine(WatchAdminListChanges()); } [IteratorStateMachine(typeof(<g__WatchAdminListChanges|2_0>d))] static IEnumerator WatchAdminListChanges() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <g__WatchAdminListChanges|2_0>d(0); } } [IteratorStateMachine(typeof(d__3))] private static IEnumerator sendZPackage(List peers, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { peers = peers, package = package }; } [IteratorStateMachine(typeof(d__4))] private static IEnumerator TellPeerAdminStatus(ZNetPeer peer, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { peer = peer, package = package }; } internal static void RPC_AdminPieceAddRemove(long sender, ZPackage package) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown ZNetPeer peer = ZNet.instance.GetPeer(sender); bool flag = false; try { flag = package.ReadBool(); } catch { } if (isServer) { ZRoutedRpc instance = ZRoutedRpc.instance; long everybody = ZRoutedRpc.Everybody; BaseUnityPlugin plugin = BuildPiece._plugin; instance.InvokeRoutedRPC(everybody, ((plugin != null) ? plugin.Info.Metadata.Name : null) + " PMAdminStatusSync", new object[1] { (object)new ZPackage() }); if (ZNet.instance.ListContainsId(ZNet.instance.m_adminList, peer.m_rpc.GetSocket().GetHostName())) { ZPackage val = new ZPackage(); val.Write(true); ZRpc rpc = peer.m_rpc; BaseUnityPlugin plugin2 = BuildPiece._plugin; rpc.Invoke(((plugin2 != null) ? plugin2.Info.Metadata.Name : null) + " PMAdminStatusSync", new object[1] { val }); } return; } foreach (BuildPiece registeredPiece in BuildPiece.registeredPieces) { if (!registeredPiece.SpecialProperties.AdminOnly) { continue; } Piece component = registeredPiece.Prefab.GetComponent(); string name = component.m_name; string text = Localization.instance.Localize(name).Trim(); if (!Object.op_Implicit((Object)(object)ObjectDB.instance) || (Object)(object)ObjectDB.instance.GetItemPrefab("YmirRemains") == (Object)null) { continue; } Piece[] array = Object.FindObjectsOfType(); foreach (Piece val2 in array) { if (flag) { if (val2.m_name == name) { val2.m_enabled = true; } } else if (val2.m_name == name) { val2.m_enabled = false; } } List pieces = ObjectDB.instance.GetItemPrefab("Hammer").GetComponent().m_itemData.m_shared.m_buildPieces.m_pieces; if (flag) { if (!pieces.Contains(ZNetScene.instance.GetPrefab(((Object)component).name))) { pieces.Add(ZNetScene.instance.GetPrefab(((Object)component).name)); } } else if (pieces.Contains(ZNetScene.instance.GetPrefab(((Object)component).name))) { pieces.Remove(ZNetScene.instance.GetPrefab(((Object)component).name)); } } } [CompilerGenerated] internal static void g__SendAdmin|2_2(List peers, bool isAdmin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(isAdmin); ((MonoBehaviour)ZNet.instance).StartCoroutine(sendZPackage(peers, val)); } [CompilerGenerated] internal static void g__SendPackage|4_0(ZPackage pkg, ref <>c__DisplayClass4_0 P_1) { BaseUnityPlugin plugin = BuildPiece._plugin; string text = ((plugin != null) ? plugin.Info.Metadata.Name : null) + " PMAdminStatusSync"; if (isServer) { P_1.peer.m_rpc.Invoke(text, new object[1] { pkg }); } else { P_1.rpc.InvokeRoutedRPC(P_1.peer.m_server ? 0 : P_1.peer.m_uid, text, new object[1] { pkg }); } } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal class RegisterClientRPCPatch { private static void Postfix(ZNet __instance, ZNetPeer peer) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown if (!__instance.IsServer()) { ZRpc rpc = peer.m_rpc; BaseUnityPlugin plugin = BuildPiece._plugin; rpc.Register(((plugin != null) ? plugin.Info.Metadata.Name : null) + " PMAdminStatusSync", (Action)RPC_InitialAdminSync); return; } ZPackage val = new ZPackage(); val.Write(__instance.ListContainsId(__instance.m_adminList, peer.m_rpc.GetSocket().GetHostName())); ZRpc rpc2 = peer.m_rpc; BaseUnityPlugin plugin2 = BuildPiece._plugin; rpc2.Invoke(((plugin2 != null) ? plugin2.Info.Metadata.Name : null) + " PMAdminStatusSync", new object[1] { val }); } private static void RPC_InitialAdminSync(ZRpc rpc, ZPackage package) { AdminSyncing.RPC_AdminPieceAddRemove(0L, package); } } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public static class PiecePrefabManager { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private struct BundleId { [UsedImplicitly] public string assetBundleFileName; [UsedImplicitly] public string folderName; } private static readonly Dictionary bundleCache; private static readonly List piecePrefabs; private static readonly Dictionary PieceCategories; private static readonly Dictionary OtherPieceCategories; private static readonly Dictionary VanillaLabels; internal static bool CategoryRefreshNeeded; static PiecePrefabManager() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Expected O, but got Unknown //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_02eb: Expected O, but got Unknown //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Expected O, but got Unknown //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Expected O, but got Unknown //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Expected O, but got Unknown //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Expected O, but got Unknown //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Expected O, but got Unknown //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Expected O, but got Unknown bundleCache = new Dictionary(); piecePrefabs = new List(); PieceCategories = new Dictionary(); OtherPieceCategories = new Dictionary(); VanillaLabels = new Dictionary(); Harmony val = new Harmony("org.bepinex.helpers.PieceManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(BuildPiece), "Patch_FejdStartup", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(LocalizeKey), "AddLocalizedKeys", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(LocalizationCache), "LocalizationPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "Patch_ObjectDBInit", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(BuildPiece), "Patch_ObjectDBInit", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ObjectDB), "CopyOtherDB", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "Patch_ObjectDBInit", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNet), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(AdminSyncing), "AdminStatusSync", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "Patch_ZNetSceneAwake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "RefFixPatch_ZNetSceneAwake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(PieceTable), "UpdateAvailable", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "UpdateAvailable_Transpiler", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(PieceTable), "UpdateAvailable", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "UpdateAvailable_Prefix", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "UpdateAvailable_Postfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "SetPlaceMode", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "Patch_SetPlaceMode", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Hud), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "Hud_AwakeCreateTabs", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Hud), "UpdateBuild", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "RepositionCatsIfNeeded", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Hud), "LateUpdate", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "RepositionCatsIfNeeded", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Enum), "GetValues", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "EnumGetValuesPatch", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Enum), "GetNames", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "EnumGetNamesPatch", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static AssetBundle RegisterAssetBundle(string assetBundleFileName, string folderName = "assets") { BundleId bundleId = default(BundleId); bundleId.assetBundleFileName = assetBundleFileName; bundleId.folderName = folderName; BundleId key = bundleId; if (!bundleCache.TryGetValue(key, out var value)) { Dictionary dictionary = bundleCache; AssetBundle? obj = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)([NullableContext(0)] (AssetBundle a) => ((Object)a).name == assetBundleFileName)) ?? AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + "." + folderName + "." + assetBundleFileName)); AssetBundle result = obj; dictionary[key] = obj; return result; } return value; } public static IEnumerable FixRefs(AssetBundle assetBundle) { return assetBundle.LoadAllAssets(); } public static GameObject RegisterPrefab(string assetBundleFileName, string prefabName, string folderName = "assets") { return RegisterPrefab(RegisterAssetBundle(assetBundleFileName, folderName), prefabName); } public static GameObject RegisterPrefab(AssetBundle assets, string prefabName) { if ((Object)(object)assets == (Object)null) { Debug.LogError((object)"Failed to load asset bundle. Please make sure to mark all asset bundles as embedded resources."); return null; } GameObject val = assets.LoadAsset(prefabName); if ((Object)(object)val == (Object)null) { Debug.LogError((object)("Failed to load prefab " + prefabName + " from asset bundle " + ((Object)assets).name)); return null; } piecePrefabs.Add(val); return val; } public static Sprite RegisterSprite(string assetBundleFileName, string prefabName, string folderName = "assets") { return RegisterSprite(RegisterAssetBundle(assetBundleFileName, folderName), prefabName); } public static Sprite RegisterSprite(AssetBundle assets, string prefabName) { return assets.LoadAsset(prefabName); } private static void EnumGetValuesPatch(Type enumType, ref Array __result) { if (!(enumType != typeof(PieceCategory)) && PieceCategories.Count != 0) { PieceCategory[] array = (PieceCategory[])(object)new PieceCategory[__result.Length + PieceCategories.Count]; __result.CopyTo(array, 0); PieceCategories.Values.CopyTo(array, __result.Length); __result = array; } } private static void EnumGetNamesPatch(Type enumType, ref string[] __result) { if (!(enumType != typeof(PieceCategory)) && PieceCategories.Count != 0) { __result = CollectionExtensions.AddRangeToArray(__result, PieceCategories.Keys.ToArray()); } } public static Dictionary GetPieceCategoriesMap() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) Array values = Enum.GetValues(typeof(PieceCategory)); string[] names = Enum.GetNames(typeof(PieceCategory)); Dictionary dictionary = new Dictionary(); for (int i = 0; i < values.Length; i++) { dictionary[(PieceCategory)values.GetValue(i)] = names[i]; } return dictionary; } public static PieceCategory GetCategory(string name) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (Enum.TryParse(name, ignoreCase: true, out PieceCategory result)) { return result; } if (PieceCategories.TryGetValue(name, out result)) { return result; } if (OtherPieceCategories.TryGetValue(name, out result)) { return result; } Dictionary pieceCategoriesMap = GetPieceCategoriesMap(); foreach (KeyValuePair item in pieceCategoriesMap) { if (item.Value == name) { result = item.Key; OtherPieceCategories[name] = result; return result; } } result = (PieceCategory)(pieceCategoriesMap.Count - 1); PieceCategories[name] = result; string categoryToken = GetCategoryToken(name); Localization.instance.AddWord(categoryToken, name); return result; } internal static void CreateCategoryTabs() { if (Object.op_Implicit((Object)(object)Hud.instance)) { int num = ModifiedMaxCategory(); for (int i = Hud.instance.m_pieceCategoryTabs.Length; i < num; i++) { GameObject val = CreateCategoryTab(); Hud.instance.m_pieceCategoryTabs = CollectionExtensions.AddItem((IEnumerable)Hud.instance.m_pieceCategoryTabs, val).ToArray(); } if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)Player.m_localPlayer.m_buildPieces)) { RepositionCategories(Player.m_localPlayer.m_buildPieces); Player.m_localPlayer.UpdateAvailablePiecesList(); } } } private static GameObject CreateCategoryTab() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) GameObject val = Hud.instance.m_pieceCategoryTabs[0]; GameObject val2 = Object.Instantiate(Hud.instance.m_pieceCategoryTabs[0], val.transform.parent); val2.SetActive(false); UIInputHandler orAddComponent = val2.GetOrAddComponent(); orAddComponent.m_onLeftDown = (Action)Delegate.Combine(orAddComponent.m_onLeftDown, new Action(Hud.instance.OnLeftClickCategory)); TMP_Text[] componentsInChildren = val2.GetComponentsInChildren(); foreach (TMP_Text val3 in componentsInChildren) { val3.rectTransform.offsetMin = new Vector2(3f, 1f); val3.rectTransform.offsetMax = new Vector2(-3f, -1f); val3.enableAutoSizing = true; val3.fontSizeMin = 12f; val3.fontSizeMax = 20f; val3.lineSpacing = 0.8f; val3.textWrappingMode = (TextWrappingModes)1; val3.overflowMode = (TextOverflowModes)3; } return val2; } private static int ModifiedMaxCategory() { return Enum.GetValues(typeof(PieceCategory)).Length - 1; } private static int GetMaxCategoryOrDefault() { try { return (int)Enum.Parse(typeof(PieceCategory), "Max"); } catch (ArgumentException) { Debug.LogWarning((object)"Could not find Piece.PieceCategory.Max, using fallback value 4"); return 4; } } private static List TranspileMaxCategory(IEnumerable instructions, int maxOffset) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown int num = GetMaxCategoryOrDefault() + maxOffset; List list = new List(); foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.LoadsConstant(instruction, (long)num)) { list.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "ModifiedMaxCategory", (Type[])null, (Type[])null))); if (maxOffset != 0) { list.Add(new CodeInstruction(OpCodes.Ldc_I4, (object)maxOffset)); list.Add(new CodeInstruction(OpCodes.Add, (object)null)); } } else { list.Add(instruction); } } return list; } private static IEnumerable UpdateAvailable_Transpiler(IEnumerable instructions) { return TranspileMaxCategory(instructions, 0); } private static HashSet CategoriesInPieceTable(PieceTable pieceTable) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); Piece val = default(Piece); foreach (GameObject item in pieceTable.m_pieces.Where([NullableContext(0)] (GameObject pieceFab) => (Object)(object)pieceFab != (Object)null)) { if (item.TryGetComponent(ref val)) { hashSet.Add(val.m_category); } } return hashSet; } private static void RepositionCatsIfNeeded() { if (CategoryRefreshNeeded) { CategoryRefreshNeeded = false; CreateCategoryTabs(); RepositionCats(); } } private static void RepositionCats() { if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)Player.m_localPlayer.m_buildPieces)) { RepositionCategories(Player.m_localPlayer.m_buildPieces); } } private static void RepositionCategories(PieceTable pieceTable) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Expected O, but got Unknown //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)Hud.instance.m_pieceCategoryTabs[0].transform; RectTransform val2 = (RectTransform)Hud.instance.m_pieceCategoryRoot.transform; RectTransform val3 = (RectTransform)Hud.instance.m_pieceSelectionWindow.transform; HorizontalLayoutGroup val4 = default(HorizontalLayoutGroup); if (((Component)((Transform)val).parent).TryGetComponent(ref val4)) { Object.DestroyImmediate((Object)(object)val4); } Rect rect = val.rect; Vector2 size = ((Rect)(ref rect)).size; GridLayoutGroup val5 = default(GridLayoutGroup); GridLayoutGroup val6 = (((Component)((Transform)val).parent).TryGetComponent(ref val5) ? val5 : ((Component)((Transform)val).parent).gameObject.AddComponent()); val6.cellSize = size; val6.spacing = new Vector2(0f, 1f); val6.constraint = (Constraint)1; val6.constraintCount = 5; ((LayoutGroup)val6).childAlignment = (TextAnchor)4; HashSet hashSet = CategoriesInPieceTable(pieceTable); UpdatePieceTableCategories(pieceTable, hashSet); rect = val2.rect; int num = Mathf.Max((int)(((Rect)(ref rect)).width / size.x), 1); int count = pieceTable.m_categories.Count; float num2 = (0f - size.x) * (float)num / 2f + size.x / 2f; float num3 = (size.y + 1f) * Mathf.Floor((float)(count - 1) / (float)num) + 5f; Vector2 val7 = default(Vector2); ((Vector2)(ref val7))..ctor(num2, num3); int num4 = Mathf.CeilToInt((float)count / (float)num); float num5 = (size.y + 1f) * (float)num4; RectTransform component = ((Component)((Transform)val).parent).GetComponent(); component.anchoredPosition = new Vector2(component.anchoredPosition.x, num5 / 2f); int num6 = 0; for (int i = 0; i < Hud.instance.m_pieceCategoryTabs.Length; i++) { GameObject val8 = Hud.instance.m_pieceCategoryTabs[i]; if ((Object)(object)val8 == (Object)null) { continue; } if (i >= pieceTable.m_categories.Count) { val8.SetActive(false); continue; } PieceCategory item = pieceTable.m_categories[i]; string text = pieceTable.m_categoryLabels[i]; if (hashSet.Contains(item)) { num6++; } val8.GetComponentInChildren().text = Localization.instance.Localize(text); } Transform obj = ((Transform)val3).Find("Bkg2"); RectTransform val9 = (RectTransform)((obj != null) ? ((Component)obj).transform : null); if (Object.op_Implicit((Object)(object)val9)) { float num7 = (size.y + 1f) * (float)Mathf.Max(0, Mathf.FloorToInt((float)(num6 - 1) / (float)num)); val9.offsetMax = new Vector2(val9.offsetMax.x, num7); } else { Debug.LogWarning((object)"RefreshCategories: Could not find background image"); } ((Component)Hud.instance).GetComponentInParent().RefreshLocalization(); } private static void UpdatePieceTableCategories(PieceTable pieceTable, HashSet visibleCategories) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < GetMaxCategoryOrDefault(); i++) { PieceCategory val = (PieceCategory)i; if (visibleCategories.Contains(val) && !pieceTable.m_categories.Contains(val)) { pieceTable.m_categories.Add(val); pieceTable.m_categoryLabels.Add(GetVanillaLabel(val)); } if (!visibleCategories.Contains(val) && pieceTable.m_categories.Contains(val)) { int index = pieceTable.m_categories.IndexOf(val); pieceTable.m_categories.RemoveAt(index); pieceTable.m_categoryLabels.RemoveAt(index); } } foreach (KeyValuePair pieceCategory in PieceCategories) { string key = pieceCategory.Key; PieceCategory value = pieceCategory.Value; if (visibleCategories.Contains(value) && !pieceTable.m_categories.Contains(value)) { pieceTable.m_categories.Add(value); pieceTable.m_categoryLabels.Add("$" + GetCategoryToken(key)); } if (visibleCategories.Contains(value) && !pieceTable.m_categoryLabels.Contains("$" + GetCategoryToken(key))) { pieceTable.m_categoryLabels.Add("$" + GetCategoryToken(key)); } if (!visibleCategories.Contains(value) && pieceTable.m_categories.Contains(value)) { int index2 = pieceTable.m_categories.IndexOf(value); pieceTable.m_categories.RemoveAt(index2); pieceTable.m_categoryLabels.RemoveAt(index2); } } } private static string GetVanillaLabel(PieceCategory category) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!VanillaLabels.ContainsKey(category)) { SearchVanillaLabels(); } string value; return VanillaLabels.TryGetValue(category, out value) ? value : string.Empty; } private static void SearchVanillaLabels() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0066: Unknown result type (might be due to invalid IL or missing references) PieceTable[] array = Resources.FindObjectsOfTypeAll(); foreach (PieceTable val in array) { for (int j = 0; j < val.m_categories.Count; j++) { PieceCategory key = val.m_categories[j]; if (j < val.m_categoryLabels.Count && !VanillaLabels.ContainsKey(key) && !string.IsNullOrEmpty(val.m_categoryLabels[j])) { VanillaLabels[key] = val.m_categoryLabels[j]; } } } } private static string GetCategoryToken(string name) { char[] endChars = Localization.instance.m_endChars; string text = string.Concat(name.ToLower().Split(endChars)); return "piecemanager_cat_" + text; } private static void Patch_SetPlaceMode(Player __instance) { if (Object.op_Implicit((Object)(object)__instance.m_buildPieces)) { RepositionCategories(__instance.m_buildPieces); } } private static void UpdateAvailable_Prefix(PieceTable __instance) { if (__instance.m_availablePieces.Count > 0) { int num = ModifiedMaxCategory() - __instance.m_availablePieces.Count; for (int i = 0; i < num; i++) { __instance.m_availablePieces.Add(new List()); } } } private static void UpdateAvailable_Postfix(PieceTable __instance) { Array.Resize(ref __instance.m_selectedPiece, __instance.m_availablePieces.Count); Array.Resize(ref __instance.m_lastSelectedPiece, __instance.m_availablePieces.Count); } [HarmonyPriority(200)] private static void Hud_AwakeCreateTabs() { CreateCategoryTabs(); } [HarmonyPriority(700)] private static void Patch_ZNetSceneAwake(ZNetScene __instance) { foreach (GameObject piecePrefab in piecePrefabs) { if (!__instance.m_prefabs.Contains(piecePrefab)) { __instance.m_prefabs.Add(piecePrefab); } } } [HarmonyPriority(700)] private static void RefFixPatch_ZNetSceneAwake(ZNetScene __instance) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) foreach (GameObject piecePrefab in piecePrefabs) { if (__instance.m_prefabs.Contains(piecePrefab) && Object.op_Implicit((Object)(object)piecePrefab.GetComponent())) { piecePrefab.GetComponent().m_isUpgrade = true; piecePrefab.GetComponent().m_connectionPrefab = __instance.GetPrefab("piece_workbench_ext3").GetComponent().m_connectionPrefab; piecePrefab.GetComponent().m_connectionOffset = __instance.GetPrefab("piece_workbench_ext3").GetComponent().m_connectionOffset; } } } [HarmonyPriority(300)] private static void Patch_ObjectDBInit(ObjectDB __instance) { foreach (BuildPiece registeredPiece in BuildPiece.registeredPieces) { string[] activeTools = registeredPiece.activeTools; foreach (string text in activeTools) { GameObject itemPrefab = __instance.GetItemPrefab(text); PieceTable val = ((itemPrefab != null) ? itemPrefab.GetComponent().m_itemData.m_shared.m_buildPieces : null); if (val != null && !val.m_pieces.Contains(registeredPiece.Prefab)) { val.m_pieces.Add(registeredPiece.Prefab); } } } } } public static class PieceManagerVersion { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] public const string Version = "1.2.9"; } [PublicAPI] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] public class Conversion { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] internal class ConversionConfig { public ConfigEntry input = null; public ConfigEntry output = null; } public string Input = null; public string Output = null; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] internal ConversionConfig config; public Conversion(BuildPiece conversionPiece) { conversionPiece.Conversions.Add(this); } } } namespace LocalizationManager { [PublicAPI] [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public class Localizer { private static readonly Dictionary>> PlaceholderProcessors; private static readonly Dictionary> loadedTexts; private static readonly ConditionalWeakTable localizationLanguage; private static readonly List> localizationObjects; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static BaseUnityPlugin _plugin; private static readonly List fileExtensions; 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 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([NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] [method: NullableContext(2)] [field: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] public static event Action OnLocalizationComplete; private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out var value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out var value2)) { text = value2.Aggregate(text, [NullableContext(0)] (string current, KeyValuePair> kv) => current.Replace("{" + kv.Key + "}", kv.Value())); } localization.AddWord(key, text); } public static void AddPlaceholder(string key, string placeholder, ConfigEntry config, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 2, 1, 1 })] Func convertConfigValue = null) { if (convertConfigValue == null) { convertConfigValue = (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary>(); } config.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value); UpdatePlaceholderText(Localization.instance, key); } } public static void AddText(string key, string text) { List> list = new List>(); foreach (WeakReference localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference item in list) { localizationObjects.Remove(item); } } public static void Load() { _ = plugin; } public static void LoadLocalizationLater(Localization __instance) { LoadLocalization(Localization.instance, __instance.GetSelectedLanguage()); } public static void SafeCallLocalizeComplete() { Localizer.OnLocalizationComplete?.Invoke(); } private static void LoadLocalization(Localization __instance, string language) { if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference(__instance)); } localizationLanguage.Add(__instance, language); Dictionary dictionary = new Dictionary(); foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories) where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0 select f) { string[] array = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' }); if (array.Length >= 2) { string text = array[1]; if (dictionary.ContainsKey(text)) { Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped.")); } else { dictionary[text] = item; } } } byte[] array2 = LoadTranslationFromAssembly("English"); if (array2 == null) { throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml."); } string input = Encoding.UTF8.GetString(array2).TrimStart(new char[1] { '\ufeff' }); Dictionary dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize>(input); if (dictionary2 == null) { throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text2 = null; if (language != "English") { if (dictionary.TryGetValue(language, out var value)) { text2 = File.ReadAllText(value); } else { byte[] array3 = LoadTranslationFromAssembly(language); if (array3 != null) { text2 = Encoding.UTF8.GetString(array3); } } } if (text2 == null && dictionary.TryGetValue("English", out var value2)) { text2 = File.ReadAllText(value2); } if (text2 != null) { text2 = text2.TrimStart(new char[1] { '\ufeff' }); foreach (KeyValuePair item2 in new DeserializerBuilder().IgnoreFields().Build().Deserialize>(text2) ?? new Dictionary()) { dictionary2[item2.Key] = item2.Value; } } loadedTexts[language] = dictionary2; foreach (KeyValuePair item3 in dictionary2) { UpdatePlaceholderText(__instance, item3.Key); } } static Localizer() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown PlaceholderProcessors = new Dictionary>>(); loadedTexts = new Dictionary>(); localizationLanguage = new ConditionalWeakTable(); localizationObjects = new List>(); fileExtensions = new List(2) { ".json", ".yml" }; Harmony val = new Harmony("org.bepinex.helpers.LocalizationManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "SetupGui", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalizationLater", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "SafeCallLocalizeComplete", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static byte[] LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension); if (array != null) { return array; } } return null; } [NullableContext(2)] public static byte[] ReadEmbeddedFileBytes([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] string resourceFileName, Assembly containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } public static class LocalizationManagerVersion { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] public const string Version = "1.4.1"; } } namespace ItemManager { [PublicAPI] public enum CraftingTable { Disabled, Inventory, [InternalName("piece_workbench")] Workbench, [InternalName("piece_cauldron")] Cauldron, [InternalName("piece_MeadCauldron")] MeadCauldron, [InternalName("forge")] Forge, [InternalName("piece_artisanstation")] ArtisanTable, [InternalName("piece_stonecutter")] StoneCutter, [InternalName("piece_magetable")] MageTable, [InternalName("piece_preptable")] PrepTable, [InternalName("blackforge")] BlackForge, Custom } [PublicAPI] public enum ConversionPiece { Disabled, [InternalName("smelter")] Smelter, [InternalName("charcoal_kiln")] CharcoalKiln, [InternalName("blastfurnace")] BlastFurnace, [InternalName("windmill")] Windmill, [InternalName("piece_spinningwheel")] SpinningWheel, [InternalName("eitrrefinery")] EitrRefinery, Custom } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public class InternalName : Attribute { public readonly string internalName; public InternalName(string internalName) { this.internalName = internalName; } } [NullableContext(1)] [PublicAPI] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public class RequiredResourceList { public readonly List Requirements = new List(); public bool Free = false; public void Add(string itemName, int amount, int quality = 0) { Requirements.Add(new Requirement { itemName = itemName, amount = amount, quality = quality }); } public void Add(string itemName, ConfigEntry amountConfig, int quality = 0) { Requirements.Add(new Requirement { itemName = itemName, amountConfig = amountConfig, quality = quality }); } } [PublicAPI] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] public class CraftingStationList { public readonly List Stations = new List(); public void Add(CraftingTable table, int level) { Stations.Add(new CraftingStationConfig { Table = table, level = level }); } public void Add(string customTable, int level) { Stations.Add(new CraftingStationConfig { Table = CraftingTable.Custom, level = level, custom = customTable }); } } [PublicAPI] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [NullableContext(1)] public class ItemRecipe { public readonly RequiredResourceList RequiredItems = new RequiredResourceList(); public readonly RequiredResourceList RequiredUpgradeItems = new RequiredResourceList(); public readonly CraftingStationList Crafting = new CraftingStationList(); public int CraftAmount = 1; public bool RequireOnlyOneIngredient = false; public float QualityResultAmountMultiplier = 1f; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] public ConfigEntryBase RecipeIsActive = null; } [PublicAPI] public class Trade { public Trader Trader = Trader.None; public uint Price = 0u; public uint Stack = 1u; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] public string RequiredGlobalKey = null; } [Flags] [PublicAPI] public enum Trader { None = 0, Haldor = 1, Hildir = 2 } public struct Requirement { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] public string itemName; public int amount; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] public ConfigEntry amountConfig; [Description("Set to a non-zero value to apply the requirement only for a specific quality")] public int quality; } public struct CraftingStationConfig { public CraftingTable Table; public int level; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] public string custom; } [Flags] public enum Configurability { Disabled = 0, Recipe = 1, Stats = 2, Drop = 4, Trader = 8, Full = 0xF } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [PublicAPI] public class DropTargets { public readonly List Drops = new List(); public void Add(string creatureName, float chance, int min = 1, int? max = null, bool levelMultiplier = true) { Drops.Add(new DropTarget { creature = creatureName, chance = chance, min = min, max = max.GetValueOrDefault(min), levelMultiplier = levelMultiplier }); } } public struct DropTarget { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] public string creature; public int min; public int max; public float chance; public bool levelMultiplier; } public enum Toggle { On = 1, Off = 0 } [NullableContext(1)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] [PublicAPI] public class Item { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private class ItemConfig { [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 2, 1 })] public ConfigEntry craft; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 2, 1 })] public ConfigEntry upgrade; public ConfigEntry table = null; public ConfigEntry tableLevel = null; public ConfigEntry customTable = null; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] public ConfigEntry maximumTableLevel; public ConfigEntry requireOneIngredient = null; public ConfigEntry qualityResultAmountMultiplier = null; } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private class TraderConfig { public ConfigEntry trader = null; public ConfigEntry price = null; public ConfigEntry stack = null; public ConfigEntry requiredGlobalKey = null; } [NullableContext(0)] private class RequirementQuality { public int quality; } [NullableContext(2)] [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [UsedImplicitly] public string Category; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 2, 1 })] [UsedImplicitly] public Action CustomDrawer; public Func browsability; } [PublicAPI] [NullableContext(0)] public enum DamageModifier { Normal, Resistant, Weak, Immune, Ignore, VeryResistant, VeryWeak, None } [NullableContext(0)] private delegate void setDmgFunc(ref DamageTypes dmg, float value); [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private class SerializedRequirements { public readonly List Reqs; public SerializedRequirements(List reqs) { Reqs = reqs; } public SerializedRequirements(string reqs) : this(reqs.Split(new char[1] { ',' }).Select([NullableContext(0)] (string r) => { string[] array = r.Split(new char[1] { ':' }); Requirement result = default(Requirement); result.itemName = array[0]; result.amount = ((array.Length <= 1 || !int.TryParse(array[1], out var result2)) ? 1 : result2); result.quality = ((array.Length > 2 && int.TryParse(array[2], out var result3)) ? result3 : 0); return result; }).ToList()) { } public override string ToString() { return string.Join(",", Reqs.Select([NullableContext(0)] (Requirement r) => $"{r.itemName}:{r.amount}" + ((r.quality > 0) ? $":{r.quality}" : ""))); } [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] public static ItemDrop fetchByName(ObjectDB objectDB, string name) { GameObject itemPrefab = objectDB.GetItemPrefab(name); ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent() : null); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("The required item '" + name + "' does not exist.")); } return val; } public static Requirement[] toPieceReqs(ObjectDB objectDB, SerializedRequirements craft, SerializedRequirements upgrade) { //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_01a8: 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_01b2: Expected O, but got Unknown //IL_01b7: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown Dictionary dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func)([NullableContext(0)] (Requirement r) => r.itemName), (Func)([NullableContext(0)] (Requirement r) => { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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) ItemDrop val6 = ResItem(r); return (val6 == null) ? ((Requirement)null) : new Requirement { m_amount = (r.amountConfig?.Value ?? r.amount), m_resItem = val6, m_amountPerLevel = 0 }; })); List list = dictionary.Values.Where([NullableContext(0)] (Requirement v) => v != null).ToList(); foreach (Requirement item in upgrade.Reqs.Where((Requirement r) => r.itemName != "")) { if (item.quality > 0) { ItemDrop val = ResItem(item); if (val != null) { Requirement val2 = new Requirement { m_resItem = val, m_amountPerLevel = (item.amountConfig?.Value ?? item.amount), m_amount = 0 }; list.Add(val2); requirementQuality.Add(val2, new RequirementQuality { quality = item.quality }); } continue; } if (!dictionary.TryGetValue(item.itemName, out var value) || value == null) { ItemDrop val3 = ResItem(item); if (val3 != null) { string itemName = item.itemName; Requirement val4 = new Requirement { m_resItem = val3, m_amount = 0 }; Requirement val5 = val4; dictionary[itemName] = val4; value = val5; list.Add(value); } } if (value != null) { value.m_amountPerLevel = item.amountConfig?.Value ?? item.amount; } } return list.ToArray(); [NullableContext(2)] ItemDrop ResItem(Requirement r) { return fetchByName(objectDB, r.itemName); } } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private class SerializedDrop { public readonly List Drops; public SerializedDrop(List drops) { Drops = drops; } public SerializedDrop(string drops) { Drops = ((drops == "") ? ((IEnumerable)Array.Empty()) : ((IEnumerable)drops.Split(new char[1] { ',' }))).Select([NullableContext(0)] (string r) => { string[] array = r.Split(new char[1] { ':' }); if (array.Length <= 2 || !int.TryParse(array[2], out var result)) { result = 1; } if (array.Length <= 3 || !int.TryParse(array[3], out var result2)) { result2 = result; } bool levelMultiplier = array.Length <= 4 || array[4] != "0"; DropTarget result3 = default(DropTarget); result3.creature = array[0]; result3.chance = ((array.Length > 1 && float.TryParse(array[1], out var result4)) ? result4 : 1f); result3.min = result; result3.max = result2; result3.levelMultiplier = levelMultiplier; return result3; }).ToList(); } public override string ToString() { return string.Join(",", Drops.Select([NullableContext(0)] (DropTarget r) => $"{r.creature}:{r.chance.ToString(CultureInfo.InvariantCulture)}:{r.min}:" + ((r.min == r.max) ? "" : $"{r.max}") + (r.levelMultiplier ? "" : ":0"))); } [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static Character fetchByName(ZNetScene netScene, string name) { GameObject prefab = netScene.GetPrefab(name); Character val = ((prefab != null) ? prefab.GetComponent() : null); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("The drop target character '" + name + "' does not exist.")); } return val; } public Dictionary toCharacterDrops(ZNetScene netScene, GameObject item) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown Dictionary dictionary = new Dictionary(); foreach (DropTarget drop in Drops) { Character val = fetchByName(netScene, drop.creature); if (val != null) { dictionary[val] = new Drop { m_prefab = item, m_amountMin = drop.min, m_amountMax = drop.max, m_chance = drop.chance, m_levelMultiplier = drop.levelMultiplier }; } } return dictionary; } } [CompilerGenerated] private sealed class <>c__DisplayClass84_0 { public Quaternion? cameraRotation; public float lightIntensity; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] public ItemDrop item; public Quaternion? itemRotation; } [CompilerGenerated] private sealed class d__86 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 0, 1 })] private IEnumerable instructions; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 0, 1 })] public IEnumerable <>3__instructions; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 0, 1 })] private List 5__1; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] private FieldInfo 5__2; private int 5__3; CodeInstruction IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public d__86(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown int num; switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = instructions.ToList(); 5__2 = AccessTools.DeclaredField(typeof(Recipe), "m_amount"); 5__3 = 0; break; case 1: <>1__state = -1; if (5__3 > 1 && 5__1[5__3 - 2].opcode == OpCodes.Ldfld && CodeInstructionExtensions.OperandIs(5__1[5__3 - 2], (MemberInfo)5__2) && 5__1[5__3 - 1].opcode == OpCodes.Ldc_I4_1 && 5__1[5__3].operand is Label) { <>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null); <>1__state = 2; return true; } goto IL_01ca; case 2: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(Item), "CheckItemIsUpgrade", (Type[])null, (Type[])null)); <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Brtrue, 5__1[5__3].operand); <>1__state = 4; return true; case 4: { <>1__state = -1; goto IL_01ca; } IL_01ca: num = 5__3 + 1; 5__3 = num; break; } if (5__3 < 5__1.Count) { <>2__current = 5__1[5__3]; <>1__state = 1; return true; } 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(); } [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] IEnumerator IEnumerable.GetEnumerator() { d__86 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__86(0); } d__.instructions = <>3__instructions; return d__; } [DebuggerHidden] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static readonly List registeredItems = new List(); private static readonly Dictionary itemDropMap = new Dictionary(); private static Dictionary>> activeRecipes = new Dictionary>>(); [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 1, 1, 2 })] private static Dictionary hiddenCraftRecipes = new Dictionary(); [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 1, 1, 2 })] private static Dictionary hiddenUpgradeRecipes = new Dictionary(); private static Dictionary> itemCraftConfigs = new Dictionary>(); private static Dictionary> itemDropConfigs = new Dictionary>(); private Dictionary characterDrops = new Dictionary(); private readonly Dictionary statsConfigs = new Dictionary(); private static readonly ConditionalWeakTable requirementQuality = new ConditionalWeakTable(); public static Configurability DefaultConfigurability = Configurability.Full; public Configurability? Configurable = null; public readonly HashSet EnabledStatsConfigs = new HashSet(StringComparer.Ordinal); private Configurability configurationVisible = Configurability.Full; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private TraderConfig traderConfig; public readonly GameObject Prefab; [Description("Specifies the maximum required crafting station level to upgrade and repair the item.\nDefault is calculated from crafting station level and maximum quality.")] public int MaximumRequiredStationLevel = int.MaxValue; [Description("Assigns the item as a drop item to a creature.\nUses a creature name, a drop chance and a minimum and maximum amount.")] public readonly DropTargets DropsFrom = new DropTargets(); [Description("Configures whether the item can be bought at the trader.\nDon't forget to set cost to something above 0 or the item will be sold for free.")] public readonly Trade Trade = new Trade(); internal List Conversions = new List(); internal List conversions = new List(); public Dictionary Recipes = new Dictionary(); [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private LocalizeKey _name; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private LocalizeKey _description; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static object configManager; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static Localization _english; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static BaseUnityPlugin _plugin; private static bool hasConfigSync = true; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static object _configSync; private Configurability configurability => Configurable ?? DefaultConfigurability; [Description("Specifies the resources needed to craft the item.\nUse .Add to add resources with their internal ID and an amount.\nUse one .Add for each resource type the item should need.")] public RequiredResourceList RequiredItems => this[""].RequiredItems; [Description("Specifies the resources needed to upgrade the item.\nUse .Add to add resources with their internal ID and an amount. This amount will be multipled by the item quality level.\nUse one .Add for each resource type the upgrade should need.")] public RequiredResourceList RequiredUpgradeItems => this[""].RequiredUpgradeItems; [Description("Specifies the crafting station needed to craft the item.\nUse .Add to add a crafting station, using the CraftingTable enum and a minimum level for the crafting station.\nUse one .Add for each crafting station.")] public CraftingStationList Crafting => this[""].Crafting; [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] [Description("Specifies a config entry which toggles whether a recipe is active.")] public ConfigEntryBase RecipeIsActive { [NullableContext(2)] get { return this[""].RecipeIsActive; } [NullableContext(2)] set { this[""].RecipeIsActive = value; } } [Description("Specifies the number of items that should be given to the player with a single craft of the item.\nDefaults to 1.")] public int CraftAmount { get { return this[""].CraftAmount; } set { this[""].CraftAmount = value; } } public bool RequireOnlyOneIngredient { get { return this[""].RequireOnlyOneIngredient; } set { this[""].RequireOnlyOneIngredient = value; } } public float QualityResultAmountMultiplier { get { return this[""].QualityResultAmountMultiplier; } set { this[""].QualityResultAmountMultiplier = value; } } public ItemRecipe this[string name] { get { if (Recipes.TryGetValue(name, out var value)) { return value; } return Recipes[name] = new ItemRecipe(); } } public LocalizeKey Name { get { LocalizeKey name = _name; if (name != null) { return name; } SharedData shared = Prefab.GetComponent().m_itemData.m_shared; if (shared.m_name.StartsWith("$")) { _name = new LocalizeKey(shared.m_name); } else { string text = "$item_" + ((Object)Prefab).name.Replace(" ", "_"); _name = new LocalizeKey(text).English(shared.m_name); shared.m_name = text; } return _name; } } public LocalizeKey Description { get { LocalizeKey description = _description; if (description != null) { return description; } SharedData shared = Prefab.GetComponent().m_itemData.m_shared; if (shared.m_description.StartsWith("$")) { _description = new LocalizeKey(shared.m_description); } else { string text = "$itemdesc_" + ((Object)Prefab).name.Replace(" ", "_"); _description = new LocalizeKey(text).English(shared.m_description); shared.m_description = text; } return _description; } } 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 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([NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(2)] private static object configSync { [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 + " ItemManager"); type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString()); type.GetProperty("IsLocked").SetValue(_configSync, true); } else { hasConfigSync = false; } } return _configSync; } } public Item(string assetBundleFileName, string prefabName, string folderName = "assets") : this(PrefabManager.RegisterAssetBundle(assetBundleFileName, folderName), prefabName) { } public Item(AssetBundle bundle, string prefabName) : this(PrefabManager.RegisterPrefab(bundle, prefabName, addToObjectDb: true), skipRegistering: true) { } public Item(GameObject prefab, bool skipRegistering = false) { if (!skipRegistering) { PrefabManager.RegisterPrefab(prefab, addToObjectDb: true); } Prefab = prefab; registeredItems.Add(this); itemDropMap[Prefab.GetComponent()] = this; Prefab.GetComponent().m_itemData.m_dropPrefab = Prefab; } public void ToggleConfigurationVisibility(Configurability visible) { configurationVisible = visible; if (itemDropConfigs.TryGetValue(this, out var value)) { Toggle((ConfigEntryBase)(object)value, Configurability.Drop); } if (itemCraftConfigs.TryGetValue(this, out var value2)) { foreach (ItemConfig value4 in value2.Values) { ToggleObj(value4, Configurability.Recipe); } } foreach (Conversion conversion in Conversions) { if (conversion.config != null) { ToggleObj(conversion.config, Configurability.Recipe); } } foreach (KeyValuePair statsConfig in statsConfigs) { Toggle(statsConfig.Key, Configurability.Stats); if ((visible & Configurability.Stats) != 0) { statsConfig.Value(); } } reloadConfigDisplay(); void Toggle(ConfigEntryBase cfg, Configurability check) { object[] tags = cfg.Description.Tags; foreach (object obj2 in tags) { if (obj2 is ConfigurationManagerAttributes configurationManagerAttributes) { configurationManagerAttributes.Browsable = (visible & check) != 0 && (configurationManagerAttributes.browsability == null || configurationManagerAttributes.browsability()); } } } void ToggleObj(object obj, Configurability check) { FieldInfo[] fields = obj.GetType().GetFields(); foreach (FieldInfo fieldInfo in fields) { object? value3 = fieldInfo.GetValue(obj); ConfigEntryBase val = (ConfigEntryBase)((value3 is ConfigEntryBase) ? value3 : null); if (val != null) { Toggle(val, check); } } } } internal static void reloadConfigDisplay() { object obj = configManager?.GetType().GetProperty("DisplayingWindow").GetValue(configManager); if (obj is bool && (bool)obj) { configManager.GetType().GetMethod("BuildSettingList").Invoke(configManager, Array.Empty()); } } private void UpdateItemTableConfig(string recipeKey, CraftingTable table, string customTableValue) { if (activeRecipes.ContainsKey(this) && activeRecipes[this].TryGetValue(recipeKey, out var value)) { value.First().m_enabled = table != CraftingTable.Disabled; if ((uint)table <= 1u) { value.First().m_craftingStation = null; } else if (table == CraftingTable.Custom) { Recipe obj = value.First(); GameObject prefab = ZNetScene.instance.GetPrefab(customTableValue); obj.m_craftingStation = ((prefab != null) ? prefab.GetComponent() : null); } else { value.First().m_craftingStation = ZNetScene.instance.GetPrefab(getInternalName(table)).GetComponent(); } } } private void UpdateCraftConfig(string recipeKey, SerializedRequirements craftRequirements, SerializedRequirements upgradeRequirements) { if (!Object.op_Implicit((Object)(object)ObjectDB.instance) || !activeRecipes.ContainsKey(this) || !activeRecipes[this].TryGetValue(recipeKey, out var value)) { return; } foreach (Recipe item in value) { item.m_resources = SerializedRequirements.toPieceReqs(ObjectDB.instance, craftRequirements, upgradeRequirements); } } internal static void Patch_FejdStartup() { //IL_1001: Unknown result type (might be due to invalid IL or missing references) //IL_1006: Unknown result type (might be due to invalid IL or missing references) //IL_2395: Unknown result type (might be due to invalid IL or missing references) //IL_239f: Expected O, but got Unknown //IL_10ce: Unknown result type (might be due to invalid IL or missing references) //IL_10d1: Unknown result type (might be due to invalid IL or missing references) //IL_1127: Expected I4, but got Unknown //IL_0ccc: Unknown result type (might be due to invalid IL or missing references) //IL_0cd6: Expected O, but got Unknown //IL_1267: Unknown result type (might be due to invalid IL or missing references) //IL_126a: Unknown result type (might be due to invalid IL or missing references) //IL_126c: Invalid comparison between Unknown and I4 //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Expected O, but got Unknown //IL_0dfa: Unknown result type (might be due to invalid IL or missing references) //IL_0e04: Expected O, but got Unknown //IL_0ea6: Unknown result type (might be due to invalid IL or missing references) //IL_0eb0: Expected O, but got Unknown //IL_1270: Unknown result type (might be due to invalid IL or missing references) //IL_1274: Invalid comparison between Unknown and I4 //IL_0f5b: Unknown result type (might be due to invalid IL or missing references) //IL_0f65: Expected O, but got Unknown //IL_1489: Unknown result type (might be due to invalid IL or missing references) //IL_148c: Unknown result type (might be due to invalid IL or missing references) //IL_148e: Invalid comparison between Unknown and I4 //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Expected O, but got Unknown //IL_1278: Unknown result type (might be due to invalid IL or missing references) //IL_127c: Invalid comparison between Unknown and I4 //IL_1492: Unknown result type (might be due to invalid IL or missing references) //IL_1496: Unknown result type (might be due to invalid IL or missing references) //IL_1498: Invalid comparison between Unknown and I4 //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05b7: Expected O, but got Unknown //IL_1581: Unknown result type (might be due to invalid IL or missing references) //IL_1586: Unknown result type (might be due to invalid IL or missing references) //IL_1588: Unknown result type (might be due to invalid IL or missing references) //IL_158b: Invalid comparison between Unknown and I4 //IL_149c: Unknown result type (might be due to invalid IL or missing references) //IL_14a0: Invalid comparison between Unknown and I4 //IL_158f: Unknown result type (might be due to invalid IL or missing references) //IL_1593: Invalid comparison between Unknown and I4 //IL_0796: Unknown result type (might be due to invalid IL or missing references) //IL_07a0: Expected O, but got Unknown //IL_06eb: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Expected O, but got Unknown //IL_160c: Unknown result type (might be due to invalid IL or missing references) //IL_160f: Unknown result type (might be due to invalid IL or missing references) //IL_1611: Invalid comparison between Unknown and I4 //IL_08b0: Unknown result type (might be due to invalid IL or missing references) //IL_08ba: Expected O, but got Unknown //IL_1615: Unknown result type (might be due to invalid IL or missing references) //IL_1619: Unknown result type (might be due to invalid IL or missing references) //IL_161b: Invalid comparison between Unknown and I4 //IL_176e: Unknown result type (might be due to invalid IL or missing references) //IL_1771: Invalid comparison between Unknown and I4 //IL_161f: Unknown result type (might be due to invalid IL or missing references) //IL_1623: Invalid comparison between Unknown and I4 //IL_1980: Unknown result type (might be due to invalid IL or missing references) //IL_1987: Invalid comparison between Unknown and I4 //IL_1a5c: Unknown result type (might be due to invalid IL or missing references) //IL_1a61: Unknown result type (might be due to invalid IL or missing references) //IL_1a63: Unknown result type (might be due to invalid IL or missing references) //IL_1a67: Unknown result type (might be due to invalid IL or missing references) //IL_1a69: Invalid comparison between Unknown and I4 //IL_16de: Unknown result type (might be due to invalid IL or missing references) //IL_16e3: Unknown result type (might be due to invalid IL or missing references) //IL_1ae2: Unknown result type (might be due to invalid IL or missing references) //IL_1ae5: Unknown result type (might be due to invalid IL or missing references) //IL_1ae7: Invalid comparison between Unknown and I4 //IL_1aeb: Unknown result type (might be due to invalid IL or missing references) //IL_1aef: Invalid comparison between Unknown and I4 //IL_1af3: Unknown result type (might be due to invalid IL or missing references) //IL_1af7: Invalid comparison between Unknown and I4 //IL_1f88: Unknown result type (might be due to invalid IL or missing references) //IL_1f8b: Invalid comparison between Unknown and I4 Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([NullableContext(0)] (Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager"); if (DefaultConfigurability != 0) { bool saveOnConfigSet = plugin.Config.SaveOnConfigSet; plugin.Config.SaveOnConfigSet = false; foreach (Item item4 in registeredItems.Where([NullableContext(0)] (Item i) => i.configurability != Configurability.Disabled)) { Item item3 = item4; string name2 = item3.Prefab.GetComponent().m_itemData.m_shared.m_name; string englishName = new Regex("[=\\n\\t\\\\\"\\'\\[\\]]*").Replace(english.Localize(name2), "").Trim(); string localizedName = Localization.instance.Localize(name2).Trim(); int order = 0; if ((item3.configurability & Configurability.Recipe) != 0) { itemCraftConfigs[item3] = new Dictionary(); foreach (string item5 in item3.Recipes.Keys.DefaultIfEmpty("")) { string configKey = item5; string text = ((configKey == "") ? "" : (" (" + configKey + ")")); if (!item3.Recipes.ContainsKey(configKey) || item3.Recipes[configKey].Crafting.Stations.Count <= 0) { continue; } ItemConfig itemConfig2 = (itemCraftConfigs[item3][configKey] = new ItemConfig()); ItemConfig cfg = itemConfig2; List hideWhenNoneAttributes = new List(); cfg.table = config(englishName, "Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().Table, new ConfigDescription("Crafting station where " + englishName + " is available.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName } })); ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = CustomTableBrowsability, Browsable = (CustomTableBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; cfg.customTable = config(englishName, "Custom Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes })); cfg.table.SettingChanged += TableConfigChanged; cfg.customTable.SettingChanged += TableConfigChanged; ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = TableLevelBrowsability, Browsable = (TableLevelBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; hideWhenNoneAttributes.Add(configurationManagerAttributes); cfg.tableLevel = config(englishName, "Crafting Station Level" + text, item3.Recipes[configKey].Crafting.Stations.First().level, new ConfigDescription("Required crafting station level to craft " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); cfg.tableLevel.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value6)) { value6.First().m_minStationLevel = cfg.tableLevel.Value; } }; if (item3.Prefab.GetComponent().m_itemData.m_shared.m_maxQuality > 1) { cfg.maximumTableLevel = config(englishName, "Maximum Crafting Station Level" + text, (item3.MaximumRequiredStationLevel == int.MaxValue) ? (item3.Recipes[configKey].Crafting.Stations.First().level + item3.Prefab.GetComponent().m_itemData.m_shared.m_maxQuality - 1) : item3.MaximumRequiredStationLevel, new ConfigDescription("Maximum crafting station level to upgrade and repair " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); } cfg.requireOneIngredient = config(englishName, "Require only one resource" + text, item3.Recipes[configKey].RequireOnlyOneIngredient ? Toggle.On : Toggle.Off, new ConfigDescription("Whether only one of the ingredients is needed to craft " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Category = localizedName } })); ConfigurationManagerAttributes qualityResultAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = QualityResultBrowsability, Browsable = (QualityResultBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; cfg.requireOneIngredient.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value5)) { foreach (Recipe item6 in value5) { item6.m_requireOnlyOneIngredient = cfg.requireOneIngredient.Value == Toggle.On; } } qualityResultAttributes.Browsable = QualityResultBrowsability(); reloadConfigDisplay(); }; cfg.qualityResultAmountMultiplier = config(englishName, "Quality Multiplier" + text, item3.Recipes[configKey].QualityResultAmountMultiplier, new ConfigDescription("Multiplies the crafted amount based on the quality of the resources when crafting " + englishName + ". Only works, if Require Only One Resource is true.", (AcceptableValueBase)null, new object[1] { qualityResultAttributes })); cfg.qualityResultAmountMultiplier.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value4)) { foreach (Recipe item7 in value4) { item7.m_qualityResultAmountMultiplier = cfg.qualityResultAmountMultiplier.Value; } } }; if ((!item3.Recipes[configKey].RequiredItems.Free || item3.Recipes[configKey].RequiredItems.Requirements.Count > 0) && item3.Recipes[configKey].RequiredItems.Requirements.All((Requirement r) => r.amountConfig == null)) { cfg.craft = itemConfig("Crafting Costs" + text, new SerializedRequirements(item3.Recipes[configKey].RequiredItems.Requirements).ToString(), "Item costs to craft " + englishName, isUpgrade: false); } if (item3.Prefab.GetComponent().m_itemData.m_shared.m_maxQuality > 1 && (!item3.Recipes[configKey].RequiredUpgradeItems.Free || item3.Recipes[configKey].RequiredUpgradeItems.Requirements.Count > 0) && item3.Recipes[configKey].RequiredUpgradeItems.Requirements.All((Requirement r) => r.amountConfig == null)) { cfg.upgrade = itemConfig("Upgrading Costs" + text, new SerializedRequirements(item3.Recipes[configKey].RequiredUpgradeItems.Requirements).ToString(), "Item costs per level to upgrade " + englishName, isUpgrade: true); } if (cfg.craft != null) { cfg.craft.SettingChanged += ConfigChanged; } if (cfg.upgrade != null) { cfg.upgrade.SettingChanged += ConfigChanged; } void ConfigChanged(object o, EventArgs e) { item3.UpdateCraftConfig(configKey, new SerializedRequirements(cfg.craft?.Value ?? ""), new SerializedRequirements(cfg.upgrade?.Value ?? "")); } bool CustomTableBrowsability() { return cfg.table.Value == CraftingTable.Custom; } bool ItemBrowsability() { return cfg.table.Value != CraftingTable.Disabled; } bool QualityResultBrowsability() { return cfg.requireOneIngredient.Value == Toggle.On; } void TableConfigChanged(object o, EventArgs e) { item3.UpdateItemTableConfig(configKey, cfg.table.Value, cfg.customTable.Value); customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom; foreach (ConfigurationManagerAttributes item8 in hideWhenNoneAttributes) { item8.Browsable = cfg.table.Value != CraftingTable.Disabled; } reloadConfigDisplay(); } bool TableLevelBrowsability() { return cfg.table.Value != CraftingTable.Disabled; } ConfigEntry itemConfig(string name, string value, string desc, bool isUpgrade) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes3 = new ConfigurationManagerAttributes { CustomDrawer = drawRequirementsConfigTable(item3, isUpgrade), Order = (order -= 1), browsability = ItemBrowsability, Browsable = (ItemBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; hideWhenNoneAttributes.Add(configurationManagerAttributes3); return config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes3 })); } } if ((item3.configurability & Configurability.Drop) != 0) { ConfigEntry val3 = (itemDropConfigs[item3] = config(englishName, "Drops from", new SerializedDrop(item3.DropsFrom.Drops).ToString(), new ConfigDescription(englishName + " drops from this creature.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = drawDropsConfigTable, Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Drop) != 0) } }))); ConfigEntry val4 = val3; val4.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { item3.UpdateCharacterDrop(); }; } for (int j = 0; j < item3.Conversions.Count; j++) { string text2 = ((item3.Conversions.Count > 1) ? $"{j + 1}. " : ""); Conversion conversion = item3.Conversions[j]; conversion.config = new Conversion.ConversionConfig(); int index = j; conversion.config.input = config(englishName, text2 + "Conversion Input Item", conversion.Input, new ConfigDescription("Input item to create " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0) } })); conversion.config.input.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { if (index < item3.conversions.Count) { ObjectDB instance = ObjectDB.instance; if (instance != null) { ItemDrop from = SerializedRequirements.fetchByName(instance, conversion.config.input.Value); item3.conversions[index].m_from = from; UpdatePiece(); } } }; conversion.config.piece = config(englishName, text2 + "Conversion Piece", conversion.Piece, new ConfigDescription("Conversion piece used to create " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0) } })); conversion.config.piece.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { UpdatePiece(); }; conversion.config.customPiece = config(englishName, text2 + "Conversion Custom Piece", conversion.customPiece ?? "", new ConfigDescription("Custom conversion piece to create " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0) } })); conversion.config.customPiece.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { UpdatePiece(); }; void UpdatePiece() { if (index < item3.conversions.Count && Object.op_Implicit((Object)(object)ZNetScene.instance)) { string text3 = ((conversion.config.piece.Value == ConversionPiece.Disabled) ? null : ((conversion.config.piece.Value == ConversionPiece.Custom) ? conversion.config.customPiece.Value : getInternalName(conversion.config.piece.Value))); string activePiece = conversion.config.activePiece; if (conversion.config.activePiece != null) { Smelter component = ZNetScene.instance.GetPrefab(conversion.config.activePiece).GetComponent(); int num = component.m_conversion.IndexOf(item3.conversions[index]); if (num >= 0) { Smelter[] array3 = Resources.FindObjectsOfTypeAll(); foreach (Smelter val6 in array3) { if (Utils.GetPrefabName(((Component)val6).gameObject) == activePiece) { val6.m_conversion.RemoveAt(num); } } } conversion.config.activePiece = null; } if (item3.conversions[index].m_from != null && conversion.config.piece.Value != 0) { GameObject prefab = ZNetScene.instance.GetPrefab(text3); if (((prefab != null) ? prefab.GetComponent() : null) != null) { conversion.config.activePiece = text3; Smelter[] array4 = Resources.FindObjectsOfTypeAll(); foreach (Smelter val7 in array4) { if (Utils.GetPrefabName(((Component)val7).gameObject) == text3) { val7.m_conversion.Add(item3.conversions[index]); } } } } } } } } if ((item3.configurability & Configurability.Stats) != 0) { item3.statsConfigs.Clear(); SharedData shared2 = item3.Prefab.GetComponent().m_itemData.m_shared; ItemType itemType = shared2.m_itemType; statcfg("Weight", "Weight of " + englishName + ".", (SharedData shared) => shared.m_weight, delegate(SharedData shared, float value) { shared.m_weight = value; }); statcfg("Trader Value", "Trader value of " + englishName + ".", (SharedData shared) => shared.m_value, delegate(SharedData shared, int value) { shared.m_value = value; }); bool flag; switch (itemType - 3) { case 0: case 1: case 2: case 3: case 4: case 8: case 9: case 11: case 14: case 16: case 19: flag = true; break; default: flag = false; break; } if (flag) { statcfg("Durability", "Durability of " + englishName + ".", (SharedData shared) => shared.m_maxDurability, delegate(SharedData shared, float value) { shared.m_maxDurability = value; }); statcfg("Durability per Level", "Durability gain per level of " + englishName + ".", (SharedData shared) => shared.m_durabilityPerLevel, delegate(SharedData shared, float value) { shared.m_durabilityPerLevel = value; }); statcfg("Movement Speed Modifier", "Movement speed modifier of " + englishName + ".", (SharedData shared) => shared.m_movementModifier, delegate(SharedData shared, float value) { shared.m_movementModifier = value; }); } if ((itemType - 3 <= 2 || (int)itemType == 14 || (int)itemType == 22) ? true : false) { statcfg("Block Armor", "Block armor of " + englishName + ".", (SharedData shared) => shared.m_blockPower, delegate(SharedData shared, float value) { shared.m_blockPower = value; }); statcfg("Block Armor per Level", "Block armor per level for " + englishName + ".", (SharedData shared) => shared.m_blockPowerPerLevel, delegate(SharedData shared, float value) { shared.m_blockPowerPerLevel = value; }); statcfg("Block Force", "Block force of " + englishName + ".", (SharedData shared) => shared.m_deflectionForce, delegate(SharedData shared, float value) { shared.m_deflectionForce = value; }); statcfg("Block Force per Level", "Block force per level for " + englishName + ".", (SharedData shared) => shared.m_deflectionForcePerLevel, delegate(SharedData shared, float value) { shared.m_deflectionForcePerLevel = value; }); statcfg("Parry Bonus", "Parry bonus of " + englishName + ".", (SharedData shared) => shared.m_timedBlockBonus, delegate(SharedData shared, float value) { shared.m_timedBlockBonus = value; }); } else if ((itemType - 6 <= 1 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false) { statcfg("Armor", "Armor of " + englishName + ".", (SharedData shared) => shared.m_armor, delegate(SharedData shared, float value) { shared.m_armor = value; }); statcfg("Armor per Level", "Armor per level for " + englishName + ".", (SharedData shared) => shared.m_armorPerLevel, delegate(SharedData shared, float value) { shared.m_armorPerLevel = value; }); } SkillType skillType = shared2.m_skillType; if (((int)skillType == 7 || (int)skillType == 12) ? true : false) { statcfg("Tool tier", "Tool tier of " + englishName + ".", (SharedData shared) => shared.m_toolTier, delegate(SharedData shared, int value) { shared.m_toolTier = value; }); } if ((itemType - 5 <= 2 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false) { Dictionary modifiers = shared2.m_damageModifiers.ToDictionary((DamageModPair d) => d.m_type, (DamageModPair d) => (DamageModifier)d.m_modifier); DamageType[] first = (DamageType[])Enum.GetValues(typeof(DamageType)); DamageType[] array = new DamageType[5]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); foreach (DamageType item9 in first.Except((IEnumerable)(object)array)) { DamageType damageType = item9; statcfg(((object)(DamageType)(ref damageType)).ToString() + " Resistance", ((object)(DamageType)(ref damageType)).ToString() + " resistance of " + englishName + ".", (SharedData _) => modifiers.TryGetValue(damageType, out var value3) ? value3 : DamageModifier.None, delegate(SharedData shared, DamageModifier value) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //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) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0066: Unknown result type (might be due to invalid IL or missing references) DamageModPair val8 = default(DamageModPair); val8.m_type = damageType; val8.m_modifier = (DamageModifier)value; DamageModPair val9 = val8; for (int num2 = 0; num2 < shared.m_damageModifiers.Count; num2++) { if (shared.m_damageModifiers[num2].m_type == damageType) { if (value == DamageModifier.None) { shared.m_damageModifiers.RemoveAt(num2); } else { shared.m_damageModifiers[num2] = val9; } return; } } if (value != DamageModifier.None) { shared.m_damageModifiers.Add(val9); } }); } } if ((int)itemType == 2 && shared2.m_food > 0f) { statcfg("Health", "Health value of " + englishName + ".", (SharedData shared) => shared.m_food, delegate(SharedData shared, float value) { shared.m_food = value; }); statcfg("Stamina", "Stamina value of " + englishName + ".", (SharedData shared) => shared.m_foodStamina, delegate(SharedData shared, float value) { shared.m_foodStamina = value; }); statcfg("Eitr", "Eitr value of " + englishName + ".", (SharedData shared) => shared.m_foodEitr, delegate(SharedData shared, float value) { shared.m_foodEitr = value; }); statcfg("Duration", "Duration of " + englishName + ".", (SharedData shared) => shared.m_foodBurnTime, delegate(SharedData shared, float value) { shared.m_foodBurnTime = value; }); statcfg("Health Regen", "Health regen value of " + englishName + ".", (SharedData shared) => shared.m_foodRegen, delegate(SharedData shared, float value) { shared.m_foodRegen = value; }); } if ((int)shared2.m_skillType == 10) { statcfg("Health Cost", "Health cost of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackHealth, delegate(SharedData shared, float value) { shared.m_attack.m_attackHealth = value; }); statcfg("Health Cost Percentage", "Health cost percentage of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackHealthPercentage, delegate(SharedData shared, float value) { shared.m_attack.m_attackHealthPercentage = value; }); } skillType = shared2.m_skillType; if (skillType - 9 <= 1) { statcfg("Eitr Cost", "Eitr cost of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackEitr, delegate(SharedData shared, float value) { shared.m_attack.m_attackEitr = value; }); } if ((itemType - 3 <= 1 || (int)itemType == 14 || (int)itemType == 22) ? true : false) { statcfg("Knockback", "Knockback of " + englishName + ".", (SharedData shared) => shared.m_attackForce, delegate(SharedData shared, float value) { shared.m_attackForce = value; }); statcfg("Backstab Bonus", "Backstab bonus of " + englishName + ".", (SharedData shared) => shared.m_backstabBonus, delegate(SharedData shared, float value) { shared.m_backstabBonus = value; }); statcfg("Attack Stamina", "Attack stamina of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackStamina, delegate(SharedData shared, float value) { shared.m_attack.m_attackStamina = value; }); SetDmg("True", (DamageTypes dmg) => dmg.m_damage, delegate(ref DamageTypes dmg, float val) { dmg.m_damage = val; }); SetDmg("Slash", (DamageTypes dmg) => dmg.m_slash, delegate(ref DamageTypes dmg, float val) { dmg.m_slash = val; }); SetDmg("Pierce", (DamageTypes dmg) => dmg.m_pierce, delegate(ref DamageTypes dmg, float val) { dmg.m_pierce = val; }); SetDmg("Blunt", (DamageTypes dmg) => dmg.m_blunt, delegate(ref DamageTypes dmg, float val) { dmg.m_blunt = val; }); SetDmg("Chop", (DamageTypes dmg) => dmg.m_chop, delegate(ref DamageTypes dmg, float val) { dmg.m_chop = val; }); SetDmg("Pickaxe", (DamageTypes dmg) => dmg.m_pickaxe, delegate(ref DamageTypes dmg, float val) { dmg.m_pickaxe = val; }); SetDmg("Fire", (DamageTypes dmg) => dmg.m_fire, delegate(ref DamageTypes dmg, float val) { dmg.m_fire = val; }); SetDmg("Poison", (DamageTypes dmg) => dmg.m_poison, delegate(ref DamageTypes dmg, float val) { dmg.m_poison = val; }); SetDmg("Frost", (DamageTypes dmg) => dmg.m_frost, delegate(ref DamageTypes dmg, float val) { dmg.m_frost = val; }); SetDmg("Lightning", (DamageTypes dmg) => dmg.m_lightning, delegate(ref DamageTypes dmg, float val) { dmg.m_lightning = val; }); SetDmg("Spirit", (DamageTypes dmg) => dmg.m_spirit, delegate(ref DamageTypes dmg, float val) { dmg.m_spirit = val; }); if ((int)itemType == 4) { statcfg("Projectiles", "Number of projectiles that " + englishName + " shoots at once.", (SharedData shared) => shared.m_attack.m_projectileBursts, delegate(SharedData shared, int value) { shared.m_attack.m_projectileBursts = value; }); statcfg("Burst Interval", "Time between the projectiles " + englishName + " shoots at once.", (SharedData shared) => shared.m_attack.m_burstInterval, delegate(SharedData shared, float value) { shared.m_attack.m_burstInterval = value; }); statcfg("Minimum Accuracy", "Minimum accuracy for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileAccuracyMin, delegate(SharedData shared, float value) { shared.m_attack.m_projectileAccuracyMin = value; }); statcfg("Accuracy", "Accuracy for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileAccuracy, delegate(SharedData shared, float value) { shared.m_attack.m_projectileAccuracy = value; }); statcfg("Minimum Velocity", "Minimum velocity for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileVelMin, delegate(SharedData shared, float value) { shared.m_attack.m_projectileVelMin = value; }); statcfg("Velocity", "Velocity for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileVel, delegate(SharedData shared, float value) { shared.m_attack.m_projectileVel = value; }); statcfg("Maximum Draw Time", "Time until " + englishName + " is fully drawn at skill level 0.", (SharedData shared) => shared.m_attack.m_drawDurationMin, delegate(SharedData shared, float value) { shared.m_attack.m_drawDurationMin = value; }); statcfg("Stamina Drain", "Stamina drain per second while drawing " + englishName + ".", (SharedData shared) => shared.m_attack.m_drawStaminaDrain, delegate(SharedData shared, float value) { shared.m_attack.m_drawStaminaDrain = value; }); } } } List traderAttributes; if ((item3.configurability & Configurability.Trader) != 0) { traderAttributes = new List(); item3.traderConfig = new TraderConfig { trader = config(englishName, "Trader Selling", item3.Trade.Trader, new ConfigDescription("Which traders sell " + englishName + ".", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Browsable = ((item3.configurationVisible & Configurability.Trader) != 0), Category = localizedName } })) }; item3.traderConfig.trader.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { item3.ReloadTraderConfiguration(); foreach (ConfigurationManagerAttributes item10 in traderAttributes) { item10.Browsable = TraderBrowsability(); } reloadConfigDisplay(); }; item3.traderConfig.price = traderConfig("Trader Price", item3.Trade.Price, "Price of " + englishName + " at the trader."); item3.traderConfig.stack = traderConfig("Trader Stack", item3.Trade.Stack, "Stack size of " + englishName + " in the trader. Also known as the number of items sold by a trader in one transaction."); item3.traderConfig.requiredGlobalKey = traderConfig("Trader Required Global Key", item3.Trade.RequiredGlobalKey ?? "", "Required global key to unlock " + englishName + " at the trader."); if (item3.traderConfig.trader.Value != 0) { PrefabManager.AddItemToTrader(item3.Prefab, item3.traderConfig.trader.Value, item3.traderConfig.price.Value, item3.traderConfig.stack.Value, item3.traderConfig.requiredGlobalKey.Value); } } else if (item3.Trade.Trader != 0) { PrefabManager.AddItemToTrader(item3.Prefab, item3.Trade.Trader, item3.Trade.Price, item3.Trade.Stack, item3.Trade.RequiredGlobalKey); } void SetDmg(string dmgType, Func readDmg, setDmgFunc setDmg) { statcfg(dmgType + " Damage", dmgType + " damage dealt by " + englishName + ".", (SharedData shared) => readDmg(shared.m_damages), delegate(SharedData shared, float val) { setDmg(ref shared.m_damages, val); }); statcfg(dmgType + " Damage Per Level", dmgType + " damage dealt increase per level for " + englishName + ".", (SharedData shared) => readDmg(shared.m_damagesPerLevel), delegate(SharedData shared, float val) { setDmg(ref shared.m_damagesPerLevel, val); }); } bool TraderBrowsability() { return item3.traderConfig.trader.Value != Trader.None; } void statcfg(string configName, string description, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 1, 1, 0 })] Func readDefault, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 1, 1, 0 })] Action setValue) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown ConfigEntry cfg2; if (item3.EnabledStatsConfigs.Count <= 0 || item3.EnabledStatsConfigs.Contains(configName)) { SharedData shared3 = item3.Prefab.GetComponent().m_itemData.m_shared; cfg2 = config(englishName, configName, readDefault(shared3), new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Stats) != 0) } })); if ((item3.configurationVisible & Configurability.Stats) != 0) { setValue(shared3, cfg2.Value); } item3.statsConfigs.Add((ConfigEntryBase)(object)cfg2, ApplyConfig); cfg2.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { if ((item3.configurationVisible & Configurability.Stats) != 0) { ApplyConfig(); } }; } void ApplyConfig() { item3.ApplyToAllInstances(delegate(ItemData item) { setValue(item.m_shared, cfg2.Value); }); } } [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 1, 0 })] ConfigEntry traderConfig(string name, [<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(0)] T value, string desc) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes2 = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = TraderBrowsability, Browsable = (TraderBrowsability() && (item3.configurationVisible & Configurability.Trader) != 0), Category = localizedName }; traderAttributes.Add(configurationManagerAttributes2); ConfigEntry val5 = config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes2 })); val5.SettingChanged += [NullableContext(0)] (object _, EventArgs _) => { item3.ReloadTraderConfiguration(); }; return val5; } } if (saveOnConfigSet) { plugin.Config.SaveOnConfigSet = true; plugin.Config.Save(); } } configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type)); foreach (Item registeredItem in registeredItems) { Item item2 = registeredItem; foreach (KeyValuePair recipe in item2.Recipes) { KeyValuePair kv = recipe; RequiredResourceList[] array2 = new RequiredResourceList[2] { kv.Value.RequiredItems, kv.Value.RequiredUpgradeItems }; foreach (RequiredResourceList requiredResourceList in array2) { for (int l = 0; l < requiredResourceList.Requirements.Count; l++) { ConfigEntry amountCfg; int resourceIndex; if ((item2.configurability & Configurability.Recipe) != 0) { amountCfg = requiredResourceList.Requirements[l].amountConfig; if (amountCfg != null) { resourceIndex = l; amountCfg.SettingChanged += ConfigChanged; } } void ConfigChanged(object o, EventArgs e) { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && activeRecipes.ContainsKey(item2) && activeRecipes[item2].TryGetValue(kv.Key, out var value2)) { foreach (Recipe item11 in value2) { item11.m_resources[resourceIndex].m_amount = amountCfg.Value; } } } } } } item2.InitializeNewRegisteredItem(); } } private void InitializeNewRegisteredItem() { foreach (KeyValuePair recipe in Recipes) { KeyValuePair kv = recipe; ConfigEntryBase enabledCfg = kv.Value.RecipeIsActive; if (enabledCfg != null) { ((object)enabledCfg).GetType().GetEvent("SettingChanged").AddEventHandler(enabledCfg, new EventHandler(ConfigChanged)); } void ConfigChanged(object o, EventArgs e) { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && activeRecipes.ContainsKey(this) && activeRecipes[this].TryGetValue(kv.Key, out var value)) { foreach (Recipe item in value) { item.m_enabled = (int)enabledCfg.BoxedValue != 0; } } } } } public void ReloadCraftingConfiguration() { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && ObjectDB.instance.GetItemPrefab(StringExtensionMethods.GetStableHashCode(((Object)Prefab).name)) == null) { registerRecipesInObjectDB(ObjectDB.instance); ObjectDB.instance.m_items.Add(Prefab); ObjectDB.instance.m_itemByHash.Add(StringExtensionMethods.GetStableHashCode(((Object)Prefab).name), Prefab); ZNetScene.instance.m_prefabs.Add(Prefab); ZNetScene.instance.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)Prefab).name), Prefab); } foreach (string item in Recipes.Keys.DefaultIfEmpty("")) { if (Recipes.TryGetValue(item, out var value) && value.Crafting.Stations.Count > 0) { UpdateItemTableConfig(item, value.Crafting.Stations.First().Table, value.Crafting.Stations.First().custom ?? ""); UpdateCraftConfig(item, new SerializedRequirements(value.RequiredItems.Requirements), new SerializedRequirements(value.RequiredUpgradeItems.Requirements)); } } } private void ReloadTraderConfiguration() { if (traderConfig.trader.Value == Trader.None) { PrefabManager.RemoveItemFromTrader(Prefab); } else { PrefabManager.AddItemToTrader(Prefab, traderConfig.trader.Value, traderConfig.price.Value, traderConfig.stack.Value, traderConfig.requiredGlobalKey.Value); } } public static void ApplyToAllInstances(GameObject prefab, Action callback) { callback(prefab.GetComponent().m_itemData); string name = prefab.GetComponent().m_itemData.m_shared.m_name; Inventory[] source = (from c in Player.s_players.Select([NullableContext(0)] (Player p) => ((Humanoid)p).GetInventory()).Concat(from c in Object.FindObjectsOfType() select c.GetInventory()) where c != null select c).ToArray(); foreach (ItemData item in (from i in (from p in ObjectDB.instance.m_items select p.GetComponent() into c where Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)((Component)c).GetComponent()) select c).Concat(ItemDrop.s_instances) select i.m_itemData).Concat(source.SelectMany([NullableContext(0)] (Inventory i) => i.GetAllItems()))) { if (item.m_shared.m_name == name) { callback(item); } } } public void ApplyToAllInstances(Action callback) { ApplyToAllInstances(Prefab, callback); } [NullableContext(0)] [return: <49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(1)] private static string getInternalName(T value) where T : struct { return ((InternalName)typeof(T).GetMember(value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName; } private void registerRecipesInObjectDB(ObjectDB objectDB) { //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Expected O, but got Unknown activeRecipes[this] = new Dictionary>(); itemCraftConfigs.TryGetValue(this, out var value); foreach (KeyValuePair recipe in Recipes) { List list = new List(); foreach (CraftingStationConfig station in recipe.Value.Crafting.Stations) { ItemConfig itemConfig = value?[recipe.Key]; Recipe val = ScriptableObject.CreateInstance(); string name = ((Object)Prefab).name; CraftingTable table = station.Table; ((Object)val).name = name + "_Recipe_" + table; val.m_amount = recipe.Value.CraftAmount; bool enabled; if (itemConfig != null) { enabled = itemConfig.table.Value != CraftingTable.Disabled; } else { ConfigEntryBase recipeIsActive = recipe.Value.RecipeIsActive; enabled = (int)(((recipeIsActive != null) ? recipeIsActive.BoxedValue : null) ?? ((object)1)) != 0; } val.m_enabled = enabled; val.m_item = Prefab.GetComponent(); val.m_resources = SerializedRequirements.toPieceReqs(objectDB, (itemConfig?.craft == null) ? new SerializedRequirements(recipe.Value.RequiredItems.Requirements) : new SerializedRequirements(itemConfig.craft.Value), (itemConfig?.upgrade == null) ? new SerializedRequirements(recipe.Value.RequiredUpgradeItems.Requirements) : new SerializedRequirements(itemConfig.upgrade.Value)); table = ((itemConfig == null || list.Count > 0) ? station.Table : itemConfig.table.Value); if ((uint)table <= 1u) { val.m_craftingStation = null; } else if (((itemConfig == null || list.Count > 0) ? station.Table : itemConfig.table.Value) == CraftingTable.Custom) { GameObject prefab = ZNetScene.instance.GetPrefab((itemConfig == null || list.Count > 0) ? station.custom : itemConfig.customTable.Value); if (prefab != null) { val.m_craftingStation = prefab.GetComponent(); } else { Debug.LogWarning((object)("Custom crafting station '" + ((itemConfig == null || list.Count > 0) ? station.custom : itemConfig.customTable.Value) + "' does not exist")); } } else { val.m_craftingStation = ZNetScene.instance.GetPrefab(getInternalName((itemConfig == null || list.Count > 0) ? station.Table : itemConfig.table.Value)).GetComponent(); } val.m_minStationLevel = ((itemConfig == null || list.Count > 0) ? station.level : itemConfig.tableLevel.Value); val.m_requireOnlyOneIngredient = ((itemConfig == null) ? recipe.Value.RequireOnlyOneIngredient : (itemConfig.requireOneIngredient.Value == Toggle.On)); val.m_qualityResultAmountMultiplier = itemConfig?.qualityResultAmountMultiplier.Value ?? recipe.Value.QualityResultAmountMultiplier; list.Add(val); RequiredResourceList requiredItems = recipe.Value.RequiredItems; if (requiredItems != null && !requiredItems.Free) { List requirements = requiredItems.Requirements; if (requirements != null && requirements.Count == 0) { hiddenCraftRecipes.Add(val, recipe.Value.RecipeIsActive); } } requiredItems = recipe.Value.RequiredUpgradeItems; if (requiredItems != null && !requiredItems.Free) { List requirements = requiredItems.Requirements; if (requirements != null && requirements.Count == 0) { hiddenUpgradeRecipes.Add(val, recipe.Value.RecipeIsActive); } } } activeRecipes[this].Add(recipe.Key, list); objectDB.m_recipes.AddRange(list); } conversions = new List(); for (int i = 0; i < Conversions.Count; i++) { Conversion conversion = Conversions[i]; conversions.Add(new ItemConversion { m_from = SerializedRequirements.fetchByName(ObjectDB.instance, conversion.config?.input.Value ?? conversion.Input), m_to = Prefab.GetComponent() }); ConversionPiece conversionPiece = conversion.config?.piece.Value ?? conversion.Piece; string text = null; if (conversionPiece != 0 && conversions[i].m_from != null) { text = ((conversionPiece != ConversionPiece.Custom) ? getInternalName(conversionPiece) : (conversion.config?.customPiece.Value ?? conversion.customPiece)); GameObject prefab2 = ZNetScene.instance.GetPrefab(text); Smelter val2 = ((prefab2 != null) ? prefab2.GetComponent() : null); if (val2 != null) { val2.m_conversion.Add(conversions[i]); } else { text = null; } } if (conversion.config != null) { conversion.config.activePiece = text; } } } [HarmonyPriority(0)] internal static void Patch_ObjectDBInit(ObjectDB __instance) { if ((Object)(object)__instance.GetItemPrefab("YagluthDrop") == (Object)null) { return; } hiddenCraftRecipes.Clear(); hiddenUpgradeRecipes.Clear(); foreach (Item registeredItem in registeredItems) { registeredItem.registerRecipesInObjectDB(__instance); } } internal static void Patch_TraderGetAvailableItems(Trader __instance, ref List __result) { string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject); if (1 == 0) { } Trader trader2 = ((prefabName == "Haldor") ? Trader.Haldor : ((prefabName == "Hildir") ? Trader.Hildir : Trader.None)); if (1 == 0) { } Trader trader = trader2; __result.AddRange(from tuple in PrefabManager.CustomTradeItems.Values where (tuple.Item1 & trader) != 0 select tuple.Item2 into tradeItem where string.IsNullOrEmpty(tradeItem.m_requiredGlobalKey) || ZoneSystem.instance.GetGlobalKey(tradeItem.m_requiredGlobalKey) select tradeItem); } internal static void Patch_OnAddSmelterInput(ItemData item, bool __result) { if (__result) { ((Humanoid)Player.m_localPlayer).UnequipItem(item, true); } } internal static void Patch_MaximumRequiredStationLevel(Recipe __instance, ref int __result, int quality) { if (!itemDropMap.TryGetValue(__instance.m_item, out var value)) { return; } IEnumerable source; if (!itemCraftConfigs.TryGetValue(value, out var value2)) { source = Enumerable.Empty(); } else { CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation(); if (currentCraftingStation != null) { string stationName = Utils.GetPrefabName(((Component)currentCraftingStation).gameObject); source = from c in value2.Where([NullableContext(0)] (KeyValuePair c) => { CraftingTable value3 = c.Value.table.Value; if (1 == 0) { } bool result; switch (value3) { case CraftingTable.Disabled: case CraftingTable.Inventory: result = false; break; case CraftingTable.Custom: result = c.Value.customTable.Value == stationName; break; default: result = getInternalName(c.Value.table.Value) == stationName; break; } if (1 == 0) { } return result; }) select c.Value; } else { source = value2.Values; } } __result = Mathf.Min(Mathf.Max(1, __instance.m_minStationLevel) + (quality - 1), (from cfg in source where cfg.maximumTableLevel != null select cfg.maximumTableLevel.Value).DefaultIfEmpty(value.MaximumRequiredStationLevel).Max()); } internal static void Patch_GetAvailableRecipesPrefix([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 2, 1, 1, 1, 2 })] ref Dictionary> __state) { if (__state == null) { __state = new Dictionary>(); } Dictionary dictionary; if (InventoryGui.instance.InCraftTab()) { dictionary = hiddenCraftRecipes; } else { if (!InventoryGui.instance.InUpradeTab()) { return; } dictionary = hiddenUpgradeRecipes; } foreach (Recipe key in dictionary.Keys) { key.m_enabled = false; } __state[Assembly.GetExecutingAssembly()] = dictionary; } internal static void Patch_GetAvailableRecipesFinalizer([<49e4b12e-f0b5-4be8-bcf3-f4780f1def32>Nullable(new byte[] { 1, 1, 1, 1, 2 })] Dictionary> __state) { if (!__state.TryGetValue(Assembly.GetExecutingAssembly(), out var value)) { return; } foreach (KeyValuePair item in value) { Recipe key = item.Key; ConfigEntryBase value2 = item.Value; key.m_enabled = (int)(((value2 != null) ? value2.BoxedValue : null) ?? ((object)1)) != 0; } } internal static IEnumerable Transpile_SetupRequirementList(IEnumerable instructionsEnumerable, ILGenerator ilg) { //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Expected O, but got Unknown //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Expected O, but got Unknown //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected O, but got Unknown //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Expected O, but got Unknown //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Expected O, but got Unknown //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Expected O, but got Unknown //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Expected O, but got Unknown List list = instructionsEnumerable.ToList(); MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(InventoryGui), "SetupRequirement", (Type[])null, (Type[])null); CodeInstruction val = null; CodeInstruction val2 = null; LocalBuilder localBuilder = ilg.DeclareLocal(typeof(int)); Dictionary dictionary = new Dictionary(); bool flag = false; int num = 0; int value = 0; Label? label = default(Label?); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo)) { val = list[i + 2]; val2 = list[i + 5]; flag = true; } if (flag) { if (CodeInstructionExtensions.Branches(list[i], ref label) && dictionary.TryGetValue(label.Value, out value)) { num = i; break; } continue; } foreach (Label label4 in list[i].labels) { dictionary[label4] = i; } } if (list[value - 3].opcode == OpCodes.Dup) { return list; } Label label2 = ilg.DefineLabel(); Label label3 = ilg.DefineLabel(); list[num + 1].labels.Add(label2); list.InsertRange(num + 1, (IEnumerable)(object)new CodeInstruction[11] { new CodeInstruction(OpCodes.Ldloc, (object)localBuilder), new CodeInstruction(OpCodes.Brfalse, (object)label2), val.Clone(), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.DeclaredField(typeof(InventoryGui), "m_recipeRequirementList")), new CodeInstruction(OpCodes.Ldlen, (object)null), new CodeInstruction(OpCodes.Bgt, (object)label2), new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), val2.Clone(), new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), new CodeInstruction(OpCodes.Br, (object)label3) }); list.InsertRange(value - 2, (IEnumerable)(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Dup, (object)null) { labels = new List