Decompiled source of Map Value Tracker v1.0.3

MapValueTracker.dll

Decompiled 14 hours 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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using MapValueTracker.Config;
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: AssemblyCompany("MapValueTracker")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3")]
[assembly: AssemblyProduct("MapValueTracker")]
[assembly: AssemblyTitle("MapValueTracker")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MapValueTracker
{
	[BepInPlugin("MapValueTracker", "MapValueTracker", "1.0.3")]
	public class MapValueTracker : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "MapValueTracker";

		public const string PLUGIN_NAME = "MapValueTracker";

		public const string PLUGIN_VERSION = "1.0.3";

		internal static ManualLogSource Logger;

		private readonly Harmony harmony = new Harmony("Tansinator.REPO.MapValueTracker");

		public static MapValueTracker instance;

		public static GameObject textInstance;

		public static TextMeshProUGUI valueText;

		public void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin MapValueTracker is loaded!");
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			Configuration.Init(((BaseUnityPlugin)this).Config);
			harmony.PatchAll(typeof(MapValueTracker));
		}

		[HarmonyPatch(typeof(RoundDirector), "Update")]
		[HarmonyPostfix]
		private static void CountValues()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			ValuableDirector val = ValuableDirector.instance;
			if (LevelGenerator.Instance.Generated && ((Object)val == (Object)null || val.valuableList == null))
			{
				return;
			}
			int count = val.valuableList.Count;
			float num = 0f;
			for (int i = 0; i < count; i++)
			{
				num += val.valuableList[i].dollarValueCurrent;
			}
			int? num2 = Traverse.Create((object)RoundDirector.instance).Field("extractionHaulGoal").GetValue<int>();
			if ((Object)(object)textInstance == (Object)null)
			{
				GameObject val2 = GameObject.Find("Game Hud");
				GameObject val3 = GameObject.Find("Tax Haul");
				if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null)
				{
					return;
				}
				TMP_FontAsset font = val3.GetComponent<TMP_Text>().font;
				textInstance = new GameObject();
				textInstance.SetActive(false);
				((Object)textInstance).name = "Value HUD";
				textInstance.AddComponent<TextMeshProUGUI>();
				valueText = textInstance.GetComponent<TextMeshProUGUI>();
				((TMP_Text)valueText).font = font;
				((Graphic)valueText).color = Color.op_Implicit(new Vector4(0.7882f, 0.9137f, 0.902f, 1f));
				((TMP_Text)valueText).fontSize = 24f;
				((TMP_Text)valueText).enableWordWrapping = false;
				((TMP_Text)valueText).alignment = (TextAlignmentOptions)2052;
				((TMP_Text)valueText).horizontalAlignment = (HorizontalAlignmentOptions)4;
				((TMP_Text)valueText).verticalAlignment = (VerticalAlignmentOptions)2048;
				textInstance.transform.SetParent(val2.transform, false);
				RectTransform component = textInstance.GetComponent<RectTransform>();
				component.pivot = new Vector2(1f, 1f);
				component.anchoredPosition = new Vector2(1f, -1f);
				component.anchorMin = new Vector2(0f, 0f);
				component.anchorMax = new Vector2(1f, 0f);
				component.sizeDelta = new Vector2(0f, 0f);
				component.offsetMax = new Vector2(0f, 225f);
				component.offsetMin = new Vector2(0f, 225f);
			}
			if ((Object)(object)valueText != (Object)null && num2.HasValue && num2 != 0 && (Configuration.AlwaysOn.Value || num / (float)num2.Value <= Configuration.ValueRatio.Value))
			{
				RectTransform component2 = textInstance.GetComponent<RectTransform>();
				component2.pivot = new Vector2(1f, 1f);
				component2.anchoredPosition = new Vector2(1f, -1f);
				component2.anchorMin = new Vector2(0f, 0f);
				component2.anchorMax = new Vector2(1f, 0f);
				component2.sizeDelta = new Vector2(0f, 0f);
				component2.offsetMax = new Vector2(0f, 225f);
				component2.offsetMin = new Vector2(0f, 225f);
				textInstance.SetActive(true);
				((TMP_Text)valueText).SetText("Map: $" + num.ToString("N0"), true);
			}
			else
			{
				textInstance.SetActive(false);
			}
			Logger.LogInfo((object)("Total Value: " + num));
			ManualLogSource logger = Logger;
			int? num3 = num2;
			logger.LogInfo((object)("Current Goal: " + num3));
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MapValueTracker";

		public const string PLUGIN_NAME = "MapValueTracker";

		public const string PLUGIN_VERSION = "1.0.3";
	}
}
namespace MapValueTracker.Config
{
	internal class Configuration
	{
		public static ConfigEntry<bool> AlwaysOn;

		public static ConfigEntry<float> ValueRatio;

		public static void Init(ConfigFile config)
		{
			config.SaveOnConfigSet = false;
			AlwaysOn = config.Bind<bool>("Default", "AlwaysOn", true, "Toggle to always display map value when an extraction goal is active.");
			ValueRatio = config.Bind<float>("Default", "ValueRatio", 2f, "Ratio of Map Value to Extraction Goal. Ex: 20k map value to 10k goal is 2.0");
			ClearOrphanedEntries(config);
			config.Save();
			config.SaveOnConfigSet = true;
		}

		private static void ClearOrphanedEntries(ConfigFile cfg)
		{
			PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg);
			dictionary.Clear();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}