Decompiled source of Bloons v1.0.2

Bloons.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Receiver2;
using SimpleJSON;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("Bloons")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Balloons!")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Bloons")]
[assembly: AssemblyTitle("Bloons")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 Bloons
{
	public abstract class BaseBalloon : MonoBehaviour
	{
		public abstract bool OnShoot(ref Balloon instance, ref ShootableQuery query);

		public abstract bool OnTouch(ref Balloon instance, Collider collider);

		public virtual void OnStart(ref Balloon instance)
		{
		}

		public void Start()
		{
			Balloon instance = ((Component)this).GetComponentInParent<Balloon>();
			OnStart(ref instance);
		}

		protected int bonus()
		{
			return Random.Range(0, 2);
		}

		public virtual void GetPersistentData(ref Balloon instance, ref JSONObject result)
		{
		}

		public virtual void SetPersistentData(ref Balloon instance, JSONObject data)
		{
		}

		public static void CustomPop(Balloon __instance, ShootableQuery shootable_query, int min, int max)
		{
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.IsPopped)
			{
				return;
			}
			int num = Random.Range(min, max);
			if ((Object)(object)ReceiverCoreScript.Instance().RoundPrefab != (Object)null)
			{
				for (int i = 0; i < num; i++)
				{
					ShellCasingScript component = Object.Instantiate<GameObject>(ReceiverCoreScript.Instance().RoundPrefab).GetComponent<ShellCasingScript>();
					((Component)component).transform.position = ((Component)__instance).transform.position + Random.insideUnitSphere * 0.1f;
					((Component)component).transform.rotation = Random.rotationUniform;
					((InventoryItem)component).item_owner_id = -1;
					((Component)component).GetComponent<InventoryItem>().Move((InventorySlot)null);
					if (ReceiverCoreScript.Instance().IsPlayerAlive())
					{
						LocalAimHandler.player_instance.PickUpBullet((InventoryItem)(object)component, (List<InventoryItem>)null);
					}
				}
			}
			AudioManager.PlayOneShot3D(__instance.balloon_pop, ((Component)__instance).transform.position, 1f, 1f);
			ReceiverEvents.TriggerEvent(new EntityDestroyed
			{
				shootable_query = shootable_query,
				entity_type = (ReceiverEntityType)7,
				game_object = ((Component)__instance).gameObject
			});
			Object.Instantiate<GameObject>(__instance.pop_prefab, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
			__instance.SetPopped();
		}
	}
	public class BlinkBalloon : BaseBalloon
	{
		private float next_time;

		private bool on;

		public override void OnStart(ref Balloon instance)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)instance == (Object)null) && !instance.IsPopped)
			{
				next_time = Time.time + 0.5f;
				on = false;
				((Component)instance).GetComponentInChildren<Renderer>().material.color = Color.yellow;
				((Component)instance).GetComponentInChildren<Renderer>().material.EnableKeyword("_EMISSION");
				((Component)instance).GetComponentInChildren<Renderer>().material.SetColor("_EmissionColor", Color.black);
			}
		}

		public void Update()
		{
			//IL_0061: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			if (Time.frameCount % 5 != 0)
			{
				return;
			}
			Balloon componentInParent = ((Component)this).GetComponentInParent<Balloon>();
			if (!((Object)(object)componentInParent == (Object)null) && !componentInParent.IsPopped)
			{
				if (on)
				{
					((Component)this).GetComponentInChildren<Renderer>().material.SetColor("_EmissionColor", Color.yellow * 2f);
				}
				else
				{
					((Component)this).GetComponentInChildren<Renderer>().material.SetColor("_EmissionColor", Color.black);
				}
				if (!(Time.time < next_time))
				{
					on = !on;
					next_time = Time.time + (on ? 0.5f : Random.Range(1f, 2f));
				}
			}
		}

		public override bool OnShoot(ref Balloon instance, ref ShootableQuery query)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (!instance.IsPopped)
			{
				PopAlarm(instance, query);
				query.shot_response = (ShotResponse)3;
				query.hit_event = (Event)5;
			}
			return false;
		}

		public override void GetPersistentData(ref Balloon instance, ref JSONObject result)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if (!((Object)(object)instance == (Object)null) && !instance.IsPopped)
			{
				((JSONNode)result).Add("type", (JSONNode)new JSONString("blink"));
			}
		}

		public override void SetPersistentData(ref Balloon instance, JSONObject data)
		{
			if (((JSONNode)data).HasKey("type") && ((JSONNode)data)["type"].Value == "blink")
			{
				((Component)instance).gameObject.AddComponent<BlinkBalloon>();
			}
		}

		public override bool OnTouch(ref Balloon instance, Collider other)
		{
			PopAlarm(instance, null);
			return false;
		}

		private void PopAlarm(Balloon instance, ShootableQuery query)
		{
			if (!on)
			{
				BaseBalloon.CustomPop(instance, query, 0, 1);
				return;
			}
			int num = bonus();
			BaseBalloon.CustomPop(instance, query, 1 + num, 3 + num);
		}
	}
	public class GhostBalloon : BaseBalloon
	{
		public override void OnStart(ref Balloon instance)
		{
			//IL_0020: 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)
			if (!((Object)(object)instance == (Object)null) && !instance.IsPopped)
			{
				((Component)instance).GetComponentInChildren<Renderer>().material.color = Color.white;
				((Component)instance).GetComponentInChildren<Renderer>().material.EnableKeyword("_EMISSION");
				((Component)instance).transform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
			}
		}

		public override void GetPersistentData(ref Balloon instance, ref JSONObject result)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if (!((Object)(object)instance == (Object)null) && !instance.IsPopped)
			{
				((JSONNode)result).Add("type", (JSONNode)new JSONString("ghost"));
			}
		}

		public override void SetPersistentData(ref Balloon instance, JSONObject data)
		{
			if (((JSONNode)data).HasKey("type") && ((JSONNode)data)["type"].Value == "ghost")
			{
				((Component)instance).gameObject.AddComponent<GhostBalloon>();
			}
		}

		public void Update()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (Time.frameCount % 5 != 0)
			{
				return;
			}
			Balloon componentInParent = ((Component)this).GetComponentInParent<Balloon>();
			if ((Object)(object)componentInParent == (Object)null || componentInParent.IsPopped)
			{
				return;
			}
			LocalAimHandler player_instance = LocalAimHandler.player_instance;
			if (!((Object)(object)player_instance == (Object)null))
			{
				if (((Component)player_instance).gameObject.GetComponent<QuickDrawListener>().quickDraw())
				{
					((Component)this).GetComponentInChildren<Renderer>().material.SetColor("_EmissionColor", Color.white * 2f);
				}
				else
				{
					((Component)this).GetComponentInChildren<Renderer>().material.SetColor("_EmissionColor", Color.black);
				}
			}
		}

		public override bool OnShoot(ref Balloon instance, ref ShootableQuery query)
		{
			//IL_0059: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			LocalAimHandler player_instance = LocalAimHandler.player_instance;
			if ((Object)(object)player_instance == (Object)null)
			{
				return false;
			}
			QuickDrawListener component = ((Component)player_instance).gameObject.GetComponent<QuickDrawListener>();
			if (!instance.IsPopped)
			{
				if (component.quickDraw())
				{
					int num = bonus();
					BaseBalloon.CustomPop(instance, query, 1 + num, 3 + num);
					query.shot_response = (ShotResponse)3;
					query.hit_event = (Event)5;
				}
				else
				{
					query.shot_response = (ShotResponse)2;
					query.hit_event = (Event)0;
					if (!component.ghost)
					{
						ReceiverOnScreenMessage.QueueMessage("", "Draw and shoot quickly to break ghost balloons.", true);
						component.ghost = true;
					}
				}
			}
			return false;
		}

		public override bool OnTouch(ref Balloon instance, Collider other)
		{
			return false;
		}
	}
	public class LeadBalloon : BaseBalloon
	{
		private bool canBreak;

		private IEnumerator routine;

		public override void OnStart(ref Balloon instance)
		{
			//IL_002f: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)instance == (Object)null) && !instance.IsPopped)
			{
				((Component)instance).GetComponentInChildren<Renderer>().material.color = new Color(0.2f, 0.2f, 0.2f);
				((Component)instance).GetComponentInChildren<BallisticMaterialSpecial>().ballistic_properties.no_penetration = true;
				((Component)instance).transform.localScale = new Vector3(1.6f, 1.6f, 1.6f);
				((Component)instance).GetComponentInChildren<Renderer>().material.EnableKeyword("_EMISSION");
				((Component)instance).GetComponentInChildren<Renderer>().material.SetColor("_EmissionColor", Color.black);
			}
		}

		public override bool OnShoot(ref Balloon instance, ref ShootableQuery query)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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)
			if (!instance.IsPopped && (int)query.hit_type == 0)
			{
				if (!canBreak)
				{
					canBreak = true;
					routine = clearShot(instance);
					((MonoBehaviour)this).StartCoroutine(routine);
					((Component)instance).GetComponentInChildren<Renderer>().material.SetColor("_EmissionColor", Color.gray * 2f);
					query.shot_response = (ShotResponse)0;
					query.hit_event = (Event)0;
				}
				else
				{
					((MonoBehaviour)this).StopCoroutine(routine);
					canBreak = false;
					int num = bonus();
					BaseBalloon.CustomPop(instance, query, 2 + num, 5 + num);
					query.shot_response = (ShotResponse)3;
					query.hit_event = (Event)5;
				}
			}
			return false;
		}

		public override void GetPersistentData(ref Balloon instance, ref JSONObject result)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if (!((Object)(object)instance == (Object)null) && !instance.IsPopped)
			{
				((JSONNode)result).Add("type", (JSONNode)new JSONString("lead"));
			}
		}

		public override void SetPersistentData(ref Balloon instance, JSONObject data)
		{
			if (((JSONNode)data).HasKey("type") && ((JSONNode)data)["type"].Value == "lead")
			{
				((Component)instance).gameObject.AddComponent<LeadBalloon>();
			}
		}

		public override bool OnTouch(ref Balloon instance, Collider other)
		{
			return false;
		}

		private IEnumerator clearShot(Balloon instance)
		{
			yield return (object)new WaitForSeconds(1f);
			Debug.Log((object)(Time.time + " Reset!"));
			canBreak = false;
			((Component)instance).GetComponentInChildren<Renderer>().material.SetColor("_EmissionColor", Color.black);
			LocalAimHandler player_instance = LocalAimHandler.player_instance;
			if ((Object)(object)player_instance != (Object)null)
			{
				QuickDrawListener component = ((Component)player_instance).gameObject.GetComponent<QuickDrawListener>();
				if (!component.lead)
				{
					ReceiverOnScreenMessage.QueueMessage("", "Lead balloons require a double tap to break.", true);
					component.lead = true;
				}
			}
			yield return null;
		}
	}
	[BepInPlugin("Bloons", "Bloons", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private static ConfigEntry<bool> allBalloons;

		private static List<string> rankSpawnTable = new List<string> { ".", "l.", "lg..", "lgbn....", "lgsbn.....", "lgsbn....." };

		private static List<string> allSpawnTable = new List<string> { ".", "lgsbn.....", "lgsbn.....", "lgsbn.....", "lgsbn.....", "lgsbn....." };

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Balloons !");
			Harmony.CreateAndPatchAll(((object)this).GetType(), (string)null);
			allBalloons = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Toggles", "SpawnAllBalloons", false, "Spawn all balloon types in all levels.");
		}

		[HarmonyPatch(typeof(LocalAimHandler), "Awake")]
		[HarmonyPostfix]
		public static void LahAwake(LocalAimHandler __instance)
		{
			((Component)LocalAimHandler.player_instance).gameObject.AddComponent<QuickDrawListener>();
		}

		[HarmonyPatch(typeof(LocalAimHandler), "DrawMainItem")]
		[HarmonyPostfix]
		public static void DrawItem(LocalAimHandler __instance, Type type)
		{
			((Component)__instance).gameObject.GetComponent<QuickDrawListener>().startQuickdraw();
		}

		[HarmonyPatch(typeof(Balloon), "Start")]
		[HarmonyPostfix]
		public static void Start(Balloon __instance)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			if ((int)ReceiverCoreScript.Instance().game_mode.GetGameMode() == 2 && !__instance.IsPopped)
			{
				GameModeBase game_mode = ReceiverCoreScript.Instance().game_mode;
				int receiver_rank = ((RankingProgressionGameMode)((game_mode is RankingProgressionGameMode) ? game_mode : null)).progression_data.receiver_rank;
				string text = (allBalloons.Value ? allSpawnTable : rankSpawnTable)[receiver_rank];
				switch (text[Random.Range(0, text.Length)])
				{
				case 'l':
					((Component)__instance).gameObject.AddComponent<LeadBalloon>();
					break;
				case 'b':
					((Component)__instance).gameObject.AddComponent<BlinkBalloon>();
					break;
				case 'g':
					((Component)__instance).gameObject.AddComponent<GhostBalloon>();
					break;
				case 's':
					((Component)__instance).gameObject.AddComponent<SpawnBalloon>();
					break;
				case 'n':
					((Component)__instance).gameObject.AddComponent<SnipeBalloon>();
					break;
				}
			}
		}

		[HarmonyPatch(typeof(Balloon), "WasShot")]
		[HarmonyPrefix]
		public static bool WasShot(Balloon __instance, ref ShootableQuery shootable_query)
		{
			BaseBalloon component = ((Component)__instance).GetComponent<BaseBalloon>();
			if ((Object)(object)component == (Object)null)
			{
				return true;
			}
			if (!__instance.IsPopped)
			{
				return component.OnShoot(ref __instance, ref shootable_query);
			}
			return false;
		}

		[HarmonyPatch(typeof(Balloon), "SetPersistentData")]
		[HarmonyPostfix]
		public static void SetPersistentData(Balloon __instance, JSONObject data)
		{
			try
			{
				if (!((Object)(object)__instance == (Object)null) && !__instance.IsPopped)
				{
					((Component)__instance).gameObject.GetComponent<BaseBalloon>().SetPersistentData(ref __instance, data);
				}
			}
			catch (Exception ex)
			{
				Debug.Log((object)("Caught exception in SetPersistentData " + ex.ToString()));
			}
		}

		[HarmonyPatch(typeof(Balloon), "GetPersistentData")]
		[HarmonyPostfix]
		public static void GetPersistentData(Balloon __instance, JSONObject __result)
		{
			try
			{
				if (!((Object)(object)__instance == (Object)null) && !__instance.IsPopped)
				{
					((Component)__instance).gameObject.GetComponent<BaseBalloon>().GetPersistentData(ref __instance, ref __result);
				}
			}
			catch (Exception)
			{
			}
		}

		[HarmonyPatch(typeof(Balloon), "OnTriggerEnter")]
		[HarmonyPrefix]
		public static bool OnTriggerEnter(Balloon __instance, Collider other)
		{
			if (!__instance.IsPopped)
			{
				BaseBalloon component = ((Component)__instance).gameObject.GetComponent<BaseBalloon>();
				if ((Object)(object)component != (Object)null)
				{
					return component.OnTouch(ref __instance, other);
				}
			}
			return true;
		}
	}
	public class QuickDrawListener : MonoBehaviour
	{
		private bool qd;

		public bool lead;

		public bool ghost;

		public bool snipe;

		public bool quickDraw()
		{
			return qd;
		}

		public void startQuickdraw()
		{
			if (!qd)
			{
				qd = true;
				((MonoBehaviour)this).StartCoroutine(endQuickdraw());
			}
		}

		private IEnumerator endQuickdraw()
		{
			yield return (object)new WaitForSeconds(2f);
			qd = false;
			yield return null;
		}
	}
	public class SnipeBalloon : BaseBalloon
	{
		public override void OnStart(ref Balloon instance)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)instance == (Object)null) && !instance.IsPopped)
			{
				((Component)instance).GetComponentInChildren<Renderer>().material.color = Color.green;
				((Component)instance).GetComponentInChildren<Renderer>().material.EnableKeyword("_EMISSION");
			}
		}

		public override void GetPersistentData(ref Balloon instance, ref JSONObject result)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if (!((Object)(object)instance == (Object)null) && !instance.IsPopped)
			{
				((JSONNode)result).Add("type", (JSONNode)new JSONString("snipe"));
			}
		}

		public override void SetPersistentData(ref Balloon instance, JSONObject data)
		{
			if (((JSONNode)data).HasKey("type") && ((JSONNode)data)["type"].Value == "snipe")
			{
				((Component)instance).gameObject.AddComponent<GhostBalloon>();
			}
		}

		public void Update()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			if (Time.frameCount % 5 != 0)
			{
				return;
			}
			Balloon componentInParent = ((Component)this).GetComponentInParent<Balloon>();
			if ((Object)(object)componentInParent == (Object)null || componentInParent.IsPopped)
			{
				return;
			}
			LocalAimHandler player_instance = LocalAimHandler.player_instance;
			if (!((Object)(object)player_instance == (Object)null))
			{
				if (Vector3.Distance(((Component)componentInParent).transform.position, ((Component)player_instance).gameObject.transform.position) > 12f)
				{
					((Component)this).GetComponentInChildren<Renderer>().material.SetColor("_EmissionColor", Color.green * 2f);
				}
				else
				{
					((Component)this).GetComponentInChildren<Renderer>().material.SetColor("_EmissionColor", Color.black);
				}
			}
		}

		public override bool OnShoot(ref Balloon instance, ref ShootableQuery query)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			LocalAimHandler player_instance = LocalAimHandler.player_instance;
			if ((Object)(object)player_instance == (Object)null)
			{
				return false;
			}
			QuickDrawListener component = ((Component)player_instance).gameObject.GetComponent<QuickDrawListener>();
			if (!instance.IsPopped)
			{
				if (Vector3.Distance(((Component)instance).transform.position, ((Component)player_instance).gameObject.transform.position) > 12f)
				{
					int num = bonus();
					BaseBalloon.CustomPop(instance, query, 1 + num, 3 + num);
					query.shot_response = (ShotResponse)3;
					query.hit_event = (Event)5;
				}
				else
				{
					query.shot_response = (ShotResponse)2;
					query.hit_event = (Event)0;
					if (!component.snipe)
					{
						ReceiverOnScreenMessage.QueueMessage("", "Stand far enough away until the balloon glows.", true);
						component.snipe = true;
					}
				}
			}
			return false;
		}

		public override bool OnTouch(ref Balloon instance, Collider other)
		{
			return false;
		}
	}
	public class SpawnBalloon : BaseBalloon
	{
		public override void OnStart(ref Balloon instance)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)instance == (Object)null) && !instance.IsPopped)
			{
				((Component)instance).GetComponentInChildren<Renderer>().material.color = new Color(1f, 0f, 1f);
			}
		}

		public override bool OnShoot(ref Balloon instance, ref ShootableQuery query)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (!instance.IsPopped)
			{
				PopSpawn(instance, query);
				query.shot_response = (ShotResponse)3;
				query.hit_event = (Event)5;
			}
			return false;
		}

		public override void GetPersistentData(ref Balloon instance, ref JSONObject result)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if (!((Object)(object)instance == (Object)null) && !instance.IsPopped)
			{
				((JSONNode)result).Add("type", (JSONNode)new JSONString("spawn"));
			}
		}

		public override void SetPersistentData(ref Balloon instance, JSONObject data)
		{
			if (((JSONNode)data).HasKey("type") && ((JSONNode)data)["type"].Value == "spawn")
			{
				((Component)instance).gameObject.AddComponent<SpawnBalloon>();
			}
		}

		public override bool OnTouch(ref Balloon instance, Collider other)
		{
			PopSpawn(instance, null);
			return false;
		}

		private void PopSpawn(Balloon instance, ShootableQuery query)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			TileEnemySpawn val = new TileEnemySpawn();
			val.spawn_type = (SpawnType)2;
			val.offset = Vector3.up;
			GameObject drone = ReceiverCoreScript.Instance().SpawnStandaloneEnemy(((Component)instance).transform.position, val);
			int num = bonus();
			BaseBalloon.CustomPop(instance, query, 2 + num, 5 + num);
			IEnumerator enumerator = AlertDrone(drone);
			((MonoBehaviour)this).StartCoroutine(enumerator);
		}

		private IEnumerator AlertDrone(GameObject drone)
		{
			yield return (object)new WaitForSeconds(0.01f);
			ShockDrone component = drone.GetComponent<ShockDrone>();
			CameraPart val = (((Object)(object)component != (Object)null) ? component.camera_part : null);
			if ((Object)(object)val != (Object)null)
			{
				val.AlertImmediate();
			}
			yield return null;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Bloons";

		public const string PLUGIN_NAME = "Bloons";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}