Decompiled source of Quads Upgrade Cost Preview v0.1.0

plugins/UpgradeCostPreview/UpgradeCostPreview.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was partially or fully created with the assistance of Generative AI.")]
[assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic")]
[assembly: AssemblyCompany("UpgradeCostPreview")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ef989ee3ff978f7a8e3025bfd03838f8c47a9203")]
[assembly: AssemblyProduct("UpgradeCostPreview")]
[assembly: AssemblyTitle("UpgradeCostPreview")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace UpgradeCostPreview
{
	[BepInPlugin("quadslab.mycopunk.upgradecostpreview", "Quad's Upgrade Cost Preview", "0.1.0")]
	[BepInProcess("Mycopunk.exe")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "quadslab.mycopunk.upgradecostpreview";

		public const string Title = "Quad's Upgrade Cost Preview";

		public const string Version = "0.1.0";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> ShowTurbochargeCost;

		internal static ConfigEntry<bool> ShowOwned;

		private Harmony harmony;

		private void Awake()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			ShowTurbochargeCost = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowTurbochargeCost", true, "Show what turbocharging an upgrade costs as soon as you point at it, not only once you start holding the key.");
			ShowOwned = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowOwned", true, "Show each cost in the info panel against how much you have: \"40 / 125\".");
			harmony = new Harmony("quadslab.mycopunk.upgradecostpreview");
			harmony.PatchAll(typeof(Plugin).Assembly);
			Log.LogInfo((object)"Quad's Upgrade Cost Preview 0.1.0 loaded");
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}
	}
	[HarmonyPatch(typeof(GearUpgradeUI), "HasUnlockAction")]
	internal static class ShowCostUpfront
	{
		private static void Postfix(ref UnlockActionParams data)
		{
			if (Plugin.ShowTurbochargeCost.Value)
			{
				data.OnlyShowCostWhileUnlocking = false;
			}
		}
	}
	[HarmonyPatch(typeof(UseResourceUI), "Setup")]
	internal static class WiderCosts
	{
		private const float Spacing = 130f;

		private static void Postfix(UseResourceUI __instance)
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.ShowOwned.Value && __instance.costs.Count != 0)
			{
				int count = __instance.costs.Count;
				for (int i = 0; i < count && i < ((Transform)__instance.resourceParent).childCount; i++)
				{
					RectTransform val = (RectTransform)((Transform)__instance.resourceParent).GetChild(i);
					val.anchoredPosition = new Vector2(((float)i - (float)count * 0.5f) * 130f + 65f, val.anchoredPosition.y);
				}
				RectTransform val2 = (RectTransform)((Component)__instance).transform;
				val2.sizeDelta = new Vector2(130f * (float)count + 30f, val2.sizeDelta.y);
			}
		}
	}
	[HarmonyPatch(typeof(ResourceUI), "SetCount")]
	internal static class ShowOwned
	{
		private static void Postfix(ResourceUI __instance, int count, char prefix)
		{
			if (Plugin.ShowOwned.Value && __instance.resource != null && PlayerData.Instance != null && !((Object)(object)((Component)__instance).GetComponentInParent<UseResourceUI>() == (Object)null))
			{
				int resource = PlayerData.Instance.GetResource(__instance.resource);
				TextMeshProUGUI count2 = __instance.GetCount();
				((TMP_Text)count2).textWrappingMode = (TextWrappingModes)0;
				((TMP_Text)count2).overflowMode = (TextOverflowModes)0;
				((TMP_Text)count2).SetText(((prefix != 0) ? prefix.ToString() : "") + count + "<size=70%><color=#B8C2CC> / " + Compact(resource) + "</color></size>");
			}
		}

		private static string Compact(int n)
		{
			if (n < 1000000)
			{
				if (n < 10000)
				{
					return n.ToString();
				}
				return ((float)n / 1000f).ToString((n >= 100000) ? "0" : "0.#") + "k";
			}
			return ((float)n / 1000000f).ToString((n >= 10000000) ? "0" : "0.#") + "M";
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}