nukemod.dll

Decompiled 2 weeks 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.2.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 ConfigEntry<float> waitfordmg;

	private const string daeffname = "E_ExplosionGrenade";

	private static GameObject effobj;

	private void Awake()
	{
		whichkeymakesboom = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("general", "nukekey", (KeyCode)282, "the key that triggers the nuke");
		thefbiwillplayitoff = ((BaseUnityPlugin)this).Config.Bind<int>("general", "maxexplosions", 40, "the max explosions per nuke. the actual end amount depends on units in area that can be exploded");
		howbigisit = ((BaseUnityPlugin)this).Config.Bind<float>("boom", "explosionradius", 6f, "size of each explosion");
		howhardhitter = ((BaseUnityPlugin)this).Config.Bind<float>("boom", "explosiondamage", 150f, "the base damage that is done by each explosion");
		howbigofpush = ((BaseUnityPlugin)this).Config.Bind<float>("boom", "explosionforce", 40f, "knockback force of each explosion at base");
		pauseeeeee = ((BaseUnityPlugin)this).Config.Bind<float>("general", "delaybetweenexplosions", 0.08f, "seconds between each explosion (delay)");
		whereeventhedoshoulddie = ((BaseUnityPlugin)this).Config.Bind<float>("general", "fallbackspreadradius", 30f, "spread used if ZERO units are there");
		waitfordmg = ((BaseUnityPlugin)this).Config.Bind<float>("boom", "damagedelay", 0.5f, "seconds between the knockback happening and the damage actually happening. set higher than 0 if you want them to get flung first");
	}

	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_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: 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)(object)array[i] != (Object)null)
				{
					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_003a: 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)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Expected O, but got Unknown
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = doeffects();
		GameObject val2;
		Explosion val3;
		if ((Object)(object)val != (Object)null)
		{
			val2 = Object.Instantiate<GameObject>(val, spot, Quaternion.identity);
			((Object)val2).name = "zeronukeexplosion";
			val2.transform.localScale = Vector3.one * (howbigisit.Value / 6f);
			val3 = val2.GetComponentInChildren<Explosion>();
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = val2.AddComponent<Explosion>();
			}
			ObjectException[] components = ((Component)val3).GetComponents<ObjectException>();
			for (int i = 0; i < components.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)components[i]);
			}
			ExplosionEffect[] components2 = ((Component)val3).GetComponents<ExplosionEffect>();
			for (int i = 0; i < components2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)components2[i]);
			}
		}
		else
		{
			val2 = new GameObject("zeronukeexplosion");
			val2.transform.position = spot;
			val3 = val2.AddComponent<Explosion>();
		}
		val3.damage = 0f;
		val3.radius = howbigisit.Value;
		val3.force = howbigofpush.Value;
		val3.forceDirection = (ForceDirection)0;
		val3.layerMask = LayerMask.op_Implicit(-1);
		val3.ignoreRoot = false;
		val3.ignoreTeamMates = false;
		val3.minMassCap = 1f;
		explosivethingies(val3);
		Collider[] array = Physics.OverlapSphere(((Component)val3).transform.position, val3.radius, -1);
		int num = 0;
		Collider[] array2 = array;
		for (int i = 0; i < array2.Length; i++)
		{
			if ((Object)(object)array2[i].attachedRigidbody != (Object)null)
			{
				num++;
			}
		}
		Debug.Log((object)$"[zeronuke] pos={((Component)val3).transform.position} radius={val3.radius} force={val3.force} minMassCap={val3.minMassCap} exceptions={((Component)val3).GetComponents<ObjectException>().Length} colliders={array.Length} withRigidbodies={num}");
		val3.Explode();
		Object.Destroy((Object)(object)val2, 2f);
		if (waitfordmg.Value > 0f)
		{
			((MonoBehaviour)this).StartCoroutine(thepainarriveslater(spot));
		}
		else
		{
			dodamageonlyexplosion(spot);
		}
	}

	private IEnumerator thepainarriveslater(Vector3 spot)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		yield return (object)new WaitForSeconds(waitfordmg.Value);
		dodamageonlyexplosion(spot);
	}

	private void dodamageonlyexplosion(Vector3 spot)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: 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_0016: 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_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Expected O, but got Unknown
		GameObject val = new GameObject("zeronukedamageonly");
		val.transform.position = spot;
		Explosion val2 = val.AddComponent<Explosion>();
		val2.damage = howhardhitter.Value;
		val2.radius = howbigisit.Value;
		val2.force = 0f;
		val2.forceDirection = (ForceDirection)0;
		val2.layerMask = LayerMask.op_Implicit(-1);
		val2.ignoreRoot = false;
		val2.ignoreTeamMates = false;
		explosivethingies(val2);
		val2.Explode();
		Object.Destroy((Object)val, 0.1f);
	}

	private static GameObject doeffects()
	{
		if ((Object)(object)effobj != (Object)null)
		{
			return effobj;
		}
		Explosion[] array = Resources.FindObjectsOfTypeAll<Explosion>();
		foreach (Explosion val in array)
		{
			if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null && ((Object)((Component)val).gameObject).name == "E_ExplosionGrenade")
			{
				effobj = ((Component)val).gameObject;
				return effobj;
			}
		}
		return null;
	}

	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));
			}
		}
	}
}