Decompiled source of BetterStoneHarvest v1.1.0

BepInEx/plugins/BetterStoneHarvest.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BetterStoneHarvest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterStoneHarvest")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3d92cc92-c772-450b-9b6e-d511fab9b467")]
[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")]
[BepInPlugin("com.lan.BetterStoneHarvest", "更好的挖矿收获", "1.1.0")]
public class BetterStoneHarvest : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("com.lan.BetterStoneHarvest");
		val.PatchAll();
		Debug.LogWarning((object)"更好的挖矿收获 --作者:她说缝上都不给我");
	}
}
[HarmonyPatch]
public static class HarvestablePatch
{
	[HarmonyPrefix]
	[HarmonyPatch(typeof(Harvestable), "Start")]
	private static bool PrefixStart(Harvestable __instance)
	{
		Resource val = (Resource)(object)((__instance is Resource) ? __instance : null);
		if (val != null && val.outputItem.itemName.Contains("stone"))
		{
			((Harvestable)val).health = ((Harvestable)val).health * 2;
			val.amount *= 2;
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(Resource), "SpawnResourcesServer")]
	public static bool PrefixSpawnResourcesServer(Resource __instance)
	{
		if (!__instance.outputItem.itemName.Contains("stone"))
		{
			return true;
		}
		if (!((NetworkBehaviour)__instance).IsServer)
		{
			return true;
		}
		FieldInfo fieldInfo = AccessTools.Field(typeof(Resource), "isHarvested");
		FieldInfo fieldInfo2 = AccessTools.Field(typeof(Resource), "id");
		NetworkVariable<bool> val = (NetworkVariable<bool>)fieldInfo.GetValue(__instance);
		string text = (string)fieldInfo2.GetValue(__instance);
		if (val.Value)
		{
			return true;
		}
		val.Value = true;
		GameManager.Instance.AddToNewHarvestedResources(text, GameManager.Instance.GetCurrentDayRaw());
		PlayerInventory component = ((Component)NetworkManager.Singleton.LocalClient.PlayerObject).GetComponent<PlayerInventory>();
		if ((Object)(object)component != (Object)null)
		{
			component.GiveItemServerRpc(__instance.outputItem.id, __instance.amount, 0, 0);
		}
		return false;
	}
}