nukemod.dll

Decompiled 10 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Landfall.TABS;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Tabs Poof Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Tabs Poof Mod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8aad4f38-2ad4-4206-bf0b-7d28fb6d5c2e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace zeronuke;

[BepInPlugin("tabs.bayturtleking.zero", "Zero", "1.0.0")]
public class thebigredbutton : BaseUnityPlugin
{
	private ConfigEntry<KeyCode> whichkeymakesboom;

	private ConfigEntry<int> thefbiwillplayitoff;

	private ConfigEntry<float> howbigisit;

	private ConfigEntry<float> howhardhitter;

	private ConfigEntry<float> howbigofpush;

	private ConfigEntry<float> pauseeeeee;

	private ConfigEntry<float> whereeventhedoshoulddie;

	private static GameObject stolengoodsfromthegame;

	private static readonly string[] explosivehints = new string[9] { "tnt", "explosive", "explosion_tnt", "bomb", "grenade", "dynamite", "barrel_explo", "powderkeg", "keg" };

	private static readonly string[] notwhatwewant = new string[10] { "boulder", "cannonball", "cannon", "rock", "arrow", "spear", "ballista", "catapult", "projectile", "impact" };

	private void Awake()
	{
		whichkeymakesboom = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("general", "nukekey", (KeyCode)112, "the key that triggers the nuke");
		thefbiwillplayitoff = ((BaseUnityPlugin)this).Config.Bind<int>("general", "maxexplosions", 40, "the max explosions per nuke");
		howbigisit = ((BaseUnityPlugin)this).Config.Bind<float>("boom", "explosionradius", 6f, "size of each explosion");
		howhardhitter = ((BaseUnityPlugin)this).Config.Bind<float>("boom", "explosiondamage", 150f, "damage done by each explosion");
		howbigofpush = ((BaseUnityPlugin)this).Config.Bind<float>("boom", "explosionforce", 40f, "knockback force of each explosion");
		pauseeeeee = ((BaseUnityPlugin)this).Config.Bind<float>("general", "delaybetweenexplosions", 0.08f, "seconds between each explosion");
		whereeventhedoshoulddie = ((BaseUnityPlugin)this).Config.Bind<float>("general", "fallbackspreadradius", 30f, "spread used if ZERO units are there");
	}

	private void Update()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKeyDown(whichkeymakesboom.Value))
		{
			((MonoBehaviour)this).StartCoroutine(theywillwishtheydidntdothis());
		}
	}

	private IEnumerator theywillwishtheydidntdothis()
	{
		List<Vector3> list = rounduptheunfortunatepeoples();
		foreach (Vector3 item in list)
		{
			dosomearsonheree(item);
			if (pauseeeeee.Value > 0f)
			{
				yield return (object)new WaitForSeconds(pauseeeeee.Value);
			}
		}
	}

	private List<Vector3> rounduptheunfortunatepeoples()
	{
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		List<Vector3> list = new List<Vector3>();
		Unit[] array = Object.FindObjectsOfType<Unit>();
		if (array.Length != 0)
		{
			int num = Mathf.Min(array.Length, thefbiwillplayitoff.Value);
			for (int i = 0; i < num; i++)
			{
				if (Object.op_Implicit((Object)(object)array[i]))
				{
					list.Add(((Component)array[i]).transform.position);
				}
			}
		}
		else
		{
			int num2 = Mathf.Min(12, thefbiwillplayitoff.Value);
			for (int j = 0; j < num2; j++)
			{
				list.Add(youarentveryluckyifyouarehere(whereeventhedoshoulddie.Value));
			}
		}
		return list;
	}

	private Vector3 youarentveryluckyifyouarehere(float radius)
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(Random.Range(0f - radius, radius), 200f, Random.Range(0f - radius, radius));
		int mask = LayerMask.GetMask(new string[1] { "Map" });
		RaycastHit val2 = default(RaycastHit);
		if (Physics.Raycast(val, Vector3.down, ref val2, 1000f, mask))
		{
			return ((RaycastHit)(ref val2)).point + Vector3.up;
		}
		return new Vector3(val.x, 1f, val.z);
	}

	private void dosomearsonheree(Vector3 spot)
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = letsjustguessiguess();
		GameObject val2;
		Explosion val3;
		if ((Object)(object)val != (Object)null)
		{
			val2 = Object.Instantiate<GameObject>(val, spot, Quaternion.identity);
			((Object)val2).name = "zeronukeexplosion";
			val3 = val2.GetComponentInChildren<Explosion>();
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = val2.AddComponent<Explosion>();
			}
		}
		else
		{
			val2 = new GameObject("zeronukeexplosion");
			val2.transform.position = spot;
			val3 = val2.AddComponent<Explosion>();
		}
		val3.damage = howhardhitter.Value;
		val3.radius = howbigisit.Value;
		val3.force = howbigofpush.Value;
		val3.forceDirection = (ForceDirection)0;
		val3.layerMask = LayerMask.op_Implicit(-1);
		val3.ignoreRoot = false;
		val3.ignoreTeamMates = false;
		explosivethingies(val3);
		val3.Explode();
		Object.Destroy((Object)(object)val2, 2f);
	}

	private static GameObject letsjustguessiguess()
	{
		if ((Object)(object)stolengoodsfromthegame != (Object)null)
		{
			return stolengoodsfromthegame;
		}
		GameObject val = null;
		GameObject val2 = null;
		Explosion[] array = Resources.FindObjectsOfTypeAll<Explosion>();
		foreach (Explosion val3 in array)
		{
			if ((Object)(object)val3 == (Object)null || (Object)(object)((Component)val3).gameObject == (Object)null || ((Object)((Component)val3).gameObject).name == "zeronukeexplosion" || (Object)(object)((Component)val3).GetComponentInParent<Unit>() != (Object)null)
			{
				continue;
			}
			bool num = (Object)(object)((Component)val3).GetComponentInChildren<ParticleSystem>(true) != (Object)null;
			bool flag = (Object)(object)((Component)val3).GetComponentInChildren<PlaySoundEffect>(true) != (Object)null || (Object)(object)((Component)val3).GetComponentInChildren<AudioSource>(true) != (Object)null;
			if (!num && !flag)
			{
				continue;
			}
			string text = ((Object)((Component)val3).gameObject).name.ToLowerInvariant();
			bool flag2 = false;
			string[] array2 = notwhatwewant;
			foreach (string value in array2)
			{
				if (text.Contains(value))
				{
					flag2 = true;
					break;
				}
			}
			if (flag2)
			{
				continue;
			}
			bool flag3 = false;
			array2 = explosivehints;
			foreach (string value2 in array2)
			{
				if (text.Contains(value2))
				{
					flag3 = true;
					break;
				}
			}
			if (flag3 && (Object)(object)val == (Object)null)
			{
				val = ((Component)val3).gameObject;
				break;
			}
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = ((Component)val3).gameObject;
			}
		}
		stolengoodsfromthegame = (((Object)(object)val != (Object)null) ? val : val2);
		return stolengoodsfromthegame;
	}

	private void explosivethingies(Explosion theexplod)
	{
		FieldInfo[] fields = typeof(Explosion).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		foreach (FieldInfo fieldInfo in fields)
		{
			if (typeof(UnityEventBase).IsAssignableFrom(fieldInfo.FieldType) && fieldInfo.GetValue(theexplod) == null)
			{
				fieldInfo.SetValue(theexplod, Activator.CreateInstance(fieldInfo.FieldType));
			}
		}
	}
}