Decompiled source of Dollar to Euro v2.0.0

EmpressDollarToEuro.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Omniscye/Empress")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+5f1b735e473ca4ccf3b383128fbebd889cb564da")]
[assembly: AssemblyProduct("EmpressDollarToEuro")]
[assembly: AssemblyTitle("EmpressDollarToEuro")]
[assembly: AssemblyVersion("1.0.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 EmpressDollarToEuro
{
	[BepInPlugin("Empress.EmpressDollarToEuro", "Empress Dollar To Euro", "1.0.1")]
	public sealed class EmpressDollarToEuroPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "Empress.EmpressDollarToEuro";

		public const string PluginName = "Empress Dollar To Euro";

		public const string PluginVersion = "1.0.1";

		private Harmony? harmony;

		private void Awake()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			((Component)this).transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			harmony = new Harmony("Empress.EmpressDollarToEuro");
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Empress Dollar To Euro v1.0.1 loaded.");
		}
	}
	internal static class EmpressCurrencyText
	{
		private const string Euro = "€";

		private const string SpriteTripleToken = "\u0001";

		private const string SpriteDoubleToken = "\u0002";

		private static readonly Dictionary<string, string> TextCache = new Dictionary<string, string>(StringComparer.Ordinal);

		public static readonly FieldRef<WorldSpaceUIValue, TextMeshProUGUI> WorldSpaceValueText = AccessTools.FieldRefAccess<WorldSpaceUIValue, TextMeshProUGUI>("text");

		public static readonly FieldRef<WorldSpaceUIValueLost, TextMeshProUGUI> WorldSpaceValueLostText = AccessTools.FieldRefAccess<WorldSpaceUIValueLost, TextMeshProUGUI>("text");

		public static readonly FieldRef<ExtractionPoint, TextMeshPro> ExtractionHaulGoalScreen = AccessTools.FieldRefAccess<ExtractionPoint, TextMeshPro>("haulGoalScreen");

		public static readonly FieldRef<ValueScreen, TextMeshPro> ValueScreenDisplayText = AccessTools.FieldRefAccess<ValueScreen, TextMeshPro>("displayText");

		public static readonly FieldRef<MenuPageSaves, TextMeshProUGUI> SaveInfoRow1 = AccessTools.FieldRefAccess<MenuPageSaves, TextMeshProUGUI>("saveFileInfoRow1");

		public static readonly FieldRef<MenuPageSaves, TextMeshProUGUI> SaveInfoRow2 = AccessTools.FieldRefAccess<MenuPageSaves, TextMeshProUGUI>("saveFileInfoRow2");

		public static string Fix(string value)
		{
			if (string.IsNullOrEmpty(value))
			{
				return value;
			}
			if (TextCache.TryGetValue(value, out string value2))
			{
				return value2;
			}
			string text = value;
			if (text.Contains("$") || text.Contains("<sprite name=$") || text.Contains(">k</color>") || text.Contains(">K</color>"))
			{
				bool num = text.Contains("<sprite");
				if (num)
				{
					text = text.Replace("<sprite name=$$$>", "\u0001");
					text = text.Replace("<sprite name=$$>", "\u0002");
				}
				text = text.Replace("$", "€");
				text = text.Replace("K", string.Empty);
				text = text.Replace(">k</color>", "></color>");
				if (num)
				{
					text = text.Replace("\u0001", "<sprite name=$$$>");
					text = text.Replace("\u0002", "<sprite name=$$>");
				}
			}
			TextCache[value] = text;
			if (TextCache.Count > 300)
			{
				TextCache.Clear();
			}
			return text;
		}

		public static void FixComponent(Component component)
		{
			if (!((Object)(object)component == (Object)null))
			{
				FixTMP(component.GetComponent<TMP_Text>());
			}
		}

		public static void FixTMP(TMP_Text tmp)
		{
			if (!((Object)(object)tmp == (Object)null))
			{
				string text = tmp.text;
				string text2 = Fix(text);
				if (!string.Equals(text, text2, StringComparison.Ordinal))
				{
					tmp.text = text2;
				}
			}
		}
	}
	[HarmonyPatch(typeof(CurrencyUI), "Update")]
	internal static class CurrencyUIUpdatePatch
	{
		private static void Postfix(CurrencyUI __instance)
		{
			EmpressCurrencyText.FixComponent((Component)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(CurrencyUI), "FetchCurrency")]
	internal static class CurrencyUIFetchCurrencyPatch
	{
		private static void Postfix(CurrencyUI __instance)
		{
			EmpressCurrencyText.FixComponent((Component)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(ShopCostUI), "Update")]
	internal static class ShopCostUIUpdatePatch
	{
		private static void Postfix(ShopCostUI __instance)
		{
			EmpressCurrencyText.FixComponent((Component)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(HaulUI), "Update")]
	internal static class HaulUIUpdatePatch
	{
		private static void Postfix(HaulUI __instance)
		{
			EmpressCurrencyText.FixComponent((Component)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(WorldSpaceUIValue), "Show", new Type[]
	{
		typeof(PhysGrabObject),
		typeof(int),
		typeof(bool),
		typeof(Vector3)
	})]
	internal static class WorldSpaceUIValuePhysGrabShowPatch
	{
		private static void Postfix(WorldSpaceUIValue __instance)
		{
			EmpressCurrencyText.FixTMP((TMP_Text)(object)EmpressCurrencyText.WorldSpaceValueText.Invoke(__instance));
		}
	}
	[HarmonyPatch(typeof(WorldSpaceUIValue), "Show", new Type[]
	{
		typeof(StaticGrabObject),
		typeof(int),
		typeof(bool),
		typeof(Vector3)
	})]
	internal static class WorldSpaceUIValueStaticGrabShowPatch
	{
		private static void Postfix(WorldSpaceUIValue __instance)
		{
			EmpressCurrencyText.FixTMP((TMP_Text)(object)EmpressCurrencyText.WorldSpaceValueText.Invoke(__instance));
		}
	}
	[HarmonyPatch(typeof(WorldSpaceUIValueLost), "Start")]
	internal static class WorldSpaceUIValueLostStartPatch
	{
		private static void Postfix(WorldSpaceUIValueLost __instance)
		{
			EmpressCurrencyText.FixTMP((TMP_Text)(object)EmpressCurrencyText.WorldSpaceValueLostText.Invoke(__instance));
		}
	}
	[HarmonyPatch(typeof(ExtractionPoint), "SetHaulText")]
	internal static class ExtractionPointSetHaulTextPatch
	{
		private static void Postfix(ExtractionPoint __instance)
		{
			EmpressCurrencyText.FixTMP((TMP_Text)(object)EmpressCurrencyText.ExtractionHaulGoalScreen.Invoke(__instance));
		}
	}
	[HarmonyPatch(typeof(ExtractionPoint), "StateSuccess")]
	internal static class ExtractionPointStateSuccessPatch
	{
		private static void Postfix(ExtractionPoint __instance)
		{
			EmpressCurrencyText.FixTMP((TMP_Text)(object)EmpressCurrencyText.ExtractionHaulGoalScreen.Invoke(__instance));
		}
	}
	[HarmonyPatch(typeof(ExtractionPoint), "StateSurplus")]
	internal static class ExtractionPointStateSurplusPatch
	{
		private static void Postfix(ExtractionPoint __instance)
		{
			EmpressCurrencyText.FixTMP((TMP_Text)(object)EmpressCurrencyText.ExtractionHaulGoalScreen.Invoke(__instance));
		}
	}
	[HarmonyPatch(typeof(ExtractionPoint), "GlitchyText")]
	internal static class ExtractionPointGlitchyTextPatch
	{
		private static void Postfix(ref string __result)
		{
			__result = EmpressCurrencyText.Fix(__result);
		}
	}
	[HarmonyPatch(typeof(ValueScreen), "SetValueText")]
	internal static class ValueScreenSetValueTextPatch
	{
		private static void Postfix(ValueScreen __instance)
		{
			EmpressCurrencyText.FixTMP((TMP_Text)(object)EmpressCurrencyText.ValueScreenDisplayText.Invoke(__instance));
		}
	}
	[HarmonyPatch(typeof(ValueScreen), "GlitchyText")]
	internal static class ValueScreenGlitchyTextPatch
	{
		private static void Postfix(ref string __result)
		{
			__result = EmpressCurrencyText.Fix(__result);
		}
	}
	[HarmonyPatch(typeof(MenuPageSaves), "SaveFileSelected")]
	internal static class MenuPageSavesSaveFileSelectedPatch
	{
		private static void Postfix(MenuPageSaves __instance)
		{
			EmpressCurrencyText.FixTMP((TMP_Text)(object)EmpressCurrencyText.SaveInfoRow1.Invoke(__instance));
			EmpressCurrencyText.FixTMP((TMP_Text)(object)EmpressCurrencyText.SaveInfoRow2.Invoke(__instance));
		}
	}
}