Decompiled source of MoonPriceDisplay v1.0.1

MoonPriceDisplay.dll

Decompiled 4 months 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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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("MoonPriceDisplay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Shows the prices of moons on the menu")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5bb1204ed5ea805afae4e972edfd3a1c5429722f")]
[assembly: AssemblyProduct("MoonPriceDisplay")]
[assembly: AssemblyTitle("MoonPriceDisplay")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MoonPriceDisplay
{
	[BepInPlugin("gloveman.MoonPriceDisplay", "MoonPriceDisplay", "1.0.0.0")]
	[BepInProcess("Lethal Company.exe")]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "gloveman.MoonPriceDisplay";

		private const string LEVELLOADER_GUID = "imabatby.lethallevelloader";

		private readonly Harmony harmony = new Harmony("gloveman.MoonPriceDisplay");

		private static readonly ManualLogSource Logger = Logger.CreateLogSource("gloveman.MoonPriceDisplay");

		public Plugin Instance;

		public static TerminalKeyword route;

		private void Awake()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			Instance = new Plugin();
			MethodInfo method = typeof(Plugin).GetMethod("AddPrice");
			MethodInfo methodInfo = AccessTools.Method(typeof(Terminal), "TextPostProcess", (Type[])null, (Type[])null);
			MethodInfo method2 = typeof(Plugin).GetMethod("TerminalAwake");
			MethodInfo methodInfo2 = AccessTools.Method(typeof(Terminal), "Awake", (Type[])null, (Type[])null);
			harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Logger.LogInfo((object)"gloveman.MoonPriceDisplay is loaded!");
		}

		public static bool AddPrice(Terminal __instance, ref string modifiedDisplayText, TerminalNode node, ref string __result)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			int num = modifiedDisplayText.Split("[planetTime]").Length - 1;
			if (num > 0)
			{
				Regex regex = new Regex(Regex.Escape("[planetTime]"));
				for (int i = 0; i < num && __instance.moonsCatalogueList.Length > i; i++)
				{
					Debug.Log((object)$"isDemo:{GameNetworkManager.Instance.isDemo} ; {__instance.moonsCatalogueList[i].lockedForDemo}");
					string text = ((GameNetworkManager.Instance.isDemo && __instance.moonsCatalogueList[i].lockedForDemo) ? "(Locked)" : (((int)__instance.moonsCatalogueList[i].currentWeather != -1) ? ("(" + ((object)(LevelWeatherType)(ref __instance.moonsCatalogueList[i].currentWeather)).ToString() + ")") : ""));
					CompatibleNoun[] compatibleNouns = route.compatibleNouns;
					foreach (CompatibleNoun val in compatibleNouns)
					{
						TerminalNode result = val.result;
						if (result.displayPlanetInfo == __instance.moonsCatalogueList[i].levelID && result.itemCost > 0)
						{
							text = text + " $" + result.itemCost;
							break;
						}
					}
					modifiedDisplayText = regex.Replace(modifiedDisplayText, text, 1);
				}
				__result = modifiedDisplayText;
			}
			return true;
		}

		public static void TerminalAwake(Terminal __instance)
		{
			TerminalKeyword[] allKeywords = __instance.terminalNodes.allKeywords;
			foreach (TerminalKeyword val in allKeywords)
			{
				if (((Object)val).name == "Route")
				{
					route = val;
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MoonPriceDisplay";

		public const string PLUGIN_NAME = "MoonPriceDisplay";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}