Decompiled source of MinerVeinCoverage v1.4.3

MinerVeinCoverage.dll

Decompiled 7 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("MinerVeinCoverage")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.4.3.0")]
[assembly: AssemblyInformationalVersion("1.4.3+c3c136f73b9d2c0e831cc35de02c64038bc05441")]
[assembly: AssemblyProduct("MinerVeinCoverage")]
[assembly: AssemblyTitle("MinerVeinCoverage")]
[assembly: AssemblyVersion("1.4.3.0")]
namespace MinerVeinCoverage;

[BepInPlugin("com.enriquein.plugins.minerveincoverage", "MinerVeinCoverage", "1.4.3")]
[BepInProcess("DSPGAME.exe")]
public class MainPlugin : BaseUnityPlugin
{
	public const string ModGuid = "com.enriquein.plugins.minerveincoverage";

	public const string ModName = "MinerVeinCoverage";

	public const string ModVersion = "1.4.3";

	public static ConfigEntry<bool> DisplayAsPerSecond { get; set; }

	public void Awake()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		DisplayAsPerSecond = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "DisplayAsPerSecond", false, "Set to \"true\" to show the production as \"per second\" (default is \"per minute\").");
		Harmony val = new Harmony("com.enriquein.plugins.minerveincoverage.patch");
		val.PatchAll(typeof(Patch_UIMinerWindow__OnUpdate));
		val.PatchAll(typeof(Patch_UIVeinCollectorPanel__OnUpdate));
	}
}
[HarmonyPatch(typeof(UIMinerWindow))]
[HarmonyPatch("_OnUpdate")]
internal static class Patch_UIMinerWindow__OnUpdate
{
	private static readonly string _coverText = Localization.Translate("覆盖矿");

	private static readonly string _veinText = (Localization.isENUS ? " veins" : Localization.Translate("个矿脉"));

	private static readonly string _displayUnit = (MainPlugin.DisplayAsPerSecond.Value ? "sec" : "min");

	private static readonly float _displayFactor = (MainPlugin.DisplayAsPerSecond.Value ? 60f : 1f);

	private static readonly float _oreValuePerNode = 30f;

	private static void Postfix(UIMinerWindow __instance)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Invalid comparison between Unknown and I4
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		if (__instance.minerId == 0 || __instance.factory == null)
		{
			((ManualBehaviour)__instance)._Close();
			return;
		}
		MinerComponent val = __instance.factorySystem.minerPool[__instance.minerId];
		if (val.id != __instance.minerId)
		{
			((ManualBehaviour)__instance)._Close();
		}
		else if ((int)val.type == 2)
		{
			string text = (_oreValuePerNode * GameMain.data.history.miningSpeedScale * (float)val.veinCount / _displayFactor).ToString("0.##");
			__instance.coverText.text = $"{_coverText}{val.veinCount}{_veinText} ({text}/{_displayUnit})";
		}
	}
}
[HarmonyPatch(typeof(UIVeinCollectorPanel))]
[HarmonyPatch("_OnUpdate")]
internal static class Patch_UIVeinCollectorPanel__OnUpdate
{
	private static readonly string _coverText = Localization.Translate("覆盖矿");

	private static readonly string _veinText = (Localization.isENUS ? " veins" : Localization.Translate("个矿脉"));

	private static readonly string _displayUnit = (MainPlugin.DisplayAsPerSecond.Value ? "sec" : "min");

	private static readonly float _displayFactor = (MainPlugin.DisplayAsPerSecond.Value ? 60f : 1f);

	private static readonly float _oreValuePerNode = 60f;

	private static void Postfix(UIVeinCollectorPanel __instance)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Invalid comparison between Unknown and I4
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		if (__instance.minerId == 0 || __instance.factory == null)
		{
			((ManualBehaviour)__instance)._Close();
			return;
		}
		MinerComponent val = __instance.factorySystem.minerPool[__instance.minerId];
		if (val.id != __instance.minerId)
		{
			((ManualBehaviour)__instance)._Close();
		}
		else if ((int)val.type == 2)
		{
			string text = ((double)(_oreValuePerNode * GameMain.data.history.miningSpeedScale * (float)val.veinCount) * ((double)(float)val.speed / 10000.0) / (double)_displayFactor).ToString("0.##");
			string text2 = ((val.productCount > 0) ? "" : _coverText);
			__instance.coverText.text = $"{text2}{val.veinCount}{_veinText} ({text}/{_displayUnit})";
		}
	}
}