Decompiled source of InfiniteSoil v1.0.1

InfiniteSoil.dll

Decompiled 3 days ago
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace InfiniteSoil;

[BepInPlugin("com.doubao.infinitesoil", "无限沙土 (Infinite Soil Pile)", "1.0.1")]
public class InfiniteSoilPlugin : BaseUnityPlugin
{
	private const long MaxSandValue = 999999999L;

	private static Harmony _harmony;

	private void Awake()
	{
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"========================================");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"无限沙土MOD v1.0.1 已加载!");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"支持游戏版本: 0.10.34.28529");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"========================================");
		_harmony = new Harmony("com.doubao.infinitesoil");
		_harmony.PatchAll(Assembly.GetExecutingAssembly());
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony补丁已应用!");
	}

	private void Start()
	{
		((MonoBehaviour)this).InvokeRepeating("EnsureSand", 1f, 0.5f);
	}

	private void EnsureSand()
	{
		if (GameMain.mainPlayer != null)
		{
			GameMain.mainPlayer.SetSandCount(999999999L, (ESandSource)3);
		}
	}

	private void OnDestroy()
	{
		if (_harmony != null)
		{
			_harmony.UnpatchSelf();
		}
	}
}
[HarmonyPatch(typeof(Player), "SetSandCount")]
public static class SetSandCountPatch
{
	private const long MaxSandValue = 999999999L;

	private static bool Prefix(Player __instance, ref long newSandCount, ESandSource sandSource)
	{
		newSandCount = 999999999L;
		return true;
	}
}
[HarmonyPatch(typeof(Player), "get_sandCount")]
public static class GetSandCountPatch
{
	private const long MaxSandValue = 999999999L;

	private static void Postfix(ref long __result)
	{
		__result = 999999999L;
	}
}
[HarmonyPatch]
public static class GetNeedSandCountPatch
{
	private static MethodBase TargetMethod()
	{
		return AccessTools.Method("BuildTool_Reform:GetNeedSandCountByInc", (Type[])null, (Type[])null);
	}

	private static void Postfix(ref int __result)
	{
		__result = 0;
	}
}