Please disclose if your mod was created primarily 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 Honeyvore v0.0.3
plugins\Honeyvore.dll
Decompiled a month agousing 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.Permissions; using BepInEx; using HarmonyLib; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Honeyvore")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Honeyvore")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.0.3")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.3.0")] namespace Honeyvore; [BepInPlugin("de.sirskunkalot.Honeyvore", "Honeyvore", "0.0.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Honeyvore : BaseUnityPlugin { public const string PluginGUID = "de.sirskunkalot.Honeyvore"; public const string PluginName = "Honeyvore"; public const string PluginVersion = "0.0.3"; private static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization(); private static HashSet<string> HoneyItems = new HashSet<string>(); private void Awake() { CustomLocalization localization = Localization; string text = "English"; localization.AddTranslation(ref text, new Dictionary<string, string> { { "honeymessage1", "There is no honey in {item_name}, hun" }, { "honeymessage2", "No beeswax, no {item_name}" }, { "honeymessage3", "No honey, no love" }, { "honeymessage4", "Error 404: Honey not found" }, { "honeymessage5", "{item_name}.getHoney() returned null" }, { "honeymessage6", "Un-bee-lievable. No honey in {item_name}" }, { "honeymessage7", "You stare at {item_name}. It stares back. No honey. You walk away" }, { "honeymessage8", "Player is not happy, no honey in {item_name}" }, { "honeymessage9", "Valhalla has honey. {item_name} does not" }, { "honeymessage10", "{item_name}? Honey, please" } }); MinimapManager.OnVanillaMapAvailable += BuildHoneyItemsCache; Harmony.CreateAndPatchAll(typeof(Honeyvore), "de.sirskunkalot.Honeyvore"); } private static void BuildHoneyItemsCache() { HashSet<GameObject> hashSet = new HashSet<GameObject>(ZNetScene.instance.m_prefabs); hashSet.UnionWith(ZNetScene.instance.m_namedPrefabs.Values); hashSet.Remove(null); List<(string, string)> list = new List<(string, string)>(); CookingStation val = default(CookingStation); Fermenter val2 = default(Fermenter); foreach (GameObject item in hashSet) { if (item.TryGetComponent<CookingStation>(ref val)) { foreach (ItemConversion item2 in val.m_conversion) { list.Add((item2.m_from.m_itemData.m_shared.m_name, item2.m_to.m_itemData.m_shared.m_name)); } } if (!item.TryGetComponent<Fermenter>(ref val2)) { continue; } foreach (ItemConversion item3 in val2.m_conversion) { list.Add((item3.m_from.m_itemData.m_shared.m_name, item3.m_to.m_itemData.m_shared.m_name)); } } HoneyItems.Clear(); HoneyItems.Add("$item_honey"); bool flag = true; while (flag) { flag = false; foreach (Recipe recipe in ObjectDB.instance.m_recipes) { if ((Object)(object)recipe.m_item == (Object)null) { continue; } string name = recipe.m_item.m_itemData.m_shared.m_name; if (HoneyItems.Contains(name)) { continue; } Requirement[] resources = recipe.m_resources; foreach (Requirement val3 in resources) { if (HoneyItems.Contains(val3.m_resItem.m_itemData.m_shared.m_name)) { flag = HoneyItems.Add(name); break; } } } foreach (var item4 in list) { if (HoneyItems.Contains(item4.Item1) && HoneyItems.Add(item4.Item2)) { flag = true; } } } } [HarmonyPatch(typeof(Player), "CanConsumeItem")] [HarmonyPrefix] private static bool PrefixPlayerCanConsumeItem(Player __instance, ItemData item) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || (Object)(object)Player.m_localPlayer != (Object)(object)__instance) { return true; } if ((int)item.m_shared.m_itemType != 2) { return true; } if (!HoneyItems.Contains(item.m_shared.m_name)) { ((Character)__instance).Message((MessageType)2, GetMessage(item.m_shared.m_name), 0, (Sprite)null); return false; } return true; } [HarmonyPatch(typeof(Player), "ConsumeItem")] [HarmonyPrefix] private static bool PrefixPlayerConsumeItem(Player __instance, ItemData item) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || (Object)(object)Player.m_localPlayer != (Object)(object)__instance) { return true; } if ((int)item.m_shared.m_itemType != 2) { return true; } if (!HoneyItems.Contains(item.m_shared.m_name)) { ((Character)__instance).Message((MessageType)2, GetMessage(item.m_shared.m_name), 0, (Sprite)null); return false; } return true; } private static string GetMessage(string itemName) { CustomLocalization localization = Localization; string text = "English"; string[] array = localization.GetTranslations(ref text).Keys.ToArray(); int num = Random.Range(0, array.Length); string text2 = "$" + array[num]; return Localization.TryTranslate(text2).Replace("{item_name}", itemName); } }