Decompiled source of ProfitPercent v1.0.3

ProfitPercent.dll

Decompiled 2 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 HarmonyLib;
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("ProfitPercent")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProfitPercent")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1aa9f185-5e80-46e0-935b-a30791a11860")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ProfitPercent;

[BepInPlugin("pr0skynesis.profitpercent", "Profit Percent", "1.0.2")]
public class ProfitPercentMain : BaseUnityPlugin
{
	public const string pluginGuid = "pr0skynesis.profitpercent";

	public const string pluginName = "Profit Percent";

	public const string pluginVersion = "1.0.2";

	public void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		Harmony val = new Harmony("pr0skynesis.profitpercent");
		MethodInfo methodInfo = AccessTools.Method(typeof(EconomyUI), "GetProfitString", (Type[])null, (Type[])null);
		MethodInfo methodInfo2 = AccessTools.Method(typeof(ProfitPercentPatches), "GetProfitString_Patch", (Type[])null, (Type[])null);
		val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}
}
public class ProfitPercentPatches
{
	[HarmonyPrefix]
	public static bool GetProfitString_Patch(int portIndex, int goodIndex, ref string __result, IslandMarket ___currentIsland, Currency ___currentPlayerCurrency)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		int num = SellPrice(portIndex, goodIndex, ___currentIsland, ___currentPlayerCurrency);
		int num2 = BuyPrice(___currentIsland.GetPortIndex(), goodIndex, ___currentIsland, ___currentPlayerCurrency);
		if (num2 == 0)
		{
			__result = "<color=#CC7F00>-</color>";
			return false;
		}
		float num3 = Mathf.Round((float)(num - num2) / (float)num2 * 100f);
		if (num > num2)
		{
			__result = $"<color=#113905><size=52%>{num - num2} <size=42%>({num3}%)</size></size></color>";
		}
		else if (num < num2)
		{
			__result = $"<color=#7C0000><size=52%>{num - num2} <size=42%>({num3}%)</size></size></color>";
		}
		else if (num == num2)
		{
			__result = $"<color=#CC7F00><size=52%>{num - num2} <size=42%>({num3}%)</size></size></color>";
		}
		return false;
	}

	private static int SellPrice(int portIndex, int goodIndex, IslandMarket currentIsland, Currency currentPlayerCurrency)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		int num = currentIsland.knownPrices[portIndex].sellPrices[goodIndex];
		bool flag = Port.ports[portIndex].region != (PortRegion)currentPlayerCurrency;
		return CurrencyMarket.instance.GetSellPriceInCurrency(currentPlayerCurrency, (float)num, flag);
	}

	private static int BuyPrice(int portIndex, int goodIndex, IslandMarket currentIsland, Currency currentPlayerCurrency)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		int num = currentIsland.knownPrices[portIndex].buyPrices[goodIndex];
		bool flag = Port.ports[portIndex].region != (PortRegion)currentPlayerCurrency;
		return CurrencyMarket.instance.GetBuyPriceInCurrency(currentPlayerCurrency, (float)num, flag);
	}
}