Decompiled source of Bout to Blow this whole mf plane v1.0.7

Bout_to_Blow_this_whole_mf_plane.dll

Decompiled a year ago
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Bout_to_Blow_this_whole_mf_plane.Patches;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Bout_to_Blow_this_whole_mf_plane")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Bout_to_Blow_this_whole_mf_plane")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e8606493-6a49-4c81-8b9b-2c59e7e9c83c")]
[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 Bout_to_Bomb_this_whole_mf_plane
{
	[BepInPlugin("Pepeja-Bout_to_Bomb_this_whole_mf_plane", "Bout_to_Bomb_this_whole_mf_plane", "1.0.7")]
	public class TheBomb : BaseUnityPlugin
	{
		private const string modGUID = "Pepeja-Bout_to_Bomb_this_whole_mf_plane";

		private const string modName = "Bout_to_Bomb_this_whole_mf_plane";

		private const string modVersion = "1.0.7";

		private readonly Harmony harmony = new Harmony("Pepeja-Bout_to_Bomb_this_whole_mf_plane");

		private static TheBomb Instance;

		public static ManualLogSource mls;

		public static List<AudioClip> Announcements;

		public static AssetBundle Bundle;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Pepeja-Bout_to_Bomb_this_whole_mf_plane");
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("Bout_to_Bomb_this_whole_mf_plane.dll".ToCharArray());
			Bundle = AssetBundle.LoadFromFile(location + "bomb");
			if ((Object)(object)Bundle != (Object)null)
			{
				mls.LogInfo((object)"Bomb has been planted.");
				Announcements = Bundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogError((object)"Bomb has been defused.");
			}
			harmony.PatchAll();
		}
	}
}
namespace Bout_to_Bomb_this_whole_mf_plane.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch : MonoBehaviour
	{
		private static AudioSource speaker;

		private static Vector3 pos;

		private static IEnumerator Explode(int type)
		{
			switch (type)
			{
			case 0:
			{
				yield return (object)new WaitForSeconds(10f);
				pos = GameObject.Find("StartGameLever").transform.position;
				for (int x = 0; x < 8; x++)
				{
					((Vector3)(ref pos)).Set(pos.x - 4f, pos.y, pos.z);
					Landmine.SpawnExplosion(pos, true, 5f, 5f);
				}
				break;
			}
			case 1:
			{
				yield return (object)new WaitForSeconds(12.3f);
				pos = GameObject.Find("StartGameLever").transform.position;
				((Vector3)(ref pos)).Set(pos.x + 10f, pos.y, pos.z - 5f);
				for (int y = 0; y < 2; y++)
				{
					for (int z = 0; z < 3; z++)
					{
						if (y != 0 || z != 1)
						{
							for (int x2 = 0; x2 < 10; x2++)
							{
								((Vector3)(ref pos)).Set(pos.x - 4f, pos.y, pos.z);
								Landmine.SpawnExplosion(pos, true, 5f, 5f);
							}
							((Vector3)(ref pos)).Set(pos.x + 40f, pos.y, pos.z + 5f);
						}
						else
						{
							((Vector3)(ref pos)).Set(pos.x, pos.y, pos.z + 5f);
						}
					}
					((Vector3)(ref pos)).Set(pos.x, pos.y + 7f, pos.z - 15f);
				}
				break;
			}
			case 2:
			{
				yield return (object)new WaitForSeconds(3.8f);
				pos = GameObject.Find("StartGameLever").transform.position;
				((Vector3)(ref pos)).Set(pos.x - 4f, pos.y, pos.z);
				Landmine.SpawnExplosion(pos, true, 5f, 5f);
				yield return (object)new WaitForSeconds(1.5f);
				pos = GameObject.Find("StartGameLever").transform.position;
				((Vector3)(ref pos)).Set(pos.x, pos.y, pos.z - 5f);
				for (int z3 = 0; z3 <= 3; z3++)
				{
					if (z3 != 1)
					{
						for (int x3 = 0; x3 < 9; x3++)
						{
							((Vector3)(ref pos)).Set(pos.x - 4f, pos.y, pos.z);
							Landmine.SpawnExplosion(pos, true, 5f, 5f);
						}
						((Vector3)(ref pos)).Set(pos.x + 36f, pos.y, pos.z + 5f);
					}
					else
					{
						((Vector3)(ref pos)).Set(pos.x, pos.y, pos.z + 5f);
					}
				}
				yield return (object)new WaitForSeconds(4.5f);
				pos = GameObject.Find("StartGameLever").transform.position;
				((Vector3)(ref pos)).Set(pos.x, pos.y, pos.z - 5f);
				for (int y2 = 0; y2 < 2; y2++)
				{
					for (int z2 = 0; z2 < 3; z2++)
					{
						for (int x4 = 0; x4 < 9; x4++)
						{
							((Vector3)(ref pos)).Set(pos.x - 4f, pos.y, pos.z);
							Landmine.SpawnExplosion(pos, true, 5f, 5f);
						}
						((Vector3)(ref pos)).Set(pos.x + 36f, pos.y, pos.z + 5f);
					}
					((Vector3)(ref pos)).Set(pos.x, pos.y + 7f, pos.z - 15f);
				}
				yield return (object)new WaitForSeconds(1f);
				pos = GameObject.Find("StartGameLever").transform.position;
				((Vector3)(ref pos)).Set(pos.x - 4f, pos.y, pos.z);
				Landmine.SpawnExplosion(pos, true, 5f, 5f);
				yield return (object)new WaitForSeconds(0.1f);
				pos = GameObject.Find("StartGameLever").transform.position;
				((Vector3)(ref pos)).Set(pos.x - 4f, pos.y, pos.z);
				Landmine.SpawnExplosion(pos, true, 5f, 5f);
				yield return (object)new WaitForSeconds(0.1f);
				pos = GameObject.Find("StartGameLever").transform.position;
				((Vector3)(ref pos)).Set(pos.x - 4f, pos.y, pos.z);
				Landmine.SpawnExplosion(pos, true, 5f, 5f);
				break;
			}
			}
		}

		[HarmonyPatch("ShipLeave")]
		[HarmonyPostfix]
		public static void Detonate(StartOfRound __instance)
		{
			if (!Object.op_Implicit((Object)(object)speaker))
			{
				speaker = __instance.speakerAudioSource;
			}
			if (__instance.allPlayersDead || !TimeOfDayPatch.explosionImminent)
			{
				return;
			}
			int num = -1;
			if (TimeOfDayPatch.quoata > 200 && TimeOfDayPatch.quoata < 350)
			{
				num = 0;
			}
			if (TimeOfDayPatch.quoata > 1100 && TimeOfDayPatch.quoata < 1500)
			{
				num = 1;
			}
			if (TimeOfDayPatch.quoata > 1900 && TimeOfDayPatch.quoata < 2500)
			{
				num = 2;
			}
			if (num != -1 && TimeOfDayPatch.explosionImminent)
			{
				TimeOfDayPatch.explosionImminent = false;
				if (speaker.isPlaying)
				{
					speaker.Stop();
				}
				speaker.PlayOneShot(TheBomb.Announcements[num]);
				((MonoBehaviour)Timer.Instance).StartCoroutine(Explode(num));
			}
		}
	}
	public class Timer : MonoBehaviour
	{
		private static Timer instance;

		public static Timer Instance
		{
			get
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				if ((Object)(object)instance == (Object)null)
				{
					GameObject val = new GameObject("Timer");
					instance = val.AddComponent<Timer>();
				}
				return instance;
			}
		}
	}
}
namespace Bout_to_Blow_this_whole_mf_plane.Patches
{
	[HarmonyPatch(typeof(TimeOfDay), "SetBuyingRateForDay")]
	internal class TimeOfDayPatch
	{
		public static bool explosionImminent;

		public static int quoata;

		[HarmonyPostfix]
		public static void SetBuyingRateForDay(ref int ___daysUntilDeadline, ref int ___profitQuota)
		{
			if (___daysUntilDeadline == 1)
			{
				explosionImminent = true;
				quoata = ___profitQuota;
			}
			else
			{
				explosionImminent = false;
			}
			quoata = ___profitQuota;
		}
	}
}