Decompiled source of HS CraftableBossItems v0.1.3
plugins/HS_CraftableBossItems.dll
Decompiled 6 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Buffers; using System.Collections; using System.Collections.Generic; 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.Numerics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HS; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; [assembly: AssemblyTitle("HS_CraftableBossItems")] [assembly: AssemblyProduct("HS_CraftableBossItems")] [assembly: AssemblyInformationalVersion("0.1.3+222176b933df4fc190f17b79a48938b41c6ea217")] [assembly: AssemblyFileVersion("0.1.3.0")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCompany("HS")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.3.0")] [module: <d7f566c5-4d2b-45ef-97b6-306ebc918b39>RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<de7844f0-cd83-4e24-887d-28c3a3a6ea36>Embedded] internal sealed class <de7844f0-cd83-4e24-887d-28c3a3a6ea36>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [<de7844f0-cd83-4e24-887d-28c3a3a6ea36>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [CompilerGenerated] internal sealed class <d7a857e5-55f7-4181-aac5-d47bf1828e30>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <d7a857e5-55f7-4181-aac5-d47bf1828e30>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <d7a857e5-55f7-4181-aac5-d47bf1828e30>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<de7844f0-cd83-4e24-887d-28c3a3a6ea36>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContextAttribute : Attribute { public readonly byte Flag; public <4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContextAttribute(byte P_0) { Flag = P_0; } } [<de7844f0-cd83-4e24-887d-28c3a3a6ea36>Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] [CompilerGenerated] internal sealed class <d7f566c5-4d2b-45ef-97b6-306ebc918b39>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <d7f566c5-4d2b-45ef-97b6-306ebc918b39>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(1)] [<d7a857e5-55f7-4181-aac5-d47bf1828e30>Nullable(0)] internal sealed class ConfigurationManagerAttributes { [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput); public bool? ShowRangeAsPercent; public Action<ConfigEntryBase> CustomDrawer; public CustomHotkeyDrawerFunc CustomHotkeyDrawer; public bool? Browsable; public string Category; public object DefaultValue; public bool? HideDefaultButton; public bool? HideSettingName; public string Description; public string DispName; public int? Order; public bool? ReadOnly; public bool? IsAdvanced; public Func<object, string> ObjToStr; public Func<string, object> StrToObj; } namespace HS { [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(1)] [<d7a857e5-55f7-4181-aac5-d47bf1828e30>Nullable(0)] internal static class VersionChecker { private const string ValheimVersion = "0.218.15"; public static bool Check(ManualLogSource logger, PluginInfo info, bool allowWrongVersion = false, [<d7a857e5-55f7-4181-aac5-d47bf1828e30>Nullable(2)] ConfigFile config = null) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) GameVersion currentVersion = Version.CurrentVersion; string text = ((object)(GameVersion)(ref currentVersion)).ToString(); if (text == "0.218.15") { return true; } string text2 = $"The current version of {info.Metadata.Name} (v{info.Metadata.Version}) is designed for Valheim version {"0.218.15"}, however, your current Valheim version was {text}.\n"; if (!allowWrongVersion) { string text3 = "ERROR: " + text2 + "To resolve this issue, please obtain the appropriate plugin version, or alternatively, await an update if one is not currently available.\nPlease download the correct plugin version or wait for the plugin to be updated if a new version is not available."; logger.LogError((object)text3); Chainloader.DependencyErrors.Add(text3); if (config != null) { SetConfigAlert(config, text3); } return false; } logger.LogWarning((object)("WARNING: " + text2 + "Although the plugin author has permitted this version to work with an outdated Valheim version, it's important to note that unforeseen complications may occur\nPlease download the correct plugin version or wait for the plugin to be updated if a new version is not available and any issues arise.")); return true; } private static void SetConfigAlert([<d7a857e5-55f7-4181-aac5-d47bf1828e30>Nullable(2)] ConfigFile config, string errorMessage) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown if (config != null) { config.Bind<string>("", "NotCompatable", "", new ConfigDescription(errorMessage, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = ErrorLabelDrawer, ReadOnly = true, HideDefaultButton = true, HideSettingName = true, Category = null } })); } } private static void ErrorLabelDrawer(ConfigEntryBase entry) { //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) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.label) { wordWrap = true, stretchWidth = true }; GUIStyle val2 = new GUIStyle(GUI.skin.label) { stretchWidth = true, alignment = (TextAnchor)4 }; val2.normal.textColor = Color.red; val2.fontStyle = (FontStyle)1; GUIStyle val3 = val2; GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Label(entry.Description.Description, val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label("Plugin has been disabled!", val3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.EndVertical(); } } } namespace HS_CraftableBossItems { [BepInPlugin("HS_CraftableBossItems", "HS_CraftableBossItems", "0.1.3")] [<d7a857e5-55f7-4181-aac5-d47bf1828e30>Nullable(0)] [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(1)] public class Plugin : BaseUnityPlugin { [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] private enum Toggle { On = 1, Off = 0 } [<d7a857e5-55f7-4181-aac5-d47bf1828e30>Nullable(0)] public class InternalName : Attribute { public readonly string internalName; public InternalName(string internalName) { this.internalName = internalName; } } [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] public enum CraftingTable { [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 } [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] public struct Requirement { [<d7a857e5-55f7-4181-aac5-d47bf1828e30>Nullable(1)] public string ItemName; public int Amount; [<d7a857e5-55f7-4181-aac5-d47bf1828e30>Nullable(2)] public ConfigEntry<int> AmountConfig; } [<d7a857e5-55f7-4181-aac5-d47bf1828e30>Nullable(0)] public class SerializedRequirements { public readonly List<Requirement> Requirements; public SerializedRequirements(List<Requirement> requirements) { Requirements = requirements; } public SerializedRequirements(string requirements) { Requirements = requirements.Split(new char[1] { ',' }).Select([<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>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); return result; }).ToList(); } public override string ToString() { return string.Join(",", Requirements.Select([<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (Requirement r) => $"{r.ItemName}:{r.Amount}")); } [return: <d7a857e5-55f7-4181-aac5-d47bf1828e30>Nullable(2)] public static ItemDrop FetchByName(ObjectDB objectDB, string name) { GameObject itemPrefab = objectDB.GetItemPrefab(name); if (itemPrefab == null) { return null; } return itemPrefab.GetComponent<ItemDrop>(); } public static Requirement[] ToPieceReqs(ObjectDB objectDB, SerializedRequirements craft, SerializedRequirements upgrade) { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00e0: Expected O, but got Unknown //IL_00e5: Expected O, but got Unknown Dictionary<string, Requirement> dictionary = craft.Requirements.Where((Requirement r) => r.ItemName != "").ToDictionary((Func<Requirement, string>)([<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (Requirement r) => r.ItemName), (Func<Requirement, Requirement>)([<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown ItemDrop val4 = ResItem(r); return (val4 != null) ? new Requirement { m_amount = (r.AmountConfig?.Value ?? r.Amount), m_resItem = val4, m_amountPerLevel = 0 } : ((Requirement)null); })); foreach (Requirement item in upgrade.Requirements.Where((Requirement r) => r.ItemName != "")) { if (!dictionary.TryGetValue(item.ItemName, out var value) || value == null) { ItemDrop val = ResItem(item); if (val != null) { string itemName = item.ItemName; Requirement val2 = new Requirement { m_resItem = val, m_amount = 0 }; Requirement val3 = val2; dictionary[itemName] = val2; value = val3; } } if (value != null) { value.m_amountPerLevel = item.AmountConfig?.Value ?? item.Amount; } } return dictionary.Values.Where([<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (Requirement v) => v != null).ToArray(); [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(2)] ItemDrop ResItem(Requirement r) { return FetchByName(objectDB, r.ItemName); } } } public static ConfigSync ConfigSync = new ConfigSync("HS_CraftableBossItems") { DisplayName = "HS_CraftableBossItems", CurrentVersion = "0.1.3", MinimumRequiredVersion = "0.1.1", ModRequired = true }; private static ConfigEntry<Toggle> _serverConfigLocked = null; private static ConfigEntry<bool> _modEnabled = null; private static ConfigEntry<bool> _overrideVersionCheck = null; public static ConfigEntry<bool> EikythrDropEnabled = null; public static ConfigEntry<CraftingTable> EikythrTable = null; public static ConfigEntry<string> EikythrRequirements = null; public static ConfigEntry<int> EikythrAmount = null; public static ConfigEntry<int> EikythrLevel = null; public static ConfigEntry<bool> EikythrTrophyEnabled = null; public static ConfigEntry<CraftingTable> EikythrTrophyTable = null; public static ConfigEntry<string> EikythrTrophyRequirements = null; public static ConfigEntry<int> EikythrTrophyAmount = null; public static ConfigEntry<int> EikythrTrophyLevel = null; public static ConfigEntry<bool> TheElderDropEnabled = null; public static ConfigEntry<CraftingTable> TheElderTable = null; public static ConfigEntry<string> TheElderRequirements = null; public static ConfigEntry<int> TheElderAmount = null; public static ConfigEntry<int> TheElderLevel = null; public static ConfigEntry<bool> TheElderTrophyEnabled = null; public static ConfigEntry<CraftingTable> TheElderTrophyTable = null; public static ConfigEntry<string> TheElderTrophyRequirements = null; public static ConfigEntry<int> TheElderTrophyAmount = null; public static ConfigEntry<int> TheElderTrophyLevel = null; public static ConfigEntry<bool> YagluthDropEnabled = null; public static ConfigEntry<CraftingTable> YagluthTable = null; public static ConfigEntry<string> YagluthRequirements = null; public static ConfigEntry<int> YagluthAmount = null; public static ConfigEntry<int> YagluthLevel = null; public static ConfigEntry<bool> YagluthTrophyEnabled = null; public static ConfigEntry<CraftingTable> YagluthTrophyTable = null; public static ConfigEntry<string> YagluthTrophyRequirements = null; public static ConfigEntry<int> YagluthTrophyAmount = null; public static ConfigEntry<int> YagluthTrophyLevel = null; public static ConfigEntry<bool> DragonQueenDropEnabled = null; public static ConfigEntry<CraftingTable> DragonQueenTable = null; public static ConfigEntry<string> DragonQueenRequirements = null; public static ConfigEntry<int> DragonQueenAmount = null; public static ConfigEntry<int> DragonQueenLevel = null; public static ConfigEntry<bool> DragonQueenTrophyEnabled = null; public static ConfigEntry<CraftingTable> DragonQueenTrophyTable = null; public static ConfigEntry<string> DragonQueenTrophyRequirements = null; public static ConfigEntry<int> DragonQueenTrophyAmount = null; public static ConfigEntry<int> DragonQueenTrophyLevel = null; public static ConfigEntry<bool> BonemassDropEnabled = null; public static ConfigEntry<CraftingTable> BonemassTable = null; public static ConfigEntry<string> BonemassRequirements = null; public static ConfigEntry<int> BonemassAmount = null; public static ConfigEntry<int> BonemassLevel = null; public static ConfigEntry<bool> BonemassTrophyEnabled = null; public static ConfigEntry<CraftingTable> BonemassTrophyTable = null; public static ConfigEntry<string> BonemassTrophyRequirements = null; public static ConfigEntry<int> BonemassTrophyAmount = null; public static ConfigEntry<int> BonemassTrophyLevel = null; public static ConfigEntry<bool> TheQueenDropEnabled = null; public static ConfigEntry<CraftingTable> TheQueenTable = null; public static ConfigEntry<string> TheQueenRequirements = null; public static ConfigEntry<int> TheQueenAmount = null; public static ConfigEntry<int> TheQueenLevel = null; public static ConfigEntry<bool> TheQueenTrophyEnabled = null; public static ConfigEntry<CraftingTable> TheQueenTrophyTable = null; public static ConfigEntry<string> TheQueenTrophyRequirements = null; public static ConfigEntry<int> TheQueenTrophyAmount = null; public static ConfigEntry<int> TheQueenTrophyLevel = null; public static ConfigEntry<bool> FaderDropEnabled = null; public static ConfigEntry<CraftingTable> FaderTable = null; public static ConfigEntry<string> FaderRequirements = null; public static ConfigEntry<int> FaderAmount = null; public static ConfigEntry<int> FaderLevel = null; public static ConfigEntry<bool> FaderTrophyEnabled = null; public static ConfigEntry<CraftingTable> FaderTrophyTable = null; public static ConfigEntry<string> FaderTrophyRequirements = null; public static ConfigEntry<int> FaderTrophyAmount = null; public static ConfigEntry<int> FaderTrophyLevel = null; public static readonly ManualLogSource HS_Logger = Logger.CreateLogSource("HS_CraftableBossItems"); private ConfigEntry<T> Config<[<d7a857e5-55f7-4181-aac5-d47bf1828e30>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, description); ConfigSync.AddConfigEntry<T>(val).SynchronizedConfig = synchronizedSetting; return val; } private ConfigEntry<T> Config<[<d7a857e5-55f7-4181-aac5-d47bf1828e30>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return Config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting); } public void Awake() { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_13eb: Unknown result type (might be due to invalid IL or missing references) //IL_1416: Unknown result type (might be due to invalid IL or missing references) //IL_1424: Expected O, but got Unknown _serverConfigLocked = Config("1 - General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only."); ConfigSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked); _modEnabled = Config("1 - General", "Mod Enabled", value: true, ""); _modEnabled.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { InvokeOnVanillaObjectsAvailable(); }; _overrideVersionCheck = Config("1 - General", "Override Version Check", value: true, new ConfigDescription("Set to True to override the Valheim version check and allow the mod to start even if an incorrect Valheim version is detected.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = false } })); EikythrDropEnabled = Config("2 - HardAntler (Eikythr)", "Boss Drop Enabled", value: true, " Enable Crafting of HardAntler"); EikythrDropEnabled.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { InvokeOnVanillaObjectsAvailable(); }; EikythrTable = Config("2 - HardAntler (Eikythr)", "Table", CraftingTable.Workbench, "Crafting station needed to construct HardAntler."); EikythrTable.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { ZNetScene.instance.GetPrefab(GetInternalName(EikythrTable.Value)).GetComponent<CraftingStation>(); }; EikythrRequirements = Config("2 - HardAntler (Eikythr)", "Requirements", "TrophyDeer:20,Resin:2", "The required items to construct HardAntler."); EikythrRequirements.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe42 = GetRecipe("HardAntler"); if ((Object)(object)recipe42 != (Object)null) { recipe42.m_resources = GetRequirements(EikythrRequirements); } }; EikythrAmount = Config("2 - HardAntler (Eikythr)", "Amount", 1, "The amount of HardAntler created."); EikythrAmount.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe41 = GetRecipe("HardAntler"); if ((Object)(object)recipe41 != (Object)null) { recipe41.m_amount = EikythrAmount.Value; } }; EikythrLevel = Config("2 - HardAntler (Eikythr)", "Station Level", 3, "Level of crafting station required to craft HardAntler."); EikythrLevel.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe40 = GetRecipe("HardAntler"); if ((Object)(object)recipe40 != (Object)null) { recipe40.m_minStationLevel = EikythrLevel.Value; } }; EikythrTrophyEnabled = Config("2 - TrophyEikthyr (Eikythr)", "Boss Trophy Enabled", value: true, " Enable Crafting of TrophyEikthyr"); EikythrTrophyEnabled.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { InvokeOnVanillaObjectsAvailable(); }; EikythrTrophyTable = Config("2 - TrophyEikthyr (Eikythr)", "Table", CraftingTable.Workbench, "Crafting station needed to construct TrophyEikthyr."); EikythrTrophyTable.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { ZNetScene.instance.GetPrefab(GetInternalName(EikythrTrophyTable.Value)).GetComponent<CraftingStation>(); }; EikythrTrophyRequirements = Config("2 - TrophyEikthyr (Eikythr)", "Requirements", "TrophyDeer:20,Resin:2", "The required items to construct TrophyEikthyr."); EikythrTrophyRequirements.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe39 = GetRecipe("TrophyEikthyr"); if ((Object)(object)recipe39 != (Object)null) { recipe39.m_resources = GetRequirements(EikythrTrophyRequirements); } }; EikythrTrophyAmount = Config("2 - TrophyEikthyr (Eikythr)", "Amount", 1, "The amount of TrophyEikthyr created."); EikythrTrophyAmount.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe38 = GetRecipe("TrophyEikthyr"); if ((Object)(object)recipe38 != (Object)null) { recipe38.m_amount = EikythrTrophyAmount.Value; } }; EikythrTrophyLevel = Config("2 - HardAntler (Eikythr)", "Station Level", 3, "Level of crafting station required to craft TrophyEikthyr."); EikythrTrophyLevel.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe37 = GetRecipe("TrophyEikthyr"); if ((Object)(object)recipe37 != (Object)null) { recipe37.m_minStationLevel = EikythrTrophyLevel.Value; } }; TheElderDropEnabled = Config("3 - CryptKey (TheElder)", "Boss Drop Enabled", value: true, " Enable Crafting of CryptKey"); TheElderDropEnabled.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { InvokeOnVanillaObjectsAvailable(); }; TheElderTable = Config("3 - CryptKey (TheElder)", "Table", CraftingTable.Forge, "Crafting station needed to construct CryptKey."); TheElderTable.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { ZNetScene.instance.GetPrefab(GetInternalName(TheElderTable.Value)).GetComponent<CraftingStation>(); }; TheElderRequirements = Config("3 - CryptKey (TheElder)", "Requirements", "AncientSeed:5,Bronze:20", "The required items to construct CryptKey."); TheElderRequirements.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe36 = GetRecipe("CryptKey"); if ((Object)(object)recipe36 != (Object)null) { recipe36.m_resources = GetRequirements(TheElderRequirements); } }; TheElderAmount = Config("3 - CryptKey (TheElder)", "Amount", 1, "The amount of CryptKey created."); TheElderAmount.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe35 = GetRecipe("CryptKey"); if ((Object)(object)recipe35 != (Object)null) { recipe35.m_amount = TheElderAmount.Value; } }; TheElderLevel = Config("3 - CryptKey (TheElder)", "Station Level", 3, "Level of crafting station required to craft CryptKey."); TheElderLevel.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe34 = GetRecipe("CryptKey"); if ((Object)(object)recipe34 != (Object)null) { recipe34.m_minStationLevel = TheElderLevel.Value; } }; TheElderTrophyEnabled = Config("3 - TrophyTheElder (TheElder)", "Boss Trophy Enabled", value: true, " Enable Crafting of TrophyTheElder"); TheElderTrophyEnabled.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { InvokeOnVanillaObjectsAvailable(); }; TheElderTrophyTable = Config("3 - TrophyTheElder (TheElder)", "Table", CraftingTable.Forge, "Crafting station needed to construct TrophyTheElder."); TheElderTrophyTable.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { ZNetScene.instance.GetPrefab(GetInternalName(TheElderTrophyTable.Value)).GetComponent<CraftingStation>(); }; TheElderTrophyRequirements = Config("3 - TrophyTheElder (TheElder)", "Requirements", "AncientSeed:5,Bronze:20", "The required items to construct TrophyTheElder."); TheElderTrophyRequirements.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe33 = GetRecipe("TrophyTheElder"); if ((Object)(object)recipe33 != (Object)null) { recipe33.m_resources = GetRequirements(TheElderTrophyRequirements); } }; TheElderTrophyAmount = Config("3 - TrophyTheElder (TheElder)", "Amount", 1, "The amount of TrophyTheElder created."); TheElderTrophyAmount.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe32 = GetRecipe("TrophyTheElder"); if ((Object)(object)recipe32 != (Object)null) { recipe32.m_amount = TheElderTrophyAmount.Value; } }; TheElderTrophyLevel = Config("3 - TrophyTheElder (TheElder)", "Station Level", 3, "Level of crafting station required to craft TrophyTheElder."); TheElderTrophyLevel.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe31 = GetRecipe("TrophyTheElder"); if ((Object)(object)recipe31 != (Object)null) { recipe31.m_minStationLevel = TheElderTrophyLevel.Value; } }; BonemassDropEnabled = Config("4 - Wishbone (Bonemass)", "Boss Drop Enabled", value: true, " Enable Crafting of Wishbone"); BonemassDropEnabled.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { InvokeOnVanillaObjectsAvailable(); }; BonemassTable = Config("4 - Wishbone (Bonemass)", "Table", CraftingTable.Forge, "Crafting station needed to construct Wishbone."); BonemassTable.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { ZNetScene.instance.GetPrefab(GetInternalName(BonemassTable.Value)).GetComponent<CraftingStation>(); }; BonemassRequirements = Config("4 - Wishbone (Bonemass)", "Requirements", "WitheredBone:15,Iron:2,TrophyDraugr:3,TrophyDraugrElite:1", "The required items to construct Wishbone."); BonemassRequirements.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe30 = GetRecipe("Wishbone"); if ((Object)(object)recipe30 != (Object)null) { recipe30.m_resources = GetRequirements(BonemassRequirements); } }; BonemassAmount = Config("4 - Wishbone (Bonemass)", "Amount", 1, "The amount of Wishbone created."); BonemassAmount.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe29 = GetRecipe("Wishbone"); if ((Object)(object)recipe29 != (Object)null) { recipe29.m_amount = BonemassAmount.Value; } }; BonemassLevel = Config("4 - Wishbone (Bonemass)", "Station Level", 7, "Level of crafting station required to craft Wishbone."); BonemassLevel.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe28 = GetRecipe("Wishbone"); if ((Object)(object)recipe28 != (Object)null) { recipe28.m_minStationLevel = BonemassLevel.Value; } }; BonemassTrophyEnabled = Config("4 - TrophyBonemass (Bonemass)", "Boss Trophy Enabled", value: true, " Enable Crafting of TrophyBonemass"); BonemassTrophyEnabled.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { InvokeOnVanillaObjectsAvailable(); }; BonemassTrophyTable = Config("4 - TrophyBonemass (Bonemass)", "Table", CraftingTable.Forge, "Crafting station needed to construct TrophyBonemass."); BonemassTrophyTable.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { ZNetScene.instance.GetPrefab(GetInternalName(BonemassTrophyTable.Value)).GetComponent<CraftingStation>(); }; BonemassTrophyRequirements = Config("4 - TrophyBonemass (Bonemass)", "Requirements", "WitheredBone:15,Iron:2,TrophyDraugr:3,TrophyDraugrElite:1", "The required items to construct TrophyBonemass."); BonemassTrophyRequirements.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe27 = GetRecipe("TrophyBonemass"); if ((Object)(object)recipe27 != (Object)null) { recipe27.m_resources = GetRequirements(BonemassTrophyRequirements); } }; BonemassTrophyAmount = Config("4 - TrophyBonemass (Bonemass)", "Amount", 1, "The amount of TrophyBonemass created."); BonemassTrophyAmount.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe26 = GetRecipe("TrophyBonemass"); if ((Object)(object)recipe26 != (Object)null) { recipe26.m_amount = BonemassTrophyAmount.Value; } }; BonemassTrophyLevel = Config("4 - TrophyBonemass (Bonemass)", "Station Level", 7, "Level of crafting station required to craft TrophyBonemass."); BonemassTrophyLevel.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe25 = GetRecipe("TrophyBonemass"); if ((Object)(object)recipe25 != (Object)null) { recipe25.m_minStationLevel = BonemassTrophyLevel.Value; } }; DragonQueenDropEnabled = Config("5 - DragonTear (Moder)", "Boss Drop Enabled", value: true, " Enable Crafting of DragonTear"); DragonQueenDropEnabled.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { InvokeOnVanillaObjectsAvailable(); }; DragonQueenTable = Config("5 - DragonTear (Moder)", "Table", CraftingTable.Workbench, "Crafting station needed to construct DragonTear."); DragonQueenTable.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { ZNetScene.instance.GetPrefab(GetInternalName(DragonQueenTable.Value)).GetComponent<CraftingStation>(); }; DragonQueenRequirements = Config("5 - DragonTear (Moder)", "Requirements", "DragonEgg:3,Crystal:10", "The required items to construct DragonTear."); DragonQueenRequirements.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe24 = GetRecipe("DragonTear"); if ((Object)(object)recipe24 != (Object)null) { recipe24.m_resources = GetRequirements(DragonQueenRequirements); } }; DragonQueenAmount = Config("5 - DragonTear (Moder)", "Amount", 5, "The amount of DragonTear created."); DragonQueenAmount.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe23 = GetRecipe("DragonTear"); if ((Object)(object)recipe23 != (Object)null) { recipe23.m_amount = DragonQueenAmount.Value; } }; DragonQueenLevel = Config("5 - DragonTear (Moder)", "Station Level", 5, "Level of crafting station required to craft DragonTear."); DragonQueenLevel.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe22 = GetRecipe("DragonTear"); if ((Object)(object)recipe22 != (Object)null) { recipe22.m_minStationLevel = DragonQueenLevel.Value; } }; DragonQueenTrophyEnabled = Config("5 - TrophyDragonQueen (Moder)", "Boss Trophy Enabled", value: true, " Enable Crafting of TrophyDragonQueen"); DragonQueenTrophyEnabled.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { InvokeOnVanillaObjectsAvailable(); }; DragonQueenTrophyTable = Config("5 - TrophyDragonQueen (Moder)", "Table", CraftingTable.Workbench, "Crafting station needed to construct TrophyDragonQueen."); DragonQueenTrophyTable.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { ZNetScene.instance.GetPrefab(GetInternalName(DragonQueenTrophyTable.Value)).GetComponent<CraftingStation>(); }; DragonQueenTrophyRequirements = Config("5 - TrophyDragonQueen (Moder)", "Requirements", "DragonEgg:3,Crystal:10", "The required items to construct TrophyDragonQueen."); DragonQueenTrophyRequirements.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe21 = GetRecipe("TrophyDragonQueen"); if ((Object)(object)recipe21 != (Object)null) { recipe21.m_resources = GetRequirements(DragonQueenTrophyRequirements); } }; DragonQueenTrophyAmount = Config("5 - TrophyDragonQueen (Moder)", "Amount", 1, "The amount of TrophyDragonQueen created."); DragonQueenTrophyAmount.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe20 = GetRecipe("TrophyDragonQueen"); if ((Object)(object)recipe20 != (Object)null) { recipe20.m_amount = DragonQueenTrophyAmount.Value; } }; DragonQueenTrophyLevel = Config("5 - TrophyDragonQueen (Moder)", "Station Level", 5, "Level of crafting station required to craft TrophyDragonQueen."); DragonQueenTrophyLevel.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe19 = GetRecipe("TrophyDragonQueen"); if ((Object)(object)recipe19 != (Object)null) { recipe19.m_minStationLevel = DragonQueenTrophyLevel.Value; } }; YagluthDropEnabled = Config("6 - Torn spirit (Yagluth)", "Boss Drop Enabled", value: true, " Enable Crafting of Torn spirit"); YagluthDropEnabled.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { InvokeOnVanillaObjectsAvailable(); }; YagluthTable = Config("6 - Torn spirit (Yagluth)", "Table", CraftingTable.ArtisanTable, "Crafting station needed to construct Torn spirit."); YagluthTable.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { ZNetScene.instance.GetPrefab(GetInternalName(YagluthTable.Value)).GetComponent<CraftingStation>(); }; YagluthRequirements = Config("6 - Torn spirit (Yagluth)", "Requirements", "GoblinTotem:10,TrophyGoblin:3,TrophyGoblinShaman:1,TrophyGoblinBrute:1", "The required items to construct Torn spirit."); YagluthRequirements.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe18 = GetRecipe("YagluthDrop"); if ((Object)(object)recipe18 != (Object)null) { recipe18.m_resources = GetRequirements(YagluthRequirements); } }; YagluthAmount = Config("6 - Torn spirit (Yagluth)", "Amount", 3, "The amount of Torn spirit created."); YagluthAmount.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe17 = GetRecipe("YagluthDrop"); if ((Object)(object)recipe17 != (Object)null) { recipe17.m_amount = YagluthAmount.Value; } }; YagluthLevel = Config("6 - Torn spirit (Yagluth)", "Station Level", 1, "Level of crafting station required to craft Torn spirit."); YagluthLevel.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe16 = GetRecipe("YagluthDrop"); if ((Object)(object)recipe16 != (Object)null) { recipe16.m_minStationLevel = YagluthLevel.Value; } }; YagluthTrophyEnabled = Config("6 - TrophyGoblinKing (Yagluth)", "Boss Trophy Enabled", value: true, " Enable Crafting of TrophyGoblinKing"); YagluthTrophyEnabled.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { InvokeOnVanillaObjectsAvailable(); }; YagluthTrophyTable = Config("6 - TrophyGoblinKing (Yagluth)", "Table", CraftingTable.ArtisanTable, "Crafting station needed to construct TrophyGoblinKing."); YagluthTrophyTable.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { ZNetScene.instance.GetPrefab(GetInternalName(YagluthTrophyTable.Value)).GetComponent<CraftingStation>(); }; YagluthTrophyRequirements = Config("6 - TrophyGoblinKing (Yagluth)", "Requirements", "GoblinTotem:10,TrophyGoblin:3,TrophyGoblinShaman:1,TrophyGoblinBrute:1", "The required items to construct TrophyGoblinKing."); YagluthTrophyRequirements.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe15 = GetRecipe("TrophyGoblinKing"); if ((Object)(object)recipe15 != (Object)null) { recipe15.m_resources = GetRequirements(YagluthTrophyRequirements); } }; YagluthTrophyAmount = Config("6 - TrophyGoblinKing (Yagluth)", "Amount", 1, "The amount of TrophyGoblinKing created."); YagluthTrophyAmount.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe14 = GetRecipe("TrophyGoblinKing"); if ((Object)(object)recipe14 != (Object)null) { recipe14.m_amount = YagluthTrophyAmount.Value; } }; YagluthTrophyLevel = Config("6 - TrophyGoblinKing (Yagluth)", "Station Level", 1, "Level of crafting station required to craft TrophyGoblinKing."); YagluthTrophyLevel.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe13 = GetRecipe("TrophyGoblinKing"); if ((Object)(object)recipe13 != (Object)null) { recipe13.m_minStationLevel = YagluthTrophyLevel.Value; } }; TheQueenDropEnabled = Config("7 - QueenDrop (TheQueen)", "Boss Drop Enabled", value: true, " Enable Crafting of QueenDrop"); TheQueenDropEnabled.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { InvokeOnVanillaObjectsAvailable(); }; TheQueenTable = Config("7 - QueenDrop (TheQueen)", "Table", CraftingTable.BlackForge, "Crafting station needed to construct QueenDrop."); TheQueenTable.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { ZNetScene.instance.GetPrefab(GetInternalName(TheQueenTable.Value)).GetComponent<CraftingStation>(); }; TheQueenRequirements = Config("7 - QueenDrop (TheQueen)", "Requirements", "DvergrKeyFragment:9,Mandible:5,TrophySeeker:3,TrophySeekerBrute:1", "The required items to construct QueenDrop."); TheQueenRequirements.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe12 = GetRecipe("QueenDrop"); if ((Object)(object)recipe12 != (Object)null) { recipe12.m_resources = GetRequirements(TheQueenRequirements); } }; TheQueenAmount = Config("7 - QueenDrop (TheQueen)", "Amount", 3, "The amount of QueenDrop created."); TheQueenAmount.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe11 = GetRecipe("QueenDrop"); if ((Object)(object)recipe11 != (Object)null) { recipe11.m_amount = TheQueenAmount.Value; } }; TheQueenLevel = Config("7 - QueenDrop (TheQueen)", "Station Level", 1, "Level of crafting station required to craft QueenDrop."); TheQueenLevel.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe10 = GetRecipe("QueenDrop"); if ((Object)(object)recipe10 != (Object)null) { recipe10.m_minStationLevel = TheQueenLevel.Value; } }; TheQueenTrophyEnabled = Config("7 - TrophySeekerQueen (TheQueen)", "Boss Trophy Enabled", value: true, " Enable Crafting of TrophySeekerQueen"); TheQueenTrophyEnabled.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { InvokeOnVanillaObjectsAvailable(); }; TheQueenTrophyTable = Config("7 - TrophySeekerQueen (TheQueen)", "Table", CraftingTable.BlackForge, "Crafting station needed to construct TrophySeekerQueen."); TheQueenTrophyTable.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { ZNetScene.instance.GetPrefab(GetInternalName(TheQueenTrophyTable.Value)).GetComponent<CraftingStation>(); }; TheQueenTrophyRequirements = Config("7 - TrophySeekerQueen (TheQueen)", "Requirements", "DvergrKeyFragment:9,Mandible:5,TrophySeeker:3,TrophySeekerBrute:1", "The required items to construct TrophySeekerQueen."); TheQueenTrophyRequirements.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe9 = GetRecipe("TrophySeekerQueen"); if ((Object)(object)recipe9 != (Object)null) { recipe9.m_resources = GetRequirements(TheQueenTrophyRequirements); } }; TheQueenTrophyAmount = Config("7 - TrophySeekerQueen (TheQueen)", "Amount", 1, "The amount of TrophySeekerQueen created."); TheQueenTrophyAmount.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe8 = GetRecipe("TrophySeekerQueen"); if ((Object)(object)recipe8 != (Object)null) { recipe8.m_amount = TheQueenTrophyAmount.Value; } }; TheQueenTrophyLevel = Config("7 - TrophySeekerQueen (TheQueen)", "Station Level", 1, "Level of crafting station required to craft TrophySeekerQueen."); TheQueenTrophyLevel.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe7 = GetRecipe("TrophySeekerQueen"); if ((Object)(object)recipe7 != (Object)null) { recipe7.m_minStationLevel = TheQueenTrophyLevel.Value; } }; FaderDropEnabled = Config("8 - FaderDrop (Fader)", "Boss Drop Enabled", value: true, " Enable Crafting of FaderDrop"); FaderDropEnabled.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { InvokeOnVanillaObjectsAvailable(); }; FaderTable = Config("8 - FaderDrop (Fader)", "Table", CraftingTable.BlackForge, "Crafting station needed to construct FaderDrop."); FaderTable.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { ZNetScene.instance.GetPrefab(GetInternalName(FaderTable.Value)).GetComponent<CraftingStation>(); }; FaderRequirements = Config("8 - FaderDrop (Fader)", "Requirements", "BellFragment:3,CelestialFeather:5,TrophyAsksvin:3,TrophyMorgen:1", "The required items to construct FaderDrop."); FaderRequirements.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe6 = GetRecipe("FaderDrop"); if ((Object)(object)recipe6 != (Object)null) { recipe6.m_resources = GetRequirements(FaderRequirements); } }; FaderAmount = Config("8 - FaderDrop (Fader)", "Amount", 5, "The amount of FaderDrop created."); FaderAmount.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe5 = GetRecipe("FaderDrop"); if ((Object)(object)recipe5 != (Object)null) { recipe5.m_amount = FaderAmount.Value; } }; FaderLevel = Config("8 - FaderDrop (Fader)", "Station Level", 2, "Level of crafting station required to craft FaderDrop."); FaderLevel.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe4 = GetRecipe("FaderDrop"); if ((Object)(object)recipe4 != (Object)null) { recipe4.m_minStationLevel = FaderLevel.Value; } }; FaderTrophyEnabled = Config("8 - TrophyFader (Fader)", "Boss Trophy Enabled", value: true, " Enable Crafting of TrophyFader"); FaderTrophyEnabled.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { InvokeOnVanillaObjectsAvailable(); }; FaderTrophyTable = Config("8 - TrophyFader (Fader)", "Table", CraftingTable.BlackForge, "Crafting station needed to construct TrophyFader."); FaderTrophyTable.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { ZNetScene.instance.GetPrefab(GetInternalName(FaderTrophyTable.Value)).GetComponent<CraftingStation>(); }; FaderTrophyRequirements = Config("8 - TrophyFader (Fader)", "Requirements", "BellFragment:3,CelestialFeather:5,TrophyAsksvin:3,TrophyMorgen:1", "The required items to construct TrophyFader."); FaderTrophyRequirements.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe3 = GetRecipe("TrophyFader"); if ((Object)(object)recipe3 != (Object)null) { recipe3.m_resources = GetRequirements(FaderTrophyRequirements); } }; FaderTrophyAmount = Config("8 - TrophyFader (Fader)", "Amount", 1, "The amount of TrophyFader created."); FaderTrophyAmount.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe2 = GetRecipe("TrophyFader"); if ((Object)(object)recipe2 != (Object)null) { recipe2.m_amount = FaderTrophyAmount.Value; } }; FaderTrophyLevel = Config("8 - TrophyFader (Fader)", "Station Level", 2, "Level of crafting station required to craft TrophyFader."); FaderTrophyLevel.SettingChanged += [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (object _, EventArgs _) => { Recipe recipe = GetRecipe("TrophyFader"); if ((Object)(object)recipe != (Object)null) { recipe.m_minStationLevel = FaderTrophyLevel.Value; } }; if (VersionChecker.Check(HS_Logger, ((BaseUnityPlugin)this).Info, _overrideVersionCheck.Value, ((BaseUnityPlugin)this).Config)) { new Harmony("HS_CraftableBossItems").Patch((MethodBase)AccessTools.Method(typeof(ZNet), "Start", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "InvokeOnVanillaObjectsAvailable", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } public static void InvokeOnVanillaObjectsAvailable() { if (_modEnabled.Value) { if (EikythrDropEnabled.Value) { AddRecipe("HardAntler", EikythrTable.Value, EikythrAmount.Value, EikythrLevel.Value, EikythrRequirements.Value); } else { RemoveRecipe("HardAntler"); } if (TheElderDropEnabled.Value) { AddRecipe("CryptKey", TheElderTable.Value, TheElderAmount.Value, TheElderLevel.Value, TheElderRequirements.Value); } else { RemoveRecipe("CryptKey"); } if (YagluthDropEnabled.Value) { AddRecipe("YagluthDrop", YagluthTable.Value, YagluthAmount.Value, YagluthLevel.Value, YagluthRequirements.Value); } else { RemoveRecipe("YagluthDrop"); } if (DragonQueenDropEnabled.Value) { AddRecipe("DragonTear", DragonQueenTable.Value, DragonQueenAmount.Value, DragonQueenLevel.Value, DragonQueenRequirements.Value); } else { RemoveRecipe("DragonTear"); } if (BonemassDropEnabled.Value) { AddRecipe("Wishbone", BonemassTable.Value, BonemassAmount.Value, BonemassLevel.Value, BonemassRequirements.Value); } else { RemoveRecipe("Wishbone"); } if (TheQueenDropEnabled.Value) { AddRecipe("QueenDrop", TheQueenTable.Value, TheQueenAmount.Value, TheQueenLevel.Value, TheQueenRequirements.Value); } else { RemoveRecipe("QueenDrop"); } if (FaderDropEnabled.Value) { AddRecipe("FaderDrop", FaderTable.Value, FaderAmount.Value, FaderLevel.Value, FaderRequirements.Value); } else { RemoveRecipe("FaderDrop"); } if (FaderTrophyEnabled.Value) { AddRecipe("TrophyFader", FaderTrophyTable.Value, FaderTrophyAmount.Value, FaderTrophyLevel.Value, FaderTrophyRequirements.Value); } else { RemoveRecipe("TrophyFader"); } if (TheQueenTrophyEnabled.Value) { AddRecipe("TrophySeekerQueen", TheQueenTrophyTable.Value, TheQueenTrophyAmount.Value, TheQueenTrophyLevel.Value, TheQueenTrophyRequirements.Value); } else { RemoveRecipe("TrophySeekerQueen"); } if (YagluthTrophyEnabled.Value) { AddRecipe("TrophyGoblinKing", YagluthTrophyTable.Value, YagluthTrophyAmount.Value, YagluthTrophyLevel.Value, YagluthTrophyRequirements.Value); } else { RemoveRecipe("TrophyGoblinKing"); } if (DragonQueenTrophyEnabled.Value) { AddRecipe("TrophyDragonQueen", DragonQueenTrophyTable.Value, DragonQueenTrophyAmount.Value, DragonQueenTrophyLevel.Value, DragonQueenTrophyRequirements.Value); } else { RemoveRecipe("TrophyDragonQueen"); } if (BonemassTrophyEnabled.Value) { AddRecipe("TrophyBonemass", BonemassTrophyTable.Value, BonemassTrophyAmount.Value, BonemassTrophyLevel.Value, BonemassTrophyRequirements.Value); } else { RemoveRecipe("TrophyBonemass"); } if (TheElderTrophyEnabled.Value) { AddRecipe("TrophyTheElder", TheElderTrophyTable.Value, TheElderTrophyAmount.Value, TheElderTrophyLevel.Value, TheElderTrophyRequirements.Value); } else { RemoveRecipe("TrophyTheElder"); } if (EikythrTrophyEnabled.Value) { AddRecipe("TrophyEikthyr", EikythrTrophyTable.Value, EikythrTrophyAmount.Value, EikythrTrophyLevel.Value, EikythrTrophyRequirements.Value); } else { RemoveRecipe("TrophyEikthyr"); } } else { RemoveRecipe("HardAntler"); RemoveRecipe("CryptKey"); RemoveRecipe("YagluthDrop"); RemoveRecipe("DragonTear"); RemoveRecipe("Wishbone"); RemoveRecipe("QueenDrop"); RemoveRecipe("FaderDrop"); RemoveRecipe("TrophyFader"); RemoveRecipe("TrophySeekerQueen"); RemoveRecipe("TrophyGoblinKing"); RemoveRecipe("TrophyDragonQueen"); RemoveRecipe("TrophyBonemass"); RemoveRecipe("TrophyTheElder"); RemoveRecipe("TrophyEikthyr"); } } public static void AddRecipe(string prefabName, CraftingTable table, int amount, int level, string requirements) { GameObject prefab = ZNetScene.instance.GetPrefab(prefabName); Recipe val = ScriptableObject.CreateInstance<Recipe>(); ((Object)val).name = "Recipe_" + prefabName; val.m_item = prefab.GetComponent<ItemDrop>(); val.m_amount = amount; val.m_craftingStation = ZNetScene.instance.GetPrefab(GetInternalName(table)).GetComponent<CraftingStation>(); val.m_minStationLevel = level; val.m_resources = SerializedRequirements.ToPieceReqs(ObjectDB.instance, new SerializedRequirements(requirements ?? ""), new SerializedRequirements("")); val.m_enabled = true; ObjectDB.instance.m_recipes.Add(Object.Instantiate<Recipe>(val)); } public static void RemoveRecipe(string name) { ObjectDB.instance.m_recipes?.RemoveAll([<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (Recipe recipe) => (Object)(object)recipe?.m_item != (Object)null && ((Object)recipe.m_item).name == name); } [return: <d7a857e5-55f7-4181-aac5-d47bf1828e30>Nullable(2)] public static Recipe GetRecipe(string name) { return ((IEnumerable<Recipe>)ObjectDB.instance.m_recipes).FirstOrDefault((Func<Recipe, bool>)([<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] (Recipe recipe) => (Object)(object)recipe.m_item != (Object)null && ((Object)recipe.m_item).name == name)); } public static Requirement[] GetRequirements(ConfigEntry<string> configEntry) { return SerializedRequirements.ToPieceReqs(ObjectDB.instance, new SerializedRequirements(configEntry.Value ?? ""), new SerializedRequirements("")); } [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(0)] [return: <d7a857e5-55f7-4181-aac5-d47bf1828e30>Nullable(1)] public static string GetInternalName<T>(T value) where T : struct { return ((InternalName)typeof(T).GetMember(value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName; } } [<d7a857e5-55f7-4181-aac5-d47bf1828e30>Nullable(0)] [<4cbbac62-52eb-4ceb-8b8c-b97ec3558686>NullableContext(1)] public static class MyPluginInfo { public const string PLUGIN_GUID = "HS_CraftableBossItems"; public const string PLUGIN_NAME = "HS_CraftableBossItems"; public const string PLUGIN_VERSION = "0.1.3"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<d507819d-810b-499a-89d3-ab3a948a024f>Embedded] internal sealed class <d507819d-810b-499a-89d3-ab3a948a024f>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [<d507819d-810b-499a-89d3-ab3a948a024f>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [CompilerGenerated] internal sealed class <e3c94967-4846-4284-9259-2c1eeb508514>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <e3c94967-4846-4284-9259-2c1eeb508514>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <e3c94967-4846-4284-9259-2c1eeb508514>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [<d507819d-810b-499a-89d3-ab3a948a024f>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [CompilerGenerated] internal sealed class <a33b2df4-6460-408a-ac71-522ab3d49044>NullableContextAttribute : Attribute { public readonly byte Flag; public <a33b2df4-6460-408a-ac71-522ab3d49044>NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [<d507819d-810b-499a-89d3-ab3a948a024f>Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class <5320ea92-6235-4205-b165-dc7f6d8fad90>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <5320ea92-6235-4205-b165-dc7f6d8fad90>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ServerSync { [PublicAPI] [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(0)] [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(1)] internal abstract class OwnConfigEntryBase { [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] public object LocalBaseValue; public bool SynchronizedConfig = true; public abstract ConfigEntryBase BaseConfig { get; } } [PublicAPI] [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(0)] [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(1)] internal class SyncedConfigEntry<[<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] T> : OwnConfigEntryBase { public readonly ConfigEntry<T> SourceConfig; public override ConfigEntryBase BaseConfig => (ConfigEntryBase)(object)SourceConfig; public T Value { get { return SourceConfig.Value; } set { SourceConfig.Value = value; } } public SyncedConfigEntry(ConfigEntry<T> sourceConfig) { SourceConfig = sourceConfig; } public void AssignLocalValue(T value) { if (LocalBaseValue == null) { Value = value; } else { LocalBaseValue = value; } } } [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(2)] [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(0)] internal abstract class CustomSyncedValueBase { public object LocalBaseValue; [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(1)] public readonly string Identifier; [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(1)] public readonly Type Type; private object boxedValue; protected bool localIsOwner; public readonly int Priority; public object BoxedValue { get { return boxedValue; } set { boxedValue = value; this.ValueChanged?.Invoke(); } } public event Action ValueChanged; [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(1)] protected CustomSyncedValueBase(ConfigSync configSync, string identifier, Type type, int priority) { Priority = priority; Identifier = identifier; Type = type; configSync.AddCustomValue(this); localIsOwner = configSync.IsSourceOfTruth; configSync.SourceOfTruthChanged += delegate(bool truth) { localIsOwner = truth; }; } } [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(1)] [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(0)] [PublicAPI] internal sealed class CustomSyncedValue<[<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] T> : CustomSyncedValueBase { public T Value { get { return (T)base.BoxedValue; } set { base.BoxedValue = value; } } public CustomSyncedValue(ConfigSync configSync, string identifier, T value = default(T), int priority = 0) : base(configSync, identifier, typeof(T), priority) { Value = value; } public void AssignLocalValue(T value) { if (localIsOwner) { Value = value; } else { LocalBaseValue = value; } } } internal class ConfigurationManagerAttributes { [UsedImplicitly] public bool? ReadOnly = false; } [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(1)] [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(0)] [PublicAPI] internal class ConfigSync { [HarmonyPatch(typeof(ZRpc), "HandlePackage")] [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] private static class SnatchCurrentlyHandlingRPC { [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] public static ZRpc currentRpc; [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(1)] [HarmonyPrefix] private static void Prefix(ZRpc __instance) { currentRpc = __instance; } } [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] [HarmonyPatch(typeof(ZNet), "Awake")] internal static class RegisterRPCPatch { [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(1)] [HarmonyPostfix] private static void Postfix(ZNet __instance) { isServer = __instance.IsServer(); foreach (ConfigSync configSync2 in configSyncs) { ZRoutedRpc.instance.Register<ZPackage>(configSync2.Name + " ConfigSync", (Action<long, ZPackage>)configSync2.RPC_FromOtherClientConfigSync); if (isServer) { configSync2.InitialSyncDone = true; Debug.Log((object)("Registered '" + configSync2.Name + " ConfigSync' RPC - waiting for incoming connections")); } } if (isServer) { ((MonoBehaviour)__instance).StartCoroutine(WatchAdminListChanges()); } [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(1)] static void SendAdmin(List<ZNetPeer> peers, bool isAdmin) { ZPackage package = ConfigsToPackage(null, null, new PackageEntry[1] { new PackageEntry { section = "Internal", key = "lockexempt", type = typeof(bool), value = isAdmin } }); ConfigSync configSync = configSyncs.First(); if (configSync != null) { ((MonoBehaviour)ZNet.instance).StartCoroutine(configSync.sendZPackage(peers, package)); } } [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(1)] static IEnumerator WatchAdminListChanges() { MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); List<string> CurrentList = new List<string>(adminList.GetList()); while (true) { yield return (object)new WaitForSeconds(30f); if (!adminList.GetList().SequenceEqual(CurrentList)) { CurrentList = new List<string>(adminList.GetList()); List<ZNetPeer> adminPeer = ZNet.instance.GetPeers().Where(delegate(ZNetPeer p) { string hostName = p.m_rpc.GetSocket().GetHostName(); return ((object)listContainsId == null) ? adminList.Contains(hostName) : ((bool)listContainsId.Invoke(ZNet.instance, new object[2] { adminList, hostName })); }).ToList(); List<ZNetPeer> nonAdminPeer = ZNet.instance.GetPeers().Except(adminPeer).ToList(); SendAdmin(nonAdminPeer, isAdmin: false); SendAdmin(adminPeer, isAdmin: true); } } } } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] private static class RegisterClientRPCPatch { [HarmonyPostfix] [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(1)] private static void Postfix(ZNet __instance, ZNetPeer peer) { if (__instance.IsServer()) { return; } foreach (ConfigSync configSync in configSyncs) { peer.m_rpc.Register<ZPackage>(configSync.Name + " ConfigSync", (Action<ZRpc, ZPackage>)configSync.RPC_FromServerConfigSync); } } } [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] private class ParsedConfigs { [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(new byte[] { 1, 1, 2 })] public readonly Dictionary<OwnConfigEntryBase, object> configValues = new Dictionary<OwnConfigEntryBase, object>(); [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(new byte[] { 1, 1, 2 })] public readonly Dictionary<CustomSyncedValueBase, object> customValues = new Dictionary<CustomSyncedValueBase, object>(); } [HarmonyPatch(typeof(ZNet), "Shutdown")] [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] private class ResetConfigsOnShutdown { [HarmonyPostfix] private static void Postfix() { ProcessingServerUpdate = true; foreach (ConfigSync configSync in configSyncs) { configSync.resetConfigsFromServer(); configSync.IsSourceOfTruth = true; configSync.InitialSyncDone = false; } ProcessingServerUpdate = false; } } [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(0)] private class SendConfigsAfterLogin { [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(0)] private class BufferingSocket : ISocket { public volatile bool finished = false; public volatile int versionMatchQueued = -1; public readonly List<ZPackage> Package = new List<ZPackage>(); public readonly ISocket Original; public BufferingSocket(ISocket original) { Original = original; } public bool IsConnected() { return Original.IsConnected(); } public ZPackage Recv() { return Original.Recv(); } public int GetSendQueueSize() { return Original.GetSendQueueSize(); } public int GetCurrentSendRate() { return Original.GetCurrentSendRate(); } public bool IsHost() { return Original.IsHost(); } public void Dispose() { Original.Dispose(); } public bool GotNewData() { return Original.GotNewData(); } public void Close() { Original.Close(); } public string GetEndPointString() { return Original.GetEndPointString(); } public void GetAndResetStats(out int totalSent, out int totalRecv) { Original.GetAndResetStats(ref totalSent, ref totalRecv); } public void GetConnectionQuality(out float localQuality, out float remoteQuality, out int ping, out float outByteSec, out float inByteSec) { Original.GetConnectionQuality(ref localQuality, ref remoteQuality, ref ping, ref outByteSec, ref inByteSec); } public ISocket Accept() { return Original.Accept(); } public int GetHostPort() { return Original.GetHostPort(); } public bool Flush() { return Original.Flush(); } public string GetHostName() { return Original.GetHostName(); } public void VersionMatch() { if (finished) { Original.VersionMatch(); } else { versionMatchQueued = Package.Count; } } public void Send(ZPackage pkg) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown int pos = pkg.GetPos(); pkg.SetPos(0); int num = pkg.ReadInt(); if ((num == StringExtensionMethods.GetStableHashCode("PeerInfo") || num == StringExtensionMethods.GetStableHashCode("RoutedRPC") || num == StringExtensionMethods.GetStableHashCode("ZDOData")) && !finished) { ZPackage val = new ZPackage(pkg.GetArray()); val.SetPos(pos); Package.Add(val); } else { pkg.SetPos(pos); Original.Send(pkg); } } } [HarmonyPriority(800)] [HarmonyPrefix] private static void Prefix([<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(new byte[] { 2, 1, 1 })] ref Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 if (__instance.IsServer()) { BufferingSocket value = new BufferingSocket(rpc.GetSocket()); AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, value); object? obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc }); ZNetPeer val = (ZNetPeer)((obj is ZNetPeer) ? obj : null); if (val != null && (int)ZNet.m_onlineBackend > 0) { AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, value); } if (__state == null) { __state = new Dictionary<Assembly, BufferingSocket>(); } __state[Assembly.GetExecutingAssembly()] = value; } } [HarmonyPostfix] private static void Postfix(Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc) { ZNetPeer peer; if (__instance.IsServer()) { object obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc }); peer = (ZNetPeer)((obj is ZNetPeer) ? obj : null); if (peer == null) { SendBufferedData(); } else { ((MonoBehaviour)__instance).StartCoroutine(sendAsync()); } } void SendBufferedData() { if (rpc.GetSocket() is BufferingSocket bufferingSocket) { AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, bufferingSocket.Original); object? obj2 = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc }); ZNetPeer val = (ZNetPeer)((obj2 is ZNetPeer) ? obj2 : null); if (val != null) { AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, bufferingSocket.Original); } } BufferingSocket bufferingSocket2 = __state[Assembly.GetExecutingAssembly()]; bufferingSocket2.finished = true; for (int i = 0; i < bufferingSocket2.Package.Count; i++) { if (i == bufferingSocket2.versionMatchQueued) { bufferingSocket2.Original.VersionMatch(); } bufferingSocket2.Original.Send(bufferingSocket2.Package[i]); } if (bufferingSocket2.Package.Count == bufferingSocket2.versionMatchQueued) { bufferingSocket2.Original.VersionMatch(); } } IEnumerator sendAsync() { foreach (ConfigSync configSync in configSyncs) { List<PackageEntry> entries = new List<PackageEntry>(); if (configSync.CurrentVersion != null) { entries.Add(new PackageEntry { section = "Internal", key = "serverversion", type = typeof(string), value = configSync.CurrentVersion }); } MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); entries.Add(new PackageEntry { section = "Internal", key = "lockexempt", type = typeof(bool), value = (((object)listContainsId == null) ? ((object)adminList.Contains(rpc.GetSocket().GetHostName())) : listContainsId.Invoke(ZNet.instance, new object[2] { adminList, rpc.GetSocket().GetHostName() })) }); ZPackage package = ConfigsToPackage(configSync.allConfigs.Select([<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (OwnConfigEntryBase c) => c.BaseConfig), configSync.allCustomValues, entries, partial: false); yield return ((MonoBehaviour)__instance).StartCoroutine(configSync.sendZPackage(new List<ZNetPeer> { peer }, package)); } SendBufferedData(); } } } [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(0)] private class PackageEntry { public string section = null; public string key = null; public Type type = null; [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] public object value; } [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] [HarmonyPatch(typeof(ConfigEntryBase), "GetSerializedValue")] private static class PreventSavingServerInfo { [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(1)] [HarmonyPrefix] private static bool Prefix(ConfigEntryBase __instance, ref string __result) { OwnConfigEntryBase ownConfigEntryBase = configData(__instance); if (ownConfigEntryBase == null || isWritableConfig(ownConfigEntryBase)) { return true; } __result = TomlTypeConverter.ConvertToString(ownConfigEntryBase.LocalBaseValue, __instance.SettingType); return false; } } [HarmonyPatch(typeof(ConfigEntryBase), "SetSerializedValue")] [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] private static class PreventConfigRereadChangingValues { [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(1)] [HarmonyPrefix] private static bool Prefix(ConfigEntryBase __instance, string value) { OwnConfigEntryBase ownConfigEntryBase = configData(__instance); if (ownConfigEntryBase == null || ownConfigEntryBase.LocalBaseValue == null) { return true; } try { ownConfigEntryBase.LocalBaseValue = TomlTypeConverter.ConvertToValue(value, __instance.SettingType); } catch (Exception ex) { Debug.LogWarning((object)$"Config value of setting \"{__instance.Definition}\" could not be parsed and will be ignored. Reason: {ex.Message}; Value: {value}"); } return false; } } [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(0)] private class InvalidDeserializationTypeException : Exception { public string expected = null; public string received = null; public string field = ""; } public static bool ProcessingServerUpdate; public readonly string Name; [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] public string DisplayName; [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] public string CurrentVersion; [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] public string MinimumRequiredVersion; public bool ModRequired = false; private bool? forceConfigLocking; private bool isSourceOfTruth = true; private static readonly HashSet<ConfigSync> configSyncs; private readonly HashSet<OwnConfigEntryBase> allConfigs = new HashSet<OwnConfigEntryBase>(); private HashSet<CustomSyncedValueBase> allCustomValues = new HashSet<CustomSyncedValueBase>(); private static bool isServer; private static bool lockExempt; [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] private OwnConfigEntryBase lockedConfig = null; private const byte PARTIAL_CONFIGS = 1; private const byte FRAGMENTED_CONFIG = 2; private const byte COMPRESSED_CONFIG = 4; private readonly Dictionary<string, SortedDictionary<int, byte[]>> configValueCache = new Dictionary<string, SortedDictionary<int, byte[]>>(); [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(new byte[] { 1, 0, 1 })] private readonly List<KeyValuePair<long, string>> cacheExpirations = new List<KeyValuePair<long, string>>(); private static long packageCounter; public bool IsLocked { get { bool? flag = forceConfigLocking; bool num; if (!flag.HasValue) { if (lockedConfig == null) { goto IL_0052; } num = ((IConvertible)lockedConfig.BaseConfig.BoxedValue).ToInt32(CultureInfo.InvariantCulture) != 0; } else { num = flag.GetValueOrDefault(); } if (!num) { goto IL_0052; } int result = ((!lockExempt) ? 1 : 0); goto IL_0053; IL_0053: return (byte)result != 0; IL_0052: result = 0; goto IL_0053; } set { forceConfigLocking = value; } } public bool IsAdmin => lockExempt || isSourceOfTruth; public bool IsSourceOfTruth { get { return isSourceOfTruth; } private set { if (value != isSourceOfTruth) { isSourceOfTruth = value; this.SourceOfTruthChanged?.Invoke(value); } } } public bool InitialSyncDone { get; private set; } = false; [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] [method: <a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(2)] [field: <e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] public event Action<bool> SourceOfTruthChanged; [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] [method: <a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(2)] [field: <e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] private event Action lockedConfigChanged; static ConfigSync() { ProcessingServerUpdate = false; configSyncs = new HashSet<ConfigSync>(); lockExempt = false; packageCounter = 0L; RuntimeHelpers.RunClassConstructor(typeof(VersionCheck).TypeHandle); } public ConfigSync(string name) { Name = name; configSyncs.Add(this); new VersionCheck(this); } public SyncedConfigEntry<T> AddConfigEntry<[<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] T>(ConfigEntry<T> configEntry) { OwnConfigEntryBase ownConfigEntryBase = configData((ConfigEntryBase)(object)configEntry); SyncedConfigEntry<T> syncedEntry = ownConfigEntryBase as SyncedConfigEntry<T>; if (syncedEntry == null) { syncedEntry = new SyncedConfigEntry<T>(configEntry); AccessTools.DeclaredField(typeof(ConfigDescription), "<Tags>k__BackingField").SetValue(((ConfigEntryBase)configEntry).Description, new object[1] { new ConfigurationManagerAttributes() }.Concat(((ConfigEntryBase)configEntry).Description.Tags ?? Array.Empty<object>()).Concat(new SyncedConfigEntry<T>[1] { syncedEntry }).ToArray()); configEntry.SettingChanged += [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (object _, EventArgs _) => { if (!ProcessingServerUpdate && syncedEntry.SynchronizedConfig) { Broadcast(ZRoutedRpc.Everybody, (ConfigEntryBase)configEntry); } }; allConfigs.Add(syncedEntry); } return syncedEntry; } public SyncedConfigEntry<T> AddLockingConfigEntry<[<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(0)] T>(ConfigEntry<T> lockingConfig) where T : IConvertible { if (lockedConfig != null) { throw new Exception("Cannot initialize locking ConfigEntry twice"); } lockedConfig = AddConfigEntry<T>(lockingConfig); lockingConfig.SettingChanged += [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (object _, EventArgs _) => { this.lockedConfigChanged?.Invoke(); }; return (SyncedConfigEntry<T>)lockedConfig; } internal void AddCustomValue(CustomSyncedValueBase customValue) { if (allCustomValues.Select([<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (CustomSyncedValueBase v) => v.Identifier).Concat(new string[1] { "serverversion" }).Contains(customValue.Identifier)) { throw new Exception("Cannot have multiple settings with the same name or with a reserved name (serverversion)"); } allCustomValues.Add(customValue); allCustomValues = new HashSet<CustomSyncedValueBase>(allCustomValues.OrderByDescending([<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (CustomSyncedValueBase v) => v.Priority)); customValue.ValueChanged += delegate { if (!ProcessingServerUpdate) { Broadcast(ZRoutedRpc.Everybody, customValue); } }; } private void RPC_FromServerConfigSync(ZRpc rpc, ZPackage package) { lockedConfigChanged += serverLockedSettingChanged; IsSourceOfTruth = false; if (HandleConfigSyncRPC(0L, package, clientUpdate: false)) { InitialSyncDone = true; } } private void RPC_FromOtherClientConfigSync(long sender, ZPackage package) { HandleConfigSyncRPC(sender, package, clientUpdate: true); } private bool HandleConfigSyncRPC(long sender, ZPackage package, bool clientUpdate) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected O, but got Unknown try { if (isServer && IsLocked) { ZRpc currentRpc = SnatchCurrentlyHandlingRPC.currentRpc; object obj; if (currentRpc == null) { obj = null; } else { ISocket socket = currentRpc.GetSocket(); obj = ((socket != null) ? socket.GetHostName() : null); } string text = (string)obj; if (text != null) { MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); SyncedList val = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); if (!(((object)methodInfo == null) ? val.Contains(text) : ((bool)methodInfo.Invoke(ZNet.instance, new object[2] { val, text })))) { return false; } } } cacheExpirations.RemoveAll(([<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(new byte[] { 0, 1 })] KeyValuePair<long, string> kv) => { if (kv.Key < DateTimeOffset.Now.Ticks) { configValueCache.Remove(kv.Value); return true; } return false; }); byte b = package.ReadByte(); if ((b & 2u) != 0) { long num = package.ReadLong(); string text2 = sender.ToString() + num; if (!configValueCache.TryGetValue(text2, out var value)) { value = new SortedDictionary<int, byte[]>(); configValueCache[text2] = value; cacheExpirations.Add(new KeyValuePair<long, string>(DateTimeOffset.Now.AddSeconds(60.0).Ticks, text2)); } int key = package.ReadInt(); int num2 = package.ReadInt(); value.Add(key, package.ReadByteArray()); if (value.Count < num2) { return false; } configValueCache.Remove(text2); package = new ZPackage(value.Values.SelectMany([<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (byte[] a) => a).ToArray()); b = package.ReadByte(); } ProcessingServerUpdate = true; if ((b & 4u) != 0) { byte[] buffer = package.ReadByteArray(); MemoryStream stream = new MemoryStream(buffer); MemoryStream memoryStream = new MemoryStream(); using (DeflateStream deflateStream = new DeflateStream(stream, CompressionMode.Decompress)) { deflateStream.CopyTo(memoryStream); } package = new ZPackage(memoryStream.ToArray()); b = package.ReadByte(); } if ((b & 1) == 0) { resetConfigsFromServer(); } ParsedConfigs parsedConfigs = ReadConfigsFromPackage(package); ConfigFile val2 = null; bool saveOnConfigSet = false; foreach (KeyValuePair<OwnConfigEntryBase, object> configValue in parsedConfigs.configValues) { if (!isServer && configValue.Key.LocalBaseValue == null) { configValue.Key.LocalBaseValue = configValue.Key.BaseConfig.BoxedValue; } if (val2 == null) { val2 = configValue.Key.BaseConfig.ConfigFile; saveOnConfigSet = val2.SaveOnConfigSet; val2.SaveOnConfigSet = false; } configValue.Key.BaseConfig.BoxedValue = configValue.Value; } if (val2 != null) { val2.SaveOnConfigSet = saveOnConfigSet; } foreach (KeyValuePair<CustomSyncedValueBase, object> customValue in parsedConfigs.customValues) { if (!isServer) { CustomSyncedValueBase key2 = customValue.Key; if (key2.LocalBaseValue == null) { key2.LocalBaseValue = customValue.Key.BoxedValue; } } customValue.Key.BoxedValue = customValue.Value; } Debug.Log((object)string.Format("Received {0} configs and {1} custom values from {2} for mod {3}", parsedConfigs.configValues.Count, parsedConfigs.customValues.Count, (isServer || clientUpdate) ? $"client {sender}" : "the server", DisplayName ?? Name)); if (!isServer) { serverLockedSettingChanged(); } return true; } finally { ProcessingServerUpdate = false; } } private ParsedConfigs ReadConfigsFromPackage(ZPackage package) { ParsedConfigs parsedConfigs = new ParsedConfigs(); Dictionary<string, OwnConfigEntryBase> dictionary = allConfigs.Where([<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (OwnConfigEntryBase c) => c.SynchronizedConfig).ToDictionary([<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (OwnConfigEntryBase c) => c.BaseConfig.Definition.Section + "_" + c.BaseConfig.Definition.Key, [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (OwnConfigEntryBase c) => c); Dictionary<string, CustomSyncedValueBase> dictionary2 = allCustomValues.ToDictionary([<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (CustomSyncedValueBase c) => c.Identifier, [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (CustomSyncedValueBase c) => c); int num = package.ReadInt(); for (int i = 0; i < num; i++) { string text = package.ReadString(); string text2 = package.ReadString(); string text3 = package.ReadString(); Type type = Type.GetType(text3); if (text3 == "" || type != null) { object obj; try { obj = ((text3 == "") ? null : ReadValueWithTypeFromZPackage(package, type)); } catch (InvalidDeserializationTypeException ex) { Debug.LogWarning((object)("Got unexpected struct internal type " + ex.received + " for field " + ex.field + " struct " + text3 + " for " + text2 + " in section " + text + " for mod " + (DisplayName ?? Name) + ", expecting " + ex.expected)); continue; } OwnConfigEntryBase value2; if (text == "Internal") { CustomSyncedValueBase value; if (text2 == "serverversion") { if (obj?.ToString() != CurrentVersion) { Debug.LogWarning((object)("Received server version is not equal: server version = " + (obj?.ToString() ?? "null") + "; local version = " + (CurrentVersion ?? "unknown"))); } } else if (text2 == "lockexempt") { if (obj is bool flag) { lockExempt = flag; } } else if (dictionary2.TryGetValue(text2, out value)) { if ((text3 == "" && (!value.Type.IsValueType || Nullable.GetUnderlyingType(value.Type) != null)) || GetZPackageTypeString(value.Type) == text3) { parsedConfigs.customValues[value] = obj; continue; } Debug.LogWarning((object)("Got unexpected type " + text3 + " for internal value " + text2 + " for mod " + (DisplayName ?? Name) + ", expecting " + value.Type.AssemblyQualifiedName)); } } else if (dictionary.TryGetValue(text + "_" + text2, out value2)) { Type type2 = configType(value2.BaseConfig); if ((text3 == "" && (!type2.IsValueType || Nullable.GetUnderlyingType(type2) != null)) || GetZPackageTypeString(type2) == text3) { parsedConfigs.configValues[value2] = obj; continue; } Debug.LogWarning((object)("Got unexpected type " + text3 + " for " + text2 + " in section " + text + " for mod " + (DisplayName ?? Name) + ", expecting " + type2.AssemblyQualifiedName)); } else { Debug.LogWarning((object)("Received unknown config entry " + text2 + " in section " + text + " for mod " + (DisplayName ?? Name) + ". This may happen if client and server versions of the mod do not match.")); } continue; } Debug.LogWarning((object)("Got invalid type " + text3 + ", abort reading of received configs")); return new ParsedConfigs(); } return parsedConfigs; } private static bool isWritableConfig(OwnConfigEntryBase config) { ConfigSync configSync = configSyncs.FirstOrDefault([<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (ConfigSync cs) => cs.allConfigs.Contains(config)); if (configSync == null) { return true; } return configSync.IsSourceOfTruth || !config.SynchronizedConfig || config.LocalBaseValue == null || (!configSync.IsLocked && (config != configSync.lockedConfig || lockExempt)); } private void serverLockedSettingChanged() { foreach (OwnConfigEntryBase allConfig in allConfigs) { configAttribute<ConfigurationManagerAttributes>(allConfig.BaseConfig).ReadOnly = !isWritableConfig(allConfig); } } private void resetConfigsFromServer() { ConfigFile val = null; bool saveOnConfigSet = false; foreach (OwnConfigEntryBase item in allConfigs.Where([<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (OwnConfigEntryBase config) => config.LocalBaseValue != null)) { if (val == null) { val = item.BaseConfig.ConfigFile; saveOnConfigSet = val.SaveOnConfigSet; val.SaveOnConfigSet = false; } item.BaseConfig.BoxedValue = item.LocalBaseValue; item.LocalBaseValue = null; } if (val != null) { val.SaveOnConfigSet = saveOnConfigSet; } foreach (CustomSyncedValueBase item2 in allCustomValues.Where([<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (CustomSyncedValueBase config) => config.LocalBaseValue != null)) { item2.BoxedValue = item2.LocalBaseValue; item2.LocalBaseValue = null; } lockedConfigChanged -= serverLockedSettingChanged; serverLockedSettingChanged(); } private IEnumerator<bool> distributeConfigToPeers(ZNetPeer peer, ZPackage package) { ZRoutedRpc rpc = ZRoutedRpc.instance; if (rpc == null) { yield break; } byte[] data = package.GetArray(); if (data != null && data.LongLength > 250000) { int fragments = (int)(1 + (data.LongLength - 1) / 250000); long packageIdentifier = ++packageCounter; int fragment = 0; while (fragment < fragments) { foreach (bool item in waitForQueue()) { yield return item; } if (peer.m_socket.IsConnected()) { ZPackage fragmentedPackage = new ZPackage(); fragmentedPackage.Write((byte)2); fragmentedPackage.Write(packageIdentifier); fragmentedPackage.Write(fragment); fragmentedPackage.Write(fragments); fragmentedPackage.Write(data.Skip(250000 * fragment).Take(250000).ToArray()); SendPackage(fragmentedPackage); if (fragment != fragments - 1) { yield return true; } int num = fragment + 1; fragment = num; continue; } break; } yield break; } foreach (bool item2 in waitForQueue()) { yield return item2; } SendPackage(package); void SendPackage(ZPackage pkg) { string text = Name + " ConfigSync"; if (isServer) { peer.m_rpc.Invoke(text, new object[1] { pkg }); } else { rpc.InvokeRoutedRPC(peer.m_server ? 0 : peer.m_uid, text, new object[1] { pkg }); } } IEnumerable<bool> waitForQueue() { float timeout = Time.time + 30f; while (peer.m_socket.GetSendQueueSize() > 20000) { if (Time.time > timeout) { Debug.Log((object)$"Disconnecting {peer.m_uid} after 30 seconds config sending timeout"); peer.m_rpc.Invoke("Error", new object[1] { (object)(ConnectionStatus)5 }); ZNet.instance.Disconnect(peer); break; } yield return false; } } } private IEnumerator sendZPackage(long target, ZPackage package) { if (!Object.op_Implicit((Object)(object)ZNet.instance)) { return Enumerable.Empty<object>().GetEnumerator(); } List<ZNetPeer> list = (List<ZNetPeer>)AccessTools.DeclaredField(typeof(ZRoutedRpc), "m_peers").GetValue(ZRoutedRpc.instance); if (target != ZRoutedRpc.Everybody) { list = list.Where([<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (ZNetPeer p) => p.m_uid == target).ToList(); } return sendZPackage(list, package); } private IEnumerator sendZPackage(List<ZNetPeer> peers, ZPackage package) { if (!Object.op_Implicit((Object)(object)ZNet.instance)) { yield break; } byte[] rawData = package.GetArray(); if (rawData != null && rawData.LongLength > 10000) { ZPackage compressedPackage = new ZPackage(); compressedPackage.Write((byte)4); MemoryStream output = new MemoryStream(); using (DeflateStream deflateStream = new DeflateStream(output, CompressionLevel.Optimal)) { deflateStream.Write(rawData, 0, rawData.Length); } compressedPackage.Write(output.ToArray()); package = compressedPackage; } List<IEnumerator<bool>> writers = (from peer in peers where peer.IsReady() select peer into p select distributeConfigToPeers(p, package)).ToList(); writers.RemoveAll((IEnumerator<bool> writer) => !writer.MoveNext()); while (writers.Count > 0) { yield return null; writers.RemoveAll((IEnumerator<bool> writer) => !writer.MoveNext()); } } private void Broadcast(long target, params ConfigEntryBase[] configs) { if (!IsLocked || isServer) { ZPackage package = ConfigsToPackage(configs); ZNet instance = ZNet.instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(sendZPackage(target, package)); } } } private void Broadcast(long target, params CustomSyncedValueBase[] customValues) { if (!IsLocked || isServer) { ZPackage package = ConfigsToPackage(null, customValues); ZNet instance = ZNet.instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(sendZPackage(target, package)); } } } [return: <e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] private static OwnConfigEntryBase configData(ConfigEntryBase config) { return config.Description.Tags?.OfType<OwnConfigEntryBase>().SingleOrDefault(); } [return: <e3c94967-4846-4284-9259-2c1eeb508514>Nullable(new byte[] { 2, 1 })] public static SyncedConfigEntry<T> ConfigData<[<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] T>(ConfigEntry<T> config) { return ((ConfigEntryBase)config).Description.Tags?.OfType<SyncedConfigEntry<T>>().SingleOrDefault(); } private static T configAttribute<[<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] T>(ConfigEntryBase config) { return config.Description.Tags.OfType<T>().First(); } private static Type configType(ConfigEntryBase config) { return configType(config.SettingType); } private static Type configType(Type type) { return type.IsEnum ? Enum.GetUnderlyingType(type) : type; } private static ZPackage ConfigsToPackage([<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(new byte[] { 2, 1 })] IEnumerable<ConfigEntryBase> configs = null, [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(new byte[] { 2, 1 })] IEnumerable<CustomSyncedValueBase> customValues = null, [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(new byte[] { 2, 1 })] IEnumerable<PackageEntry> packageEntries = null, bool partial = true) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown List<ConfigEntryBase> list = configs?.Where([<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(0)] (ConfigEntryBase config) => configData(config).SynchronizedConfig).ToList() ?? new List<ConfigEntryBase>(); List<CustomSyncedValueBase> list2 = customValues?.ToList() ?? new List<CustomSyncedValueBase>(); ZPackage val = new ZPackage(); val.Write((byte)(partial ? 1 : 0)); val.Write(list.Count + list2.Count + (packageEntries?.Count() ?? 0)); foreach (PackageEntry item in packageEntries ?? Array.Empty<PackageEntry>()) { AddEntryToPackage(val, item); } foreach (CustomSyncedValueBase item2 in list2) { AddEntryToPackage(val, new PackageEntry { section = "Internal", key = item2.Identifier, type = item2.Type, value = item2.BoxedValue }); } foreach (ConfigEntryBase item3 in list) { AddEntryToPackage(val, new PackageEntry { section = item3.Definition.Section, key = item3.Definition.Key, type = configType(item3), value = item3.BoxedValue }); } return val; } private static void AddEntryToPackage(ZPackage package, PackageEntry entry) { package.Write(entry.section); package.Write(entry.key); package.Write((entry.value == null) ? "" : GetZPackageTypeString(entry.type)); AddValueToZPackage(package, entry.value); } private static string GetZPackageTypeString(Type type) { return type.AssemblyQualifiedName; } private static void AddValueToZPackage(ZPackage package, [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] object value) { Type type = value?.GetType(); if (value is Enum) { value = ((IConvertible)value).ToType(Enum.GetUnderlyingType(value.GetType()), CultureInfo.InvariantCulture); } else { if (value is ICollection collection) { package.Write(collection.Count); { foreach (object item in collection) { AddValueToZPackage(package, item); } return; } } if ((object)type != null && type.IsValueType && !type.IsPrimitive) { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); package.Write(fields.Length); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { package.Write(GetZPackageTypeString(fieldInfo.FieldType)); AddValueToZPackage(package, fieldInfo.GetValue(value)); } return; } } ZRpc.Serialize(new object[1] { value }, ref package); } private static object ReadValueWithTypeFromZPackage(ZPackage package, Type type) { if ((object)type != null && type.IsValueType && !type.IsPrimitive && !type.IsEnum) { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); int num = package.ReadInt(); if (num != fields.Length) { throw new InvalidDeserializationTypeException { received = $"(field count: {num})", expected = $"(field count: {fields.Length})" }; } object uninitializedObject = FormatterServices.GetUninitializedObject(type); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { string text = package.ReadString(); if (text != GetZPackageTypeString(fieldInfo.FieldType)) { throw new InvalidDeserializationTypeException { received = text, expected = GetZPackageTypeString(fieldInfo.FieldType), field = fieldInfo.Name }; } fieldInfo.SetValue(uninitializedObject, ReadValueWithTypeFromZPackage(package, fieldInfo.FieldType)); } return uninitializedObject; } if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary<, >)) { int num2 = package.ReadInt(); IDictionary dictionary = (IDictionary)Activator.CreateInstance(type); Type type2 = typeof(KeyValuePair<, >).MakeGenericType(type.GenericTypeArguments); FieldInfo field = type2.GetField("key", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = type2.GetField("value", BindingFlags.Instance | BindingFlags.NonPublic); for (int j = 0; j < num2; j++) { object obj = ReadValueWithTypeFromZPackage(package, type2); dictionary.Add(field.GetValue(obj), field2.GetValue(obj)); } return dictionary; } if (type != typeof(List<string>) && type.IsGenericType) { Type type3 = typeof(ICollection<>).MakeGenericType(type.GenericTypeArguments[0]); if ((object)type3 != null && type3.IsAssignableFrom(type)) { int num3 = package.ReadInt(); object obj2 = Activator.CreateInstance(type); MethodInfo method = type3.GetMethod("Add"); for (int k = 0; k < num3; k++) { method.Invoke(obj2, new object[1] { ReadValueWithTypeFromZPackage(package, type.GenericTypeArguments[0]) }); } return obj2; } } ParameterInfo parameterInfo = (ParameterInfo)FormatterServices.GetUninitializedObject(typeof(ParameterInfo)); AccessTools.DeclaredField(typeof(ParameterInfo), "ClassImpl").SetValue(parameterInfo, type); List<object> source = new List<object>(); ZRpc.Deserialize(new ParameterInfo[2] { null, parameterInfo }, package, ref source); return source.First(); } } [HarmonyPatch] [PublicAPI] [<a33b2df4-6460-408a-ac71-522ab3d49044>NullableContext(1)] [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(0)] internal class VersionCheck { private static readonly HashSet<VersionCheck> versionChecks; private static readonly Dictionary<string, string> notProcessedNames; public string Name; [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] private string displayName; [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] private string currentVersion; [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] private string minimumRequiredVersion; public bool ModRequired = true; [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] private string ReceivedCurrentVersion; [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] private string ReceivedMinimumRequiredVersion; private readonly List<ZRpc> ValidatedClients = new List<ZRpc>(); [<e3c94967-4846-4284-9259-2c1eeb508514>Nullable(2)] private ConfigSync ConfigSync; public string DisplayN