Decompiled source of ScrapCalculator v1.1.0

ScrapCalculator.dll

Decompiled 10 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
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 = "")]
[assembly: AssemblyCompany("ScrapCalculator")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Highlights bare minimum scrap required to complete quota")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("ScrapCalculator")]
[assembly: AssemblyTitle("ScrapCalculator")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
namespace ScrapCalculator
{
	[BepInPlugin("ScrapCalculator", "ScrapCalculator", "1.1.0")]
	public class ScrapCalculator : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ScrapCalculator is loaded!");
			Harmony val = new Harmony("ScrapCalculator");
			val.PatchAll(Assembly.GetExecutingAssembly());
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ScrapCalculator";

		public const string PLUGIN_NAME = "ScrapCalculator";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace ScrapCalculator.Patches
{
	[HarmonyPatch]
	public class HudManagerPatcher
	{
		private enum ScanType
		{
			Default,
			Enemy,
			Scrap
		}

		private static int _totalNodes;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HUDManager), "UpdateScanNodes")]
		private static void OnScan(HUDManager __instance, PlayerControllerB playerScript)
		{
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || (!StartOfRound.Instance.inShipPhase && !GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom) || _totalNodes == __instance.scanNodes.Count)
			{
				return;
			}
			_totalNodes = __instance.scanNodes.Count;
			List<KeyValuePair<RectTransform, ScanNodeProperties>> list = (from pair in __instance.scanNodes
				where pair.Value.nodeType == 2
				orderby pair.Value.scrapValue descending
				select pair).ToList();
			int num = TimeOfDay.Instance.profitQuota - TimeOfDay.Instance.quotaFulfilled;
			int num2 = 0;
			while (num2 < list.Count)
			{
				KeyValuePair<RectTransform, ScanNodeProperties> item = list[num2];
				int num3 = num - item.Value.scrapValue;
				if (num3 >= 0)
				{
					((Component)item.Key).GetComponent<Animator>().SetInteger("colorNumber", 1);
					list.Remove(item);
					num = num3;
					num2 = 0;
				}
				else
				{
					num2++;
				}
			}
		}
	}
}