using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("AddBerryPlugin")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("AddBerryPlugin")] [assembly: AssemblyTitle("AddBerryPlugin")] [assembly: AssemblyVersion("1.0.0.0")] namespace AddBerryPlugin; [BepInPlugin("com.addberry.plugin", "AddBerry", "1.0.1")] [BepInProcess("valheim.exe")] public class Plugin : BaseUnityPlugin { public const string GUID = "com.addberry.plugin"; public const string NAME = "AddBerry"; public const string VERSION = "1.0.1"; private readonly Harmony _harmony = new Harmony("com.addberry.plugin"); internal static Dictionary Min, ConfigEntry Max)> ItemConfig; private void Awake() { ItemConfig = new Dictionary, ConfigEntry)> { ["RaspberryBush"] = Bind("Raspberry"), ["BlueberryBush"] = Bind("Blueberry"), ["CloudberryBush"] = Bind("Cloudberry"), ["Pickable_Mushroom"] = Bind("Mushroom"), ["Pickable_Mushroom_yellow"] = Bind("Yellow Mushroom"), ["Pickable_Dandelion"] = Bind("Dandelion"), ["Pickable_Thistle"] = Bind("Thistle") }; _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"AddBerry 1.0.1 loaded"); } private (ConfigEntry, ConfigEntry) Bind(string section) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown ConfigEntry item = ((BaseUnityPlugin)this).Config.Bind(section, "Min Drop Amount", 1, new ConfigDescription("Minimum number of items dropped when picked.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 20), Array.Empty())); ConfigEntry item2 = ((BaseUnityPlugin)this).Config.Bind(section, "Max Drop Amount", 10, new ConfigDescription("Maximum number of items dropped when picked.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 20), Array.Empty())); return (item, item2); } private void OnDestroy() { _harmony.UnpatchSelf(); } } [HarmonyPatch(typeof(Pickable), "Interact")] public static class Patch_PickableAmount { public static void Prefix(Pickable __instance) { string key = ((Object)((Component)__instance).gameObject).name.Replace("(Clone)", "").Trim(); if (Plugin.ItemConfig.TryGetValue(key, out (ConfigEntry, ConfigEntry) value)) { __instance.m_amount = Random.Range(value.Item1.Value, value.Item2.Value + 1); } } }