Decompiled source of MorePlantmatter v2.0.0

plugins/MorePlantmatter/MorePlantmatter.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using MorePlantmatter.Patches;
using PropStreaming;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MorePlantmatter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MorePlantmatter")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a1da3b87-b759-4ad2-93ef-ff98347ad5bc")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MorePlantmatter
{
	[BepInPlugin("com.equinox.MorePlantmatter", "MorePlantmatter", "2.0.0")]
	public class MorePlantmatterPlugin : BaseUnityPlugin
	{
		private const string MyGUID = "com.equinox.MorePlantmatter";

		private const string PluginName = "MorePlantmatter";

		private const string VersionString = "2.0.0";

		private const string multiplierKey = "Multiplier";

		public static ConfigEntry<int> multiplier;

		private static readonly Harmony Harmony = new Harmony("com.equinox.MorePlantmatter");

		public static ManualLogSource Log = new ManualLogSource("MorePlantmatter");

		private void Awake()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			multiplier = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Multiplier", 2, new ConfigDescription("Multiplier for amount of plantmatter gained when harvesting plants", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: MorePlantmatter, VersionString: 2.0.0 is loading...");
			Harmony.PatchAll();
			Harmony.CreateAndPatchAll(typeof(HitDestructibleActionPatch), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: MorePlantmatter, VersionString: 2.0.0 is loaded.");
			Log = ((BaseUnityPlugin)this).Logger;
		}
	}
}
namespace MorePlantmatter.Patches
{
	internal class HitDestructibleActionPatch
	{
		[HarmonyPatch(typeof(HitDestructibleAction), "ProcessOnHost")]
		[HarmonyPrefix]
		private static void AddMorePlantmatter(HitDestructibleAction __instance)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			InstanceLookup[] propLookups = __instance.info.propLookups;
			DestructibleData val2 = default(DestructibleData);
			for (int i = 0; i < propLookups.Length; i++)
			{
				InstanceLookup val = propLookups[i];
				if (!PropManager.instance.GetDestructibleData(ref val, ref val2) || !val2.WouldBeDestroyed(val, __instance.info.hitStrength))
				{
					continue;
				}
				foreach (DestructibleReward reward in val2.rewards)
				{
					if (reward != null && reward.resource.displayName == "Plantmatter")
					{
						int value = MorePlantmatterPlugin.multiplier.Value;
						((InventoryWrapper)Player.instance.inventory).AddResources(reward.resource, (value - 1) * reward.quantity);
					}
				}
			}
		}
	}
}