Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RepairCost v1.0.2
plugins/RepairCost.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using ItemManager; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.ObjectPool; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Callbacks; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: Guid("E74EB49A-461D-48EA-85BC-F462D60C98C4")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyProduct("RepairCost")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("RepairCost")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyFileVersion("1.0.2")] [assembly: AssemblyCompany("Radamanto")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: <8ff0612c-76ce-4388-ac04-0d03d5e91472>RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<08a11b1e-502b-41af-b461-d5ed2053f347>Embedded] internal sealed class <08a11b1e-502b-41af-b461-d5ed2053f347>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [<08a11b1e-502b-41af-b461-d5ed2053f347>Embedded] [CompilerGenerated] internal sealed class <859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [<08a11b1e-502b-41af-b461-d5ed2053f347>Embedded] [CompilerGenerated] internal sealed class <b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContextAttribute : Attribute { public readonly byte Flag; public <b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContextAttribute(byte P_0) { Flag = P_0; } } [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] [<08a11b1e-502b-41af-b461-d5ed2053f347>Embedded] [CompilerGenerated] internal sealed class <8ff0612c-76ce-4388-ac04-0d03d5e91472>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <8ff0612c-76ce-4388-ac04-0d03d5e91472>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LocalizationManager { [PublicAPI] [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(1)] public class Localizer { private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors; private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts; private static readonly ConditionalWeakTable<Localization, string> localizationLanguage; private static readonly List<WeakReference<Localization>> localizationObjects; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private static BaseUnityPlugin _plugin; private static readonly List<string> fileExtensions; private static BaseUnityPlugin plugin { get { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown if (_plugin == null) { IEnumerable<TypeInfo> source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] [method: <b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(2)] [field: <859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] public static event Action OnLocalizationComplete; private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out var value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out var value2)) { text = value2.Aggregate(text, [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value())); } localization.AddWord(key, text); } public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null) { if (convertConfigValue == null) { convertConfigValue = (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary<string, Func<string>>(); } config.SettingChanged += [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (object _, EventArgs _) => { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value); UpdatePlaceholderText(Localization.instance, key); } } public static void AddText(string key, string text) { List<WeakReference<Localization>> list = new List<WeakReference<Localization>>(); foreach (WeakReference<Localization> localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference<Localization> item in list) { localizationObjects.Remove(item); } } public static void Load() { _ = plugin; } public static void LoadLocalizationLater(Localization __instance) { LoadLocalization(Localization.instance, __instance.GetSelectedLanguage()); } public static void SafeCallLocalizeComplete() { Localizer.OnLocalizationComplete?.Invoke(); } private static void LoadLocalization(Localization __instance, string language) { if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference<Localization>(__instance)); } localizationLanguage.Add(__instance, language); Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories) where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0 select f) { string[] array = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' }); if (array.Length >= 2) { string text = array[1]; if (dictionary.ContainsKey(text)) { Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped.")); } else { dictionary[text] = item; } } } byte[] array2 = LoadTranslationFromAssembly("English"); if (array2 == null) { throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml."); } string input = Encoding.UTF8.GetString(array2).TrimStart(new char[1] { '\ufeff' }); Dictionary<string, string> dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(input); if (dictionary2 == null) { throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text2 = null; if (language != "English") { if (dictionary.TryGetValue(language, out var value)) { text2 = File.ReadAllText(value); } else { byte[] array3 = LoadTranslationFromAssembly(language); if (array3 != null) { text2 = Encoding.UTF8.GetString(array3); } } } if (text2 == null && dictionary.TryGetValue("English", out var value2)) { text2 = File.ReadAllText(value2); } if (text2 != null) { text2 = text2.TrimStart(new char[1] { '\ufeff' }); foreach (KeyValuePair<string, string> item2 in new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>()) { dictionary2[item2.Key] = item2.Value; } } loadedTexts[language] = dictionary2; foreach (KeyValuePair<string, string> item3 in dictionary2) { UpdatePlaceholderText(__instance, item3.Key); } } static Localizer() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>(); loadedTexts = new Dictionary<string, Dictionary<string, string>>(); localizationLanguage = new ConditionalWeakTable<Localization, string>(); localizationObjects = new List<WeakReference<Localization>>(); fileExtensions = new List<string>(2) { ".json", ".yml" }; Harmony val = new Harmony("org.bepinex.helpers.LocalizationManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "SetupGui", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalizationLater", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "SafeCallLocalizeComplete", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } [return: <859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private static byte[] LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension); if (array != null) { return array; } } return null; } [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(2)] public static byte[] ReadEmbeddedFileBytes([<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(1)] string resourceFileName, Assembly containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } public static class LocalizationManagerVersion { [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(1)] public const string Version = "1.4.1"; } } namespace RepairCost { internal static class Registry_Repairkit { public static void RegistryRepairkit() { Item item = new Item("rd_repair", "RD_repair_kit_t0"); item.Crafting.Add(CraftingTable.Workbench, 1); item.CraftAmount = 10; item.RequiredItems.Add("LeatherScraps", 2); item.RequiredItems.Add("Stone", 2); item.RequiredItems.Add("Resin", 2); Item item2 = new Item("rd_repair", "RD_repair_kit_t1"); item2.Crafting.Add(CraftingTable.Workbench, 1); item2.CraftAmount = 10; item2.RequiredItems.Add("DeerHide", 1); item2.RequiredItems.Add("Resin", 2); item2.RequiredItems.Add("Flint", 2); Item item3 = new Item("rd_repair", "RD_repair_kit_t2"); item3.Crafting.Add(CraftingTable.Workbench, 1); item3.CraftAmount = 10; item3.RequiredItems.Add("Resin", 2); item3.RequiredItems.Add("DeerHide", 2); item3.RequiredItems.Add("Copper", 1); Item item4 = new Item("rd_repair", "RD_repair_kit_t3"); item4.Crafting.Add(CraftingTable.Workbench, 1); item4.CraftAmount = 10; item4.RequiredItems.Add("Resin", 4); item4.RequiredItems.Add("Iron", 1); item4.RequiredItems.Add("LeatherScraps", 2); Item item5 = new Item("rd_repair", "RD_repair_kit_t4"); item5.Crafting.Add(CraftingTable.Workbench, 1); item5.CraftAmount = 10; item5.RequiredItems.Add("Resin", 4); item5.RequiredItems.Add("Silver", 1); item5.RequiredItems.Add("WolfPelt", 1); Item item6 = new Item("rd_repair", "RD_repair_kit_t5"); item6.Crafting.Add(CraftingTable.Workbench, 1); item6.CraftAmount = 10; item6.RequiredItems.Add("Resin", 4); item6.RequiredItems.Add("BlackMetal", 1); item6.RequiredItems.Add("LoxPelt", 1); Item item7 = new Item("rd_repair", "RD_repair_kit_t6"); item7.Crafting.Add(CraftingTable.Workbench, 1); item7.CraftAmount = 10; item7.RequiredItems.Add("Resin", 4); item7.RequiredItems.Add("Bronze", 2); item7.RequiredItems.Add("ScaleHide", 1); Item item8 = new Item("rd_repair", "RD_repair_kit_t7"); item8.Crafting.Add(CraftingTable.Workbench, 1); item8.CraftAmount = 10; item8.RequiredItems.Add("Resin", 6); item8.RequiredItems.Add("FlametalNew", 1); item8.RequiredItems.Add("AskHide", 1); } } [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(1)] internal static class RepairCostLogic { [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private static string _currencySharedName; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private static string _currencyDisplayName; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private static string _currencyPrefabName; private static bool _warnedCurrencyPrefabMissing; private static bool _warnedCurrencyItemDropMissing; private static readonly HashSet<string> _bypassPrefabs = new HashSet<string>(StringComparer.Ordinal); private static string _bypassRaw = string.Empty; internal static bool TryGetNextRepairableItem(InventoryGui gui, [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] out ItemData item) { item = null; Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { return false; } List<ItemData> list = new List<ItemData>(); ((Humanoid)localPlayer).GetInventory().GetWornItems(list); foreach (ItemData item2 in list) { if (!CanRepairItem(item2)) { continue; } item = item2; return true; } return false; } internal static int GetRepairCost(ItemData item) { if (!ShouldUseRepairCost(item)) { return 0; } float maxDurability = item.GetMaxDurability(); if (maxDurability <= 0f) { return 0; } if (item.m_durability >= maxDurability) { return 0; } float num = 1f - Mathf.Clamp01(item.m_durability / maxDurability); if (num <= 0f) { return 0; } int num2 = Mathf.Max(0, RepairCostPlugin.CE_MaxRepairCost.Value); if (num2 <= 0) { return 0; } float qualityMultiplier = GetQualityMultiplier(item); int num3 = Mathf.CeilToInt((float)num2 * num * qualityMultiplier); int num4 = Mathf.Max(1, Mathf.CeilToInt((float)num2 * qualityMultiplier)); if (num3 < 1) { num3 = 1; } if (num3 > num4) { num3 = num4; } return num3; } internal static bool HasValidCurrency() { EnsureCurrencyCache(); return !string.IsNullOrWhiteSpace(_currencySharedName); } internal static bool HasEnoughCurrency(Inventory inventory, int amount) { if (amount <= 0) { return true; } string currencySharedName = GetCurrencySharedName(); if (currencySharedName.Length == 0) { return false; } return inventory.CountItems(currencySharedName, -1, true) >= amount; } internal static bool TryConsumeCurrency(Inventory inventory, int amount) { if (amount <= 0) { return true; } string currencySharedName = GetCurrencySharedName(); if (currencySharedName.Length == 0) { return false; } if (inventory.CountItems(currencySharedName, -1, true) < amount) { return false; } inventory.RemoveItem(currencySharedName, amount, -1, true); return true; } internal static string BuildTooltipLine(ItemData item) { if (!RepairCostPlugin.CE_Enabled.Value) { return string.Empty; } if (!ShouldShowRepairCost(item)) { return string.Empty; } int repairCost = GetRepairCost(item); if (repairCost <= 0) { return string.Empty; } if (!HasValidCurrency()) { string text = Localize("$repaircost_tooltip_invalid_currency"); if (text.Length == 0) { return string.Empty; } return "\n<color=#FF3B3B>" + text + "</color>"; } string currencyDisplayName = GetCurrencyDisplayName(); if (currencyDisplayName.Length == 0) { return string.Empty; } Player localPlayer = Player.m_localPlayer; bool flag = Object.op_Implicit((Object)(object)localPlayer) && HasEnoughCurrency(((Humanoid)localPlayer).GetInventory(), repairCost); string text2 = SanitizeColor(flag ? RepairCostPlugin.CE_TextColorCanAfford.Value : RepairCostPlugin.CE_TextColorCannotAfford.Value, flag ? "#32CD32" : "#FF3B3B"); string text3 = FormatLocalized("$repaircost_tooltip_cost", repairCost.ToString(CultureInfo.InvariantCulture), currencyDisplayName); return (text3.Length == 0) ? string.Empty : ("\n<color=" + text2 + ">" + text3 + "</color>"); } internal static string BuildMissingCurrencyMessage(ItemData item, int cost) { if (!HasValidCurrency()) { return string.Empty; } string currencyDisplayName = GetCurrencyDisplayName(); if (currencyDisplayName.Length == 0) { return string.Empty; } return FormatLocalized("$repaircost_msg_need_currency", cost.ToString(CultureInfo.InvariantCulture), currencyDisplayName, GetItemDisplayName(item)); } internal static string GetInvalidCurrencyMessage() { return Localize("$repaircost_msg_invalid_currency"); } internal static string GetItemDisplayName(ItemData item) { if (item == null) { return string.Empty; } string text = item.m_shared.m_name ?? string.Empty; if (text.Length == 0) { return string.Empty; } string text2 = Localize(text); return (text2.Length > 0) ? text2 : text.Trim(); } internal static string GetCurrencyDisplayName() { EnsureCurrencyCache(); RefreshCurrencyDisplayName(); return _currencyDisplayName ?? string.Empty; } internal static bool IsBypassedItem(ItemData item) { if (item == null) { return false; } RefreshBypassCache(); string text = (Object.op_Implicit((Object)(object)item.m_dropPrefab) ? ((Object)item.m_dropPrefab).name : string.Empty); if (text.Length == 0) { return false; } return _bypassPrefabs.Contains(text); } private static bool CanRepairItem(ItemData item) { if (item == null) { return false; } if (!item.m_shared.m_canBeReparied) { return false; } Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { return false; } if (localPlayer.NoCostCheat()) { return true; } CraftingStation currentCraftingStation = localPlayer.GetCurrentCraftingStation(); if (!Object.op_Implicit((Object)(object)currentCraftingStation)) { return false; } Recipe recipe = ObjectDB.instance.GetRecipe(item); if (!Object.op_Implicit((Object)(object)recipe)) { return false; } if (!Object.op_Implicit((Object)(object)recipe.m_craftingStation) && !Object.op_Implicit((Object)(object)recipe.m_repairStation)) { return false; } if ((!Object.op_Implicit((Object)(object)recipe.m_repairStation) || !(recipe.m_repairStation.m_name == currentCraftingStation.m_name)) && (!Object.op_Implicit((Object)(object)recipe.m_craftingStation) || !(recipe.m_craftingStation.m_name == currentCraftingStation.m_name)) && item.m_worldLevel >= Game.m_worldLevel) { return false; } return Mathf.Min(currentCraftingStation.GetLevel(true), 4) >= recipe.m_minStationLevel; } private static bool ShouldUseRepairCost(ItemData item) { if (item == null) { return false; } if (!item.m_shared.m_useDurability) { return false; } if (!item.m_shared.m_canBeReparied) { return false; } if (IsBypassedItem(item)) { return false; } return true; } private static bool ShouldShowRepairCost(ItemData item) { if (item == null) { return false; } if (!item.m_shared.m_useDurability) { return false; } if (!item.m_shared.m_canBeReparied) { return false; } if (IsBypassedItem(item)) { return false; } return true; } private static float GetQualityMultiplier(ItemData item) { if (item == null) { return 1f; } float num = Mathf.Max(0f, RepairCostPlugin.CE_QualityCostFactor.Value); if (num <= 0f) { return 1f; } int num2 = Mathf.Max(1, item.m_quality); return 1f + (float)(num2 - 1) * num; } private static string GetCurrencySharedName() { EnsureCurrencyCache(); return _currencySharedName ?? string.Empty; } private static void EnsureCurrencyCache() { string currencyPrefabName = GetCurrencyPrefabName(); if (!string.Equals(_currencyPrefabName, currencyPrefabName, StringComparison.Ordinal)) { _currencyPrefabName = currencyPrefabName; _currencySharedName = string.Empty; _currencyDisplayName = string.Empty; _warnedCurrencyPrefabMissing = false; _warnedCurrencyItemDropMissing = false; if (currencyPrefabName.Length == 0) { return; } GameObject val = null; if ((Object)(object)ObjectDB.instance != (Object)null) { val = ObjectDB.instance.GetItemPrefab(currencyPrefabName); } if (!Object.op_Implicit((Object)(object)val) && (Object)(object)ZNetScene.instance != (Object)null) { val = ZNetScene.instance.GetPrefab(currencyPrefabName); } if (!Object.op_Implicit((Object)(object)val)) { WarnOnce(ref _warnedCurrencyPrefabMissing, "RepairCost: currency prefab '" + currencyPrefabName + "' was not found in ObjectDB/ZNetScene."); return; } ItemDrop component = val.GetComponent<ItemDrop>(); if (!Object.op_Implicit((Object)(object)component)) { WarnOnce(ref _warnedCurrencyItemDropMissing, "RepairCost: prefab '" + currencyPrefabName + "' does not contain ItemDrop."); return; } string text = component.m_itemData.m_shared.m_name ?? string.Empty; if (string.IsNullOrWhiteSpace(text)) { return; } _currencySharedName = text.Trim(); } RefreshCurrencyDisplayName(); } private static void RefreshCurrencyDisplayName() { string text = _currencySharedName ?? string.Empty; if (text.Length != 0) { string text2 = Localize(text); _currencyDisplayName = ((text2.Length > 0) ? text2 : text); } } private static void RefreshBypassCache() { string text = RepairCostPlugin.CE_BypassPrefabNames.Value ?? string.Empty; if (string.Equals(_bypassRaw, text, StringComparison.Ordinal)) { return; } _bypassRaw = text; _bypassPrefabs.Clear(); if (_bypassRaw.Length == 0) { return; } string[] array = _bypassRaw.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.Length != 0) { _bypassPrefabs.Add(text2); } } } private static string GetCurrencyPrefabName() { string effectiveCurrencyPrefabName = RepairCostProgressionCurrency.GetEffectiveCurrencyPrefabName(); return string.IsNullOrWhiteSpace(effectiveCurrencyPrefabName) ? string.Empty : effectiveCurrencyPrefabName.Trim(); } private static string SanitizeColor([<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] string value, string fallback) { if (string.IsNullOrWhiteSpace(value)) { return fallback; } string text = value.Trim(); if (!text.StartsWith("#", StringComparison.Ordinal)) { return fallback; } Color val = default(Color); return ColorUtility.TryParseHtmlString(text, ref val) ? text : fallback; } private static string Localize(string token) { if (Localization.instance == null) { return string.Empty; } if (string.IsNullOrWhiteSpace(token)) { return string.Empty; } string text = Localization.instance.Localize(token); if (string.IsNullOrWhiteSpace(text)) { return string.Empty; } text = text.Trim(); return string.Equals(text, token, StringComparison.Ordinal) ? string.Empty : text; } private static string FormatLocalized(string token, params string[] args) { if (Localization.instance == null) { return string.Empty; } string text = Localization.instance.Localize(token); if (string.IsNullOrWhiteSpace(text) || string.Equals(text, token, StringComparison.Ordinal)) { return string.Empty; } try { return string.Format(CultureInfo.InvariantCulture, text, args); } catch { return string.Empty; } } private static void WarnOnce(ref bool flag, string message) { if (!flag) { flag = true; ManualLogSource log = RepairCostPlugin.Log; if (log != null) { log.LogWarning((object)message); } } } } [HarmonyPatch] [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(1)] internal static class RepairCostPatches { [HarmonyPrefix] [HarmonyPatch(typeof(InventoryGui), "RepairOneItem")] private static bool InventoryGui_RepairOneItem_Prefix(InventoryGui __instance) { if (!RepairCostPlugin.CE_Enabled.Value) { return true; } Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { return true; } if (!RepairCostLogic.TryGetNextRepairableItem(__instance, out var item) || item == null) { return true; } int repairCost = RepairCostLogic.GetRepairCost(item); if (repairCost <= 0) { return true; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); if (RepairCostLogic.HasEnoughCurrency(inventory, repairCost)) { RepairCostLogic.TryConsumeCurrency(inventory, repairCost); return true; } ShowRepairBlockedMessage(localPlayer, item, repairCost); return false; } [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(int) })] [HarmonyPostfix] private static void ItemDrop_ItemData_GetTooltip_Instance_Postfix(ItemData __instance, ref string __result) { AppendRepairCostLine(__instance, ref __result); } [HarmonyPostfix] [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int) })] private static void ItemDrop_ItemData_GetTooltip_Static_Postfix(ItemData item, ref string __result) { AppendRepairCostLine(item, ref __result); } private static void AppendRepairCostLine([<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] ItemData item, ref string tooltip) { if (RepairCostPlugin.CE_Enabled.Value && item != null && !string.IsNullOrEmpty(tooltip)) { string text = RepairCostLogic.BuildTooltipLine(item); if (text.Length != 0 && !tooltip.Contains(text)) { tooltip += text; } } } private static void ShowRepairBlockedMessage(Player player, ItemData item, int cost) { string text = RepairCostLogic.BuildMissingCurrencyMessage(item, cost); if (string.IsNullOrWhiteSpace(text)) { text = RepairCostLogic.GetInvalidCurrencyMessage(); } if (!string.IsNullOrWhiteSpace(text)) { ((Character)player).Message((MessageType)2, text, 0, (Sprite)null); } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("radamanto.RepairCost", "RepairCost", "1.0.2")] [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(1)] [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] public class RepairCostPlugin : BaseUnityPlugin { [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] private sealed class ConfigurationManagerAttributes { public bool? Browsable = false; } [CompilerGenerated] private sealed class <ReloadConfigAfterQuietPeriod>d__37 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] private object <>2__current; public float quietSeconds; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] public RepairCostPlugin <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] [return: <859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public <ReloadConfigAfterQuietPeriod>d__37(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if ((DateTime.UtcNow - <>4__this._lastCfgWriteUtc).TotalSeconds < (double)quietSeconds) { <>2__current = null; <>1__state = 1; return true; } try { if (<>4__this._configWatcher == null || !<>4__this._watcherReady) { return false; } <>4__this._configWatcher.EnableRaisingEvents = false; if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { ((BaseUnityPlugin)<>4__this).Config.Reload(); <>4__this._ignoreEventsUntilUtc = DateTime.UtcNow.AddSeconds(1.0); ((BaseUnityPlugin)<>4__this).Config.Save(); } } catch { } finally { if (<>4__this._configWatcher != null) { <>4__this._configWatcher.EnableRaisingEvents = true; } <>4__this._reloadScheduled = false; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal const string ModGuid = "radamanto.RepairCost"; internal const string ModName = "RepairCost"; internal const string ModVersion = "1.0.2"; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] internal static ManualLogSource Log; private Harmony _harmony = null; internal static ConfigEntry<bool> CE_Enabled; internal static ConfigEntry<int> CE_MaxRepairCost; internal static ConfigEntry<float> CE_QualityCostFactor; internal static ConfigEntry<string> CE_TextColorCanAfford; internal static ConfigEntry<string> CE_TextColorCannotAfford; internal static ConfigEntry<string> CE_BypassPrefabNames; internal static ConfigEntry<bool> CE_EnableCurrencyProgression; internal static ConfigEntry<string> CE_CurrencyPrefab_T0; internal static ConfigEntry<string> CE_CurrencyPrefab_Eikthyr; internal static ConfigEntry<string> CE_CurrencyPrefab_GdKing; internal static ConfigEntry<string> CE_CurrencyPrefab_Bonemass; internal static ConfigEntry<string> CE_CurrencyPrefab_Moder; internal static ConfigEntry<string> CE_CurrencyPrefab_GoblinKing; internal static ConfigEntry<string> CE_CurrencyPrefab_Queen; internal static ConfigEntry<string> CE_CurrencyPrefab_Fader; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] internal static ConfigSync ConfigSync; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private static ConfigEntry<bool> _serverConfigLocked; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private FileSystemWatcher _configWatcher; private DateTime _lastCfgWriteUtc = DateTime.MinValue; private DateTime _ignoreEventsUntilUtc = DateTime.MinValue; private bool _reloadScheduled; private bool _watcherReady; private void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown Localizer.Load(); Log = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("radamanto.RepairCost"); SetupServerSyncAndWatcher(); SetupConfigBinds(); Registry_Repairkit.RegistryRepairkit(); _harmony.PatchAll(); } public static bool IsLocalPlayerAdmin() { return ConfigSync != null && ConfigSync.IsAdmin; } private void SetupConfigBinds() { CE_Enabled = Cfg("01 - General", "Enabled", defaultValue: true, "If true, enables repair costs."); CE_MaxRepairCost = Cfg("02 - Repair Cost", "02.01 - MaxRepairCost", 10, "Maximum base repair cost at 0% durability for quality 1. Final cost scales with durability loss and item quality, and can exceed this base value."); CE_QualityCostFactor = Cfg("02 - Repair Cost", "02.02 - QualityFactor", 0.1f, "Extra repair cost multiplier added per quality level above 1. Example: 0.10 = q2 1.10x, q3 1.20x, q4 1.30x."); CE_BypassPrefabNames = Cfg("02 - Repair Cost", "02.03 - BypassPrefabNames", "Hammer,Hoe,Cultivator", "Comma-separated prefab names that bypass repair cost entirely."); CE_EnableCurrencyProgression = Cfg("03 - Currency Progression", "03.01 - EnableProgression", defaultValue: true, "If true, the repair currency progresses by unlocked boss keys. If false, the system always uses CurrencyPrefab_T0."); CE_CurrencyPrefab_T0 = Cfg("03 - Currency Progression", "03.02 - CurrencyPrefab_T0", "RD_repair_kit_t0", "Repair currency prefab used when the player has no progression key unlocked yet."); CE_CurrencyPrefab_Eikthyr = Cfg("03 - Currency Progression", "03.03 - CurrencyPrefab_Eikthyr", "RD_repair_kit_t1", "Repair currency prefab used when the highest unlocked progression key is defeated_eikthyr."); CE_CurrencyPrefab_GdKing = Cfg("03 - Currency Progression", "03.04 - CurrencyPrefab_GdKing", "RD_repair_kit_t2", "Repair currency prefab used when the highest unlocked progression key is defeated_gdking."); CE_CurrencyPrefab_Bonemass = Cfg("03 - Currency Progression", "03.05 - CurrencyPrefab_Bonemass", "RD_repair_kit_t3", "Repair currency prefab used when the highest unlocked progression key is defeated_bonemass."); CE_CurrencyPrefab_Moder = Cfg("03 - Currency Progression", "03.06 - CurrencyPrefab_Moder", "RD_repair_kit_t4", "Repair currency prefab used when the highest unlocked progression key is defeated_moder."); CE_CurrencyPrefab_GoblinKing = Cfg("03 - Currency Progression", "03.07 - CurrencyPrefab_GoblinKing", "RD_repair_kit_t5", "Repair currency prefab used when the highest unlocked progression key is defeated_goblinking."); CE_CurrencyPrefab_Queen = Cfg("03 - Currency Progression", "03.08 - CurrencyPrefab_Queen", "RD_repair_kit_t6", "Repair currency prefab used when the highest unlocked progression key is defeated_queen."); CE_CurrencyPrefab_Fader = Cfg("03 - Currency Progression", "03.09 - CurrencyPrefab_Fader", "RD_repair_kit_t7", "Repair currency prefab used when the highest unlocked progression key is defeated_fader."); CE_TextColorCanAfford = Cfg("04 - Tooltip", "04.01 - CanAffordColor", "#32CD32", "Text color used when the player has enough currency."); CE_TextColorCannotAfford = Cfg("04 - Tooltip", "04.02 - CannotAffordColor", "#FF3B3B", "Text color used when the player does not have enough currency."); } public void SetupServerSyncAndWatcher() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown bool flag = false; try { ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; ConfigSync = new ConfigSync(((BaseUnityPlugin)this).Info.Metadata.GUID) { DisplayName = ((BaseUnityPlugin)this).Info.Metadata.Name, CurrentVersion = ((BaseUnityPlugin)this).Info.Metadata.Version.ToString(), MinimumRequiredVersion = ((BaseUnityPlugin)this).Info.Metadata.Version.ToString() }; _serverConfigLocked = ((BaseUnityPlugin)this).Config.Bind<bool>("01 - General", "LockConfiguration", true, new ConfigDescription("If true, the server locks synchronized configs.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = false } })); ConfigSync.AddLockingConfigEntry<bool>(_serverConfigLocked); SetupConfigWatcher(); flag = true; } catch { } finally { ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; if (flag) { ((BaseUnityPlugin)this).Config.Save(); } } } protected ConfigEntry<T> Cfg<[<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] T>(string section, string key, T defaultValue, string description, bool synced = true) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown return BindConfig(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synced); } private ConfigEntry<T> BindConfig<[<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] T>(string section, string key, T defaultValue, ConfigDescription description, bool synchronizedSetting = true) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags); ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, val); try { SyncedConfigEntry<T> syncedConfigEntry = ((ConfigSync != null) ? ConfigSync.AddConfigEntry<T>(val2) : null); if (syncedConfigEntry != null) { syncedConfigEntry.SynchronizedConfig = synchronizedSetting; } } catch { } return val2; } private void SetupConfigWatcher() { try { _configWatcher?.Dispose(); string configPath = Paths.ConfigPath; string fileName = Path.GetFileName(((BaseUnityPlugin)this).Config.ConfigFilePath); _configWatcher = new FileSystemWatcher(configPath, fileName) { IncludeSubdirectories = false, NotifyFilter = (NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite | NotifyFilters.CreationTime) }; _configWatcher.Changed += OnConfigFileChanged; _configWatcher.Created += OnConfigFileChanged; _configWatcher.Renamed += OnConfigFileRenamed; _configWatcher.EnableRaisingEvents = true; _watcherReady = true; } catch { } } private void OnConfigFileChanged(object sender, FileSystemEventArgs e) { if (!(DateTime.UtcNow < _ignoreEventsUntilUtc)) { _lastCfgWriteUtc = DateTime.UtcNow; if (!_reloadScheduled) { _reloadScheduled = true; ((MonoBehaviour)this).StartCoroutine(ReloadConfigAfterQuietPeriod(0.75f)); } } } private void OnConfigFileRenamed(object sender, RenamedEventArgs e) { OnConfigFileChanged(sender, e); } [IteratorStateMachine(typeof(<ReloadConfigAfterQuietPeriod>d__37))] private IEnumerator ReloadConfigAfterQuietPeriod(float quietSeconds) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ReloadConfigAfterQuietPeriod>d__37(0) { <>4__this = this, quietSeconds = quietSeconds }; } } [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(1)] internal static class RepairCostProgressionCurrency { private static readonly string[] OrderedKeys = new string[7] { "defeated_eikthyr", "defeated_gdking", "defeated_bonemass", "defeated_moder", "defeated_goblinking", "defeated_queen", "defeated_fader" }; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private static MethodInfo _miHasPrivateKey; private static int _biomeLockResolveAttempts; private const int MaxBiomeLockResolveAttempts = 3; internal static string GetEffectiveCurrencyPrefabName() { if (!RepairCostPlugin.CE_Enabled.Value) { return GetT0CurrencyPrefabName(); } if (!RepairCostPlugin.CE_EnableCurrencyProgression.Value) { return GetT0CurrencyPrefabName(); } string highestUnlockedKey = GetHighestUnlockedKey(); string text = ((highestUnlockedKey.Length == 0) ? GetT0CurrencyPrefabName() : GetMappedPrefabName(highestUnlockedKey)); if (string.IsNullOrWhiteSpace(text)) { return string.Empty; } text = text.Trim(); return (text.Length == 0) ? string.Empty : text; } private static string GetHighestUnlockedKey() { string result = string.Empty; if (CanUseBiomeLock()) { for (int i = 0; i < OrderedKeys.Length; i++) { string text = OrderedKeys[i]; if (HasBiomeLockPrivateKey(text)) { result = text; } } return result; } if ((Object)(object)ZoneSystem.instance == (Object)null) { return string.Empty; } for (int j = 0; j < OrderedKeys.Length; j++) { string text2 = OrderedKeys[j]; if (HasVanillaGlobalKey(text2)) { result = text2; } } return result; } private static bool HasVanillaGlobalKey(string key) { try { return (Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGlobalKey(key); } catch { return false; } } private static bool CanUseBiomeLock() { ResolveBiomeLock(); return _miHasPrivateKey != null; } private static bool HasBiomeLockPrivateKey(string key) { ResolveBiomeLock(); if (_miHasPrivateKey == null) { return false; } try { object obj = _miHasPrivateKey.Invoke(null, new object[1] { key }); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch { return false; } } private static void ResolveBiomeLock() { if (_miHasPrivateKey != null || _biomeLockResolveAttempts >= 3) { return; } _biomeLockResolveAttempts++; try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType("BiomeLock.BiomeLockAPI", throwOnError: false); if (!(type == null)) { MethodInfo method = type.GetMethod("HasPrivateKey", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(string) }, null); if (!(method == null)) { _miHasPrivateKey = method; break; } } } } catch { } } private static string GetMappedPrefabName(string key) { if (1 == 0) { } string result = key switch { "defeated_eikthyr" => GetCfgValue(RepairCostPlugin.CE_CurrencyPrefab_Eikthyr), "defeated_gdking" => GetCfgValue(RepairCostPlugin.CE_CurrencyPrefab_GdKing), "defeated_bonemass" => GetCfgValue(RepairCostPlugin.CE_CurrencyPrefab_Bonemass), "defeated_moder" => GetCfgValue(RepairCostPlugin.CE_CurrencyPrefab_Moder), "defeated_goblinking" => GetCfgValue(RepairCostPlugin.CE_CurrencyPrefab_GoblinKing), "defeated_queen" => GetCfgValue(RepairCostPlugin.CE_CurrencyPrefab_Queen), "defeated_fader" => GetCfgValue(RepairCostPlugin.CE_CurrencyPrefab_Fader), _ => string.Empty, }; if (1 == 0) { } return result; } private static string GetT0CurrencyPrefabName() { return GetCfgValue(RepairCostPlugin.CE_CurrencyPrefab_T0); } private static string GetCfgValue(ConfigEntry<string> entry) { string value = entry.Value; return string.IsNullOrWhiteSpace(value) ? string.Empty : value.Trim(); } } } namespace ItemManager { [PublicAPI] public enum CraftingTable { Disabled, Inventory, [InternalName("piece_workbench")] Workbench, [InternalName("piece_cauldron")] Cauldron, [InternalName("piece_MeadCauldron")] MeadCauldron, [InternalName("forge")] Forge, [InternalName("piece_artisanstation")] ArtisanTable, [InternalName("piece_stonecutter")] StoneCutter, [InternalName("piece_magetable")] MageTable, [InternalName("piece_preptable")] PrepTable, [InternalName("blackforge")] BlackForge, Custom } [PublicAPI] public enum ConversionPiece { Disabled, [InternalName("smelter")] Smelter, [InternalName("charcoal_kiln")] CharcoalKiln, [InternalName("blastfurnace")] BlastFurnace, [InternalName("windmill")] Windmill, [InternalName("piece_spinningwheel")] SpinningWheel, [InternalName("eitrrefinery")] EitrRefinery, Custom } [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(1)] public class InternalName : Attribute { public readonly string internalName; public InternalName(string internalName) { this.internalName = internalName; } } [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(1)] [PublicAPI] public class RequiredResourceList { public readonly List<Requirement> Requirements = new List<Requirement>(); public bool Free = false; public void Add(string itemName, int amount, int quality = 0) { Requirements.Add(new Requirement { itemName = itemName, amount = amount, quality = quality }); } public void Add(string itemName, ConfigEntry<int> amountConfig, int quality = 0) { Requirements.Add(new Requirement { itemName = itemName, amountConfig = amountConfig, quality = quality }); } } [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(1)] [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] [PublicAPI] public class CraftingStationList { public readonly List<CraftingStationConfig> Stations = new List<CraftingStationConfig>(); public void Add(CraftingTable table, int level) { Stations.Add(new CraftingStationConfig { Table = table, level = level }); } public void Add(string customTable, int level) { Stations.Add(new CraftingStationConfig { Table = CraftingTable.Custom, level = level, custom = customTable }); } } [PublicAPI] [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(1)] public class ItemRecipe { public readonly RequiredResourceList RequiredItems = new RequiredResourceList(); public readonly RequiredResourceList RequiredUpgradeItems = new RequiredResourceList(); public readonly CraftingStationList Crafting = new CraftingStationList(); public int CraftAmount = 1; public bool RequireOnlyOneIngredient = false; public float QualityResultAmountMultiplier = 1f; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] public ConfigEntryBase RecipeIsActive = null; } [PublicAPI] public class Trade { public Trader Trader = Trader.None; public uint Price = 0u; public uint Stack = 1u; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] public string RequiredGlobalKey = null; } [PublicAPI] [Flags] public enum Trader { None = 0, Haldor = 1, Hildir = 2 } public struct Requirement { [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(1)] public string itemName; public int amount; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] public ConfigEntry<int> amountConfig; [Description("Set to a non-zero value to apply the requirement only for a specific quality")] public int quality; } public struct CraftingStationConfig { public CraftingTable Table; public int level; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] public string custom; } [Flags] public enum Configurability { Disabled = 0, Recipe = 1, Stats = 2, Drop = 4, Trader = 8, Full = 0xF } [PublicAPI] [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(1)] public class DropTargets { public readonly List<DropTarget> Drops = new List<DropTarget>(); public void Add(string creatureName, float chance, int min = 1, int? max = null, bool levelMultiplier = true) { Drops.Add(new DropTarget { creature = creatureName, chance = chance, min = min, max = max.GetValueOrDefault(min), levelMultiplier = levelMultiplier }); } } public struct DropTarget { [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(1)] public string creature; public int min; public int max; public float chance; public bool levelMultiplier; } public enum Toggle { On = 1, Off = 0 } [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] [PublicAPI] [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(1)] public class Item { [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] private class ItemConfig { [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(new byte[] { 2, 1 })] public ConfigEntry<string> craft; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(new byte[] { 2, 1 })] public ConfigEntry<string> upgrade; public ConfigEntry<CraftingTable> table = null; public ConfigEntry<int> tableLevel = null; public ConfigEntry<string> customTable = null; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] public ConfigEntry<int> maximumTableLevel; public ConfigEntry<Toggle> requireOneIngredient = null; public ConfigEntry<float> qualityResultAmountMultiplier = null; } [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] private class TraderConfig { public ConfigEntry<Trader> trader = null; public ConfigEntry<uint> price = null; public ConfigEntry<uint> stack = null; public ConfigEntry<string> requiredGlobalKey = null; } [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] private class RequirementQuality { public int quality; } [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(2)] [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [UsedImplicitly] public string Category; [UsedImplicitly] [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(new byte[] { 2, 1 })] public Action<ConfigEntryBase> CustomDrawer; public Func<bool> browsability; } [PublicAPI] [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] public enum DamageModifier { Normal, Resistant, Weak, Immune, Ignore, VeryResistant, VeryWeak, None } [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] private delegate void setDmgFunc(ref DamageTypes dmg, float value); [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] private class SerializedRequirements { public readonly List<Requirement> Reqs; public SerializedRequirements(List<Requirement> reqs) { Reqs = reqs; } public SerializedRequirements(string reqs) : this(reqs.Split(new char[1] { ',' }).Select([<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (string r) => { string[] array = r.Split(new char[1] { ':' }); Requirement result = default(Requirement); result.itemName = array[0]; result.amount = ((array.Length <= 1 || !int.TryParse(array[1], out var result2)) ? 1 : result2); result.quality = ((array.Length > 2 && int.TryParse(array[2], out var result3)) ? result3 : 0); return result; }).ToList()) { } public override string ToString() { return string.Join(",", Reqs.Select([<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (Requirement r) => $"{r.itemName}:{r.amount}" + ((r.quality > 0) ? $":{r.quality}" : ""))); } [return: <859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] public static ItemDrop fetchByName(ObjectDB objectDB, string name) { GameObject itemPrefab = objectDB.GetItemPrefab(name); ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("The required item '" + name + "' does not exist.")); } return val; } public static Requirement[] toPieceReqs(ObjectDB objectDB, SerializedRequirements craft, SerializedRequirements upgrade) { //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected O, but got Unknown //IL_01b7: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown Dictionary<string, Requirement> dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func<Requirement, string>)([<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (Requirement r) => r.itemName), (Func<Requirement, Requirement>)([<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (Requirement r) => { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) ItemDrop val6 = ResItem(r); return (val6 == null) ? ((Requirement)null) : new Requirement { m_amount = (r.amountConfig?.Value ?? r.amount), m_resItem = val6, m_amountPerLevel = 0 }; })); List<Requirement> list = dictionary.Values.Where([<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (Requirement v) => v != null).ToList(); foreach (Requirement item in upgrade.Reqs.Where((Requirement r) => r.itemName != "")) { if (item.quality > 0) { ItemDrop val = ResItem(item); if (val != null) { Requirement val2 = new Requirement { m_resItem = val, m_amountPerLevel = (item.amountConfig?.Value ?? item.amount), m_amount = 0 }; list.Add(val2); requirementQuality.Add(val2, new RequirementQuality { quality = item.quality }); } continue; } if (!dictionary.TryGetValue(item.itemName, out var value) || value == null) { ItemDrop val3 = ResItem(item); if (val3 != null) { string itemName = item.itemName; Requirement val4 = new Requirement { m_resItem = val3, m_amount = 0 }; Requirement val5 = val4; dictionary[itemName] = val4; value = val5; list.Add(value); } } if (value != null) { value.m_amountPerLevel = item.amountConfig?.Value ?? item.amount; } } return list.ToArray(); [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(2)] ItemDrop ResItem(Requirement r) { return fetchByName(objectDB, r.itemName); } } } [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] private class SerializedDrop { public readonly List<DropTarget> Drops; public SerializedDrop(List<DropTarget> drops) { Drops = drops; } public SerializedDrop(string drops) { Drops = ((drops == "") ? ((IEnumerable<string>)Array.Empty<string>()) : ((IEnumerable<string>)drops.Split(new char[1] { ',' }))).Select([<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (string r) => { string[] array = r.Split(new char[1] { ':' }); if (array.Length <= 2 || !int.TryParse(array[2], out var result)) { result = 1; } if (array.Length <= 3 || !int.TryParse(array[3], out var result2)) { result2 = result; } bool levelMultiplier = array.Length <= 4 || array[4] != "0"; DropTarget result3 = default(DropTarget); result3.creature = array[0]; result3.chance = ((array.Length > 1 && float.TryParse(array[1], out var result4)) ? result4 : 1f); result3.min = result; result3.max = result2; result3.levelMultiplier = levelMultiplier; return result3; }).ToList(); } public override string ToString() { return string.Join(",", Drops.Select([<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (DropTarget r) => $"{r.creature}:{r.chance.ToString(CultureInfo.InvariantCulture)}:{r.min}:" + ((r.min == r.max) ? "" : $"{r.max}") + (r.levelMultiplier ? "" : ":0"))); } [return: <859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private static Character fetchByName(ZNetScene netScene, string name) { GameObject prefab = netScene.GetPrefab(name); Character val = ((prefab != null) ? prefab.GetComponent<Character>() : null); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("The drop target character '" + name + "' does not exist.")); } return val; } public Dictionary<Character, Drop> toCharacterDrops(ZNetScene netScene, GameObject item) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown Dictionary<Character, Drop> dictionary = new Dictionary<Character, Drop>(); foreach (DropTarget drop in Drops) { Character val = fetchByName(netScene, drop.creature); if (val != null) { dictionary[val] = new Drop { m_prefab = item, m_amountMin = drop.min, m_amountMax = drop.max, m_chance = drop.chance, m_levelMultiplier = drop.levelMultiplier }; } } return dictionary; } } [CompilerGenerated] private sealed class <>c__DisplayClass83_0 { public Quaternion? cameraRotation; public float lightIntensity; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] public ItemDrop item; public Quaternion? itemRotation; } [CompilerGenerated] private sealed class <Transpile_InventoryGui>d__85 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(new byte[] { 0, 1 })] private IEnumerable<CodeInstruction> instructions; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(new byte[] { 0, 1 })] public IEnumerable<CodeInstruction> <>3__instructions; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(new byte[] { 0, 1 })] private List<CodeInstruction> <instrs>5__1; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] private FieldInfo <amountField>5__2; private int <i>5__3; CodeInstruction IEnumerator<CodeInstruction>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public <Transpile_InventoryGui>d__85(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <instrs>5__1 = null; <amountField>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown int num; switch (<>1__state) { default: return false; case 0: <>1__state = -1; <instrs>5__1 = instructions.ToList(); <amountField>5__2 = AccessTools.DeclaredField(typeof(Recipe), "m_amount"); <i>5__3 = 0; break; case 1: <>1__state = -1; if (<i>5__3 > 1 && <instrs>5__1[<i>5__3 - 2].opcode == OpCodes.Ldfld && CodeInstructionExtensions.OperandIs(<instrs>5__1[<i>5__3 - 2], (MemberInfo)<amountField>5__2) && <instrs>5__1[<i>5__3 - 1].opcode == OpCodes.Ldc_I4_1 && <instrs>5__1[<i>5__3].operand is Label) { <>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null); <>1__state = 2; return true; } goto IL_01ca; case 2: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(Item), "CheckItemIsUpgrade", (Type[])null, (Type[])null)); <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Brtrue, <instrs>5__1[<i>5__3].operand); <>1__state = 4; return true; case 4: { <>1__state = -1; goto IL_01ca; } IL_01ca: num = <i>5__3 + 1; <i>5__3 = num; break; } if (<i>5__3 < <instrs>5__1.Count) { <>2__current = <instrs>5__1[<i>5__3]; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] [return: <859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator() { <Transpile_InventoryGui>d__85 <Transpile_InventoryGui>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <Transpile_InventoryGui>d__ = this; } else { <Transpile_InventoryGui>d__ = new <Transpile_InventoryGui>d__85(0); } <Transpile_InventoryGui>d__.instructions = <>3__instructions; return <Transpile_InventoryGui>d__; } [DebuggerHidden] [return: <859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(0)] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<CodeInstruction>)this).GetEnumerator(); } } private static readonly List<Item> registeredItems = new List<Item>(); private static readonly Dictionary<ItemDrop, Item> itemDropMap = new Dictionary<ItemDrop, Item>(); private static Dictionary<Item, Dictionary<string, List<Recipe>>> activeRecipes = new Dictionary<Item, Dictionary<string, List<Recipe>>>(); [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(new byte[] { 1, 1, 2 })] private static Dictionary<Recipe, ConfigEntryBase> hiddenCraftRecipes = new Dictionary<Recipe, ConfigEntryBase>(); [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(new byte[] { 1, 1, 2 })] private static Dictionary<Recipe, ConfigEntryBase> hiddenUpgradeRecipes = new Dictionary<Recipe, ConfigEntryBase>(); private static Dictionary<Item, Dictionary<string, ItemConfig>> itemCraftConfigs = new Dictionary<Item, Dictionary<string, ItemConfig>>(); private static Dictionary<Item, ConfigEntry<string>> itemDropConfigs = new Dictionary<Item, ConfigEntry<string>>(); private Dictionary<CharacterDrop, Drop> characterDrops = new Dictionary<CharacterDrop, Drop>(); private readonly Dictionary<ConfigEntryBase, Action> statsConfigs = new Dictionary<ConfigEntryBase, Action>(); private static readonly ConditionalWeakTable<Requirement, RequirementQuality> requirementQuality = new ConditionalWeakTable<Requirement, RequirementQuality>(); public static Configurability DefaultConfigurability = Configurability.Full; public Configurability? Configurable = null; private Configurability configurationVisible = Configurability.Full; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private TraderConfig traderConfig; public readonly GameObject Prefab; [Description("Specifies the maximum required crafting station level to upgrade and repair the item.\nDefault is calculated from crafting station level and maximum quality.")] public int MaximumRequiredStationLevel = int.MaxValue; [Description("Assigns the item as a drop item to a creature.\nUses a creature name, a drop chance and a minimum and maximum amount.")] public readonly DropTargets DropsFrom = new DropTargets(); [Description("Configures whether the item can be bought at the trader.\nDon't forget to set cost to something above 0 or the item will be sold for free.")] public readonly Trade Trade = new Trade(); internal List<Conversion> Conversions = new List<Conversion>(); internal List<ItemConversion> conversions = new List<ItemConversion>(); public Dictionary<string, ItemRecipe> Recipes = new Dictionary<string, ItemRecipe>(); [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private LocalizeKey _name; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private LocalizeKey _description; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private static object configManager; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private static Localization _english; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private static BaseUnityPlugin _plugin; private static bool hasConfigSync = true; [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private static object _configSync; private Configurability configurability => Configurable ?? DefaultConfigurability; [Description("Specifies the resources needed to craft the item.\nUse .Add to add resources with their internal ID and an amount.\nUse one .Add for each resource type the item should need.")] public RequiredResourceList RequiredItems => this[""].RequiredItems; [Description("Specifies the resources needed to upgrade the item.\nUse .Add to add resources with their internal ID and an amount. This amount will be multipled by the item quality level.\nUse one .Add for each resource type the upgrade should need.")] public RequiredResourceList RequiredUpgradeItems => this[""].RequiredUpgradeItems; [Description("Specifies the crafting station needed to craft the item.\nUse .Add to add a crafting station, using the CraftingTable enum and a minimum level for the crafting station.\nUse one .Add for each crafting station.")] public CraftingStationList Crafting => this[""].Crafting; [Description("Specifies a config entry which toggles whether a recipe is active.")] [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] public ConfigEntryBase RecipeIsActive { [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(2)] get { return this[""].RecipeIsActive; } [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(2)] set { this[""].RecipeIsActive = value; } } [Description("Specifies the number of items that should be given to the player with a single craft of the item.\nDefaults to 1.")] public int CraftAmount { get { return this[""].CraftAmount; } set { this[""].CraftAmount = value; } } public bool RequireOnlyOneIngredient { get { return this[""].RequireOnlyOneIngredient; } set { this[""].RequireOnlyOneIngredient = value; } } public float QualityResultAmountMultiplier { get { return this[""].QualityResultAmountMultiplier; } set { this[""].QualityResultAmountMultiplier = value; } } public ItemRecipe this[string name] { get { if (Recipes.TryGetValue(name, out var value)) { return value; } return Recipes[name] = new ItemRecipe(); } } public LocalizeKey Name { get { LocalizeKey name = _name; if (name != null) { return name; } SharedData shared = Prefab.GetComponent<ItemDrop>().m_itemData.m_shared; if (shared.m_name.StartsWith("$")) { _name = new LocalizeKey(shared.m_name); } else { string text = "$item_" + ((Object)Prefab).name.Replace(" ", "_"); _name = new LocalizeKey(text).English(shared.m_name); shared.m_name = text; } return _name; } } public LocalizeKey Description { get { LocalizeKey description = _description; if (description != null) { return description; } SharedData shared = Prefab.GetComponent<ItemDrop>().m_itemData.m_shared; if (shared.m_description.StartsWith("$")) { _description = new LocalizeKey(shared.m_description); } else { string text = "$itemdesc_" + ((Object)Prefab).name.Replace(" ", "_"); _description = new LocalizeKey(text).English(shared.m_description); shared.m_description = text; } return _description; } } private static Localization english => _english ?? (_english = LocalizationCache.ForLanguage("English")); private static BaseUnityPlugin plugin { get { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown if (_plugin == null) { IEnumerable<TypeInfo> source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } [<859ce5cc-1bd0-4b9c-b73f-4fbcd2c0ea82>Nullable(2)] private static object configSync { [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(2)] get { if (_configSync == null && hasConfigSync) { Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync"); if ((object)type != null) { _configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " ItemManager"); type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString()); type.GetProperty("IsLocked").SetValue(_configSync, true); } else { hasConfigSync = false; } } return _configSync; } } public Item(string assetBundleFileName, string prefabName, string folderName = "assets") : this(PrefabManager.RegisterAssetBundle(assetBundleFileName, folderName), prefabName) { } public Item(AssetBundle bundle, string prefabName) : this(PrefabManager.RegisterPrefab(bundle, prefabName, addToObjectDb: true), skipRegistering: true) { } public Item(GameObject prefab, bool skipRegistering = false) { if (!skipRegistering) { PrefabManager.RegisterPrefab(prefab, addToObjectDb: true); } Prefab = prefab; registeredItems.Add(this); itemDropMap[Prefab.GetComponent<ItemDrop>()] = this; Prefab.GetComponent<ItemDrop>().m_itemData.m_dropPrefab = Prefab; } public void ToggleConfigurationVisibility(Configurability visible) { configurationVisible = visible; if (itemDropConfigs.TryGetValue(this, out var value)) { Toggle((ConfigEntryBase)(object)value, Configurability.Drop); } if (itemCraftConfigs.TryGetValue(this, out var value2)) { foreach (ItemConfig value4 in value2.Values) { ToggleObj(value4, Configurability.Recipe); } } foreach (Conversion conversion in Conversions) { if (conversion.config != null) { ToggleObj(conversion.config, Configurability.Recipe); } } foreach (KeyValuePair<ConfigEntryBase, Action> statsConfig in statsConfigs) { Toggle(statsConfig.Key, Configurability.Stats); if ((visible & Configurability.Stats) != 0) { statsConfig.Value(); } } reloadConfigDisplay(); void Toggle(ConfigEntryBase cfg, Configurability check) { object[] tags = cfg.Description.Tags; foreach (object obj2 in tags) { if (obj2 is ConfigurationManagerAttributes configurationManagerAttributes) { configurationManagerAttributes.Browsable = (visible & check) != 0 && (configurationManagerAttributes.browsability == null || configurationManagerAttributes.browsability()); } } } void ToggleObj(object obj, Configurability check) { FieldInfo[] fields = obj.GetType().GetFields(); foreach (FieldInfo fieldInfo in fields) { object? value3 = fieldInfo.GetValue(obj); ConfigEntryBase val = (ConfigEntryBase)((value3 is ConfigEntryBase) ? value3 : null); if (val != null) { Toggle(val, check); } } } } internal static void reloadConfigDisplay() { object obj = configManager?.GetType().GetProperty("DisplayingWindow").GetValue(configManager); if (obj is bool && (bool)obj) { configManager.GetType().GetMethod("BuildSettingList").Invoke(configManager, Array.Empty<object>()); } } private void UpdateItemTableConfig(string recipeKey, CraftingTable table, string customTableValue) { if (activeRecipes.ContainsKey(this) && activeRecipes[this].TryGetValue(recipeKey, out var value)) { value.First().m_enabled = table != CraftingTable.Disabled; if ((uint)table <= 1u) { value.First().m_craftingStation = null; } else if (table == CraftingTable.Custom) { Recipe obj = value.First(); GameObject prefab = ZNetScene.instance.GetPrefab(customTableValue); obj.m_craftingStation = ((prefab != null) ? prefab.GetComponent<CraftingStation>() : null); } else { value.First().m_craftingStation = ZNetScene.instance.GetPrefab(getInternalName(table)).GetComponent<CraftingStation>(); } } } private void UpdateCraftConfig(string recipeKey, SerializedRequirements craftRequirements, SerializedRequirements upgradeRequirements) { if (!Object.op_Implicit((Object)(object)ObjectDB.instance) || !activeRecipes.ContainsKey(this) || !activeRecipes[this].TryGetValue(recipeKey, out var value)) { return; } foreach (Recipe item in value) { item.m_resources = SerializedRequirements.toPieceReqs(ObjectDB.instance, craftRequirements, upgradeRequirements); } } internal static void Patch_FejdStartup() { //IL_1001: Unknown result type (might be due to invalid IL or missing references) //IL_1006: Unknown result type (might be due to invalid IL or missing references) //IL_2395: Unknown result type (might be due to invalid IL or missing references) //IL_239f: Expected O, but got Unknown //IL_10ce: Unknown result type (might be due to invalid IL or missing references) //IL_10d1: Unknown result type (might be due to invalid IL or missing references) //IL_1127: Expected I4, but got Unknown //IL_0ccc: Unknown result type (might be due to invalid IL or missing references) //IL_0cd6: Expected O, but got Unknown //IL_1267: Unknown result type (might be due to invalid IL or missing references) //IL_126a: Unknown result type (might be due to invalid IL or missing references) //IL_126c: Invalid comparison between Unknown and I4 //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Expected O, but got Unknown //IL_0dfa: Unknown result type (might be due to invalid IL or missing references) //IL_0e04: Expected O, but got Unknown //IL_0ea6: Unknown result type (might be due to invalid IL or missing references) //IL_0eb0: Expected O, but got Unknown //IL_1270: Unknown result type (might be due to invalid IL or missing references) //IL_1274: Invalid comparison between Unknown and I4 //IL_0f5b: Unknown result type (might be due to invalid IL or missing references) //IL_0f65: Expected O, but got Unknown //IL_1489: Unknown result type (might be due to invalid IL or missing references) //IL_148c: Unknown result type (might be due to invalid IL or missing references) //IL_148e: Invalid comparison between Unknown and I4 //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Expected O, but got Unknown //IL_1278: Unknown result type (might be due to invalid IL or missing references) //IL_127c: Invalid comparison between Unknown and I4 //IL_1492: Unknown result type (might be due to invalid IL or missing references) //IL_1496: Unknown result type (might be due to invalid IL or missing references) //IL_1498: Invalid comparison between Unknown and I4 //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05b7: Expected O, but got Unknown //IL_1581: Unknown result type (might be due to invalid IL or missing references) //IL_1586: Unknown result type (might be due to invalid IL or missing references) //IL_1588: Unknown result type (might be due to invalid IL or missing references) //IL_158b: Invalid comparison between Unknown and I4 //IL_149c: Unknown result type (might be due to invalid IL or missing references) //IL_14a0: Invalid comparison between Unknown and I4 //IL_158f: Unknown result type (might be due to invalid IL or missing references) //IL_1593: Invalid comparison between Unknown and I4 //IL_0796: Unknown result type (might be due to invalid IL or missing references) //IL_07a0: Expected O, but got Unknown //IL_06eb: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Expected O, but got Unknown //IL_160c: Unknown result type (might be due to invalid IL or missing references) //IL_160f: Unknown result type (might be due to invalid IL or missing references) //IL_1611: Invalid comparison between Unknown and I4 //IL_08b0: Unknown result type (might be due to invalid IL or missing references) //IL_08ba: Expected O, but got Unknown //IL_1615: Unknown result type (might be due to invalid IL or missing references) //IL_1619: Unknown result type (might be due to invalid IL or missing references) //IL_161b: Invalid comparison between Unknown and I4 //IL_176e: Unknown result type (might be due to invalid IL or missing references) //IL_1771: Invalid comparison between Unknown and I4 //IL_161f: Unknown result type (might be due to invalid IL or missing references) //IL_1623: Invalid comparison between Unknown and I4 //IL_1980: Unknown result type (might be due to invalid IL or missing references) //IL_1987: Invalid comparison between Unknown and I4 //IL_1a5c: Unknown result type (might be due to invalid IL or missing references) //IL_1a61: Unknown result type (might be due to invalid IL or missing references) //IL_1a63: Unknown result type (might be due to invalid IL or missing references) //IL_1a67: Unknown result type (might be due to invalid IL or missing references) //IL_1a69: Invalid comparison between Unknown and I4 //IL_16de: Unknown result type (might be due to invalid IL or missing references) //IL_16e3: Unknown result type (might be due to invalid IL or missing references) //IL_1ae2: Unknown result type (might be due to invalid IL or missing references) //IL_1ae5: Unknown result type (might be due to invalid IL or missing references) //IL_1ae7: Invalid comparison between Unknown and I4 //IL_1aeb: Unknown result type (might be due to invalid IL or missing references) //IL_1aef: Invalid comparison between Unknown and I4 //IL_1af3: Unknown result type (might be due to invalid IL or missing references) //IL_1af7: Invalid comparison between Unknown and I4 //IL_1f88: Unknown result type (might be due to invalid IL or missing references) //IL_1f8b: Invalid comparison between Unknown and I4 Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager"); if (DefaultConfigurability != 0) { bool saveOnConfigSet = plugin.Config.SaveOnConfigSet; plugin.Config.SaveOnConfigSet = false; foreach (Item item4 in registeredItems.Where([<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (Item i) => i.configurability != Configurability.Disabled)) { Item item3 = item4; string name2 = item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name; string englishName = new Regex("[=\\n\\t\\\\\"\\'\\[\\]]*").Replace(english.Localize(name2), "").Trim(); string localizedName = Localization.instance.Localize(name2).Trim(); int order = 0; if ((item3.configurability & Configurability.Recipe) != 0) { itemCraftConfigs[item3] = new Dictionary<string, ItemConfig>(); foreach (string item5 in item3.Recipes.Keys.DefaultIfEmpty("")) { string configKey = item5; string text = ((configKey == "") ? "" : (" (" + configKey + ")")); if (!item3.Recipes.ContainsKey(configKey) || item3.Recipes[configKey].Crafting.Stations.Count <= 0) { continue; } ItemConfig itemConfig2 = (itemCraftConfigs[item3][configKey] = new ItemConfig()); ItemConfig cfg = itemConfig2; List<ConfigurationManagerAttributes> hideWhenNoneAttributes = new List<ConfigurationManagerAttributes>(); cfg.table = config(englishName, "Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().Table, new ConfigDescription("Crafting station where " + englishName + " is available.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName } })); ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = CustomTableBrowsability, Browsable = (CustomTableBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; cfg.customTable = config(englishName, "Custom Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes })); cfg.table.SettingChanged += TableConfigChanged; cfg.customTable.SettingChanged += TableConfigChanged; ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = TableLevelBrowsability, Browsable = (TableLevelBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; hideWhenNoneAttributes.Add(configurationManagerAttributes); cfg.tableLevel = config(englishName, "Crafting Station Level" + text, item3.Recipes[configKey].Crafting.Stations.First().level, new ConfigDescription("Required crafting station level to craft " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); cfg.tableLevel.SettingChanged += [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (object _, EventArgs _) => { if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value6)) { value6.First().m_minStationLevel = cfg.tableLevel.Value; } }; if (item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1) { cfg.maximumTableLevel = config(englishName, "Maximum Crafting Station Level" + text, (item3.MaximumRequiredStationLevel == int.MaxValue) ? (item3.Recipes[configKey].Crafting.Stations.First().level + item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality - 1) : item3.MaximumRequiredStationLevel, new ConfigDescription("Maximum crafting station level to upgrade and repair " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); } cfg.requireOneIngredient = config(englishName, "Require only one resource" + text, item3.Recipes[configKey].RequireOnlyOneIngredient ? Toggle.On : Toggle.Off, new ConfigDescription("Whether only one of the ingredients is needed to craft " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Category = localizedName } })); ConfigurationManagerAttributes qualityResultAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = QualityResultBrowsability, Browsable = (QualityResultBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; cfg.requireOneIngredient.SettingChanged += [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (object _, EventArgs _) => { if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value5)) { foreach (Recipe item6 in value5) { item6.m_requireOnlyOneIngredient = cfg.requireOneIngredient.Value == Toggle.On; } } qualityResultAttributes.Browsable = QualityResultBrowsability(); reloadConfigDisplay(); }; cfg.qualityResultAmountMultiplier = config(englishName, "Quality Multiplier" + text, item3.Recipes[configKey].QualityResultAmountMultiplier, new ConfigDescription("Multiplies the crafted amount based on the quality of the resources when crafting " + englishName + ". Only works, if Require Only One Resource is true.", (AcceptableValueBase)null, new object[1] { qualityResultAttributes })); cfg.qualityResultAmountMultiplier.SettingChanged += [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (object _, EventArgs _) => { if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value4)) { foreach (Recipe item7 in value4) { item7.m_qualityResultAmountMultiplier = cfg.qualityResultAmountMultiplier.Value; } } }; if ((!item3.Recipes[configKey].RequiredItems.Free || item3.Recipes[configKey].RequiredItems.Requirements.Count > 0) && item3.Recipes[configKey].RequiredItems.Requirements.All((Requirement r) => r.amountConfig == null)) { cfg.craft = itemConfig("Crafting Costs" + text, new SerializedRequirements(item3.Recipes[configKey].RequiredItems.Requirements).ToString(), "Item costs to craft " + englishName, isUpgrade: false); } if (item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1 && (!item3.Recipes[configKey].RequiredUpgradeItems.Free || item3.Recipes[configKey].RequiredUpgradeItems.Requirements.Count > 0) && item3.Recipes[configKey].RequiredUpgradeItems.Requirements.All((Requirement r) => r.amountConfig == null)) { cfg.upgrade = itemConfig("Upgrading Costs" + text, new SerializedRequirements(item3.Recipes[configKey].RequiredUpgradeItems.Requirements).ToString(), "Item costs per level to upgrade " + englishName, isUpgrade: true); } if (cfg.craft != null) { cfg.craft.SettingChanged += ConfigChanged; } if (cfg.upgrade != null) { cfg.upgrade.SettingChanged += ConfigChanged; } void ConfigChanged(object o, EventArgs e) { item3.UpdateCraftConfig(configKey, new SerializedRequirements(cfg.craft?.Value ?? ""), new SerializedRequirements(cfg.upgrade?.Value ?? "")); } bool CustomTableBrowsability() { return cfg.table.Value == CraftingTable.Custom; } bool ItemBrowsability() { return cfg.table.Value != CraftingTable.Disabled; } bool QualityResultBrowsability() { return cfg.requireOneIngredient.Value == Toggle.On; } void TableConfigChanged(object o, EventArgs e) { item3.UpdateItemTableConfig(configKey, cfg.table.Value, cfg.customTable.Value); customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom; foreach (ConfigurationManagerAttributes item8 in hideWhenNoneAttributes) { item8.Browsable = cfg.table.Value != CraftingTable.Disabled; } reloadConfigDisplay(); } bool TableLevelBrowsability() { return cfg.table.Value != CraftingTable.Disabled; } ConfigEntry<string> itemConfig(string name, string value, string desc, bool isUpgrade) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes3 = new ConfigurationManagerAttributes { CustomDrawer = drawRequirementsConfigTable(item3, isUpgrade), Order = (order -= 1), browsability = ItemBrowsability, Browsable = (ItemBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; hideWhenNoneAttributes.Add(configurationManagerAttributes3); return config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes3 })); } } if ((item3.configurability & Configurability.Drop) != 0) { ConfigEntry<string> val3 = (itemDropConfigs[item3] = config(englishName, "Drops from", new SerializedDrop(item3.DropsFrom.Drops).ToString(), new ConfigDescription(englishName + " drops from this creature.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = drawDropsConfigTable, Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Drop) != 0) } }))); ConfigEntry<string> val4 = val3; val4.SettingChanged += [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (object _, EventArgs _) => { item3.UpdateCharacterDrop(); }; } for (int j = 0; j < item3.Conversions.Count; j++) { string text2 = ((item3.Conversions.Count > 1) ? $"{j + 1}. " : ""); Conversion conversion = item3.Conversions[j]; conversion.config = new Conversion.ConversionConfig(); int index = j; conversion.config.input = config(englishName, text2 + "Conversion Input Item", conversion.Input, new ConfigDescription("Input item to create " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0) } })); conversion.config.input.SettingChanged += [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (object _, EventArgs _) => { if (index < item3.conversions.Count) { ObjectDB instance = ObjectDB.instance; if (instance != null) { ItemDrop from = SerializedRequirements.fetchByName(instance, conversion.config.input.Value); item3.conversions[index].m_from = from; UpdatePiece(); } } }; conversion.config.piece = config(englishName, text2 + "Conversion Piece", conversion.Piece, new ConfigDescription("Conversion piece used to create " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0) } })); conversion.config.piece.SettingChanged += [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (object _, EventArgs _) => { UpdatePiece(); }; conversion.config.customPiece = config(englishName, text2 + "Conversion Custom Piece", conversion.customPiece ?? "", new ConfigDescription("Custom conversion piece to create " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0) } })); conversion.config.customPiece.SettingChanged += [<b699a420-994c-477c-a892-4bcb3f2fa4d6>NullableContext(0)] (object _, EventArgs _) => { UpdatePiece(); }; void UpdatePiece() { if (index < item3.conversions.Count && Object.op_Implicit((Object)(object)ZNetScene.instance)) { string text3 = ((conversion.config.piece.Value == ConversionPiece.Disabled) ? null : ((conversion.config.piece.Value == ConversionPiece.Custom) ? conversion.config.customPiece.Value : getInternalName(conversion.config.piece.Value))); string activePiece = conversion.config.activePiece; if (conversion.config.activePiece != null) { Smelter component = ZNetScene.instance.GetPrefab(conversion.config.activePiece).GetComponent<Smelter>(); int num = component.m_conversion.IndexOf(item3.conversions[index]); if (num >= 0) { Smelter[] array3 = Resources.FindObjectsOfTypeAll<Smelter>(); foreach (Smelter val6 in array3) { if (Utils.GetPrefabName(((Component)val6).gameObject) == activePiece) { val6.m_conversion.RemoveAt(num); } } } conversion.config.activePiece = null; } if (item3.conversions[index].m_from != null && conversion.config.piece.Value != 0) { GameObject prefab = ZNetScene.instance.GetPrefab(text3); if (((prefab != null) ? prefab.GetComponent<Smelter>() : null) != null) { conversion.config.activePiece = text3; Smelter[] array4 = Resources.FindObjectsOfTypeAll<Smelter>(); foreach (Smelter val7 in array4) { if (Utils.GetPrefabName(((Component)val7).gameObject) == text3) { val7.m_conversion.Add(item3.conversions[index]); } } } } } } } } if ((item3.configurability & Configurability.Stats) != 0) { item3.statsConfigs.Clear(); SharedData shared2 = item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared; ItemType itemType = shared2.m_itemType; statcfg<float>("Weight", "Weight of " + englishName + ".", (SharedData shared) => shared.m_weight, delegate(SharedData shared, float value) { shared.m_weight = value; }); statcfg<int>("Trader Value", "Trader value of " + englishName + ".", (SharedData shared) => shared.m_value, delegate(SharedData shared, int value) { shared.m_value = value; }); bool flag; switch (itemType - 3) { case 0: case 1: case 2: case 3: case 4: case 8: case 9: case 11: case 14: case 16: case 19: flag = true; break; default: flag = false; break; } if (flag) { statcfg<float>("Durability", "Durability of " + englishName + ".", (SharedData shared) => shared.m_maxDurability, delegate(SharedData shared, float value) { shared.m_maxDurability = value; }); statcfg<float>("Durability per Level", "Durability gain per level of " + englishName + ".", (SharedData shared) => shared.m_durabilityPerLevel, delegate(SharedData shared, float value) { shared.m_durabilityPerLevel = value; }); statcfg<float>("Movement Speed Modifier", "Movement speed modifier of " + englishName + ".", (SharedData shared) => shared.m_movementModifier, delegate(SharedData shared, float value) { shared.m_movementModifier = value; }); } if ((itemType - 3 <= 2 || (int)itemType == 14 || (int)itemType == 22) ? true : false) { statcfg<float>("Block Armor", "Block armor of " + englishName + ".", (SharedData shared) => shared.m_blockPower, delegate(SharedData shared, float value) { shared.m_blockPower = value; }); statcfg<float>("Block Armor per Level", "Block armor per level for " + englishName + ".", (SharedData shared) => shared.m_blockPowerPerLevel, delegate(SharedData shared, float value) { shared.m_blockPowerPerLevel = value; }); statcfg<float>("Block Force", "Block force of " + englishName + ".", (SharedData shared) => shared.m_deflectionForce, delegate(SharedData shared, float value) { shared.m_deflectionForce = value; }); statcfg<float>("Block Force per Level", "Block force per level for " + englishName + ".", (SharedData shared) => shared.m_deflectionForcePerLevel, delegate(SharedData shared, float value) { shared.m_deflectionForcePerLevel = value; }); statcfg<float>("Parry Bonus", "Parry bonus of " + englishName + ".", (SharedData shared) => shared.m_timedBlockBonus, delegate(SharedData shared, float value) {