Decompiled source of MelkorTerminalPlus v1.0.0

MelkorTerminalPlus.dll

Decompiled 3 months ago
using System;
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 GameNetcodeStuff;
using Microsoft.CodeAnalysis;
using TerminalApi;
using TerminalApi.Events;
using UnityEngine;
using UnityEngine.Events;

[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("MelkorTerminalPlus")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MelkorTerminalPlus")]
[assembly: AssemblyTitle("MelkorTerminalPlus")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace MelkorTerminalPlus
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "melkor.terminalplus";

		public const string PLUGIN_NAME = "MelkorTerminalPlus";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	[BepInPlugin("melkor.terminalplus", "MelkorTerminalPlus", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"MelkorTerminalPlus loaded!");
			Events.TerminalAwake += new TerminalEventHandler(OnTerminalAwake);
			Events.TerminalParsedSentence += new TerminalParseSentenceEventHandler(OnTextSubmitted);
			Events.TerminalBeginUsing += new TerminalEventHandler(OnBeginUsing);
		}

		private void OnTerminalAwake(object sender, TerminalEventArgs e)
		{
			TerminalApi.AddCommand("detailedscan", "Ship is not Landed!\n\n", "ds1", true);
			TerminalApi.AddCommand("dscan", "Ship is not Landed!\n\n", "ds2", true);
			TerminalApi.AddCommand("detscan", "Ship is not Landed!\n\n", "ds3", true);
			TerminalApi.AddCommand("ds", "Ship is not Landed!\n\n", "ds4", true);
			TerminalApi.AddCommand("tp", "Attempting Teleport...\n\n", "tele1", true);
			TerminalApi.AddCommand("teleport", "Attempting Teleport...\n\n", "tele2", true);
			TerminalApi.AddCommand("inverse", "Attempting Inverse Teleport...\n\n", "intele", true);
			TerminalApi.AddCommand("light", "Toggling lights...\n\n", "lightswitch1", true);
			TerminalApi.AddCommand("lights", "Toggling lights...\n\n", "lightswitch2", true);
		}

		private void OnTextSubmitted(object sender, TerminalParseSentenceEventArgs e)
		{
			switch (e.SubmittedText)
			{
			case "tp":
			case "teleport":
			{
				ShipTeleporter[] array2 = Object.FindObjectsOfType<ShipTeleporter>();
				foreach (ShipTeleporter val2 in array2)
				{
					if (!val2.isInverseTeleporter && val2.buttonTrigger.interactable)
					{
						((UnityEvent<PlayerControllerB>)(object)val2.buttonTrigger.onInteract).Invoke(GameNetworkManager.Instance.localPlayerController);
					}
				}
				break;
			}
			case "inverse":
			{
				ShipTeleporter[] array3 = Object.FindObjectsOfType<ShipTeleporter>();
				foreach (ShipTeleporter val3 in array3)
				{
					if (val3.isInverseTeleporter && val3.buttonTrigger.interactable)
					{
						((UnityEvent<PlayerControllerB>)(object)val3.buttonTrigger.onInteract).Invoke(GameNetworkManager.Instance.localPlayerController);
					}
				}
				break;
			}
			case "light":
			case "lights":
			{
				InteractTrigger[] array = Object.FindObjectsOfType<InteractTrigger>();
				foreach (InteractTrigger val in array)
				{
					if (((Object)val).name == "LightSwitch")
					{
						((UnityEvent<PlayerControllerB>)(object)val.onInteract).Invoke(GameNetworkManager.Instance.localPlayerController);
					}
				}
				break;
			}
			}
		}

		private void OnBeginUsing(object sender, TerminalEventArgs e)
		{
			List<GrabbableObject> list = new List<GrabbableObject>();
			int num = 0;
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			foreach (GrabbableObject val in array)
			{
				if (val.itemProperties.isScrap && !val.scrapPersistedThroughRounds && !val.isInShipRoom)
				{
					list.Add(val);
					num += val.scrapValue;
				}
			}
			string arg = string.Join("\n", list.Select((GrabbableObject x) => $"{x.itemProperties.itemName} : {x.scrapValue} Value"));
			string text = $"Items not in ship: {list.Count}\n\n{arg}\n\nWith a total value of: {num}\n\n";
			TerminalNode val2 = TerminalApi.CreateTerminalNode(text, true, "");
			TerminalApi.UpdateKeywordCompatibleNoun("ds1", "detailedscan", val2);
			TerminalApi.UpdateKeywordCompatibleNoun("ds2", "dscan", val2);
			TerminalApi.UpdateKeywordCompatibleNoun("ds3", "detscan", val2);
			TerminalApi.UpdateKeywordCompatibleNoun("ds4", "ds", val2);
		}
	}
}