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 HealingPotions v1.0.4
HealingBottles.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Valheim HealingBottles Mod")] [assembly: AssemblyDescription("Addsfour different healing potions to the game")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("HearthStone")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("E7550497-2C76-44FE-A5B9-9E85080E8BB0")] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.4.0")] [module: UnverifiableCode] namespace Hearthstone; [BepInPlugin("mennowar.mods.HealingBottles", "HealingBottles", "1.0.4")] [BepInDependency("com.jotunn.jotunn", "2.23.2")] public class HealingBottles : BaseUnityPlugin { [HarmonyPatch(typeof(ItemStand), "CanAttach")] public static class AttachPatch { [HarmonyPostfix] private static void Postfix(ItemStand __instance, ItemData item, ref bool __result) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (!__result) { __result = __instance.m_supportedTypes.Contains(item.m_shared.m_itemType) && IsBottle(item); } } } [HarmonyPatch(typeof(Player), "ConsumeItem")] public static class ConsumePatch { private static bool Prefix(ItemData item) { if (item != null && item.m_shared != null && (Object)(object)item.m_dropPrefab != (Object)null && (Object)(object)item.m_dropPrefab.gameObject != (Object)null && bottleNames.Contains(((Object)item.m_dropPrefab.gameObject).name)) { string name = ((Object)item.m_dropPrefab.gameObject).name; if (name.ToUpper().StartsWith("HEAL")) { if (name.EndsWith("00")) { return FillHealth(25f); } if (name.EndsWith("01")) { return FillHealth(50f); } if (name.EndsWith("02")) { return FillHealth(75f); } if (name.EndsWith("03")) { return FillHealth(100f); } } else if (name.ToUpper().StartsWith("STAM")) { if (name.EndsWith("00")) { return FillStamina(25f); } if (name.EndsWith("01")) { return FillStamina(50f); } if (name.EndsWith("02")) { return FillStamina(75f); } if (name.EndsWith("03")) { return FillStamina(100f); } } else if (name.ToUpper().StartsWith("MANA")) { if (name.EndsWith("00")) { return FillMana(25f); } if (name.EndsWith("01")) { return FillMana(50f); } if (name.EndsWith("02")) { return FillMana(75f); } if (name.EndsWith("03")) { return FillMana(100f); } } if (Debugger.IsAttached) { Debugger.Break(); } } return true; } } public const string PluginGUID = "mennowar.mods.HealingBottles"; private Harmony harmony = new Harmony("mennowar.mods.HealingBottles"); private static List<string> bottleNames = new List<string>(); private static DateTime lastHealDateTime = DateTime.MinValue; private static DateTime lastStaminaDateTime = DateTime.MinValue; private static DateTime lastEitrDateTime = DateTime.MinValue; private AssetBundle assetBundle; private const string healingBottleAssetNameBase = "HealingBottle"; private string healingBottleAssetName0 = "Assets/_Custom/HealingBottle00.prefab"; private string healingBottleAssetName1 = "Assets/_Custom/HealingBottle01.prefab"; private string healingBottleAssetName2 = "Assets/_Custom/HealingBottle02.prefab"; private string healingBottleAssetName3 = "Assets/_Custom/HealingBottle03.prefab"; private const string staminaBottleAssetNameBase = "StaminaBottle"; private string staminaBottleAssetName0 = "Assets/_Custom/StaminaBottle00.prefab"; private string staminaBottleAssetName1 = "Assets/_Custom/StaminaBottle01.prefab"; private string staminaBottleAssetName2 = "Assets/_Custom/StaminaBottle02.prefab"; private string staminaBottleAssetName3 = "Assets/_Custom/StaminaBottle03.prefab"; private const string manaBottleAssetNameBase = "ManaBottle"; private string manaBottleAssetName0 = "Assets/_Custom/ManaBottle00.prefab"; private string manaBottleAssetName1 = "Assets/_Custom/ManaBottle01.prefab"; private string manaBottleAssetName2 = "Assets/_Custom/ManaBottle02.prefab"; private string manaBottleAssetName3 = "Assets/_Custom/ManaBottle03.prefab"; private ConfigEntry<string> craftingStationItemName; private ConfigEntry<string> baseItemName; private ConfigEntry<int> baseItemAmount; private ConfigEntry<string> smallPotionQualityItemName; private ConfigEntry<int> smallPotionQualityItemAmount; private ConfigEntry<int> smallPotionCraftingStationLevel; private ConfigEntry<string> mediumPotionQualityItemName; private ConfigEntry<int> mediumPotionQualityItemAmount; private ConfigEntry<int> mediumPotionCraftingStationLevel; private ConfigEntry<string> hugePotionQualityItemName; private ConfigEntry<int> hugePotionQualityItemAmount; private ConfigEntry<int> hugePotionCraftingStationLevel; private ConfigEntry<string> godlyPotionQualityItemName; private ConfigEntry<int> godlyPotionQualityItemAmount; private ConfigEntry<int> godlyPotionCraftingStationLevel; private ConfigEntry<string> healingPotionTypeItemName; private ConfigEntry<int> healingPotionTypeItemAmount; private static ConfigEntry<int> healingPotionTimeOut; private ConfigEntry<string> staminaPotionTypeItemName; private ConfigEntry<int> staminaPotionTypeItemAmount; private static ConfigEntry<int> staminaPotionTimeOut; private ConfigEntry<string> manaPotionTypeItemName; private ConfigEntry<int> manaPotionTypeItemAmount; private static ConfigEntry<int> manaPotionTimeOut; private ConfigEntry<bool> healingPotionsEnabled; private ConfigEntry<bool> staminaPotionsEnabled; private ConfigEntry<bool> manaPotionsEnabled; private static string drinkNotPossibleMessage = "You can't drink this potion right now"; private void Awake() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Expected O, but got Unknown //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Expected O, but got Unknown //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Expected O, but got Unknown //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Expected O, but got Unknown //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Expected O, but got Unknown //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Expected O, but got Unknown //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Expected O, but got Unknown //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Expected O, but got Unknown //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Expected O, but got Unknown //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Expected O, but got Unknown //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Expected O, but got Unknown //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Expected O, but got Unknown //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Expected O, but got Unknown //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Expected O, but got Unknown //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Expected O, but got Unknown //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Expected O, but got Unknown //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Expected O, but got Unknown //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Expected O, but got Unknown //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Expected O, but got Unknown //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Expected O, but got Unknown //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Expected O, but got Unknown //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Expected O, but got Unknown //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Expected O, but got Unknown //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Expected O, but got Unknown //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Expected O, but got Unknown //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_0509: Expected O, but got Unknown //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_0513: Expected O, but got Unknown //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Expected O, but got Unknown //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Expected O, but got Unknown //IL_0578: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Expected O, but got Unknown //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Expected O, but got Unknown //IL_05b8: Unknown result type (might be due to invalid IL or missing references) //IL_05bd: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Expected O, but got Unknown //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Expected O, but got Unknown //IL_05f4: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Expected O, but got Unknown //IL_0601: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Expected O, but got Unknown //IL_0634: Unknown result type (might be due to invalid IL or missing references) //IL_0639: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Expected O, but got Unknown //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_064b: Expected O, but got Unknown //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_067d: Expected O, but got Unknown //IL_067d: Unknown result type (might be due to invalid IL or missing references) //IL_0687: Expected O, but got Unknown harmony.PatchAll(); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; craftingStationItemName = ((BaseUnityPlugin)this).Config.Bind<string>("General", "CraftingStationID", "piece_cauldron", new ConfigDescription("The id of the crafting station.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); healingPotionsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HealingPotionsEnabled", true, new ConfigDescription("Indicates whether healing potions are craftable.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); staminaPotionsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "StaminaPotionsEnabled", true, new ConfigDescription("Indicates whether stamina potions are craftable.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); manaPotionsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ManaPotionsEnabled", true, new ConfigDescription("Indicates whether Eitr/Mana potions are craftable.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); baseItemName = ((BaseUnityPlugin)this).Config.Bind<string>("Base", "BaseItemName", "Dandelion", new ConfigDescription("Base Item, required for all Potions.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); baseItemAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Base", "BaseItemAmount", 5, new ConfigDescription("Amount of Base Item required.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); healingPotionTimeOut = ((BaseUnityPlugin)this).Config.Bind<int>("Base", "HealingPotionTimeout", 3, new ConfigDescription("Wait time in seconds before the next healing potion may be consumed.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); staminaPotionTimeOut = ((BaseUnityPlugin)this).Config.Bind<int>("Base", "StaminaPotionTimeout", 3, new ConfigDescription("Wait time in seconds before the next stamina potion may be consumed.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); manaPotionTimeOut = ((BaseUnityPlugin)this).Config.Bind<int>("Base", "EitrPotionTimeout", 3, new ConfigDescription("Wait time in seconds before the next MANA/EITR potion may be consumed.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); smallPotionCraftingStationLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Quality", "SmallPotionCraftingStationLevel", 0, new ConfigDescription("The Crafting-Station Level needed to craft small potions.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); mediumPotionCraftingStationLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Quality", "MediumPotionCraftingStationLevel", 1, new ConfigDescription("The Crafting-Station Level needed to craft medium potions.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); hugePotionCraftingStationLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Quality", "HugePotionCraftingStationLevel", 2, new ConfigDescription("The Crafting-Station Level needed to craft Huge potions.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); godlyPotionCraftingStationLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Quality", "GodlyPotionCraftingStationLevel", 3, new ConfigDescription("The Crafting-Station Level needed to craft Godly potions.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); smallPotionQualityItemName = ((BaseUnityPlugin)this).Config.Bind<string>("Quality", "SmallPotionQualityItemName", "Mushroom", new ConfigDescription("Name of the Item for identifying a potion as small quality.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); smallPotionQualityItemAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Quality", "SmallPotionQualityItemAmount", 5, new ConfigDescription("Amount of small quality item required.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); mediumPotionQualityItemName = ((BaseUnityPlugin)this).Config.Bind<string>("Quality", "MediumPotionQualityItemName", "Thistle", new ConfigDescription("Name of the Item for identifying a potion as medium quality.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); mediumPotionQualityItemAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Quality", "MediumPotionQualityItemAmount", 5, new ConfigDescription("Amount of medium quality item required.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); hugePotionQualityItemName = ((BaseUnityPlugin)this).Config.Bind<string>("Quality", "HugePotionQualityItemName", "Obsidian", new ConfigDescription("Name of the Item for identifying a potion as huge quality.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); hugePotionQualityItemAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Quality", "HugePotionQualityItemAmount", 5, new ConfigDescription("Amount of huge quality item required.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); godlyPotionQualityItemName = ((BaseUnityPlugin)this).Config.Bind<string>("Quality", "GodlyPotionQualityItemName", "Flax", new ConfigDescription("Name of the Item for identifying a potion as godly quality.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); godlyPotionQualityItemAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Quality", "GodlyPotionQualityItemAmount", 5, new ConfigDescription("Amount of godly quality item required.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); healingPotionTypeItemName = ((BaseUnityPlugin)this).Config.Bind<string>("Type", "HealthTypeItemName", "Raspberry", new ConfigDescription("Name of the Item for identifying a potion as HEALING type.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); healingPotionTypeItemAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Type", "HealthTypeItemAmount", 5, new ConfigDescription("Amount of Item for identifying a potion as HEALING type.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); staminaPotionTypeItemName = ((BaseUnityPlugin)this).Config.Bind<string>("Type", "StaminaTypeItemName", "Blueberries", new ConfigDescription("Name of the Item for identifying a potion as STAMINA type.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); staminaPotionTypeItemAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Type", "StaminaTypeItemAmount", 5, new ConfigDescription("Amount of Item for identifying a potion as STAMINA type.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); manaPotionTypeItemName = ((BaseUnityPlugin)this).Config.Bind<string>("Type", "ManaTypeItemName", "MushroomYellow", new ConfigDescription("Name of the Item for identifying a potion as MANA/EITR type.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); manaPotionTypeItemAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Type", "ManaTypeItemAmount", 5, new ConfigDescription("Amount of Item for identifying a potion as MANA/EITR type.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); PrefabManager.OnVanillaPrefabsAvailable += VanillaPrefabsAvailable; ((BaseUnityPlugin)this).Config.SettingChanged += delegate { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Config changed, reloading recipes"); ConfigChangeRecipeUpdate("HealingBottle", healingPotionTypeItemName, healingPotionTypeItemAmount); ConfigChangeRecipeUpdate("StaminaBottle", staminaPotionTypeItemName, staminaPotionTypeItemAmount); ConfigChangeRecipeUpdate("ManaBottle", manaPotionTypeItemName, manaPotionTypeItemAmount); }; } private void ConfigChangeRecipeUpdate(string bottleAssetName, ConfigEntry<string> typeItemName, ConfigEntry<int> typeItemAmount) { string text = ExtractBottleName(bottleAssetName).Split(new char[1] { '0' })[0]; UpdateExistingRecipe(text + "00", smallPotionQualityItemName, smallPotionQualityItemAmount, typeItemName, typeItemAmount, smallPotionCraftingStationLevel); UpdateExistingRecipe(text + "01", mediumPotionQualityItemName, mediumPotionQualityItemAmount, typeItemName, typeItemAmount, mediumPotionCraftingStationLevel); UpdateExistingRecipe(text + "02", hugePotionQualityItemName, hugePotionQualityItemAmount, typeItemName, typeItemAmount, hugePotionCraftingStationLevel); UpdateExistingRecipe(text + "03", godlyPotionQualityItemName, godlyPotionQualityItemAmount, typeItemName, typeItemAmount, godlyPotionCraftingStationLevel); } private void UpdateExistingRecipe(string bottleName, ConfigEntry<string> qualityItemName, ConfigEntry<int> qualityItemAmount, ConfigEntry<string> typeItemName, ConfigEntry<int> typeItemAmount, ConfigEntry<int> stationLevel) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown CustomItem item2 = ItemManager.Instance.GetItem(bottleName); List<Requirement> rqs; if (item2 != null && ObjectDB.instance.m_items.Any()) { if (item2.Recipe == null) { Recipe obj = ScriptableObject.CreateInstance<Recipe>(); ((Object)obj).name = "Recipe_" + bottleName; obj.m_item = item2.ItemDrop; CustomRecipe val2 = (item2.Recipe = new CustomRecipe(obj, true, true) { FixRequirementReferences = true }); val2.Recipe.m_minStationLevel = stationLevel.Value; } rqs = new List<Requirement>(); AddRq(baseItemName, baseItemAmount); AddRq(qualityItemName, qualityItemAmount); AddRq(typeItemName, typeItemAmount); if (((item2 != null) ? item2.Recipe : null) != null && (Object)(object)item2.Recipe.Recipe != (Object)null) { item2.Recipe.Recipe.m_resources = rqs.ToArray(); item2.Recipe.Recipe.m_minStationLevel = stationLevel.Value; } } void AddRq(ConfigEntry<string> item, ConfigEntry<int> amount) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown try { if (item != null && !string.IsNullOrEmpty(item.Value) && amount.Value > 0) { ItemDrop component = ObjectDB.instance.GetItemPrefab(item.Value).GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { rqs.Add(new Requirement { m_amount = amount.Value, m_resItem = component }); } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)ex.Message); } } } private string ExtractBottleName(string assetName) { return assetName.Replace(".prefab", "").Split(new char[1] { '/' }).Last(); } private void VanillaPrefabsAvailable() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= VanillaPrefabsAvailable; if ((Object)(object)assetBundle == (Object)null) { assetBundle = AssetUtils.LoadAssetBundleFromResources("bottles", typeof(HealingBottles).Assembly); } RequirementConfig val = new RequirementConfig(baseItemName.Value, baseItemAmount.Value, 0, false); RequirementConfig val2 = new RequirementConfig(smallPotionQualityItemName.Value, smallPotionQualityItemAmount.Value, 0, false); RequirementConfig val3 = new RequirementConfig(mediumPotionQualityItemName.Value, mediumPotionQualityItemAmount.Value, 0, false); RequirementConfig val4 = new RequirementConfig(hugePotionQualityItemName.Value, hugePotionQualityItemAmount.Value, 0, false); RequirementConfig val5 = new RequirementConfig(godlyPotionQualityItemName.Value, godlyPotionQualityItemAmount.Value, 0, false); if (healingPotionsEnabled.Value) { RequirementConfig val6 = new RequirementConfig(healingPotionTypeItemName.Value, healingPotionTypeItemAmount.Value, 0, false); AddItem(healingBottleAssetName0, smallPotionCraftingStationLevel.Value, (RequirementConfig[])(object)new RequirementConfig[3] { val, val2, val6 }); AddItem(healingBottleAssetName1, mediumPotionCraftingStationLevel.Value, (RequirementConfig[])(object)new RequirementConfig[3] { val, val3, val6 }); AddItem(healingBottleAssetName2, hugePotionCraftingStationLevel.Value, (RequirementConfig[])(object)new RequirementConfig[3] { val, val4, val6 }); AddItem(healingBottleAssetName3, godlyPotionCraftingStationLevel.Value, (RequirementConfig[])(object)new RequirementConfig[3] { val, val5, val6 }); } if (staminaPotionsEnabled.Value) { RequirementConfig val7 = new RequirementConfig(staminaPotionTypeItemName.Value, staminaPotionTypeItemAmount.Value, 0, false); AddItem(staminaBottleAssetName0, smallPotionCraftingStationLevel.Value, (RequirementConfig[])(object)new RequirementConfig[3] { val, val2, val7 }); AddItem(staminaBottleAssetName1, mediumPotionCraftingStationLevel.Value, (RequirementConfig[])(object)new RequirementConfig[3] { val, val3, val7 }); AddItem(staminaBottleAssetName2, hugePotionCraftingStationLevel.Value, (RequirementConfig[])(object)new RequirementConfig[3] { val, val4, val7 }); AddItem(staminaBottleAssetName3, godlyPotionCraftingStationLevel.Value, (RequirementConfig[])(object)new RequirementConfig[3] { val, val5, val7 }); } if (manaPotionsEnabled.Value) { RequirementConfig val8 = new RequirementConfig(manaPotionTypeItemName.Value, manaPotionTypeItemAmount.Value, 0, false); AddItem(manaBottleAssetName0, smallPotionCraftingStationLevel.Value, (RequirementConfig[])(object)new RequirementConfig[3] { val, val2, val8 }); AddItem(manaBottleAssetName1, mediumPotionCraftingStationLevel.Value, (RequirementConfig[])(object)new RequirementConfig[3] { val, val3, val8 }); AddItem(manaBottleAssetName2, hugePotionCraftingStationLevel.Value, (RequirementConfig[])(object)new RequirementConfig[3] { val, val4, val8 }); AddItem(manaBottleAssetName3, godlyPotionCraftingStationLevel.Value, (RequirementConfig[])(object)new RequirementConfig[3] { val, val5, val8 }); } void AddItem(string assetName, int craftingStationLevel, RequirementConfig[] requirements) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown string text = ExtractBottleName(assetName); ItemConfig val9 = LoadCustomItemFromPrefab(assetName, craftingStationLevel, requirements); CustomItem item = ItemManager.Instance.GetItem(text); if (item == null) { item = new CustomItem(assetBundle, assetName, true, val9); object obj; if (item == null) { obj = null; } else { CustomRecipe recipe = item.Recipe; obj = ((recipe != null) ? recipe.Recipe : null); } if ((Object)obj != (Object)null) { item.Recipe.Recipe.m_minStationLevel = craftingStationLevel; } ItemManager.Instance.AddItem(item); } } ItemConfig LoadCustomItemFromPrefab(string prefabName, int craftingStationLevel, RequirementConfig[] requirements) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown ItemDrop component = assetBundle.LoadAsset<GameObject>(prefabName).GetComponent<ItemDrop>(); SharedData shared = component.m_itemData.m_shared; if (!bottleNames.Contains(((Object)((Component)component).gameObject).name)) { bottleNames.Add(((Object)((Component)component).gameObject).name); } return new ItemConfig { Name = shared.m_name, Icons = shared.m_icons, Description = shared.m_description, CraftingStation = craftingStationItemName.Value, MinStationLevel = craftingStationLevel, Requirements = requirements }; } } public static bool FillHealth(float amount) { if ((Object)(object)Player.m_localPlayer == (Object)null) { return false; } if ((DateTime.Now - lastHealDateTime).TotalSeconds <= (double)healingPotionTimeOut.Value) { ((Character)Player.m_localPlayer).Message((MessageType)2, drinkNotPossibleMessage, 0, (Sprite)null); return false; } float maxHealth = ((Character)Player.m_localPlayer).GetMaxHealth(); float num = maxHealth / 100f * amount; float num2 = ((Character)Player.m_localPlayer).GetHealth() + num; if (num2 < 0f) { num2 = 20f; } else if (num2 > maxHealth) { num2 = maxHealth; } ((Character)Player.m_localPlayer).SetHealth(num2); lastHealDateTime = DateTime.Now; return true; } public static bool FillMana(float amount) { if ((Object)(object)Player.m_localPlayer == (Object)null) { return false; } if ((DateTime.Now - lastEitrDateTime).TotalSeconds <= (double)manaPotionTimeOut.Value) { ((Character)Player.m_localPlayer).Message((MessageType)2, drinkNotPossibleMessage, 0, (Sprite)null); return false; } float num = ((Character)Player.m_localPlayer).GetMaxEitr(); if (num == 0f) { num = 1f; } float num2 = num / 100f * amount; if (num2 > num) { num2 = num - num2; } ((Character)Player.m_localPlayer).AddEitr(num2); lastEitrDateTime = DateTime.Now; return true; } public static bool FillStamina(float amount) { if ((Object)(object)Player.m_localPlayer == (Object)null) { return false; } if ((DateTime.Now - lastStaminaDateTime).TotalSeconds <= (double)staminaPotionTimeOut.Value) { ((Character)Player.m_localPlayer).Message((MessageType)2, drinkNotPossibleMessage, 0, (Sprite)null); return false; } float num = ((Character)Player.m_localPlayer).GetMaxStamina() / 100f * amount; ((Character)Player.m_localPlayer).AddStamina(num); lastStaminaDateTime = DateTime.Now; return true; } private static bool IsBottle(ItemData item) { if (item != null && item.m_shared != null && (Object)(object)item.m_dropPrefab != (Object)null) { return bottleNames.Contains(((Object)item.m_dropPrefab.gameObject).name); } return false; } }