Decompiled source of LastRunResult v1.0.1

LastRunResult.dll

Decompiled 8 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RadiationIsCool")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RadiationIsCool")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8ee335db-0cbe-470c-8fbc-69263f01b35a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LastRunResult
{
	public class LastRunResult : MonoBehaviour
	{
		public bool unloaded;

		public int totalInt;

		public int currentInt;

		public TMP_Text totalText;

		public TMP_Text currentText;

		public Animator animator;

		public StartOfRound startOfRound;

		private void Start()
		{
			totalText = GameObject.Find("LastTotalText").GetComponent<TMP_Text>();
			currentText = GameObject.Find("LastTotalText (1)").GetComponent<TMP_Text>();
			totalText.font = ((TMP_Text)Object.FindObjectOfType<HUDManager>().controlTipLines[0]).font;
			currentText.font = ((TMP_Text)Object.FindObjectOfType<HUDManager>().controlTipLines[0]).font;
			currentText.text = "";
			startOfRound = Object.FindObjectOfType<StartOfRound>();
			animator = ((Component)((Component)this).transform.GetChild(0)).GetComponent<Animator>();
			animator.SetBool("display", true);
		}

		private void LateUpdate()
		{
			if (startOfRound.GetValueOfAllScrap(true, true) != 0 && currentInt != startOfRound.GetValueOfAllScrap(true, true))
			{
				currentInt = startOfRound.GetValueOfAllScrap(true, true);
			}
			if (((ButtonControl)Keyboard.current.tKey).isPressed && !StartOfRound.Instance.localPlayerController.inTerminalMenu)
			{
				animator.SetBool("display", true);
				totalText.text = "Last run:";
				currentText.text = currentInt + "/" + RoundManager.Instance.totalScrapValueInLevel;
			}
			else
			{
				animator.SetBool("display", false);
				totalText.text = "";
				currentText.text = "";
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		public static GameObject lastRunResultObject;

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void Start_Postfix()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			lastRunResultObject = Object.Instantiate<GameObject>(Plugin.lastRunResultPrefab);
			lastRunResultObject.AddComponent<LastRunResult>();
			lastRunResultObject.transform.parent = GameObject.Find("Systems").transform.GetChild(4).GetChild(1).GetChild(10);
			lastRunResultObject.transform.localPosition = new Vector3(54.38699f, -100f, 0f);
			lastRunResultObject.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
			lastRunResultObject.transform.localScale = new Vector3(1f, 1f, 1f);
		}
	}
	[BepInPlugin("Piggy3590.LastRunResult", "LastRunResult", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "Piggy3590.LastRunResult";

		private const string modName = "LastRunResult";

		private const string modVersion = "1.0.1";

		private readonly Harmony harmony = new Harmony("Piggy3590.LastRunResult");

		private static Plugin Instance;

		internal ManualLogSource mls;

		public static AssetBundle Bundle;

		public static string PluginDirectory;

		public static GameObject lastRunResultPrefab;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Piggy3590.LastRunResult");
			PluginDirectory = ((BaseUnityPlugin)this).Info.Location;
			Bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lastrun"));
			lastRunResultPrefab = Bundle.LoadAsset<GameObject>("LastRunInfo.prefab");
			mls.LogInfo((object)"LastRunResult is loaded");
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(StartOfRoundPatch));
		}
	}
}