Decompiled source of ScanForEnemies v1.2.1

EnemyScan.dll

Decompiled a year 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.Text;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using TerminalApi;
using TerminalApi.Events;
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("EnemyScan")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2+6fd060d0b6b3dddc531a9c24ab7473e31cd48b16")]
[assembly: AssemblyProduct("EnemyScan")]
[assembly: AssemblyTitle("EnemyScan")]
[assembly: AssemblyVersion("1.1.2.0")]
[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.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;
		}
	}
	[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 EnemyScan
{
	[BepInPlugin("299792458.EnemyScan", "EnemyScan", "1.2.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class EnemyScan : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static TerminalParseSentenceEventHandler <0>__OnTerminalParsedSentence;
		}

		private const string modGUID = "299792458.EnemyScan";

		private const string modName = "EnemyScan";

		private const string modVersion = "1.2.1";

		private const string DefaultString = "No Enemies Found.\n\n";

		private static TerminalNode _triggerNode;

		private static ManualLogSource _log;

		private void Awake()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			_log = ((BaseUnityPlugin)this).Logger;
			TerminalKeyword val = TerminalApi.CreateTerminalKeyword("list", true, (TerminalNode)null);
			TerminalKeyword val2 = TerminalApi.CreateTerminalKeyword("enemies", false, (TerminalNode)null);
			val2.defaultVerb = val;
			_triggerNode = TerminalApi.CreateTerminalNode("No Enemies Found.\n\n", true, "");
			TerminalExtenstionMethods.AddCompatibleNoun(val, val2, _triggerNode);
			TerminalApi.AddTerminalKeyword(val);
			TerminalApi.AddTerminalKeyword(val2);
			object obj = <>O.<0>__OnTerminalParsedSentence;
			if (obj == null)
			{
				TerminalParseSentenceEventHandler val3 = OnTerminalParsedSentence;
				<>O.<0>__OnTerminalParsedSentence = val3;
				obj = (object)val3;
			}
			Events.TerminalParsedSentence += (TerminalParseSentenceEventHandler)obj;
		}

		private static void OnTerminalParsedSentence(object sender, TerminalParseSentenceEventArgs e)
		{
			if (!((Object)(object)e.ReturnedNode != (Object)(object)_triggerNode))
			{
				_triggerNode.displayText = BuildEnemyCountString();
			}
		}

		private static string BuildEnemyCountString()
		{
			List<IGrouping<string, EnemyAI>> list = (from ai in Object.FindObjectsOfType<EnemyAI>()
				where ((Component)ai).GetComponentInChildren<ScanNodeProperties>() != null
				group ai by ai.enemyType.enemyName into g
				orderby g.Key
				select g).ToList();
			if (list.Count == 0)
			{
				return "No Enemies Found.\n\n";
			}
			StringBuilder stringBuilder = new StringBuilder();
			foreach (IGrouping<string, EnemyAI> item in list)
			{
				stringBuilder.Append(item.Key);
				stringBuilder.Append(": ");
				stringBuilder.AppendLine(item.Count().ToString());
			}
			stringBuilder.AppendLine();
			return stringBuilder.ToString();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "299792458.EnemyScan";

		public const string PLUGIN_NAME = "EnemyScan";

		public const string PLUGIN_VERSION = "1.1.2";
	}
}