Decompiled source of Fridos Smart Ping v1.2.6

FridosSmartPing.dll

Decompiled a month ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AK;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Localization;
using Microsoft.CodeAnalysis;
using Player;
using TMPro;
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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("FridosSmartPing")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+gitbf09de6-dirty-master.bf09de620f8c2e29a882a73cf3f433ab5717dd05")]
[assembly: AssemblyProduct("FridosSmartPing")]
[assembly: AssemblyTitle("FridosSmartPing")]
[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 FridosSmartPing
{
	internal static class Logger
	{
		private static readonly ManualLogSource _Logger;

		static Logger()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_Logger = new ManualLogSource("FridosSmartPing");
			Logger.Sources.Add((ILogSource)(object)_Logger);
		}

		private static string Format(object msg)
		{
			return msg.ToString();
		}

		public static void Info(BepInExInfoLogInterpolatedStringHandler handler)
		{
			_Logger.LogInfo(handler);
		}

		public static void Info(string str)
		{
			_Logger.LogMessage((object)str);
		}

		public static void Info(object data)
		{
			_Logger.LogMessage((object)Format(data));
		}

		public static void Debug(BepInExDebugLogInterpolatedStringHandler handler)
		{
			_Logger.LogDebug(handler);
		}

		public static void Debug(string str)
		{
			_Logger.LogDebug((object)str);
		}

		public static void Debug(object data)
		{
			_Logger.LogDebug((object)Format(data));
		}

		public static void Error(BepInExErrorLogInterpolatedStringHandler handler)
		{
			_Logger.LogError(handler);
		}

		public static void Error(string str)
		{
			_Logger.LogError((object)str);
		}

		public static void Error(object data)
		{
			_Logger.LogError((object)Format(data));
		}

		public static void Fatal(BepInExFatalLogInterpolatedStringHandler handler)
		{
			_Logger.LogFatal(handler);
		}

		public static void Fatal(string str)
		{
			_Logger.LogFatal((object)str);
		}

		public static void Fatal(object data)
		{
			_Logger.LogFatal((object)Format(data));
		}

		public static void Warn(BepInExWarningLogInterpolatedStringHandler handler)
		{
			_Logger.LogWarning(handler);
		}

		public static void Warn(string str)
		{
			_Logger.LogWarning((object)str);
		}

		public static void Warn(object data)
		{
			_Logger.LogWarning((object)Format(data));
		}

		[Conditional("DEBUG")]
		public static void DebugOnly(object data)
		{
			_Logger.LogDebug((object)Format(data));
		}
	}
	[BepInPlugin("com.fridos.smartping", "FridosSmartPing", "1.2.6")]
	public class SmartPing : BasePlugin
	{
		public static List<ItemInLevel> itemList = new List<ItemInLevel>();

		public Harmony HarmonyInstance { get; private set; }

		public static void Initialize()
		{
			itemList.Clear();
			Logger.Info("Init SmartPing and preparing.");
			foreach (ItemInLevel item in Object.FindObjectsOfType<ItemInLevel>())
			{
				if (!((Object)(object)item != (Object)null))
				{
					continue;
				}
				LG_GenericTerminalItem componentInChildren = ((Component)item).GetComponentInChildren<LG_GenericTerminalItem>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					string terminalItemKey = componentInChildren.TerminalItemKey;
					if (terminalItemKey != null && (terminalItemKey.Contains("PACK") || terminalItemKey.StartsWith("TOOL_REFILL") || terminalItemKey.StartsWith("DISINFECT") || terminalItemKey.StartsWith("KEY_") || terminalItemKey.StartsWith("PID_") || terminalItemKey.StartsWith("BULKHEAD_KEY_") || terminalItemKey.StartsWith("DATA_CUBE_") || terminalItemKey.StartsWith("CELL_") || terminalItemKey.StartsWith("FOG_TURBINE") || terminalItemKey.StartsWith("GLP_") || terminalItemKey.StartsWith("PD_") || terminalItemKey.StartsWith("OSIP_") || terminalItemKey.StartsWith("HDD_") || terminalItemKey.StartsWith("PLANT_") || terminalItemKey.StartsWith("ID_") || terminalItemKey.StartsWith("HISEC_") || terminalItemKey.StartsWith("MATTER_WAVE")))
					{
						itemList.Add(item);
					}
				}
			}
		}

		public override void Load()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			Logger.Info("Fridos Smart Ping enabled!");
			HarmonyInstance = new Harmony("com.fridos.smartping");
			HarmonyInstance.PatchAll();
			LG_Factory.OnFactoryBuildDone += Action.op_Implicit((Action)Initialize);
		}
	}
	[HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "SetupCommands")]
	public class SmartPingPatch
	{
		private static void Postfix(LG_ComputerTerminalCommandInterpreter __instance)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			__instance.AddCommand((TERM_Command)10, "SMARTPING", new LocalizedText
			{
				UntranslatedText = "Ping items inside the current zone",
				Id = 0u
			}, (TERM_CommandRule)0);
		}
	}
	[HarmonyPatch(typeof(ItemInLevel), "OnPickedUp")]
	public class RemoveNavMarkerPatch
	{
		private static void Postfix(ItemInLevel __instance, PlayerAgent player, InventorySlot slot, AmmoType ammoType)
		{
			LG_GenericTerminalItem componentInChildren = ((Component)__instance).GetComponentInChildren<LG_GenericTerminalItem>();
			if (!((Object)(object)componentInChildren != (Object)null))
			{
				return;
			}
			string terminalItemKey = componentInChildren.TerminalItemKey;
			if (terminalItemKey == null)
			{
				return;
			}
			Enumerator<NavMarker> enumerator = GuiManager.NavMarkerLayer.m_markersActive.GetEnumerator();
			while (enumerator.MoveNext())
			{
				NavMarker current = enumerator.Current;
				if ((Object)(object)current != (Object)null && (Object)(object)current.m_title != (Object)null && ((TMP_Text)current.m_title).text != null && ((TMP_Text)current.m_title).text.Contains(componentInChildren.TerminalItemKey))
				{
					current.SetVisible(false);
					current.SetState((NavMarkerState)0);
					break;
				}
			}
		}
	}
	[HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "ReceiveCommand")]
	public class SmartPingOverridePatch
	{
		private static bool Prefix(LG_ComputerTerminalCommandInterpreter __instance, TERM_Command cmd, string inputLine, string param1, string param2)
		{
			LG_ComputerTerminalCommandInterpreter __instance2 = __instance;
			string param3 = param1;
			if (inputLine.StartsWith("SMARTPING"))
			{
				__instance2.m_linesSinceCommand = 0;
				__instance2.m_terminal.IsWaitingForAnyKeyInLinePause = false;
				__instance2.AddOutput(__instance2.NewLineStart() + inputLine, false);
				__instance2.AddOutput(__instance2.NewLineStart() + "  ____                       _     ____  _             ", false);
				__instance2.AddOutput(__instance2.NewLineStart() + " / ___| _ __ ___   __ _ _ __| |_  |  _ \\(_)_ __   __ _ ", false);
				__instance2.AddOutput(__instance2.NewLineStart() + " \\___ \\| '_ ` _ \\ / _` | '__| __| | |_) | | '_ \\ / _` |", false);
				__instance2.AddOutput(__instance2.NewLineStart() + "  ___) | | | | | | (_| | |  | |_  |  __/| | | | | (_| |", false);
				__instance2.AddOutput(__instance2.NewLineStart() + " |____/|_| |_| |_|\\__,_|_|   \\__| |_|   |_|_| |_|\\__, |", false);
				__instance2.AddOutput(__instance2.NewLineStart() + "                                                 |___/ ", false);
				__instance2.AddOutput(__instance2.NewLineStart() + "          by LolBit & Frido                            ", false);
				__instance2.AddOutput(__instance2.NewLineStart(), false);
				__instance2.AddOutput((TerminalLineType)4, __instance2.NewLineStart() + "Initalizing Fridos Smart Ping™...", 5f, (TerminalSoundType)0, (TerminalSoundType)0);
				__instance2.OnEndOfQueue = Action.op_Implicit((Action)delegate
				{
					//IL_0023: Unknown result type (might be due to invalid IL or missing references)
					//IL_0028: Unknown result type (might be due to invalid IL or missing references)
					//IL_002e: Invalid comparison between Unknown and I4
					//IL_0290: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
					int num = 0;
					foreach (ItemInLevel item in SmartPing.itemList)
					{
						if ((int)item.internalSync.GetCurrentState().status != 1)
						{
							string value = "ZONE_" + __instance2.m_terminal.SpawnNode.m_zone.NavInfo.Number;
							LG_GenericTerminalItem componentInChildren = ((Component)item).GetComponentInChildren<LG_GenericTerminalItem>();
							string terminalItemKey = componentInChildren.TerminalItemKey;
							try
							{
								if (terminalItemKey.ToLower().Contains(param3) && componentInChildren.FloorItemLocation.Contains(value))
								{
									NavMarker val = GuiManager.NavMarkerLayer.PrepareGenericMarker(((Component)item).gameObject);
									val.PersistentBetweenRestarts = false;
									if (((Item)item).GetCustomData().ammo >= 20f)
									{
										val.SetTitle(terminalItemKey + "\n(" + ((Item)item).GetCustomData().ammo / 20f + " Uses)");
									}
									else
									{
										val.SetTitle(terminalItemKey);
									}
									if (terminalItemKey.StartsWith("MEDIPACK"))
									{
										val.SetStyle((eNavMarkerStyle)4);
									}
									else if (terminalItemKey.StartsWith("AMMOPACK"))
									{
										val.SetStyle((eNavMarkerStyle)3);
									}
									else if (terminalItemKey.StartsWith("TOOL_REFILL"))
									{
										val.SetStyle((eNavMarkerStyle)21);
									}
									else if (terminalItemKey.StartsWith("DISINFECT_PACK"))
									{
										val.SetStyle((eNavMarkerStyle)17);
									}
									else if (terminalItemKey.StartsWith("KEY_"))
									{
										val.SetStyle((eNavMarkerStyle)20);
									}
									else
									{
										val.SetStyle((eNavMarkerStyle)5);
									}
									val.SetIconScale(0.4f);
									val.SetAlpha(0.4f);
									val.SetVisible(true);
									val.FadeOutOverTime(20f, 10f);
									val.m_fadeRoutine = CoroutineManager.StartCoroutine(GuiManager.NavMarkerLayer.FadeMarkerOverTime(val, ((Object)val).name, Random.Range(0.1f, 0.5f), 30f, false), (Action)null);
									num++;
								}
							}
							catch (Exception data)
							{
								Logger.Error((object)data);
							}
						}
					}
					CellSound.Post(EVENTS.TERMINAL_PING_MARKER_SFX, ((Component)__instance2.m_terminal).transform.position);
					__instance2.AddOutput(__instance2.NewLineStart() + "Fridos Smart Ping™ has finished and pinged a total of " + num + " items.", false);
				});
				return false;
			}
			return true;
		}
	}
	[GeneratedCode("VersionInfoGenerator", "2.0.0+git50a4b1a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "FridosSmartPing";

		public const string Version = "1.0.0";

		public const string VersionPrerelease = null;

		public const string VersionMetadata = "gitbf09de6-dirty-master";

		public const string SemVer = "1.0.0+gitbf09de6-dirty-master";

		public const string GitRevShort = "bf09de6-dirty";

		public const string GitRevLong = "bf09de620f8c2e29a882a73cf3f433ab5717dd05-dirty";

		public const string GitBranch = "master";

		public const string GitTag = null;

		public const bool GitIsDirty = true;
	}
}