Decompiled source of Upgrade Amount v0.0.2

Upgrade_Amount.dll

Decompiled 10 months 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 UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Upgrade Amount")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Upgrade Amount")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8a09a11f-d17a-4562-a1ba-9a3f43a6662b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace UpgradeAmount;

[BepInPlugin("testpostpleaseignore.dsp.upgradeamount", "Upgrade_Amount", "0.0.2")]
[BepInProcess("DSPGame.exe")]
public class UpgradeAmount : BaseUnityPlugin
{
	public const string pluginGuid = "testpostpleaseignore.dsp.upgradeamount";

	public const string pluginName = "Upgrade_Amount";

	public const string pluginVersion = "0.0.2";

	private Harmony harmony;

	public static UpgradeAmount instance;

	internal static ManualLogSource logger;

	internal static ConfigFile Config;

	private void Awake()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Expected O, but got Unknown
		logger = ((BaseUnityPlugin)this).Logger;
		Config = ((BaseUnityPlugin)this).Config;
		Assert.Null((object)instance, "An instance of UpgradeAmount has already been created!");
		instance = this;
		harmony = new Harmony("testpostpleaseignore.dsp.upgradeamount");
		try
		{
			harmony.PatchAll(typeof(UpgradeAmount));
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Harmony patching failed: " + ex.Message));
		}
		logger.LogInfo((object)"Load Complete");
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(BuildTool_Upgrade), "DeterminePreviews")]
	public static void BuildTool_Upgrade_DeterminePreview_Patch(BuildTool_Upgrade __instance)
	{
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		if (__instance.cursorType != 0 || __instance.castObjectId == 0)
		{
			return;
		}
		ItemProto itemProto = ((BuildTool)__instance).GetItemProto(__instance.castObjectId);
		if (itemProto != null && itemProto.Grade > 0 && itemProto.Upgrades.Length != 0 && ((BuildTool)__instance).GetPrefabDesc(__instance.castObjectId).isBelt && __instance.filterBelt)
		{
			BuildPreview val = ((BuildTool)__instance).buildPreviews[((BuildTool)__instance).buildPreviews.Count - 1];
			Vector3 val2 = val.lpos - ((BuildTool)__instance).player.position;
			if (!(((Vector3)(ref val2)).sqrMagnitude > ((BuildTool)__instance).player.mecha.buildArea * ((BuildTool)__instance).player.mecha.buildArea) && __instance.chainReaction)
			{
				((BuildTool)__instance).actionBuild.model.cursorText = string.Format("{0}{1}\r\n{2} Selected", Localization.Translate("升级"), ((Proto)val.item).name, ((BuildTool)__instance).buildPreviews.Count);
			}
		}
	}

	private void OnDestroy()
	{
		harmony.UnpatchSelf();
		instance = null;
	}
}