Decompiled source of ObfuscatedValues v1.0.1

ObfuscatedValues.dll

Decompiled 3 weeks 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 System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("OrigamiCoder")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+bdd4ea369f7ddfe73969e52e28944898b1ebf46c")]
[assembly: AssemblyProduct("ObfuscatedValues")]
[assembly: AssemblyTitle("ObfuscatedValues")]
[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 ObfuscatedValues
{
	[HarmonyPatch(typeof(CurrencyUI))]
	internal static class CurrencyUIPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void Update_Postfix(CurrencyUI __instance)
		{
			if (!ObfuscatedValuesConfig.ObfuscateAllValues.Value)
			{
				((TMP_Text)__instance.Text).text = "$???K";
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("FetchCurrency")]
		private static void FetchCurrency_Postfix(CurrencyUI __instance)
		{
			if (!ObfuscatedValuesConfig.ObfuscateAllValues.Value)
			{
				((TMP_Text)__instance.Text).text = "$???K";
			}
		}
	}
	[HarmonyPatch(typeof(ExtractionPoint))]
	internal static class ExtractionPointPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("SetHaulText")]
		private static void SetHaulText_Postfix(ExtractionPoint __instance)
		{
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			if (ObfuscatedValuesConfig.ObfuscateAllValues.Value)
			{
				return;
			}
			if (!__instance.isShop)
			{
				if (ObfuscatedValuesConfig.ExtractionValue.Value)
				{
					string text = "<color=#bd4300>$</color>";
					((TMP_Text)__instance.haulGoalScreen).text = text + "???";
				}
			}
			else if (ObfuscatedValuesConfig.ShopExtraction.Value)
			{
				string text2 = "<color=#bd4300>$</color>";
				((TMP_Text)__instance.haulGoalScreen).text = text2 + "???";
				if (__instance.haulGoal - __instance.haulCurrent < 0)
				{
					((TMP_Text)__instance.haulGoalScreen).text = "???";
					((Graphic)__instance.haulGoalScreen).color = Color.red;
				}
			}
		}
	}
	[HarmonyPatch(typeof(HaulUI))]
	internal static class HaulUIPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void Update_Postfix(HaulUI __instance)
		{
			if (!ObfuscatedValuesConfig.ObfuscateAllValues.Value && SemiFunc.RunIsLevel() && (ObfuscatedValuesConfig.ExtractionValue.Value || ObfuscatedValuesConfig.ExtractionGoal.Value))
			{
				int extractionHaulGoal = RoundDirector.instance.extractionHaulGoal;
				int currentHaulValue = __instance.currentHaulValue;
				string text = "<color=#558B2F>$</color>";
				string text2 = (ObfuscatedValuesConfig.ExtractionValue.Value ? "???" : SemiFunc.DollarGetString(currentHaulValue));
				string text3 = (ObfuscatedValuesConfig.ExtractionGoal.Value ? "???" : SemiFunc.DollarGetString(extractionHaulGoal));
				((TMP_Text)__instance.Text).text = "<size=30>" + text + text2 + "<color=#616161> <size=45>/</size> </color>" + text + "<u>" + text3 + "</u>";
			}
		}
	}
	[HarmonyPatch(typeof(MenuPageSaves))]
	internal static class MenuPageSavesPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("SaveFileSelected")]
		private static void SaveFileSelected_Postfix(MenuPageSaves __instance)
		{
			if (ObfuscatedValuesConfig.ObfuscateAllValues.Value)
			{
				string pattern = "(?<=<sprite name=\\$\\$>  <b>)\\d+";
				((TMP_Text)__instance.saveFileInfoRow1).text = Regex.Replace(((TMP_Text)__instance.saveFileInfoRow1).text, pattern, "???");
			}
		}
	}
	[BepInPlugin("OrigamiCoder.ObfuscatedValues", "ObfuscatedValues", "1.0.0")]
	public class ObfuscatedValues : BaseUnityPlugin
	{
		internal static ObfuscatedValues 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} has 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 ObfuscatedValuesConfig
	{
		private const string SectionAll = "Obfuscate All Values (Override)";

		private const string SectionValuables = "Obfuscate Valuables";

		private const string SectionShop = "Obfuscate Shop";

		internal static readonly ConfigEntry<bool> ObfuscateAllValues;

		private const bool DefaultObfuscateAllValues = false;

		internal static readonly ConfigEntry<bool> Valuables;

		private const bool DefaultValuables = true;

		internal static readonly ConfigEntry<bool> ValuableDamage;

		private const bool DefaultValuableDamage = false;

		internal static readonly ConfigEntry<bool> Cart;

		private const bool DefaultCart = false;

		internal static readonly ConfigEntry<bool> ExtractionValue;

		private const bool DefaultExtractionValue = false;

		internal static readonly ConfigEntry<bool> ExtractionGoal;

		private const bool DefaultExtractionGoal = false;

		internal static readonly ConfigEntry<bool> ShopItems;

		private const bool DefaultShopItems = false;

		internal static readonly ConfigEntry<bool> ShopExtraction;

		private const bool DefaultShopExtraction = false;

		static ObfuscatedValuesConfig()
		{
			ObfuscatedValues instance = ObfuscatedValues.Instance;
			ObfuscateAllValues = ((BaseUnityPlugin)instance).Config.Bind<bool>("Obfuscate All Values (Override)", "Obfuscate All Values", false, "Obscures all values. (Overrides all other settings)");
			Valuables = ((BaseUnityPlugin)instance).Config.Bind<bool>("Obfuscate Valuables", "Valuables", true, "Obscures the value of valuables.");
			ValuableDamage = ((BaseUnityPlugin)instance).Config.Bind<bool>("Obfuscate Valuables", "ValuableDamage", false, "Obscures the value of valuable damage.");
			Cart = ((BaseUnityPlugin)instance).Config.Bind<bool>("Obfuscate Valuables", "Cart", false, "Obscures the value of valuables in cart.");
			ExtractionValue = ((BaseUnityPlugin)instance).Config.Bind<bool>("Obfuscate Valuables", "Extraction", false, "Obscures the value of valuables in extraction.");
			ExtractionGoal = ((BaseUnityPlugin)instance).Config.Bind<bool>("Obfuscate Valuables", "ExtractionGoal", false, "Obscures the value of the extraction goal.");
			ShopItems = ((BaseUnityPlugin)instance).Config.Bind<bool>("Obfuscate Shop", "ShopItems", false, "Obscures the value of shop items.");
			ShopExtraction = ((BaseUnityPlugin)instance).Config.Bind<bool>("Obfuscate Shop", "ShopExtraction", false, "Obscures the value of items in shop extraction.");
		}
	}
	[HarmonyPatch(typeof(PhysGrabCart))]
	internal static class PhysGrabCartPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("SetHaulText")]
		private static void SetHaulText(PhysGrabCart __instance)
		{
			if (ObfuscatedValuesConfig.Cart.Value)
			{
				string text = "<color=#bd4300>$</color>";
				((TMP_Text)__instance.displayText).text = text + "???";
			}
		}
	}
	[HarmonyPatch(typeof(SemiFunc))]
	internal static class SemiFuncPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("DollarGetString")]
		private static string DollarGetString_Postfix(string s)
		{
			return ObfuscatedValuesConfig.ObfuscateAllValues.Value ? "???" : s;
		}
	}
	[HarmonyPatch(typeof(ShopCostUI))]
	internal static class ShopCostUIPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void Update_Postfix(ShopCostUI __instance)
		{
			if (SemiFunc.RunIsShop() && ObfuscatedValuesConfig.ShopExtraction.Value)
			{
				((TMP_Text)__instance.Text).text = "-$???K";
			}
			if (SemiFunc.RunIsLevel() && (ObfuscatedValuesConfig.ExtractionValue.Value || ObfuscatedValuesConfig.ObfuscateAllValues.Value))
			{
				((TMP_Text)__instance.Text).text = "+$???K";
			}
		}
	}
	[HarmonyPatch(typeof(WorldSpaceUIValueLost))]
	internal static class WorldSpaceUIValueLostPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void Start_Postfix(WorldSpaceUIValueLost __instance)
		{
			if (!ObfuscatedValuesConfig.ObfuscateAllValues.Value)
			{
				if (ObfuscatedValuesConfig.ValuableDamage.Value)
				{
					((TMP_Text)__instance.text).text = "-$???";
				}
				else if (ObfuscatedValuesConfig.Valuables.Value)
				{
					TextMeshProUGUI text = __instance.text;
					((TMP_Text)text).text = ((TMP_Text)text).text + "?";
				}
			}
		}
	}
	[HarmonyPatch(typeof(WorldSpaceUIValue))]
	internal static class WorldSpaceUIValuePatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Show")]
		private static void Show_Postfix(bool _cost, WorldSpaceUIValue __instance)
		{
			if (ObfuscatedValuesConfig.ObfuscateAllValues.Value)
			{
				return;
			}
			if (_cost)
			{
				if (ObfuscatedValuesConfig.ShopItems.Value)
				{
					((TMP_Text)__instance.text).text = "$???";
				}
			}
			else if (ObfuscatedValuesConfig.Valuables.Value)
			{
				((TMP_Text)__instance.text).text = "$???";
			}
		}
	}
}