Decompiled source of Lethal Fetch v1.0.0

LethalFetch.dll

Decompiled a week 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;
using BepInEx;
using BepInEx.Logging;
using LethalAPI.LibTerminal;
using LethalAPI.LibTerminal.Attributes;
using LethalAPI.LibTerminal.Models;
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("LethalFetch")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalFetch")]
[assembly: AssemblyTitle("LethalFetch")]
[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 LethalFetch
{
	[BepInPlugin("LethalFetch", "LethalFetch", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private TerminalModRegistry Commands;

		internal static ManualLogSource Logger;

		private string[] AsciiArt = new string[8] { " ╭—————╮ ", "╭ ╭———╮ ╮", "| |   | |", "╰ ╰———╯ ╯", "╭—╮   ╭—╮", "| |   | |", "╰—╯——-╰—╯", "╭———————╮" };

		private string[] SystemInfo = new string[8] { " OS: FORTUNE-9", " CPU: BORSON 300 CPU @ 2.5GHz", " MEMORY: 4.52GB", " ", " MOON: ", " NUM_LOOT: ", " VAL_LOOT: ", " EMPLOYEES: " };

		private string GetMoon()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			RoundManager val = Resources.FindObjectsOfTypeAll<RoundManager>()[0];
			SelectableLevel currentLevel = val.currentLevel;
			LevelWeatherType currentWeather = currentLevel.currentWeather;
			if ((int)currentWeather == -1)
			{
				return currentLevel.PlanetName;
			}
			return currentLevel.PlanetName + " (" + ((object)(LevelWeatherType)(ref currentWeather)).ToString() + ")";
		}

		private string CountScrapValue()
		{
			RoundManager val = Resources.FindObjectsOfTypeAll<RoundManager>()[0];
			return $"{val.valueOfFoundScrapItems}/{val.totalScrapValueInLevel}";
		}

		private string CountPlayers()
		{
			StartOfRound val = Resources.FindObjectsOfTypeAll<StartOfRound>()[0];
			return $"{val.livingPlayers}/{val.connectedPlayersAmount + 1}";
		}

		private string CountScrap()
		{
			AllItemsList val = Resources.FindObjectsOfTypeAll<AllItemsList>()[0];
			int count = val.itemsList.Count;
			int num = 5;
			GrabbableObject[] array = Resources.FindObjectsOfTypeAll<GrabbableObject>();
			int num2 = 0;
			int num3 = 0;
			RoundManager val2 = Resources.FindObjectsOfTypeAll<RoundManager>()[0];
			GrabbableObject[] array2 = array;
			foreach (GrabbableObject val3 in array2)
			{
				if (!val3.scrapPersistedThroughRounds)
				{
					num2++;
				}
			}
			num2 -= count;
			num2 -= num;
			num3 = val2.scrapCollectedInLevel;
			return $"{num3}/{num2}";
		}

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin LethalFetch is loaded!");
			Commands = TerminalRegistry.CreateTerminalRegistry();
			Commands.RegisterFrom<Plugin>(this);
		}

		[TerminalCommand("fetch", true)]
		[CommandInfo("Show system and day info.", "")]
		public string fetchCommand()
		{
			return fetch();
		}

		[TerminalCommand("lethalfetch", true)]
		[CommandInfo("Show system and day info.", "")]
		public string lethalFetchCommand()
		{
			return fetch();
		}

		public string fetch()
		{
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < 8; i++)
			{
				string text = "         ";
				if (i < AsciiArt.Length)
				{
					text = AsciiArt[i];
				}
				string text2 = "";
				if (i < SystemInfo.Length)
				{
					text2 = SystemInfo[i];
				}
				string text3 = "";
				switch (i)
				{
				case 4:
					text3 = GetMoon();
					break;
				case 5:
					text3 = CountScrap();
					break;
				case 6:
					text3 = CountScrapValue();
					break;
				case 7:
					text3 = CountPlayers();
					break;
				}
				stringBuilder.AppendLine(text + text2 + text3);
			}
			return stringBuilder.ToString();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LethalFetch";

		public const string PLUGIN_NAME = "LethalFetch";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}