Decompiled source of WeablesMod v1.2.0

WeablesMod.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
using WeablesMod.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("WeablesMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WeablesMod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a9a78ba5-4a28-4057-a090-5f42c01ee130")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WeablesMod
{
	[BepInPlugin("WeablesLethalCompanyMod", "Weables Mod", "1.2.0")]
	public class WeablesModBase : BaseUnityPlugin
	{
		private const string modGUID = "WeablesLethalCompanyMod";

		private const string modName = "Weables Mod";

		private const string modVersion = "1.2.0";

		private readonly Harmony harmony = new Harmony("WeablesLethalCompanyMod");

		private static WeablesModBase Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("WeablesLethalCompanyMod");
			mls.LogInfo((object)"Weables Mod is awake");
			harmony.PatchAll(typeof(WeablesModBase));
			harmony.PatchAll(typeof(TerminalPatch));
		}
	}
	internal class TerminalOptions
	{
		public bool displayMenu = false;
	}
}
namespace WeablesMod.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void infiniteSprintPatch(ref float ___sprintMeter)
		{
			___sprintMeter = 1f;
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		[HarmonyPatch("OnSubmit")]
		[HarmonyPrefix]
		private static void addRandomMoonOption(ref Terminal __instance, out TerminalOptions __state)
		{
			__state = new TerminalOptions();
			string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded).ToLower();
			if (text == "weablesmod")
			{
				__state.displayMenu = true;
			}
			switch (text)
			{
			default:
				if (!(text == "rndm"))
				{
					break;
				}
				goto case "random";
			case "random":
			case "rando":
			case "rand":
			case "ran":
			case "rnd":
			{
				Random random = new Random();
				string[] array = new string[8] { "Experimental", "Assurance", "Vow", "Offense", "March", "Rend", "Dine", "Titan" };
				int groupCredits = __instance.groupCredits;
				int num = groupCredits;
				int num2;
				if (num < 550)
				{
					num2 = random.Next(0, 5);
				}
				else
				{
					int num3 = num;
					if (num3 < 600)
					{
						num2 = 5;
					}
					else
					{
						int num4 = num;
						num2 = ((num4 >= 700) ? random.Next(5, 8) : random.Next(5, 7));
					}
				}
				__instance.screenText.SetTextWithoutNotify(array[num2]);
				__instance.textAdded = array[num2].Length;
				break;
			}
			}
			if (text == "randomall")
			{
				Random random2 = new Random();
				string[] array2 = new string[8] { "Experimental", "Assurance", "Vow", "Offense", "March", "Rend", "Dine", "Titan" };
				int num5 = random2.Next(0, 8);
				__instance.screenText.SetTextWithoutNotify(array2[num5]);
				__instance.textAdded = array2[num5].Length;
			}
		}

		[HarmonyPatch("OnSubmit")]
		[HarmonyPostfix]
		private static void displayModOptions(ref Terminal __instance, TerminalOptions __state)
		{
			if (__state.displayMenu)
			{
				string text = "\n\n  Welcome to WeablesMod!\n\n";
				text += "> Random - Select your next destination at random! Will only choose free moons until you can afford later moons, then will only choose those.\n\n";
				text += "> RandomAll - Select your next destination at random! Has no regard for travel fees.\n\n";
				__instance.screenText.SetTextWithoutNotify(text);
				__instance.screenText.text = __instance.screenText.text.Substring(0, __instance.screenText.text.Length - __instance.textAdded);
				__instance.currentText = __instance.screenText.text;
				__instance.textAdded = 0;
				__instance.screenText.ActivateInputField();
				((Selectable)__instance.screenText).Select();
			}
		}
	}
}