Decompiled source of Dollar to Euro v1.0.1

EmpressDollarToEuro.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+31d33a1e262fb9cd936a8fd3f583fdd7bc996e5a")]
[assembly: AssemblyProduct("EmpressDollarToEuro")]
[assembly: AssemblyTitle("EmpressDollarToEuro")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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", "EmpressDollarToEuro", "1.0.0")]
	public class EmpressDollarToEuroPlugin : BaseUnityPlugin
	{
		internal static EmpressDollarToEuroPlugin Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded.");
		}

		internal void Patch()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	internal static class EmpressCurrencyText
	{
		private static readonly Dictionary<string, string> Cache = new Dictionary<string, string>();

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

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

		internal static void FixTMP(TMP_Text tmp)
		{
			if (!((Object)(object)tmp == (Object)null))
			{
				string text = tmp.text;
				string text2 = Fix(text);
				if (text != text2)
				{
					tmp.text = text2;
				}
			}
		}
	}
	[HarmonyPatch(typeof(CurrencyUI), "Update")]
	internal static class Patch_CurrencyUI_Update
	{
		private static void Postfix(CurrencyUI __instance)
		{
			EmpressCurrencyText.FixTMP((Component)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(CurrencyUI), "FetchCurrency")]
	internal static class Patch_CurrencyUI_FetchCurrency
	{
		private static void Postfix(CurrencyUI __instance)
		{
			EmpressCurrencyText.FixTMP((Component)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(ShopCostUI), "Update")]
	internal static class Patch_ShopCostUI_Update
	{
		private static void Postfix(ShopCostUI __instance)
		{
			EmpressCurrencyText.FixTMP((Component)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(HaulUI), "Update")]
	internal static class Patch_HaulUI_Update
	{
		private static void Postfix(HaulUI __instance)
		{
			EmpressCurrencyText.FixTMP((Component)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(WorldSpaceUIValue), "Show")]
	internal static class Patch_WorldSpaceUIValue_Show
	{
		private static void Postfix(WorldSpaceUIValue __instance)
		{
			EmpressCurrencyText.FixTMP((Component)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(WorldSpaceUIValueLost), "Start")]
	internal static class Patch_WorldSpaceUIValueLost_Start
	{
		private static void Postfix(WorldSpaceUIValueLost __instance)
		{
			EmpressCurrencyText.FixTMP((Component)(object)__instance);
		}
	}
	[HarmonyPatch(typeof(ExtractionPoint), "SetHaulText")]
	internal static class Patch_ExtractionPoint_SetHaulText
	{
		private static void Postfix(ExtractionPoint __instance)
		{
			EmpressCurrencyText.FixTMP((TMP_Text)(object)__instance.haulGoalScreen);
		}
	}
	[HarmonyPatch(typeof(ExtractionPoint), "StateSuccess")]
	internal static class Patch_ExtractionPoint_StateSuccess
	{
		private static void Postfix(ExtractionPoint __instance)
		{
			EmpressCurrencyText.FixTMP((TMP_Text)(object)__instance.haulGoalScreen);
		}
	}
	[HarmonyPatch(typeof(ExtractionPoint), "StateSurplus")]
	internal static class Patch_ExtractionPoint_StateSurplus
	{
		private static void Postfix(ExtractionPoint __instance)
		{
			EmpressCurrencyText.FixTMP((TMP_Text)(object)__instance.haulGoalScreen);
		}
	}
	[HarmonyPatch(typeof(ExtractionPoint), "GlitchyText")]
	internal static class Patch_ExtractionPoint_GlitchyText
	{
		private static void Postfix(ref string __result)
		{
			__result = EmpressCurrencyText.Fix(__result);
		}
	}
	[HarmonyPatch(typeof(PhysGrabCart), "SetHaulText")]
	internal static class Patch_PhysGrabCart_SetHaulText
	{
		private static void Postfix(PhysGrabCart __instance)
		{
			EmpressCurrencyText.FixTMP((TMP_Text)(object)__instance.displayText);
		}
	}
	[HarmonyPatch(typeof(PhysGrabCart), "GlitchyText")]
	internal static class Patch_PhysGrabCart_GlitchyText
	{
		private static void Postfix(ref string __result)
		{
			__result = EmpressCurrencyText.Fix(__result);
		}
	}
	[HarmonyPatch(typeof(MenuPageSaves), "SaveFileSelected")]
	internal static class Patch_MenuPageSaves_SaveFileSelected
	{
		private static void Postfix(MenuPageSaves __instance)
		{
			if ((Object)(object)__instance.saveFileInfoRow1 != (Object)null)
			{
				EmpressCurrencyText.FixTMP((TMP_Text)(object)__instance.saveFileInfoRow1);
			}
			if ((Object)(object)__instance.saveFileInfoRow2 != (Object)null)
			{
				EmpressCurrencyText.FixTMP((TMP_Text)(object)__instance.saveFileInfoRow2);
			}
		}
	}
}