Decompiled source of ExplodeSundling v1.0.0

plugins/ExplodeSundling.dll

Decompiled 2 hours ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ExplodeSundling")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExplodeSundling")]
[assembly: AssemblyTitle("ExplodeSundling")]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ExplodeSundling
{
	[BepInPlugin("com.friendgroup.explodesundling", "ExplodeSundling", "1.0.0")]
	public class ExplodeSundlingPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private readonly Harmony harmony = new Harmony("com.friendgroup.explodesundling");

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll();
			Log.LogInfo((object)"ExplodeSundling v1.0.0 loaded. Sundling doesn't know what's coming.");
		}
	}
	[HarmonyPatch(typeof(Terminal), "OnSubmit")]
	public class TerminalSubmitPatch
	{
		private static bool Prefix(Terminal __instance)
		{
			if (__instance.screenText.text.Split('\n').Last().Trim()
				.ToLower() == "explode alex")
			{
				ExplodeSundlingPlugin.Log.LogInfo((object)"Explode Alex command received. Initiating...");
				TryExplodeSundling();
				TMP_InputField screenText = __instance.screenText;
				screenText.text += "\n\nSending package to Sundling...\n\n>";
				return false;
			}
			return true;
		}

		private static void TryExplodeSundling()
		{
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
			PlayerControllerB val = null;
			PlayerControllerB[] array2 = array;
			foreach (PlayerControllerB val2 in array2)
			{
				if (val2.playerUsername.ToLower().Contains("sundling") && !val2.isPlayerDead && val2.isPlayerControlled)
				{
					val = val2;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				PlayerControllerB[] array3 = array.Where((PlayerControllerB p) => !p.isPlayerDead && p.isPlayerControlled && !((NetworkBehaviour)p).IsOwner).ToArray();
				if (array3.Length != 0)
				{
					val = array3[Random.Range(0, array3.Length)];
					ExplodeSundlingPlugin.Log.LogWarning((object)("No player named Sundling found. Exploding " + val.playerUsername + " instead."));
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				ExplodeSundlingPlugin.Log.LogInfo((object)("Exploding player: " + val.playerUsername));
				Landmine.SpawnExplosion(((Component)val).transform.position, true, 2f, 4f, 50, 0f, (GameObject)null, false);
			}
			else
			{
				ExplodeSundlingPlugin.Log.LogWarning((object)"No valid target found to explode.");
			}
		}
	}
	internal static class PluginInfo
	{
		internal const string PLUGIN_GUID = "com.friendgroup.explodesundling";

		internal const string PLUGIN_NAME = "ExplodeSundling";

		internal const string PLUGIN_VERSION = "1.0.0";
	}
}