Decompiled source of GojoCursedTechnique v1.0.1

RELESGojoCursedTechnique.dll

Decompiled a day 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 Il2Cpp;
using Il2CppHurricaneVR.Framework.Core.Grabbers;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Reflection;
using MelonLoader;
using RedBlueMod;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "RedBlueMod", "3.2.0", "YourName", null)]
[assembly: MelonGame("Kubunautilus", "BrutalistickVR")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("cursedtechnique")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("cursedtechnique")]
[assembly: AssemblyTitle("cursedtechnique")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RedBlueMod;

public class Core : MelonMod
{
	private enum State
	{
		Idle,
		Charging,
		Ready,
		Cooldown
	}

	private enum OrbType
	{
		Red,
		Blue
	}

	public static HVRHexaBodyInputs playerInputs;

	public static HVRHandGrabber leftHand;

	public static HVRHandGrabber rightHand;

	private State leftState = State.Idle;

	private State rightState = State.Idle;

	private GameObject leftBall;

	private GameObject rightBall;

	private float leftCharge;

	private float rightCharge;

	private bool wasLeftStick;

	private bool wasRightStick;

	private float leftChargeParticleTimer;

	private float rightChargeParticleTimer;

	private const float CHARGE_SPEED = 0.5f;

	private const float MAX_CHARGE = 1f;

	private const float MIN_SIZE = 0.02f;

	private const float MAX_SIZE = 0.08f;

	private const float COOLDOWN = 0.4f;

	private const float MIN_CHARGE_TO_SHOOT = 0.15f;

	private const float RED_SHOOT_SPEED = 15f;

	private const float BLUE_SHOOT_SPEED = 7.5f;

	private const float RED_TRACK_LIFETIME = 5f;

	private const float RED_EXPLOSION_RADIUS_MIN = 3f;

	private const float RED_EXPLOSION_RADIUS_MAX = 7f;

	private const float RED_EXPLOSION_POWER_MIN = 100f;

	private const float RED_EXPLOSION_POWER_MAX = 300f;

	private const float RED_EXPLOSION_DAMAGE_MIN = 30f;

	private const float RED_EXPLOSION_DAMAGE_MAX = 100f;

	private const float RED_FLIGHT_PARTICLE_INTERVAL = 0.06f;

	private const int RED_EXPLOSION_PARTICLE_COUNT = 30;

	private const float BLUE_FLIGHT_TIME = 0.5f;

	private const float BLUE_SLOWDOWN_TIME = 1f;

	private const float BLUE_COLLISION_CHECK_RADIUS = 0.2f;

	private const float BLUE_HOLE_DURATION = 10f;

	private const float BLUE_HOLE_GROW_MULTIPLIER = 10f;

	private const float BLUE_HOLE_RADIUS_GROW_MULTIPLIER = 3f;

	private const float BLUE_PULL_RADIUS_MIN = 2f;

	private const float BLUE_PULL_RADIUS_MAX = 5f;

	private const float BLUE_PULL_FORCE_MIN = 30f;

	private const float BLUE_PULL_FORCE_MAX = 80f;

	private const float BLUE_PULL_DAMAGE_PER_SECOND_MIN = 5f;

	private const float BLUE_PULL_DAMAGE_PER_SECOND_MAX = 20f;

	private const float BLUE_FLIGHT_PARTICLE_INTERVAL = 0.07f;

	private const float BLUE_ACTIVATION_PARTICLE_INTERVAL = 0.15f;

	private const int BLUE_ACTIVATION_PARTICLE_COUNT = 2;

	private const float BLUE_PARTICLE_SIZE_MIN = 0.008f;

	private const float BLUE_PARTICLE_SIZE_MAX = 0.025f;

	private const float PURPLE_FUSION_DETECTION_RADIUS = 2.5f;

	private const float PURPLE_FUSION_COOLDOWN = 30f;

	private const float PURPLE_FUSION_MOVE_TO_ORBIT_TIME = 0.2f;

	private const float PURPLE_FUSION_HOLD_TIME = 0.5f;

	private const float PURPLE_FUSION_ACCEL_TIME = 3f;

	private const float PURPLE_FUSION_CONSTANT_ORBIT_TIME = 4f;

	private const float PURPLE_FUSION_SPIRAL_TIME = 4f;

	private const float PURPLE_FUSION_ORBIT_RADIUS_MIN = 1.2f;

	private const float PURPLE_FUSION_ORBIT_RADIUS_MAX = 3f;

	private const float PURPLE_FUSION_END_RADIUS = 0.15f;

	private const float PURPLE_FUSION_MAX_ROTATIONS_PER_SECOND = 1f;

	private const float PURPLE_FUSION_SPIRAL_SPEED_MULTIPLIER = 1.35f;

	private const float PURPLE_BALL_SIZE = 1.6f;

	private const float PURPLE_GROW_TIME = 5f;

	private const float PURPLE_EXPLOSION_RADIUS = 14f;

	private const float PURPLE_EXPLOSION_POWER = 1200f;

	private const float PURPLE_EXPLOSION_DAMAGE = 400f;

	private const float PURPLE_PARTICLE_SIZE_MIN = 0.016f;

	private const float PURPLE_PARTICLE_SIZE_MAX = 0.05f;

	private const int PURPLE_ACTIVATION_PARTICLE_COUNT = 6;

	private const float PURPLE_ACTIVATION_PARTICLE_INTERVAL = 0.15f;

	private const int PURPLE_EXPLOSION_PARTICLE_COUNT = 24;

	private const float PURPLE_SHOCKWAVE_DURATION = 0.8f;

	private const float PURPLE_SHOCKWAVE_START_ALPHA = 0.35f;

	private const float CHARGE_PARTICLE_INTERVAL = 0.03f;

	private const float READY_PARTICLE_MIN_CHARGE = 0.7f;

	private const float READY_BLUE_PARTICLE_INTERVAL = 0.25f;

	private const float READY_RED_PARTICLE_INTERVAL = 0.25f;

	private const int MAX_PARTICLES = 250;

	private int activeParticles;

	private Material redParticleMaterial;

	private Material blueParticleMaterial;

	private Material purpleParticleMaterial;

	private bool purpleFusionActive;

	private float purpleCooldownEndTime = -1f;

	private readonly List<GameObject> activeBlueHoles = new List<GameObject>();

	private readonly HashSet<GameObject> fusionLockedRedBalls = new HashSet<GameObject>();

	private readonly HashSet<GameObject> fusionLockedBlueBalls = new HashSet<GameObject>();

	public override void OnInitializeMelon()
	{
		((MelonBase)this).LoggerInstance.Msg("RedBlueMod v3.2.0 — зарядные частицы, горизонтальная орбита, взрывная волна.");
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		ResetState();
		if (sceneName == "MainMenuScene")
		{
			return;
		}
		GameObject val = GameObject.Find("Hexa4Rig26.10.23");
		if ((Object)(object)val == (Object)null)
		{
			((MelonBase)this).LoggerInstance.Warning("Hexa4Rig26.10.23 не найден!");
			return;
		}
		playerInputs = val.GetComponentInChildren<HVRHexaBodyInputs>();
		Transform obj = val.transform.Find("Physics LeftHand");
		leftHand = ((obj != null) ? ((Component)obj).GetComponent<HVRHandGrabber>() : null);
		Transform obj2 = val.transform.Find("Physics RightHand");
		rightHand = ((obj2 != null) ? ((Component)obj2).GetComponent<HVRHandGrabber>() : null);
		if ((Object)(object)leftHand == (Object)null || (Object)(object)rightHand == (Object)null)
		{
			((MelonBase)this).LoggerInstance.Warning("Руки не найдены!");
		}
		else
		{
			((MelonBase)this).LoggerInstance.Msg("RedBlueMod v3.2.0 загружен.");
		}
	}

	private void ResetState()
	{
		leftState = State.Idle;
		rightState = State.Idle;
		leftBall = null;
		rightBall = null;
		leftCharge = 0f;
		rightCharge = 0f;
		wasLeftStick = false;
		wasRightStick = false;
		leftChargeParticleTimer = 0f;
		rightChargeParticleTimer = 0f;
		playerInputs = null;
		leftHand = null;
		rightHand = null;
		activeParticles = 0;
		if ((Object)(object)redParticleMaterial != (Object)null)
		{
			Object.Destroy((Object)(object)redParticleMaterial);
		}
		if ((Object)(object)blueParticleMaterial != (Object)null)
		{
			Object.Destroy((Object)(object)blueParticleMaterial);
		}
		if ((Object)(object)purpleParticleMaterial != (Object)null)
		{
			Object.Destroy((Object)(object)purpleParticleMaterial);
		}
		redParticleMaterial = null;
		blueParticleMaterial = null;
		purpleParticleMaterial = null;
		purpleFusionActive = false;
		purpleCooldownEndTime = -1f;
		activeBlueHoles.Clear();
		fusionLockedRedBalls.Clear();
		fusionLockedBlueBalls.Clear();
	}

	public override void OnUpdate()
	{
		//IL_004d: 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 (!((Object)(object)playerInputs == (Object)null) && !((Object)(object)playerInputs.LeftController == (Object)null) && !((Object)(object)playerInputs.RightController == (Object)null))
		{
			bool active = playerInputs.LeftController.JoystickButtonState.Active;
			bool active2 = playerInputs.RightController.JoystickButtonState.Active;
			ProcessHand(isLeft: true, active, wasLeftStick, ref leftState, ref leftBall, ref leftCharge, leftHand, OrbType.Blue);
			ProcessHand(isLeft: false, active2, wasRightStick, ref rightState, ref rightBall, ref rightCharge, rightHand, OrbType.Red);
			UpdateHandChargeParticles(leftBall, leftState, leftCharge, OrbType.Blue, ref leftChargeParticleTimer);
			UpdateHandChargeParticles(rightBall, rightState, rightCharge, OrbType.Red, ref rightChargeParticleTimer);
			wasLeftStick = active;
			wasRightStick = active2;
		}
	}

	private void ProcessHand(bool isLeft, bool stick, bool wasStick, ref State state, ref GameObject ball, ref float charge, HVRHandGrabber hand, OrbType type)
	{
		if ((Object)(object)hand == (Object)null)
		{
			return;
		}
		if (state == State.Idle)
		{
			if (stick && !wasStick)
			{
				state = State.Charging;
				ball = CreateBall(((Component)hand).transform, type);
				charge = 0f;
			}
		}
		else if (state == State.Charging)
		{
			if (!stick && wasStick)
			{
				if (charge < 0.15f)
				{
					CancelBall(ref ball);
					state = State.Cooldown;
					MelonCoroutines.Start(ResetAfterCooldown(isLeft));
				}
				else
				{
					state = State.Ready;
				}
			}
			else
			{
				charge += Time.deltaTime * 0.5f;
				if (charge > 1f)
				{
					charge = 1f;
				}
				UpdateBall(ball, charge, type);
			}
		}
		else if (state == State.Ready && stick && !wasStick)
		{
			Shoot(ball, ((Component)hand).transform, charge, type);
			ball = null;
			state = State.Cooldown;
			MelonCoroutines.Start(ResetAfterCooldown(isLeft));
		}
	}

	private GameObject CreateBall(Transform hand, OrbType type)
	{
		//IL_004c: 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_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Expected O, but got Unknown
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
		Object.Destroy((Object)(object)val.GetComponent<Collider>());
		((Object)val).name = ((type == OrbType.Red) ? "RedBall" : "BlueBall");
		val.transform.SetParent(hand);
		val.transform.localPosition = new Vector3(0f, 0.05f, 0.12f);
		val.transform.localRotation = Quaternion.identity;
		val.transform.localScale = Vector3.one * 0.02f;
		Renderer component = val.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader val2 = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard");
			if ((Object)(object)val2 != (Object)null)
			{
				component.material = new Material(val2);
				if (type == OrbType.Red)
				{
					component.material.color = new Color(1f, 0.05f, 0.05f);
				}
				else
				{
					component.material.color = new Color(0.1f, 0.3f, 1f);
				}
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
		Light val3 = val.AddComponent<Light>();
		val3.type = (LightType)2;
		if (type == OrbType.Red)
		{
			val3.color = new Color(1f, 0.05f, 0.05f);
			val3.intensity = 7f;
			val3.range = 3.5f;
		}
		else
		{
			val3.color = new Color(0.2f, 0.4f, 1f);
			val3.intensity = 5f;
			val3.range = 3f;
		}
		return val;
	}

	private void UpdateBall(GameObject b, float charge, OrbType type)
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: 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_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)b == (Object)null)
		{
			return;
		}
		float num = charge / 1f;
		float num2 = Mathf.Lerp(0.02f, 0.08f, num);
		b.transform.localScale = Vector3.one * num2;
		Renderer component = b.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null && (Object)(object)component.material != (Object)null)
		{
			if (type == OrbType.Red)
			{
				component.material.color = Color.Lerp(new Color(1f, 0.15f, 0.15f), new Color(1f, 0f, 0f), num);
			}
			else
			{
				component.material.color = Color.Lerp(new Color(0.35f, 0.75f, 1f), new Color(0.05f, 0.25f, 1f), num);
			}
		}
		Light component2 = b.GetComponent<Light>();
		if ((Object)(object)component2 != (Object)null)
		{
			if (type == OrbType.Red)
			{
				component2.color = new Color(1f, 0.05f, 0.05f);
				component2.intensity = Mathf.Lerp(7f, 15f, num);
				component2.range = Mathf.Lerp(3.5f, 6f, num);
			}
			else
			{
				component2.color = new Color(0.2f, 0.4f, 1f);
				component2.intensity = Mathf.Lerp(5f, 10f, num);
				component2.range = Mathf.Lerp(3f, 5f, num);
			}
		}
	}

	private void Shoot(GameObject b, Transform hand, float charge, OrbType type)
	{
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Expected O, but got Unknown
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)b == (Object)null)
		{
			return;
		}
		b.transform.SetParent((Transform)null);
		SphereCollider val = b.AddComponent<SphereCollider>();
		val.radius = 0.5f;
		((Collider)val).isTrigger = type == OrbType.Blue;
		Rigidbody val2 = b.AddComponent<Rigidbody>();
		val2.useGravity = false;
		val2.collisionDetectionMode = (CollisionDetectionMode)2;
		float num = ((type == OrbType.Red) ? 15f : 7.5f);
		float num2 = Mathf.Lerp(num * 0.6f, num, charge / 1f);
		val2.velocity = hand.forward * num2;
		TrailRenderer val3 = b.AddComponent<TrailRenderer>();
		val3.time = 0.25f;
		val3.startWidth = b.transform.localScale.x * 1.5f;
		val3.endWidth = 0.005f;
		val3.minVertexDistance = 0.15f;
		Shader val4 = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard");
		if ((Object)(object)val4 != (Object)null)
		{
			Material val5 = new Material(val4);
			if (type == OrbType.Red)
			{
				val5.color = new Color(1f, 0.05f, 0.05f);
			}
			else
			{
				val5.color = new Color(0.25f, 0.55f, 1f);
			}
			((Renderer)val3).material = val5;
		}
		if (type == OrbType.Red)
		{
			val3.startColor = new Color(1f, 0.15f, 0.15f, 0.95f);
			val3.endColor = new Color(1f, 0f, 0f, 0f);
			MelonCoroutines.Start(RedTrack(b, charge));
		}
		else
		{
			val3.startColor = new Color(0.4f, 0.75f, 1f, 0.95f);
			val3.endColor = new Color(0.05f, 0.2f, 1f, 0f);
			MelonCoroutines.Start(BlueTrack(b, charge));
		}
	}

	private void CancelBall(ref GameObject ball)
	{
		if ((Object)(object)ball != (Object)null)
		{
			Object.Destroy((Object)(object)ball);
			ball = null;
		}
	}

	private IEnumerator ResetAfterCooldown(bool isLeft)
	{
		yield return (object)new WaitForSeconds(0.4f);
		if (isLeft)
		{
			leftState = State.Idle;
		}
		else
		{
			rightState = State.Idle;
		}
	}

	private void UpdateHandChargeParticles(GameObject ball, State state, float charge, OrbType type, ref float timer)
	{
		if ((Object)(object)ball == (Object)null || (state != State.Charging && state != State.Ready))
		{
			timer = 0f;
			return;
		}
		timer -= Time.deltaTime;
		if (timer > 0f)
		{
			return;
		}
		float num = Mathf.Clamp01(charge / 1f);
		switch (state)
		{
		case State.Charging:
		{
			int num2 = Mathf.CeilToInt(Mathf.Lerp(2f, 4f, num));
			for (int i = 0; i < num2; i++)
			{
				SpawnChargeImplodeParticle(ball, type, intense: true);
			}
			timer = 0.03f;
			break;
		}
		case State.Ready:
			if (num < 0.7f)
			{
				timer = 0.1f;
			}
			else if (type == OrbType.Blue)
			{
				SpawnChargeImplodeParticle(ball, type, intense: false);
				timer = 0.25f;
			}
			else
			{
				SpawnReadyRedOutwardParticle(ball);
				timer = 0.25f;
			}
			break;
		}
	}

	private void SpawnChargeImplodeParticle(GameObject ball, OrbType type, bool intense)
	{
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: 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_00e9: 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_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ball == (Object)null || activeParticles >= 250)
		{
			return;
		}
		Material val = ((type == OrbType.Red) ? GetRedParticleMaterial() : GetBlueParticleMaterial());
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0);
		if (!((Object)(object)val2 == (Object)null))
		{
			activeParticles++;
			Object.Destroy((Object)(object)val2.GetComponent<Collider>());
			((Object)val2).name = (intense ? "ChargeImplodeParticle" : "ReadyImplodeParticle");
			Vector3 position = ball.transform.position;
			float x = ball.transform.localScale.x;
			float num = (intense ? Mathf.Max(0.18f, x * 3.5f) : Mathf.Max(0.12f, x * 2.5f));
			val2.transform.position = position + Random.onUnitSphere * num;
			float num2 = (intense ? Random.Range(0.006f, 0.016f) : Random.Range(0.004f, 0.01f));
			val2.transform.localScale = Vector3.one * num2;
			SetupParticleRenderer(val2, val);
			float speed;
			float acceleration;
			float life;
			if (intense)
			{
				speed = Random.Range(1.2f, 2.6f);
				acceleration = Random.Range(6f, 12f);
				life = Random.Range(0.22f, 0.45f);
			}
			else
			{
				speed = Random.Range(0.15f, 0.35f);
				acceleration = Random.Range(0.25f, 0.6f);
				life = Random.Range(0.9f, 1.5f);
			}
			MelonCoroutines.Start(ChargeImplodeParticleRoutine(val2, ball, speed, acceleration, life));
		}
	}

	private IEnumerator ChargeImplodeParticleRoutine(GameObject particle, GameObject targetBall, float speed, float acceleration, float life)
	{
		if ((Object)(object)particle == (Object)null)
		{
			if (activeParticles > 0)
			{
				activeParticles--;
			}
			yield break;
		}
		Vector3 startScale = particle.transform.localScale;
		float elapsed = 0f;
		while ((Object)(object)particle != (Object)null && (Object)(object)targetBall != (Object)null && elapsed < life)
		{
			float dt = Time.deltaTime;
			Vector3 center = targetBall.transform.position;
			Vector3 pos = particle.transform.position;
			Vector3 direction = center - pos;
			float distance = ((Vector3)(ref direction)).magnitude;
			if (distance < 0.02f)
			{
				break;
			}
			((Vector3)(ref direction)).Normalize();
			speed += acceleration * dt;
			float moveDistance = Mathf.Min(speed * dt, distance);
			particle.transform.position = pos + direction * moveDistance;
			elapsed += dt;
			float t = elapsed / life;
			particle.transform.localScale = startScale * Mathf.Clamp01(1f - t);
			yield return null;
		}
		if ((Object)(object)particle != (Object)null)
		{
			Object.Destroy((Object)(object)particle);
		}
		if (activeParticles > 0)
		{
			activeParticles--;
		}
	}

	private void SpawnReadyRedOutwardParticle(GameObject ball)
	{
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ball == (Object)null || activeParticles >= 250)
		{
			return;
		}
		Material val = GetRedParticleMaterial();
		if (!((Object)(object)val == (Object)null))
		{
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0);
			if (!((Object)(object)val2 == (Object)null))
			{
				activeParticles++;
				Object.Destroy((Object)(object)val2.GetComponent<Collider>());
				((Object)val2).name = "ReadyRedOutwardParticle";
				Vector3 position = ball.transform.position;
				Vector3 onUnitSphere = Random.onUnitSphere;
				float num = Mathf.Max(0.02f, ball.transform.localScale.x * 0.8f);
				val2.transform.position = position + onUnitSphere * num;
				float num2 = Random.Range(0.004f, 0.01f);
				val2.transform.localScale = Vector3.one * num2;
				SetupParticleRenderer(val2, val);
				float num3 = Random.Range(0.18f, 0.38f);
				Vector3 velocity = onUnitSphere * num3;
				float life = Random.Range(0.8f, 1.3f);
				MelonCoroutines.Start(OutwardParticleRoutine(val2, velocity, life));
			}
		}
	}

	private IEnumerator RedTrack(GameObject ball, float charge)
	{
		yield return (object)new WaitForSeconds(0.05f);
		if ((Object)(object)ball == (Object)null)
		{
			yield break;
		}
		Rigidbody rb = ball.GetComponent<Rigidbody>();
		float startTime = Time.time;
		float checkRadius = 0.4f;
		float flightParticleTimer = 0f;
		while ((Object)(object)ball != (Object)null && Time.time - startTime < 5f)
		{
			if (fusionLockedRedBalls.Contains(ball))
			{
				yield break;
			}
			Vector3 pos = ball.transform.position;
			if (CanStartPurpleFusion())
			{
				GameObject blue = FindNearestActiveBlueHole(pos, 2.5f);
				if ((Object)(object)blue != (Object)null)
				{
					StartPurpleFusion(ball, blue);
					yield break;
				}
			}
			Collider[] hits = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(pos, checkRadius));
			Collider[] array = hits;
			foreach (Collider hit in array)
			{
				if (!((Object)(object)hit == (Object)null) && !((Object)(object)((Component)hit).gameObject == (Object)null) && !((Object)(object)((Component)hit).gameObject == (Object)(object)ball) && !hit.isTrigger && !IsPlayer(((Component)hit).gameObject))
				{
					RedExplode(pos, charge);
					Object.Destroy((Object)(object)ball);
					yield break;
				}
			}
			flightParticleTimer -= Time.deltaTime;
			if (flightParticleTimer <= 0f)
			{
				Vector3 velocity = (((Object)(object)rb != (Object)null) ? rb.velocity : Vector3.zero);
				SpawnFlightParticle(pos, velocity, GetRedParticleMaterial());
				flightParticleTimer = 0.06f;
			}
			yield return null;
		}
		if ((Object)(object)ball != (Object)null)
		{
			Object.Destroy((Object)(object)ball);
		}
	}

	private void RedExplode(Vector3 position, float charge)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Clamp01(charge / 1f);
		float num2 = Mathf.Lerp(3f, 7f, num);
		float num3 = Mathf.Lerp(100f, 300f, num);
		float damage = Mathf.Lerp(30f, 100f, num);
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(position, num2));
		Collider[] array2 = array;
		foreach (Collider val in array2)
		{
			if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null) && !IsPlayer(((Component)val).gameObject))
			{
				Rigidbody component = ((Component)val).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.AddExplosionForce(num3, position, num2, 1f, (ForceMode)1);
				}
				ApplyDamage(((Component)val).gameObject, position, damage, num2);
			}
		}
		SpawnRedExplosionEffect(position, num2);
		SpawnRedExplosionParticles(position, num2);
	}

	private void SpawnRedExplosionEffect(Vector3 position, float radius)
	{
		//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_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
		Object.Destroy((Object)(object)val.GetComponent<Collider>());
		((Object)val).name = "RedExplosion";
		val.transform.position = position;
		val.transform.localScale = Vector3.one * 0.1f;
		Renderer component = val.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader val2 = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard");
			if ((Object)(object)val2 != (Object)null)
			{
				component.material = new Material(val2);
				component.material.color = new Color(1f, 0f, 0f);
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
		Light val3 = val.AddComponent<Light>();
		val3.type = (LightType)2;
		val3.color = new Color(1f, 0.1f, 0.1f);
		val3.intensity = 30f;
		val3.range = radius * 3f;
		MelonCoroutines.Start(RedExplosionAnimation(val, val3, radius));
	}

	private IEnumerator RedExplosionAnimation(GameObject explosion, Light flash, float radius)
	{
		float duration = 0.3f;
		float elapsed = 0f;
		Vector3 startScale = Vector3.one * 0.1f;
		Vector3 maxScale = Vector3.one * Mathf.Max(2.5f, radius * 0.5f);
		while (elapsed < duration && (Object)(object)explosion != (Object)null)
		{
			elapsed += Time.deltaTime;
			float t = elapsed / duration;
			explosion.transform.localScale = Vector3.Lerp(startScale, maxScale, t);
			if ((Object)(object)flash != (Object)null)
			{
				flash.intensity = Mathf.Lerp(30f, 0f, t * t);
			}
			Renderer r = explosion.GetComponent<Renderer>();
			if ((Object)(object)r != (Object)null && (Object)(object)r.material != (Object)null)
			{
				r.material.color = Color.Lerp(new Color(1f, 0.05f, 0.05f), new Color(0.35f, 0f, 0f), t);
			}
			yield return null;
		}
		if ((Object)(object)explosion != (Object)null)
		{
			Object.Destroy((Object)(object)explosion);
		}
	}

	private void SpawnRedExplosionParticles(Vector3 center, float radius)
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: 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_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		Material val = GetRedParticleMaterial();
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		for (int i = 0; i < 30; i++)
		{
			if (activeParticles >= 250)
			{
				break;
			}
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0);
			if (!((Object)(object)val2 == (Object)null))
			{
				activeParticles++;
				Object.Destroy((Object)(object)val2.GetComponent<Collider>());
				((Object)val2).name = "RedExplosionParticle";
				Vector3 onUnitSphere = Random.onUnitSphere;
				val2.transform.position = center + onUnitSphere * 0.1f;
				float num = Random.Range(0.01f, 0.035f);
				val2.transform.localScale = Vector3.one * num;
				SetupParticleRenderer(val2, val);
				float num2 = Random.Range(5f, 11f) + radius * 0.6f;
				Vector3 velocity = onUnitSphere * num2;
				float outwardTime = Random.Range(0.25f, 0.45f);
				float floatTime = Random.Range(0.6f, 1.2f);
				float implodeTime = Random.Range(0.5f, 0.9f);
				MelonCoroutines.Start(RedExplosionParticleRoutine(val2, center, velocity, outwardTime, floatTime, implodeTime));
			}
		}
	}

	private IEnumerator RedExplosionParticleRoutine(GameObject particle, Vector3 center, Vector3 velocity, float outwardTime, float floatTime, float implodeTime)
	{
		//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)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)particle == (Object)null)
		{
			if (activeParticles > 0)
			{
				activeParticles--;
			}
			yield break;
		}
		Vector3 startScale = particle.transform.localScale;
		float elapsed = 0f;
		while ((Object)(object)particle != (Object)null && elapsed < outwardTime)
		{
			float dt = Time.deltaTime;
			Vector3 pos = particle.transform.position;
			particle.transform.position = pos + velocity * dt;
			velocity *= 0.88f;
			elapsed += dt;
			yield return null;
		}
		elapsed = 0f;
		Vector3 drift = Random.insideUnitSphere * 0.3f;
		while ((Object)(object)particle != (Object)null && elapsed < floatTime)
		{
			float dt2 = Time.deltaTime;
			Vector3 pos2 = particle.transform.position;
			particle.transform.position = pos2 + drift * dt2;
			drift *= 0.96f;
			elapsed += dt2;
			yield return null;
		}
		elapsed = 0f;
		while ((Object)(object)particle != (Object)null && elapsed < implodeTime)
		{
			float dt3 = Time.deltaTime;
			float t = elapsed / implodeTime;
			Vector3 pos3 = particle.transform.position;
			float distanceToCenter = Vector3.Distance(pos3, center);
			float speed = Mathf.Lerp(3f, 18f, t) + distanceToCenter * 2f;
			Vector3 newPos = Vector3.MoveTowards(pos3, center, speed * dt3);
			particle.transform.position = newPos;
			particle.transform.localScale = startScale * Mathf.Clamp01(1f - t);
			if (Vector3.Distance(newPos, center) < 0.05f)
			{
				break;
			}
			elapsed += dt3;
			yield return null;
		}
		if ((Object)(object)particle != (Object)null)
		{
			Object.Destroy((Object)(object)particle);
		}
		if (activeParticles > 0)
		{
			activeParticles--;
		}
	}

	private IEnumerator BlueTrack(GameObject ball, float charge)
	{
		if ((Object)(object)ball == (Object)null)
		{
			yield break;
		}
		Rigidbody rb = ball.GetComponent<Rigidbody>();
		if ((Object)(object)rb == (Object)null)
		{
			yield break;
		}
		Collider col = ball.GetComponent<Collider>();
		if ((Object)(object)col != (Object)null)
		{
			col.isTrigger = true;
		}
		Vector3 startVelocity = rb.velocity;
		float flightParticleTimer = 0f;
		float elapsed = 0f;
		while ((Object)(object)ball != (Object)null && elapsed < 0.5f)
		{
			if (CheckBlueSolidCollision(ball, rb))
			{
				StopBlueBall(rb);
				MelonCoroutines.Start(BlueHoleRoutine(ball, charge));
				yield break;
			}
			rb.velocity = startVelocity;
			flightParticleTimer -= Time.fixedDeltaTime;
			if (flightParticleTimer <= 0f)
			{
				SpawnFlightParticle(ball.transform.position, rb.velocity, GetBlueParticleMaterial());
				flightParticleTimer = 0.07f;
			}
			elapsed += Time.fixedDeltaTime;
			yield return (object)new WaitForFixedUpdate();
		}
		if ((Object)(object)ball == (Object)null)
		{
			yield break;
		}
		elapsed = 0f;
		while ((Object)(object)ball != (Object)null && elapsed < 1f)
		{
			if (CheckBlueSolidCollision(ball, rb))
			{
				StopBlueBall(rb);
				MelonCoroutines.Start(BlueHoleRoutine(ball, charge));
				yield break;
			}
			float t = elapsed / 1f;
			float speedMultiplier = Mathf.SmoothStep(1f, 0f, t);
			rb.velocity = startVelocity * speedMultiplier;
			flightParticleTimer -= Time.fixedDeltaTime;
			if (flightParticleTimer <= 0f)
			{
				SpawnFlightParticle(ball.transform.position, rb.velocity, GetBlueParticleMaterial());
				flightParticleTimer = 0.105000004f;
			}
			elapsed += Time.fixedDeltaTime;
			yield return (object)new WaitForFixedUpdate();
		}
		if (!((Object)(object)ball == (Object)null))
		{
			StopBlueBall(rb);
			MelonCoroutines.Start(BlueHoleRoutine(ball, charge));
		}
	}

	private void StopBlueBall(Rigidbody rb)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)rb == (Object)null))
		{
			rb.velocity = Vector3.zero;
			rb.isKinematic = true;
		}
	}

	private bool CheckBlueSolidCollision(GameObject ball, Rigidbody rb)
	{
		//IL_0019: 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)
		//IL_002a: 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_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_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: 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)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ball == (Object)null)
		{
			return false;
		}
		Vector3 position = ball.transform.position;
		float radius = Mathf.Max(0.2f, ball.transform.localScale.x * 0.5f);
		if (HasSolidColliderAt(position, radius, ball))
		{
			return true;
		}
		if ((Object)(object)rb != (Object)null)
		{
			Vector3 velocity = rb.velocity;
			if (((Vector3)(ref velocity)).sqrMagnitude > 0.001f)
			{
				Vector3 position2 = position - rb.velocity * Time.fixedDeltaTime;
				if (HasSolidColliderAt(position2, radius, ball))
				{
					return true;
				}
			}
		}
		return false;
	}

	private bool HasSolidColliderAt(Vector3 position, float radius, GameObject ignore)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(position, radius));
		Collider[] array2 = array;
		foreach (Collider val in array2)
		{
			if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)(object)ignore) && !val.isTrigger && !IsPlayer(((Component)val).gameObject))
			{
				return true;
			}
		}
		return false;
	}

	private IEnumerator BlueHoleRoutine(GameObject ball, float charge)
	{
		if ((Object)(object)ball == (Object)null)
		{
			yield break;
		}
		if (!activeBlueHoles.Contains(ball))
		{
			activeBlueHoles.Add(ball);
		}
		Vector3 center = ball.transform.position;
		Vector3 startScale = ball.transform.localScale;
		float chargeT = Mathf.Clamp01(charge / 1f);
		float baseRadius = Mathf.Lerp(2f, 5f, chargeT);
		float baseForce = Mathf.Lerp(30f, 80f, chargeT);
		float damagePerSecond = Mathf.Lerp(5f, 20f, chargeT);
		float elapsed = 0f;
		float damageTimer = 0f;
		Light light = ball.GetComponent<Light>();
		Renderer renderer = ball.GetComponent<Renderer>();
		Color ballColor = new Color(0.1f, 0.3f, 1f);
		Color lightColor = new Color(0.2f, 0.4f, 1f);
		if ((Object)(object)renderer != (Object)null && (Object)(object)renderer.material != (Object)null)
		{
			ballColor = renderer.material.color;
		}
		if ((Object)(object)light != (Object)null)
		{
			lightColor = light.color;
		}
		SpawnBlueActivationBurst(center, baseRadius);
		float activationParticleTimer = 0f;
		while ((Object)(object)ball != (Object)null && elapsed < 10f)
		{
			if (fusionLockedBlueBalls.Contains(ball))
			{
				activeBlueHoles.Remove(ball);
				yield break;
			}
			float t = elapsed / 10f;
			float grow = Mathf.Lerp(1f, 10f, t);
			ball.transform.localScale = startScale * grow;
			float radius = baseRadius * Mathf.Lerp(1f, 3f, t);
			float force = baseForce * Mathf.Lerp(0.6f, 1f, t);
			PullObjects(center, radius, force, ball);
			activationParticleTimer -= Time.fixedDeltaTime;
			if (activationParticleTimer <= 0f)
			{
				SpawnBlueActivationBurst(center, radius);
				activationParticleTimer = 0.15f;
			}
			damageTimer -= Time.fixedDeltaTime;
			if (damageTimer <= 0f)
			{
				ApplyAreaDamage(center, radius, damagePerSecond * 0.5f, ball);
				damageTimer = 0.5f;
			}
			if ((Object)(object)light != (Object)null)
			{
				light.color = lightColor;
				light.range = radius * 2f;
				light.intensity = Mathf.Lerp(10f, 25f, t);
			}
			if ((Object)(object)renderer != (Object)null && (Object)(object)renderer.material != (Object)null)
			{
				renderer.material.color = ballColor;
			}
			elapsed += Time.fixedDeltaTime;
			yield return (object)new WaitForFixedUpdate();
		}
		activeBlueHoles.Remove(ball);
		if ((Object)(object)ball != (Object)null)
		{
			Object.Destroy((Object)(object)ball);
		}
	}

	private void PullObjects(Vector3 center, float radius, float force, GameObject ignore)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: 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)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(center, radius));
		Collider[] array2 = array;
		foreach (Collider val in array2)
		{
			if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null || (Object)(object)((Component)val).gameObject == (Object)(object)ignore || IsPlayer(((Component)val).gameObject))
			{
				continue;
			}
			Rigidbody component = ((Component)val).GetComponent<Rigidbody>();
			if ((Object)(object)component == (Object)null || component.isKinematic)
			{
				continue;
			}
			Vector3 val2 = center - component.position;
			float magnitude = ((Vector3)(ref val2)).magnitude;
			if (!(magnitude < 0.1f))
			{
				((Vector3)(ref val2)).Normalize();
				float num = Mathf.Clamp01(magnitude / radius);
				float num2 = 1f - num;
				float num3 = Mathf.Lerp(0.35f, 1f, num2);
				float num4 = force * num3 * 1.5f;
				if (!(num4 <= 0f))
				{
					component.AddForce(val2 * num4, (ForceMode)5);
				}
			}
		}
	}

	private void ApplyAreaDamage(Vector3 center, float radius, float damage, GameObject ignore)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		if (damage <= 0f)
		{
			return;
		}
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(center, radius));
		HashSet<GameObject> hashSet = new HashSet<GameObject>();
		Collider[] array2 = array;
		foreach (Collider val in array2)
		{
			if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)(object)ignore) && !IsPlayer(((Component)val).gameObject) && hashSet.Add(((Component)val).gameObject))
			{
				ApplyDamage(((Component)val).gameObject, center, damage, radius);
			}
		}
	}

	private void SpawnBlueActivationBurst(Vector3 center, float radius)
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: 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_009b: 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)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		Material val = GetBlueParticleMaterial();
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		for (int i = 0; i < 2; i++)
		{
			if (activeParticles >= 250)
			{
				break;
			}
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0);
			if (!((Object)(object)val2 == (Object)null))
			{
				activeParticles++;
				Object.Destroy((Object)(object)val2.GetComponent<Collider>());
				((Object)val2).name = "BlueActivationParticle";
				Vector3 onUnitSphere = Random.onUnitSphere;
				float num = Mathf.Max(0.05f, radius * 0.08f);
				val2.transform.position = center + onUnitSphere * num;
				float num2 = Random.Range(0.008f, 0.025f);
				val2.transform.localScale = Vector3.one * num2;
				SetupParticleRenderer(val2, val);
				float num3 = Random.Range(0.4f, 1.4f) + radius * 0.12f;
				Vector3 velocity = onUnitSphere * num3;
				float life = Random.Range(0.7f, 1.4f);
				MelonCoroutines.Start(OutwardParticleRoutine(val2, velocity, life));
			}
		}
	}

	private IEnumerator OutwardParticleRoutine(GameObject particle, Vector3 velocity, float life)
	{
		//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)
		if ((Object)(object)particle == (Object)null)
		{
			if (activeParticles > 0)
			{
				activeParticles--;
			}
			yield break;
		}
		Vector3 startScale = particle.transform.localScale;
		float elapsed = 0f;
		while ((Object)(object)particle != (Object)null && elapsed < life)
		{
			float dt = Time.deltaTime;
			Vector3 pos = particle.transform.position;
			particle.transform.position = pos + velocity * dt;
			velocity *= 0.9f;
			elapsed += dt;
			float t = elapsed / life;
			particle.transform.localScale = startScale * Mathf.Clamp01(1f - t);
			yield return null;
		}
		if ((Object)(object)particle != (Object)null)
		{
			Object.Destroy((Object)(object)particle);
		}
		if (activeParticles > 0)
		{
			activeParticles--;
		}
	}

	private bool CanStartPurpleFusion()
	{
		return !purpleFusionActive && Time.time >= purpleCooldownEndTime;
	}

	private GameObject FindNearestActiveBlueHole(Vector3 position, float baseRadius)
	{
		//IL_0061: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		GameObject result = null;
		float num = float.MaxValue;
		for (int num2 = activeBlueHoles.Count - 1; num2 >= 0; num2--)
		{
			GameObject val = activeBlueHoles[num2];
			if ((Object)(object)val == (Object)null)
			{
				activeBlueHoles.RemoveAt(num2);
			}
			else if (!fusionLockedBlueBalls.Contains(val))
			{
				float num3 = val.transform.localScale.x * 0.5f;
				float num4 = baseRadius + num3;
				float num5 = Vector3.Distance(position, val.transform.position);
				if (num5 <= num4 && num5 < num)
				{
					result = val;
					num = num5;
				}
			}
		}
		return result;
	}

	private void StartPurpleFusion(GameObject redBall, GameObject blueBall)
	{
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)redBall == (Object)null) && !((Object)(object)blueBall == (Object)null))
		{
			purpleFusionActive = true;
			activeBlueHoles.Remove(blueBall);
			fusionLockedRedBalls.Add(redBall);
			fusionLockedBlueBalls.Add(blueBall);
			Rigidbody component = redBall.GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null)
			{
				component.velocity = Vector3.zero;
				component.isKinematic = true;
			}
			Collider component2 = redBall.GetComponent<Collider>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.isTrigger = true;
			}
			Rigidbody component3 = blueBall.GetComponent<Rigidbody>();
			if ((Object)(object)component3 != (Object)null)
			{
				component3.velocity = Vector3.zero;
				component3.isKinematic = true;
			}
			Collider component4 = blueBall.GetComponent<Collider>();
			if ((Object)(object)component4 != (Object)null)
			{
				component4.isTrigger = true;
			}
			MelonCoroutines.Start(PurpleFusionRoutine(redBall, blueBall));
		}
	}

	private IEnumerator PurpleFusionRoutine(GameObject redBall, GameObject blueBall)
	{
		if ((Object)(object)redBall == (Object)null || (Object)(object)blueBall == (Object)null)
		{
			CleanupFusion(redBall, blueBall);
			yield break;
		}
		Vector3 center = blueBall.transform.position;
		Vector3 redStartScale = redBall.transform.localScale;
		Vector3 initialPosition = redBall.transform.position;
		Vector3 offset = initialPosition - center;
		Vector3 horizontalOffset = new Vector3(offset.x, 0f, offset.z);
		if (((Vector3)(ref horizontalOffset)).sqrMagnitude < 0.01f)
		{
			horizontalOffset = Random.onUnitSphere;
			horizontalOffset.y = 0f;
			if (((Vector3)(ref horizontalOffset)).sqrMagnitude < 0.01f)
			{
				horizontalOffset = Vector3.forward;
			}
		}
		((Vector3)(ref horizontalOffset)).Normalize();
		Vector3 radial = horizontalOffset;
		Vector3 val = Vector3.Cross(Vector3.up, radial);
		Vector3 tangent = ((Vector3)(ref val)).normalized;
		val = new Vector3(offset.x, 0f, offset.z);
		float horizontalDistance = ((Vector3)(ref val)).magnitude;
		float orbitRadius = Mathf.Clamp(horizontalDistance, 1.2f, 3f);
		Vector3 holdTargetPosition = center + radial * orbitRadius;
		holdTargetPosition.y = center.y;
		float elapsed = 0f;
		while (elapsed < 0.2f)
		{
			if ((Object)(object)redBall == (Object)null || (Object)(object)blueBall == (Object)null)
			{
				CleanupFusion(redBall, blueBall);
				yield break;
			}
			float t = elapsed / 0.2f;
			float smoothT = Mathf.SmoothStep(0f, 1f, t);
			redBall.transform.position = Vector3.Lerp(initialPosition, holdTargetPosition, smoothT);
			elapsed += Time.deltaTime;
			yield return null;
		}
		elapsed = 0f;
		while (elapsed < 0.5f)
		{
			if ((Object)(object)redBall == (Object)null || (Object)(object)blueBall == (Object)null)
			{
				CleanupFusion(redBall, blueBall);
				yield break;
			}
			redBall.transform.position = holdTargetPosition;
			elapsed += Time.deltaTime;
			yield return null;
		}
		float angle = 0f;
		float maxAngularSpeed = 6.283185f;
		elapsed = 0f;
		while (elapsed < 3f)
		{
			if ((Object)(object)redBall == (Object)null || (Object)(object)blueBall == (Object)null)
			{
				CleanupFusion(redBall, blueBall);
				yield break;
			}
			float t2 = elapsed / 3f;
			float smoothT2 = Mathf.SmoothStep(0f, 1f, t2);
			float angularSpeed = Mathf.Lerp(0f, maxAngularSpeed, smoothT2);
			angle += angularSpeed * Time.deltaTime;
			Vector3 pos = center + (radial * Mathf.Cos(angle) + tangent * Mathf.Sin(angle)) * orbitRadius;
			pos.y = center.y;
			redBall.transform.position = pos;
			elapsed += Time.deltaTime;
			yield return null;
		}
		elapsed = 0f;
		while (elapsed < 4f)
		{
			if ((Object)(object)redBall == (Object)null || (Object)(object)blueBall == (Object)null)
			{
				CleanupFusion(redBall, blueBall);
				yield break;
			}
			angle += maxAngularSpeed * Time.deltaTime;
			Vector3 pos2 = center + (radial * Mathf.Cos(angle) + tangent * Mathf.Sin(angle)) * orbitRadius;
			pos2.y = center.y;
			redBall.transform.position = pos2;
			elapsed += Time.deltaTime;
			yield return null;
		}
		elapsed = 0f;
		while (elapsed < 4f)
		{
			if ((Object)(object)redBall == (Object)null || (Object)(object)blueBall == (Object)null)
			{
				CleanupFusion(redBall, blueBall);
				yield break;
			}
			float t3 = elapsed / 4f;
			float smoothT3 = Mathf.SmoothStep(0f, 1f, t3);
			float angularSpeed2 = maxAngularSpeed * Mathf.Lerp(1f, 1.35f, smoothT3);
			angle += angularSpeed2 * Time.deltaTime;
			float currentRadius = Mathf.Lerp(orbitRadius, 0.15f, smoothT3);
			Vector3 pos3 = center + (radial * Mathf.Cos(angle) + tangent * Mathf.Sin(angle)) * currentRadius;
			pos3.y = center.y;
			redBall.transform.position = pos3;
			redBall.transform.localScale = Vector3.Lerp(redStartScale, redStartScale * 0.4f, smoothT3);
			elapsed += Time.deltaTime;
			yield return null;
		}
		fusionLockedRedBalls.Remove(redBall);
		fusionLockedBlueBalls.Remove(blueBall);
		Object.Destroy((Object)(object)redBall);
		Object.Destroy((Object)(object)blueBall);
		GameObject purpleBall = CreatePurpleBall(center);
		if ((Object)(object)purpleBall == (Object)null)
		{
			purpleFusionActive = false;
		}
		else
		{
			MelonCoroutines.Start(PurpleGrowRoutine(purpleBall, center));
		}
	}

	private void CleanupFusion(GameObject redBall, GameObject blueBall)
	{
		if ((Object)(object)redBall != (Object)null)
		{
			fusionLockedRedBalls.Remove(redBall);
			Object.Destroy((Object)(object)redBall);
		}
		if ((Object)(object)blueBall != (Object)null)
		{
			fusionLockedBlueBalls.Remove(blueBall);
			activeBlueHoles.Remove(blueBall);
			Object.Destroy((Object)(object)blueBall);
		}
		purpleFusionActive = false;
	}

	private GameObject CreatePurpleBall(Vector3 center)
	{
		//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_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
		Object.Destroy((Object)(object)val.GetComponent<Collider>());
		((Object)val).name = "PurpleBall";
		val.transform.position = center;
		val.transform.localScale = Vector3.one * 0.1f;
		Renderer component = val.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader val2 = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard");
			if ((Object)(object)val2 != (Object)null)
			{
				component.material = new Material(val2);
				component.material.color = new Color(0.6f, 0.15f, 1f);
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
		Light val3 = val.AddComponent<Light>();
		val3.type = (LightType)2;
		val3.color = new Color(0.65f, 0.25f, 1f);
		val3.intensity = 15f;
		val3.range = 5f;
		return val;
	}

	private IEnumerator PurpleGrowRoutine(GameObject purpleBall, Vector3 center)
	{
		//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)
		if ((Object)(object)purpleBall == (Object)null)
		{
			purpleFusionActive = false;
			yield break;
		}
		Light light = purpleBall.GetComponent<Light>();
		Renderer renderer = purpleBall.GetComponent<Renderer>();
		float elapsed = 0f;
		float particleTimer = 0f;
		while ((Object)(object)purpleBall != (Object)null && elapsed < 5f)
		{
			float t = elapsed / 5f;
			float smoothT = Mathf.SmoothStep(0f, 1f, t);
			float scale = Mathf.Lerp(0.1f, 1.6f, smoothT);
			purpleBall.transform.localScale = Vector3.one * scale;
			if ((Object)(object)light != (Object)null)
			{
				light.color = new Color(0.65f, 0.25f, 1f);
				light.intensity = Mathf.Lerp(15f, 45f, smoothT);
				light.range = Mathf.Lerp(5f, 18f, smoothT);
			}
			if ((Object)(object)renderer != (Object)null && (Object)(object)renderer.material != (Object)null)
			{
				renderer.material.color = Color.Lerp(new Color(0.45f, 0.1f, 0.8f), new Color(0.75f, 0.3f, 1f), smoothT);
			}
			particleTimer -= Time.deltaTime;
			if (particleTimer <= 0f)
			{
				SpawnPurpleActivationBurst(center, scale);
				particleTimer = 0.15f;
			}
			elapsed += Time.deltaTime;
			yield return null;
		}
		if ((Object)(object)purpleBall != (Object)null)
		{
			Object.Destroy((Object)(object)purpleBall);
			PurpleExplode(center);
			purpleCooldownEndTime = Time.time + 30f;
		}
		purpleFusionActive = false;
	}

	private void SpawnPurpleActivationBurst(Vector3 center, float currentScale)
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: 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_009b: 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)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		Material val = GetPurpleParticleMaterial();
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		for (int i = 0; i < 6; i++)
		{
			if (activeParticles >= 250)
			{
				break;
			}
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0);
			if (!((Object)(object)val2 == (Object)null))
			{
				activeParticles++;
				Object.Destroy((Object)(object)val2.GetComponent<Collider>());
				((Object)val2).name = "PurpleParticle";
				Vector3 onUnitSphere = Random.onUnitSphere;
				float num = Mathf.Max(0.1f, currentScale * 0.55f);
				val2.transform.position = center + onUnitSphere * num;
				float num2 = Random.Range(0.016f, 0.05f);
				val2.transform.localScale = Vector3.one * num2;
				SetupParticleRenderer(val2, val);
				float num3 = Random.Range(1.2f, 3.2f) + currentScale * 0.6f;
				Vector3 velocity = onUnitSphere * num3;
				float life = Random.Range(0.7f, 1.4f);
				MelonCoroutines.Start(OutwardParticleRoutine(val2, velocity, life));
			}
		}
	}

	private void PurpleExplode(Vector3 center)
	{
		//IL_0001: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(center, 14f));
		Collider[] array2 = array;
		foreach (Collider val in array2)
		{
			if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null) && !IsPlayer(((Component)val).gameObject))
			{
				Rigidbody component = ((Component)val).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.AddExplosionForce(1200f, center, 14f, 1f, (ForceMode)1);
				}
				ApplyDamage(((Component)val).gameObject, center, 400f, 14f);
			}
		}
		SpawnPurpleExplosionEffect(center, 14f);
		SpawnPurpleShockwave(center, 14f);
		SpawnPurpleExplosionParticles(center, 14f);
	}

	private void SpawnPurpleExplosionEffect(Vector3 position, float radius)
	{
		//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_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
		Object.Destroy((Object)(object)val.GetComponent<Collider>());
		((Object)val).name = "PurpleExplosion";
		val.transform.position = position;
		val.transform.localScale = Vector3.one * 0.1f;
		Renderer component = val.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader val2 = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard");
			if ((Object)(object)val2 != (Object)null)
			{
				component.material = new Material(val2);
				component.material.color = new Color(0.65f, 0.2f, 1f);
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
		Light val3 = val.AddComponent<Light>();
		val3.type = (LightType)2;
		val3.color = new Color(0.7f, 0.3f, 1f);
		val3.intensity = 50f;
		val3.range = radius * 3f;
		MelonCoroutines.Start(PurpleExplosionAnimation(val, val3, radius));
	}

	private IEnumerator PurpleExplosionAnimation(GameObject explosion, Light flash, float radius)
	{
		float duration = 0.45f;
		float elapsed = 0f;
		Vector3 startScale = Vector3.one * 0.1f;
		Vector3 maxScale = Vector3.one * Mathf.Max(4f, radius * 0.4f);
		while (elapsed < duration && (Object)(object)explosion != (Object)null)
		{
			elapsed += Time.deltaTime;
			float t = elapsed / duration;
			explosion.transform.localScale = Vector3.Lerp(startScale, maxScale, t);
			if ((Object)(object)flash != (Object)null)
			{
				flash.intensity = Mathf.Lerp(50f, 0f, t * t);
			}
			Renderer r = explosion.GetComponent<Renderer>();
			if ((Object)(object)r != (Object)null && (Object)(object)r.material != (Object)null)
			{
				r.material.color = Color.Lerp(new Color(0.75f, 0.3f, 1f), new Color(0.2f, 0f, 0.35f), t);
			}
			yield return null;
		}
		if ((Object)(object)explosion != (Object)null)
		{
			Object.Destroy((Object)(object)explosion);
		}
	}

	private void SpawnPurpleExplosionParticles(Vector3 center, float radius)
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: 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_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		Material val = GetPurpleParticleMaterial();
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		for (int i = 0; i < 24; i++)
		{
			if (activeParticles >= 250)
			{
				break;
			}
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0);
			if (!((Object)(object)val2 == (Object)null))
			{
				activeParticles++;
				Object.Destroy((Object)(object)val2.GetComponent<Collider>());
				((Object)val2).name = "PurpleExplosionParticle";
				Vector3 onUnitSphere = Random.onUnitSphere;
				val2.transform.position = center + onUnitSphere * 0.2f;
				float num = Random.Range(0.02f, 0.07f);
				val2.transform.localScale = Vector3.one * num;
				SetupParticleRenderer(val2, val);
				float num2 = Random.Range(6f, 12f) + radius * 0.2f;
				Vector3 velocity = onUnitSphere * num2;
				float life = Random.Range(0.8f, 1.6f);
				MelonCoroutines.Start(OutwardParticleRoutine(val2, velocity, life));
			}
		}
	}

	private void SpawnPurpleShockwave(Vector3 center, float maxRadius)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: 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)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Expected O, but got Unknown
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		Object.Destroy((Object)(object)val.GetComponent<Collider>());
		((Object)val).name = "PurpleShockwave";
		val.transform.position = center;
		val.transform.localScale = Vector3.one * 0.1f;
		Renderer component = val.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader val2 = Shader.Find("Sprites/Default") ?? Shader.Find("UI/Default") ?? Shader.Find("Legacy Shaders/Transparent/Diffuse") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard");
			if ((Object)(object)val2 != (Object)null)
			{
				component.material = new Material(val2);
				component.material.color = new Color(1f, 1f, 1f, 0.35f);
				if (component.material.HasProperty("_Mode"))
				{
					component.material.SetFloat("_Mode", 3f);
				}
				if (component.material.HasProperty("_SrcBlend"))
				{
					component.material.SetFloat("_SrcBlend", 5f);
				}
				if (component.material.HasProperty("_DstBlend"))
				{
					component.material.SetFloat("_DstBlend", 10f);
				}
				if (component.material.HasProperty("_ZWrite"))
				{
					component.material.SetFloat("_ZWrite", 0f);
				}
				component.material.renderQueue = 3000;
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
		MelonCoroutines.Start(PurpleShockwaveRoutine(val, maxRadius));
	}

	private IEnumerator PurpleShockwaveRoutine(GameObject wave, float maxRadius)
	{
		if ((Object)(object)wave == (Object)null)
		{
			yield break;
		}
		Renderer r = wave.GetComponent<Renderer>();
		float elapsed = 0f;
		float targetScale = maxRadius * 2f;
		while ((Object)(object)wave != (Object)null && elapsed < 0.8f)
		{
			float t = elapsed / 0.8f;
			float smoothT = Mathf.SmoothStep(0f, 1f, t);
			wave.transform.localScale = Vector3.one * Mathf.Lerp(0.1f, targetScale, smoothT);
			if ((Object)(object)r != (Object)null && (Object)(object)r.material != (Object)null)
			{
				Color c = r.material.color;
				c.a = Mathf.Lerp(0.35f, 0f, smoothT);
				r.material.color = c;
			}
			elapsed += Time.deltaTime;
			yield return null;
		}
		if ((Object)(object)wave != (Object)null)
		{
			Object.Destroy((Object)(object)wave);
		}
	}

	private Material GetRedParticleMaterial()
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)redParticleMaterial != (Object)null)
		{
			return redParticleMaterial;
		}
		Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard");
		if ((Object)(object)val != (Object)null)
		{
			redParticleMaterial = new Material(val);
			redParticleMaterial.color = new Color(1f, 0.05f, 0.05f);
		}
		return redParticleMaterial;
	}

	private Material GetBlueParticleMaterial()
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)blueParticleMaterial != (Object)null)
		{
			return blueParticleMaterial;
		}
		Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard");
		if ((Object)(object)val != (Object)null)
		{
			blueParticleMaterial = new Material(val);
			blueParticleMaterial.color = new Color(0.25f, 0.55f, 1f);
		}
		return blueParticleMaterial;
	}

	private Material GetPurpleParticleMaterial()
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)purpleParticleMaterial != (Object)null)
		{
			return purpleParticleMaterial;
		}
		Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard");
		if ((Object)(object)val != (Object)null)
		{
			purpleParticleMaterial = new Material(val);
			purpleParticleMaterial.color = new Color(0.65f, 0.25f, 1f);
		}
		return purpleParticleMaterial;
	}

	private void SetupParticleRenderer(GameObject particle, Material material)
	{
		if ((Object)(object)particle == (Object)null)
		{
			return;
		}
		Renderer component = particle.GetComponent<Renderer>();
		if (!((Object)(object)component == (Object)null))
		{
			if ((Object)(object)material != (Object)null)
			{
				component.material = material;
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
	}

	private void SpawnFlightParticle(Vector3 position, Vector3 velocity, Material material)
	{
		//IL_0062: 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_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: 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_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: 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_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		if (activeParticles >= 250 || (Object)(object)material == (Object)null)
		{
			return;
		}
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
		if (!((Object)(object)val == (Object)null))
		{
			activeParticles++;
			Object.Destroy((Object)(object)val.GetComponent<Collider>());
			((Object)val).name = "FlightParticle";
			Vector3 val2 = Random.insideUnitSphere * 0.06f;
			if (((Vector3)(ref velocity)).sqrMagnitude > 0.001f)
			{
				val2 += -((Vector3)(ref velocity)).normalized * 0.05f;
			}
			val.transform.position = position + val2;
			float num = Random.Range(0.004f, 0.012f);
			val.transform.localScale = Vector3.one * num;
			SetupParticleRenderer(val, material);
			Vector3 val3 = Random.insideUnitSphere * 0.12f;
			if (((Vector3)(ref velocity)).sqrMagnitude > 0.001f)
			{
				val3 += -((Vector3)(ref velocity)).normalized * 0.08f;
			}
			float life = Random.Range(0.25f, 0.55f);
			MelonCoroutines.Start(FlightParticleRoutine(val, val3, life));
		}
	}

	private IEnumerator FlightParticleRoutine(GameObject particle, Vector3 drift, float life)
	{
		//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)
		if ((Object)(object)particle == (Object)null)
		{
			if (activeParticles > 0)
			{
				activeParticles--;
			}
			yield break;
		}
		Vector3 startScale = particle.transform.localScale;
		float elapsed = 0f;
		while ((Object)(object)particle != (Object)null && elapsed < life)
		{
			float dt = Time.deltaTime;
			Vector3 pos = particle.transform.position;
			particle.transform.position = pos + drift * dt;
			drift *= 0.94f;
			elapsed += dt;
			float t = elapsed / life;
			particle.transform.localScale = startScale * Mathf.Clamp01(1f - t);
			yield return null;
		}
		if ((Object)(object)particle != (Object)null)
		{
			Object.Destroy((Object)(object)particle);
		}
		if (activeParticles > 0)
		{
			activeParticles--;
		}
	}

	private bool IsPlayer(GameObject go)
	{
		if ((Object)(object)go == (Object)null)
		{
			return false;
		}
		Transform root = go.transform.root;
		string text = (((Object)(object)root != (Object)null) ? ((Object)root).name : ((Object)go).name);
		if (string.IsNullOrEmpty(text))
		{
			return false;
		}
		return text.Contains("Hexa4Rig") || text.Contains("Player");
	}

	private void ApplyDamage(GameObject target, Vector3 hitPosition, float damage, float radius)
	{
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		Component val = FindIl2CppComponent(target, "StickHealth");
		if ((Object)(object)val == (Object)null && (Object)(object)target.transform.parent != (Object)null)
		{
			val = FindIl2CppComponent(((Component)target.transform.parent).gameObject, "StickHealth");
		}
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		Type type = ((object)val).GetType();
		float num = Vector3.Distance(hitPosition, target.transform.position);
		float num2 = 1f - num / radius;
		float num3 = damage * Mathf.Clamp01(num2);
		MethodInfo method = type.GetMethod("HitByBullet");
		if (method != null)
		{
			try
			{
				method.Invoke(val, new object[3] { hitPosition, num3, false });
				return;
			}
			catch
			{
			}
		}
		MethodInfo method2 = type.GetMethod("ReceivedGeneralDamage");
		if (method2 != null)
		{
			try
			{
				Type nestedType = type.GetNestedType("DamageType");
				object obj2 = 1;
				if (nestedType != null && nestedType.IsEnum)
				{
					try
					{
						obj2 = Enum.Parse(nestedType, "Explosion");
					}
					catch
					{
						obj2 = Convert.ChangeType(1, nestedType);
					}
				}
				method2.Invoke(val, new object[4] { num3, obj2, "torso", null });
				return;
			}
			catch
			{
			}
		}
		MethodInfo method3 = type.GetMethod("KillZoneEntered");
		if (!(method3 != null))
		{
			return;
		}
		try
		{
			method3.Invoke(val, null);
		}
		catch
		{
		}
	}

	private Component FindIl2CppComponent(GameObject go, string typeName)
	{
		if ((Object)(object)go == (Object)null)
		{
			return null;
		}
		Il2CppArrayBase<Component> components = go.GetComponents<Component>();
		if (components == null)
		{
			return null;
		}
		foreach (Component item in components)
		{
			if ((Object)(object)item == (Object)null || !(((MemberInfo)((Object)item).GetIl2CppType()).Name == typeName))
			{
				continue;
			}
			return item;
		}
		return null;
	}
}