Decompiled source of ImGonnaCome v1.0.2

BepInEX/plugins/ImGonnaCome/ImGonnaCome.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BlackMagicAPI.Managers;
using BlackMagicAPI.Modules.Spells;
using BlackMagicAPI.Network;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("ImGonnaCome")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ImGonnaCome")]
[assembly: AssemblyTitle("ImGonnaCome")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ImGonnaCome;

public class ImGonnaComeData : SpellData
{
	public override string Name => "Im Gonna Come";

	public override float Cooldown => 20f;

	public override Color GlowColor => Color.white;

	public override string[] SubNames => new string[5] { "I'm Gonna Come", "Im Gonna Come", "Gonna Come", "White Missile", "Come" };

	public override bool CanSpawnInTeamChest => false;

	public override bool DebugForceSpawn => false;
}
public class ImGonnaComeLogic : SpellLogic
{
	private const int SPELL_SIGNATURE = 1229407034;

	private const float EYE_HEIGHT = 1.6f;

	private const int MISSILE_COUNT = 5;

	private static GameObject _fireballGO;

	private static GameObject _missileGO;

	private static Material _particleMat;

	private Vector3 _customFireballImpact;

	public override bool CastSpell(PlayerMovement caster, PageController page, Vector3 spawnPos, Vector3 viewDir, int level)
	{
		return true;
	}

	public override void WriteData(DataWriter writer, PageController page, PlayerMovement caster, Vector3 spawnPos, Vector3 viewDir, int level)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		writer.Write<int>(1229407034);
		writer.Write<float>(spawnPos.x);
		writer.Write<float>(spawnPos.y);
		writer.Write<float>(spawnPos.z);
		writer.Write<float>(viewDir.x);
		writer.Write<float>(viewDir.y);
		writer.Write<float>(viewDir.z);
	}

	public override void SyncData(object[] values)
	{
		//IL_0061: 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)
		if (((SpellLogic)this).IsPrefab)
		{
			return;
		}
		try
		{
			if (values.Length >= 7 && Convert.ToInt32(values[0]) == 1229407034)
			{
				Vector3 castOrigin = default(Vector3);
				((Vector3)(ref castOrigin))..ctor(Convert.ToSingle(values[1]), Convert.ToSingle(values[2]), Convert.ToSingle(values[3]));
				Vector3 castDir = default(Vector3);
				((Vector3)(ref castDir))..ctor(Convert.ToSingle(values[4]), Convert.ToSingle(values[5]), Convert.ToSingle(values[6]));
				((MonoBehaviour)this).StartCoroutine(CastSequence(castOrigin, castDir));
			}
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("[ImGonnaCome] SyncData: " + ex.Message));
		}
	}

	public override void OnPrefabCreatedAutomatically(GameObject prefab)
	{
		try
		{
			TryFindPrefabs();
			if ((Object)(object)_particleMat == (Object)null)
			{
				ParticleSystemRenderer[] array = Object.FindObjectsOfType<ParticleSystemRenderer>();
				foreach (ParticleSystemRenderer val in array)
				{
					if ((Object)(object)((Renderer)val).sharedMaterial != (Object)null)
					{
						_particleMat = ((Renderer)val).sharedMaterial;
						break;
					}
				}
			}
			Debug.Log((object)("[ImGonnaCome] fireball=" + (((Object)(object)_fireballGO != (Object)null) ? ((Object)_fireballGO).name : "null") + " missile=" + (((Object)(object)_missileGO != (Object)null) ? ((Object)_missileGO).name : "null")));
		}
		catch (Exception ex)
		{
			Debug.LogWarning((object)("[ImGonnaCome] OnPrefab: " + ex.Message));
		}
	}

	private static void TryFindPrefabs()
	{
		PageController[] array = Resources.FindObjectsOfTypeAll<PageController>();
		for (int i = 0; i < array.Length; i++)
		{
			GameObject spellprefab = array[i].spellprefab;
			if (!((Object)(object)spellprefab == (Object)null))
			{
				if ((Object)(object)_fireballGO == (Object)null && (Object)(object)spellprefab.GetComponent("FireballController") != (Object)null)
				{
					_fireballGO = spellprefab;
				}
				if ((Object)(object)_missileGO == (Object)null && (Object)(object)spellprefab.GetComponent("MagicMissleController") != (Object)null)
				{
					_missileGO = spellprefab;
				}
				if ((Object)(object)_fireballGO != (Object)null && (Object)(object)_missileGO != (Object)null)
				{
					return;
				}
			}
		}
		Object[] array2;
		if ((Object)(object)_fireballGO == (Object)null)
		{
			Type type = FindTypeByName("FireballController");
			if (type != null)
			{
				array2 = Resources.FindObjectsOfTypeAll(type);
				foreach (Object obj in array2)
				{
					Component val = (Component)(object)((obj is Component) ? obj : null);
					if ((Object)(object)val != (Object)null)
					{
						_fireballGO = val.gameObject;
						break;
					}
				}
			}
		}
		if (!((Object)(object)_missileGO == (Object)null))
		{
			return;
		}
		Type type2 = FindTypeByName("MagicMissleController");
		if (!(type2 != null))
		{
			return;
		}
		array2 = Resources.FindObjectsOfTypeAll(type2);
		foreach (Object obj2 in array2)
		{
			Component val2 = (Component)(object)((obj2 is Component) ? obj2 : null);
			if ((Object)(object)val2 != (Object)null)
			{
				_missileGO = val2.gameObject;
				break;
			}
		}
	}

	private static Type FindTypeByName(string name)
	{
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly in assemblies)
		{
			try
			{
				Type[] types = assembly.GetTypes();
				foreach (Type type in types)
				{
					if (type.Name == name)
					{
						return type;
					}
				}
			}
			catch
			{
			}
		}
		return null;
	}

	private IEnumerator CastSequence(Vector3 castOrigin, Vector3 castDir)
	{
		//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)
		//IL_0015: 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)
		castDir = ((Vector3)(ref castDir)).normalized;
		Transform casterTf = FindNearestPlayer(castOrigin);
		((MonoBehaviour)this).StartCoroutine(ShowAnnouncement(casterTf, castOrigin));
		string directoryName = Path.GetDirectoryName(typeof(ImGonnaComeLogic).Assembly.Location);
		string wavPath = Path.Combine(directoryName, "Sounds", "ImGonnaCome.wav");
		string text = "file:///" + wavPath.Replace('\\', '/');
		UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)20);
		yield return req.SendWebRequest();
		if ((int)req.result == 1)
		{
			GameObject val = new GameObject("IGCAudio");
			AudioSource val2 = val.AddComponent<AudioSource>();
			val2.spatialBlend = 0f;
			val2.volume = 1f;
			val2.clip = DownloadHandlerAudioClip.GetContent(req);
			val2.Play();
			Object.Destroy((Object)val, val2.clip.length + 1f);
		}
		else
		{
			Debug.LogWarning((object)("[ImGonnaCome] Audio: " + req.error + " | " + wavPath));
		}
		req.Dispose();
		if ((Object)(object)_fireballGO == (Object)null || (Object)(object)_missileGO == (Object)null)
		{
			TryFindPrefabs();
		}
		if ((Object)(object)_particleMat == (Object)null)
		{
			ParticleSystemRenderer[] array = Object.FindObjectsOfType<ParticleSystemRenderer>();
			foreach (ParticleSystemRenderer val3 in array)
			{
				if ((Object)(object)((Renderer)val3).sharedMaterial != (Object)null)
				{
					_particleMat = ((Renderer)val3).sharedMaterial;
					break;
				}
			}
		}
		Vector3 val4 = (((Object)(object)casterTf != (Object)null) ? casterTf.position : castOrigin) + Vector3.up * 1.6f + castDir * 2.2f;
		Vector3 impactPos;
		if ((Object)(object)_fireballGO != (Object)null)
		{
			GameObject fbGo = Object.Instantiate<GameObject>(_fireballGO, val4, Quaternion.LookRotation(castDir));
			RecolorToWhite(fbGo);
			MonoBehaviour[] components = fbGo.GetComponents<MonoBehaviour>();
			foreach (MonoBehaviour val5 in components)
			{
				if (((object)val5).GetType().Name == "FireballController")
				{
					Object.Destroy((Object)(object)val5);
					break;
				}
			}
			Rigidbody val6 = fbGo.GetComponent<Rigidbody>();
			if ((Object)(object)val6 == (Object)null)
			{
				val6 = fbGo.AddComponent<Rigidbody>();
			}
			val6.isKinematic = false;
			val6.useGravity = true;
			val6.velocity = castDir * 22f;
			val6.drag = 0.05f;
			float waited = 0f;
			Vector3 lastPos = val4;
			while ((Object)(object)fbGo != (Object)null && waited < 9f)
			{
				lastPos = fbGo.transform.position;
				if (waited > 0.4f)
				{
					bool flag = false;
					Collider[] array2 = Physics.OverlapSphere(lastPos, 0.45f);
					foreach (Collider val7 in array2)
					{
						if (!val7.isTrigger && !((Object)(object)((Component)val7).gameObject == (Object)(object)fbGo) && !((Object)(object)((Component)val7).GetComponent("PlayerMovement") != (Object)null))
						{
							flag = true;
							break;
						}
					}
					if (flag)
					{
						break;
					}
				}
				waited += Time.deltaTime;
				yield return null;
			}
			impactPos = lastPos;
			if ((Object)(object)fbGo != (Object)null)
			{
				Object.Destroy((Object)(object)fbGo);
			}
		}
		else
		{
			yield return ((MonoBehaviour)this).StartCoroutine(FireCustomFireball(val4, castDir));
			impactPos = _customFireballImpact;
		}
		((MonoBehaviour)this).StartCoroutine(SpawnWhiteExplosion(impactPos));
		((MonoBehaviour)this).StartCoroutine(SpawnGroundFlames(impactPos));
		yield return (object)new WaitForSeconds(0.12f);
		Transform target = FindNearestPlayer(impactPos, (casterTf != null) ? ((Component)casterTf).gameObject : null);
		for (int i = 0; i < 5; i++)
		{
			Vector3 pos = impactPos + new Vector3(Random.Range(-1.2f, 1.2f), 0.2f, Random.Range(-1.2f, 1.2f));
			if ((Object)(object)_missileGO != (Object)null)
			{
				((MonoBehaviour)this).StartCoroutine(LaunchGameMissileUp(pos, target));
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(LaunchCustomMissileUp(pos, target));
			}
			yield return (object)new WaitForSeconds(0.09f);
		}
	}

	private IEnumerator FireCustomFireball(Vector3 start, Vector3 dir)
	{
		//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)
		//IL_0015: 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)
		_customFireballImpact = start + dir * 50f;
		GameObject root = new GameObject("IGCFireball");
		root.transform.position = start;
		Rigidbody obj = root.AddComponent<Rigidbody>();
		obj.useGravity = true;
		obj.isKinematic = false;
		obj.drag = 0.08f;
		obj.velocity = dir * 22f;
		obj.interpolation = (RigidbodyInterpolation)1;
		GameObject val = new GameObject("Core");
		val.transform.SetParent(root.transform, false);
		ParticleSystem obj2 = val.AddComponent<ParticleSystem>();
		MainModule main = obj2.main;
		((MainModule)(ref main)).loop = true;
		((MainModule)(ref main)).duration = 999f;
		((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.08f, 0.14f);
		((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.3f, 1.2f);
		((MainModule)(ref main)).startSize = new MinMaxCurve(0.3f, 0.7f);
		((MainModule)(ref main)).startColor = new MinMaxGradient(Color.white, new Color(0.95f, 0.95f, 0.95f, 1f));
		((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main)).maxParticles = 300;
		EmissionModule emission = obj2.emission;
		((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(200f);
		ShapeModule shape = obj2.shape;
		((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
		((ShapeModule)(ref shape)).radius = 0.05f;
		if ((Object)(object)_particleMat != (Object)null)
		{
			((Renderer)val.GetComponent<ParticleSystemRenderer>()).sharedMaterial = _particleMat;
		}
		GameObject val2 = new GameObject("Trail");
		val2.transform.SetParent(root.transform, false);
		ParticleSystem obj3 = val2.AddComponent<ParticleSystem>();
		MainModule main2 = obj3.main;
		((MainModule)(ref main2)).loop = true;
		((MainModule)(ref main2)).duration = 999f;
		((MainModule)(ref main2)).startLifetime = new MinMaxCurve(0.3f, 0.7f);
		((MainModule)(ref main2)).startSpeed = new MinMaxCurve(0.2f, 0.8f);
		((MainModule)(ref main2)).startSize = new MinMaxCurve(0.15f, 0.5f);
		((MainModule)(ref main2)).startColor = new MinMaxGradient(new Color(1f, 1f, 1f, 0.9f), new Color(0.8f, 0.8f, 0.8f, 0.25f));
		((MainModule)(ref main2)).gravityModifier = new MinMaxCurve(0.15f);
		((MainModule)(ref main2)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main2)).maxParticles = 200;
		EmissionModule emission2 = obj3.emission;
		((EmissionModule)(ref emission2)).rateOverTime = MinMaxCurve.op_Implicit(80f);
		ShapeModule shape2 = obj3.shape;
		((ShapeModule)(ref shape2)).shapeType = (ParticleSystemShapeType)0;
		((ShapeModule)(ref shape2)).radius = 0.25f;
		if ((Object)(object)_particleMat != (Object)null)
		{
			((Renderer)val2.GetComponent<ParticleSystemRenderer>()).sharedMaterial = _particleMat;
		}
		Light lt = root.AddComponent<Light>();
		lt.type = (LightType)2;
		lt.color = Color.white;
		lt.intensity = 18f;
		lt.range = 18f;
		float elapsed = 0f;
		while (elapsed < 12f && (Object)(object)root != (Object)null)
		{
			if ((Object)(object)lt != (Object)null)
			{
				lt.intensity = 18f + Random.Range(-2f, 2f);
			}
			if (elapsed > 0.2f)
			{
				Collider[] array = Physics.OverlapSphere(root.transform.position, 0.4f);
				foreach (Collider val3 in array)
				{
					if (!val3.isTrigger && !((Object)(object)((Component)val3).gameObject == (Object)(object)root) && !((Object)(object)((Component)val3).GetComponent("PlayerMovement") != (Object)null))
					{
						_customFireballImpact = root.transform.position;
						Object.Destroy((Object)(object)root);
						yield break;
					}
				}
			}
			elapsed += Time.deltaTime;
			yield return null;
		}
		if ((Object)(object)root != (Object)null)
		{
			_customFireballImpact = root.transform.position;
			Object.Destroy((Object)(object)root);
		}
	}

	private IEnumerator SpawnGroundFlames(Vector3 pos)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		RaycastHit val = default(RaycastHit);
		if (Physics.Raycast(pos + Vector3.up * 2f, Vector3.down, ref val, 10f))
		{
			pos = ((RaycastHit)(ref val)).point;
		}
		GameObject go = new GameObject("IGCFlames");
		go.transform.position = pos;
		go.transform.rotation = Quaternion.Euler(-90f, 0f, 0f);
		ParticleSystem ps = go.AddComponent<ParticleSystem>();
		MainModule main = ps.main;
		((MainModule)(ref main)).duration = 7f;
		((MainModule)(ref main)).loop = true;
		((MainModule)(ref main)).startLifetime = new MinMaxCurve(1f, 2.5f);
		((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.5f, 3f);
		((MainModule)(ref main)).startSize = new MinMaxCurve(0.1f, 0.6f);
		((MainModule)(ref main)).startColor = new MinMaxGradient(Color.white, new Color(0.88f, 0.88f, 1f, 0.8f));
		((MainModule)(ref main)).gravityModifier = new MinMaxCurve(-0.12f);
		((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main)).maxParticles = 300;
		EmissionModule emission = ps.emission;
		((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(55f);
		ShapeModule shape = ps.shape;
		((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10;
		((ShapeModule)(ref shape)).radius = 2.8f;
		if ((Object)(object)_particleMat != (Object)null)
		{
			((Renderer)go.GetComponent<ParticleSystemRenderer>()).sharedMaterial = _particleMat;
		}
		Light lt = go.AddComponent<Light>();
		lt.type = (LightType)2;
		lt.color = Color.white;
		lt.intensity = 8f;
		lt.range = 10f;
		float elapsed2 = 0f;
		while (elapsed2 < 5f && (Object)(object)go != (Object)null)
		{
			elapsed2 += Time.deltaTime;
			yield return null;
		}
		elapsed2 = 0f;
		while (elapsed2 < 1.5f && (Object)(object)go != (Object)null)
		{
			EmissionModule emission2 = ps.emission;
			((EmissionModule)(ref emission2)).rateOverTime = MinMaxCurve.op_Implicit(Mathf.Lerp(55f, 0f, elapsed2 / 1.5f));
			if ((Object)(object)lt != (Object)null)
			{
				lt.intensity = Mathf.Lerp(8f, 0f, elapsed2 / 1.5f);
			}
			elapsed2 += Time.deltaTime;
			yield return null;
		}
		if ((Object)(object)go != (Object)null)
		{
			Object.Destroy((Object)(object)go);
		}
	}

	private IEnumerator LaunchGameMissileUp(Vector3 pos, Transform target)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		GameObject mg = Object.Instantiate<GameObject>(_missileGO, pos, Quaternion.identity);
		RecolorToWhite(mg);
		Rigidbody component = mg.GetComponent<Rigidbody>();
		if ((Object)(object)component != (Object)null)
		{
			component.isKinematic = false;
			component.velocity = new Vector3(Random.Range(-2.5f, 2.5f), Random.Range(10f, 16f), Random.Range(-2.5f, 2.5f));
		}
		yield return (object)new WaitForSeconds(0.55f);
		if ((Object)(object)mg == (Object)null)
		{
			yield break;
		}
		RecolorToWhite(mg);
		MonoBehaviour val = null;
		MonoBehaviour[] components = mg.GetComponents<MonoBehaviour>();
		foreach (MonoBehaviour val2 in components)
		{
			if (((object)val2).GetType().Name == "MagicMissleController")
			{
				val = val2;
				break;
			}
		}
		if (!((Object)(object)val == (Object)null))
		{
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			FieldInfo field = ((object)val).GetType().GetField("MissleTarget", bindingAttr);
			if (field != null && (Object)(object)target != (Object)null)
			{
				field.SetValue(val, ((Component)target).gameObject);
			}
			FieldInfo field2 = ((object)val).GetType().GetField("desiredHomingMissleVelocity", bindingAttr);
			if (field2 != null)
			{
				field2.SetValue(val, 18f);
			}
			val.StartCoroutine("SpawnMissles");
		}
	}

	private IEnumerator LaunchCustomMissileUp(Vector3 pos, Transform target)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		GameObject go = new GameObject("IGCMissile");
		go.transform.position = pos;
		Rigidbody rb = go.AddComponent<Rigidbody>();
		rb.useGravity = true;
		rb.velocity = new Vector3(Random.Range(-2f, 2f), Random.Range(10f, 16f), Random.Range(-2f, 2f));
		ParticleSystem obj = go.AddComponent<ParticleSystem>();
		MainModule main = obj.main;
		((MainModule)(ref main)).loop = true;
		((MainModule)(ref main)).duration = 999f;
		((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.08f, 0.15f);
		((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.2f, 0.6f);
		((MainModule)(ref main)).startSize = new MinMaxCurve(0.06f, 0.18f);
		((MainModule)(ref main)).startColor = new MinMaxGradient(Color.white, new Color(0.85f, 0.85f, 0.85f, 0.8f));
		((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main)).maxParticles = 80;
		EmissionModule emission = obj.emission;
		((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(90f);
		ShapeModule shape = obj.shape;
		((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
		((ShapeModule)(ref shape)).radius = 0.02f;
		if ((Object)(object)_particleMat != (Object)null)
		{
			((Renderer)go.GetComponent<ParticleSystemRenderer>()).sharedMaterial = _particleMat;
		}
		Light obj2 = go.AddComponent<Light>();
		obj2.type = (LightType)2;
		obj2.color = Color.white;
		obj2.intensity = 6f;
		obj2.range = 5f;
		yield return (object)new WaitForSeconds(0.5f);
		if ((Object)(object)go == (Object)null)
		{
			yield break;
		}
		Object.Destroy((Object)(object)rb);
		float elapsed = 0f;
		while (elapsed < 8f && (Object)(object)go != (Object)null)
		{
			if ((Object)(object)target != (Object)null)
			{
				Vector3 val = target.position + Vector3.up * 0.8f;
				go.transform.position = Vector3.MoveTowards(go.transform.position, val, 16f * Time.deltaTime);
				if (Vector3.Distance(go.transform.position, val) < 0.4f)
				{
					break;
				}
			}
			elapsed += Time.deltaTime;
			yield return null;
		}
		if ((Object)(object)go != (Object)null)
		{
			Object.Destroy((Object)(object)go);
		}
	}

	private IEnumerator SpawnWhiteExplosion(Vector3 pos)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		GameObject go = new GameObject("IGCExplosion");
		go.transform.position = pos;
		ParticleSystem val = go.AddComponent<ParticleSystem>();
		MainModule main = val.main;
		((MainModule)(ref main)).duration = 0.15f;
		((MainModule)(ref main)).loop = false;
		((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.4f, 0.9f);
		((MainModule)(ref main)).startSpeed = new MinMaxCurve(6f, 18f);
		((MainModule)(ref main)).startSize = new MinMaxCurve(0.2f, 0.7f);
		((MainModule)(ref main)).startColor = new MinMaxGradient(Color.white, new Color(0.88f, 0.88f, 0.88f, 0.9f));
		((MainModule)(ref main)).gravityModifier = new MinMaxCurve(0.25f);
		((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main)).maxParticles = 100;
		EmissionModule emission = val.emission;
		((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
		((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1]
		{
			new Burst(0f, (short)60, (short)90, 1, 0.01f)
		});
		ShapeModule shape = val.shape;
		((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
		((ShapeModule)(ref shape)).radius = 0.4f;
		if ((Object)(object)_particleMat != (Object)null)
		{
			((Renderer)go.GetComponent<ParticleSystemRenderer>()).sharedMaterial = _particleMat;
		}
		GameObject val2 = new GameObject("Flash");
		val2.transform.SetParent(go.transform, false);
		Light lt = val2.AddComponent<Light>();
		lt.type = (LightType)2;
		lt.color = Color.white;
		lt.intensity = 70f;
		lt.range = 32f;
		float t = 0f;
		while (t < 0.5f)
		{
			if (Object.op_Implicit((Object)(object)lt))
			{
				lt.intensity = Mathf.Lerp(70f, 0f, t / 0.5f);
			}
			t += Time.deltaTime;
			yield return null;
		}
		Object.Destroy((Object)(object)go);
	}

	private static void RecolorToWhite(GameObject go)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: 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)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: 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_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)go == (Object)null)
		{
			return;
		}
		Light[] componentsInChildren = go.GetComponentsInChildren<Light>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			componentsInChildren[i].color = Color.white;
		}
		ParticleSystem[] componentsInChildren2 = go.GetComponentsInChildren<ParticleSystem>(true);
		for (int i = 0; i < componentsInChildren2.Length; i++)
		{
			MainModule main = componentsInChildren2[i].main;
			((MainModule)(ref main)).startColor = new MinMaxGradient(Color.white, new Color(0.85f, 0.85f, 0.85f, 0.8f));
		}
		Renderer[] componentsInChildren3 = go.GetComponentsInChildren<Renderer>(true);
		foreach (Renderer val in componentsInChildren3)
		{
			try
			{
				val.material.SetColor("_BaseColor", Color.white);
				val.material.SetColor("_Color", Color.white);
				val.material.SetColor("_EmissiveColor", Color.white * 2f);
				val.material.SetColor("_EmissionColor", Color.white * 2f);
				val.material.EnableKeyword("_EMISSION");
			}
			catch
			{
			}
		}
		Component[] componentsInChildren4 = go.GetComponentsInChildren<Component>(true);
		foreach (Component val2 in componentsInChildren4)
		{
			if ((Object)(object)val2 == (Object)null || ((object)val2).GetType().Name != "LocalVolumetricFog")
			{
				continue;
			}
			try
			{
				BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
				FieldInfo field = ((object)val2).GetType().GetField("parameters", bindingAttr);
				if (field != null)
				{
					object value = field.GetValue(val2);
					FieldInfo fieldInfo = value?.GetType().GetField("albedo", bindingAttr);
					if (fieldInfo != null)
					{
						fieldInfo.SetValue(value, Color.white);
						field.SetValue(val2, value);
					}
				}
			}
			catch
			{
			}
		}
	}

	private IEnumerator ShowAnnouncement(Transform casterTf, Vector3 fallback)
	{
		//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)
		GameObject go = new GameObject("IGCText");
		TextMesh obj = go.AddComponent<TextMesh>();
		obj.text = "I'm Gonna Come!";
		obj.fontSize = 200;
		obj.characterSize = 0.032f;
		obj.color = Color.white;
		obj.anchor = (TextAnchor)4;
		obj.alignment = (TextAlignment)1;
		Light obj2 = go.AddComponent<Light>();
		obj2.type = (LightType)2;
		obj2.color = Color.white;
		obj2.intensity = 60f;
		obj2.range = 30f;
		float elapsed = 0f;
		while (elapsed < 3f)
		{
			go.transform.position = (((Object)(object)casterTf != (Object)null) ? casterTf.position : fallback) + Vector3.up * 3.2f;
			if ((Object)(object)Camera.main != (Object)null)
			{
				go.transform.rotation = Quaternion.LookRotation(((Component)Camera.main).transform.forward);
			}
			elapsed += Time.deltaTime;
			yield return null;
		}
		Object.Destroy((Object)(object)go);
	}

	private static Transform FindNearestPlayer(Vector3 pos, GameObject exclude = null)
	{
		//IL_0046: 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)
		Transform result = null;
		float num = float.MaxValue;
		Object[] array = Object.FindObjectsOfType(typeof(PlayerMovement));
		foreach (Object obj in array)
		{
			PlayerMovement val = (PlayerMovement)(object)((obj is PlayerMovement) ? obj : null);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)(object)exclude))
			{
				float num2 = Vector3.Distance(((Component)val).transform.position, pos);
				if (num2 < num)
				{
					num = num2;
					result = ((Component)val).transform;
				}
			}
		}
		return result;
	}
}
[BepInPlugin("com.thewargod_ares.imgonnacome", "ImGonnaCome", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	public const string GUID = "com.thewargod_ares.imgonnacome";

	public const string NAME = "ImGonnaCome";

	public const string VERSION = "1.0.0";

	private void Awake()
	{
		BlackMagicManager.RegisterSpell((BaseUnityPlugin)(object)this, typeof(ImGonnaComeData), typeof(ImGonnaComeLogic));
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[ImGonnaCome] Loaded.");
	}
}