Decompiled source of GojoCursedTechnique v2.0.0

cursedtechnique.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using Il2Cpp;
using Il2CppActiveRagdoll;
using Il2CppDinoFracture;
using Il2CppHurricaneVR.Framework.Core;
using Il2CppHurricaneVR.Framework.Core.Grabbers;
using Il2CppHurricaneVR.Framework.Shared;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Reflection;
using MelonLoader;
using RedBlueMod;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;

[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", "4.29.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 static class PurplePostFX
{
	public static readonly bool PP_ENABLE_POSTFX;

	private const float DECAY = 1.6f;

	private const float BLOOM_INTENSITY = 2.4f;

	private const float BLOOM_THRESHOLD = 0.9f;

	private const float BLOOM_SCATTER = 0.75f;

	private const float CA_INTENSITY = 0.45f;

	private const float LENS_INTENSITY = 0.35f;

	private static GameObject volumeObj;

	private static Volume volume;

	private static VolumeProfile profile;

	private static Bloom bloom;

	private static ChromaticAberration chroma;

	private static LensDistortion lens;

	private static UniversalAdditionalCameraData camData;

	private static bool postChanged;

	private static bool ready;

	private static float punch;

	private static int setOk;

	private static int setFail;

	public static void Init()
	{
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Expected O, but got Unknown
		Cleanup();
		if (!PP_ENABLE_POSTFX)
		{
			return;
		}
		Camera main = Camera.main;
		if ((Object)(object)main == (Object)null)
		{
			return;
		}
		try
		{
			camData = ((Component)main).GetComponent<UniversalAdditionalCameraData>();
			bool flag = (Object)(object)camData != (Object)null && camData.renderPostProcessing;
			if ((Object)(object)camData != (Object)null && !flag)
			{
				camData.renderPostProcessing = true;
				postChanged = true;
			}
			volumeObj = new GameObject("RedBluePostFXVolume");
			Object.DontDestroyOnLoad((Object)(object)volumeObj);
			volume = volumeObj.AddComponent<Volume>();
			volume.isGlobal = true;
			volume.priority = 90f;
			volume.weight = 0f;
			profile = ScriptableObject.CreateInstance<VolumeProfile>();
			volume.profile = profile;
			bloom = profile.Add<Bloom>(true);
			chroma = profile.Add<ChromaticAberration>(true);
			lens = profile.Add<LensDistortion>(true);
			setOk = 0;
			setFail = 0;
			if ((Object)(object)bloom != (Object)null)
			{
				SetParam(bloom.intensity, 2.4f);
				SetParam(bloom.threshold, 0.9f);
				SetParam(bloom.scatter, 0.75f);
			}
			if ((Object)(object)chroma != (Object)null)
			{
				SetParam(chroma.intensity, 0.45f);
			}
			if ((Object)(object)lens != (Object)null)
			{
				SetParam(lens.intensity, 0.35f);
			}
			punch = 0f;
			ready = true;
		}
		catch
		{
			ready = false;
		}
	}

	public static void Punch(float amount)
	{
		if (ready)
		{
			float num = Mathf.Clamp01(amount);
			if (num > punch)
			{
				punch = num;
			}
		}
	}

	public static void Update()
	{
		if (ready && !((Object)(object)volume == (Object)null))
		{
			punch = Mathf.Max(0f, punch - Time.deltaTime * 1.6f);
			volume.weight = punch;
		}
	}

	private static void SetParam(object param, object value)
	{
		if (param == null)
		{
			setFail++;
		}
		else if (TrySetDeep(param, value))
		{
			setOk++;
		}
		else
		{
			setFail++;
		}
	}

	private static bool TrySetDeep(object obj, object value)
	{
		if (obj == null)
		{
			return false;
		}
		string[] array = new string[3] { "m_Value", "value", "_value" };
		Type type = obj.GetType();
		while (type != null && type != typeof(object))
		{
			string[] array2 = array;
			foreach (string name in array2)
			{
				PropertyInfo property = type.GetProperty(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property != null && property.CanWrite)
				{
					try
					{
						property.SetValue(obj, value);
						return true;
					}
					catch
					{
					}
				}
			}
			string[] array3 = array;
			foreach (string name2 in array3)
			{
				FieldInfo field = type.GetField(name2, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					try
					{
						field.SetValue(obj, value);
						return true;
					}
					catch
					{
					}
				}
			}
			type = type.BaseType;
		}
		return false;
	}

	public static void Cleanup()
	{
		if (postChanged && (Object)(object)camData != (Object)null)
		{
			try
			{
				camData.renderPostProcessing = false;
			}
			catch
			{
			}
		}
		postChanged = false;
		if ((Object)(object)profile != (Object)null)
		{
			Object.Destroy((Object)(object)profile);
		}
		if ((Object)(object)volumeObj != (Object)null)
		{
			Object.Destroy((Object)(object)volumeObj);
		}
		volumeObj = null;
		profile = null;
		volume = null;
		bloom = null;
		chroma = null;
		lens = null;
		camData = null;
		punch = 0f;
		ready = false;
		setOk = 0;
		setFail = 0;
	}
}
public static class RBSound
{
	private static readonly string[][] EVENT_FILES = new string[11][]
	{
		new string[3] { "gesture_theme", "gesture_theme.wav", "Sound3.wav" },
		new string[2] { "red_charge", "ReversalLoud.wav" },
		new string[2] { "blue_charge", "BlueLoud.wav" },
		new string[2] { "red_shot", "redShot.wav" },
		new string[2] { "red_explosion", "Exp.wav" },
		new string[2] { "blue_shot", "BlueShotloud.wav" },
		new string[2] { "blue_explosion", "BlueExp.wav" },
		new string[2] { "purple_shot", "PurpleShot.wav" },
		new string[4] { "fusion_swirl", "fusion_swirl.wav", "fusion.wav", "fusion_sound.wav" },
		new string[2] { "red_loud", "RedLouds1.wav" },
		new string[2] { "red_splou", "RedSplouE.wav" }
	};

	private static readonly Dictionary<string, string> paths = new Dictionary<string, string>();

	private static readonly Dictionary<string, string[]> pools = new Dictionary<string, string[]>();

	private static readonly Dictionary<string, int> nextIdx = new Dictionary<string, int>();

	private static readonly Dictionary<string, string> openFile = new Dictionary<string, string>();

	private static int counter;

	private static bool volWarned;

	[DllImport("winmm.dll")]
	private static extern int mciSendString(string cmd, StringBuilder ret, int retLen, int hwndCallback);

	private static int PoolSize(string evt)
	{
		switch (evt)
		{
		default:
			if (!(evt == "purple_shot"))
			{
				return 1;
			}
			goto case "red_explosion";
		case "red_explosion":
		case "blue_explosion":
		case "red_shot":
		case "blue_shot":
			return 2;
		}
	}

	public static void Init(string[] dirs)
	{
		paths.Clear();
		string[][] eVENT_FILES = EVENT_FILES;
		foreach (string[] array in eVENT_FILES)
		{
			string key = array[0];
			string text = null;
			for (int j = 1; j < array.Length; j++)
			{
				if (text != null)
				{
					break;
				}
				if (dirs == null)
				{
					continue;
				}
				foreach (string text2 in dirs)
				{
					if (!string.IsNullOrEmpty(text2))
					{
						string text3 = Path.Combine(text2, array[j]);
						if (File.Exists(text3))
						{
							text = text3;
							break;
						}
					}
				}
			}
			if (text != null)
			{
				paths[key] = text;
			}
		}
	}

	private static int Send(string cmd)
	{
		return mciSendString(cmd, null, 0, 0);
	}

	private static void SetVolume(string alias, float volume)
	{
		if (mciSendString("set " + alias + " volume to " + (int)(Math.Max(0f, Math.Min(1f, volume)) * 1000f), null, 0, 0) != 0 && !volWarned)
		{
			volWarned = true;
		}
	}

	private static bool EnsureOpen(string alias, string path)
	{
		if (openFile.TryGetValue(alias, out var value) && value == path)
		{
			return true;
		}
		if (value != null)
		{
			Send("close " + alias);
		}
		if (Send("open \"" + path + "\" type waveaudio alias " + alias) != 0)
		{
			return false;
		}
		openFile[alias] = path;
		return true;
	}

	private static string PoolAlias(string evt)
	{
		if (!pools.TryGetValue(evt, out var value))
		{
			int num = PoolSize(evt);
			value = new string[num];
			for (int i = 0; i < num; i++)
			{
				value[i] = "rb_" + evt + "_" + counter++;
			}
			pools[evt] = value;
			nextIdx[evt] = 0;
		}
		int num2 = nextIdx[evt];
		nextIdx[evt] = (num2 + 1) % value.Length;
		return value[num2];
	}

	public static void Play(string evt, float volume = 1f)
	{
		try
		{
			if (paths.TryGetValue(evt, out var value))
			{
				string text = PoolAlias(evt);
				if (EnsureOpen(text, value))
				{
					SetVolume(text, volume);
					Send("play " + text + " from 0");
				}
			}
		}
		catch
		{
		}
	}

	public static void StopAll()
	{
		try
		{
			foreach (KeyValuePair<string, string[]> pool in pools)
			{
				for (int i = 0; i < pool.Value.Length; i++)
				{
					Send("stop " + pool.Value[i]);
					Send("close " + pool.Value[i]);
				}
			}
			pools.Clear();
			nextIdx.Clear();
			openFile.Clear();
		}
		catch
		{
		}
	}
}
public class Core : MelonMod
{
	private enum State
	{
		Idle,
		Charging,
		Ready,
		Cooldown
	}

	private enum OrbType
	{
		Red,
		Blue
	}

	private enum GesturePhase
	{
		None,
		Orbiting,
		MovingToHand,
		InHand,
		Flying
	}

	private sealed class ArcEntry
	{
		public GameObject obj;

		public float deathTime;
	}

	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 bool redMaxOutputMode;

	private bool wasSecondaryRight;

	private float redMaxOutputCharge;

	private bool beamPreparing;

	private const float RO_PREP_TIME = 1.1f;

	private const float RO_BEAM_GROW_TIME = 0.15f;

	private const float RO_BEAM_HOLD_TIME = 0.8f;

	private const float RO_BEAM_SQUISH_TIME = 1.13f;

	private const float RO_BEAM_TOTAL_TIME = 2.08f;

	private const float RO_BEAM_LENGTH = 30f;

	private const float RO_BEAM_CHECK_RADIUS = 0.1f;

	private const float RO_PREP_FORWARD_DIST = 0.03f;

	private const int RO_PREP_SPIRAL_COUNT = 24;

	private const int RO_PREP_RING_COUNT = 3;

	private const int RO_BEAM_PARTICLE_COUNT = 100;

	private const float RO_STAGE2_THRESHOLD = 0.5f;

	private const float RO_STAGE3_THRESHOLD = 0.75f;

	private const float RO_BEAM_WIDTH_STAGE1 = 0.027f;

	private const float RO_BEAM_WIDTH_STAGE2 = 0.053f;

	private const float RO_BEAM_WIDTH_STAGE3 = 0.083f;

	private const float RO_COOLDOWN = 1.2f;

	private const float RO_PUSH_FORCE_MAX = 18f;

	private const float RO_PUSH_RADIUS_EXTRA = 0.4f;

	private const float RO_PUSH_UPWARD_BIAS = 0.15f;

	private static readonly Color RO_BEAM_CORE_COLOR = new Color(1f, 0.9f, 0.85f, 1f);

	private static readonly Color RO_BEAM_MID_COLOR = new Color(1f, 0.15f, 0.1f, 0.9f);

	private static readonly Color RO_BEAM_OUTER_COLOR = new Color(0.6f, 0.02f, 0.02f, 0.45f);

	private GameObject aimLineObj;

	private LineRenderer aimLine;

	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 CHARGE_START_BASELINE = 0.25f;

	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_SPAWN_GRACE = 0.25f;

	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 BLUE_END_IMPLODE_TIME = 0.45f;

	private const float BLUE_END_EXPLOSION_RADIUS = 4.5f;

	private const float BLUE_END_EXPLOSION_POWER = 90f;

	private const int BLUE_END_PARTICLE_COUNT = 18;

	private const float PURPLE_FUSION_DETECTION_RADIUS = 2.5f;

	private const float PURPLE_FUSION_COOLDOWN = 30f;

	private const float FUSE_MOVE_TIME = 0.8f;

	private const float FUSE_FIRST_PASS = 5.45f;

	private const float FUSE_SPIRAL_START = 9.12f;

	private const float FUSE_MERGE_TIME = 14.56f;

	private const float FUSE_EXPLODE_TIME = 18.28f;

	private const float PURPLE_GROW_TIME = 3.7200003f;

	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_BALL_SIZE = 1.6f;

	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 = 12;

	private const float PURPLE_ACTIVATION_PARTICLE_INTERVAL = 0.08f;

	private const int PURPLE_EXPLOSION_PARTICLE_COUNT = 60;

	private const float PURPLE_SHOCKWAVE_DURATION = 0.8f;

	private const float PURPLE_SHOCKWAVE_START_ALPHA = 0.5f;

	private static readonly bool GP_SHOCKWAVE_ADDITIVE = true;

	private const float CHARGE_PARTICLE_INTERVAL = 0.03f;

	private const int MAX_PARTICLES = 400;

	private int activeParticles;

	private Material redParticleMaterial;

	private Material blueParticleMaterial;

	private Material purpleParticleMaterial;

	private Material purpleSparkMaterial;

	private Material purpleGlowMat;

	private Material blueRingMat;

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

	private const float ORB_LIGHT_INTENSITY = 1.2f;

	private const float ORB_LIGHT_RANGE = 0.6f;

	private const float ORB_LIGHT_INTENSITY_MAX = 2f;

	private const float ORB_LIGHT_RANGE_MAX = 1f;

	private const float ORB_HOLE_LIGHT_INTENSITY_MAX = 2.5f;

	private const float ORB_HOLE_LIGHT_RANGE_MAX = 1.2f;

	private const float RED_FLASH_INTENSITY = 12f;

	private const float PURPLE_FLASH_INTENSITY = 18f;

	private const float BLUE_END_FLASH_INTENSITY = 7f;

	private const float FLASH_RANGE_MULTIPLIER = 1.2f;

	private static readonly Color RED_BALL_START = new Color(1f, 0.25f, 0.25f);

	private static readonly Color RED_BALL_FULL = new Color(1f, 0.02f, 0.02f);

	private static readonly Color BLUE_BALL_START = new Color(0.2f, 0.55f, 1f);

	private static readonly Color BLUE_BALL_FULL = new Color(0.02f, 0.15f, 1f);

	private static readonly Color RED_LIGHT_COLOR = new Color(1f, 0.12f, 0.12f);

	private static readonly Color BLUE_LIGHT_COLOR = new Color(0.1f, 0.3f, 1f);

	private const float BALL_HAND_FOLLOW_SPEED = 12f;

	private static readonly bool PP_ENABLE_TRAIL = true;

	private static readonly bool PP_ENABLE_ORB_TRAILS = true;

	private static readonly bool PP_ENABLE_CORE = true;

	private static readonly bool PP_ENABLE_GLOW_SHELL = true;

	private static readonly bool PP_ENABLE_RIM_SHELL = true;

	private static readonly bool PP_ENABLE_SPARKS = true;

	private static readonly bool PP_ENABLE_LIGHTNING = true;

	private const float PP_CORE_RELATIVE = 0.5f;

	private const float PP_CORE_HDR = 3.5f;

	private const float PP_GLOW_SHELL_SCALE = 1.45f;

	private const float PP_RIM_SHELL_SCALE = 1.18f;

	private const float PP_GLOW_ALPHA = 0.3f;

	private const float PP_RIM_ALPHA = 0.35f;

	private const int PP_BODY_QUEUE = 3000;

	private const int PP_GLOW_QUEUE = 3010;

	private const int PP_RIM_QUEUE = 3011;

	private const int PP_TRAIL_QUEUE = 3020;

	private const int PP_ARC_QUEUE = 3015;

	private const int PP_ARC_EDGE_QUEUE = 3016;

	private const float PP_CORE_PULSE_SPEED = 7f;

	private const float PP_CORE_PULSE_AMOUNT = 0.06f;

	private const float PP_RING_PULSE_SPEED = 5f;

	private const float PP_RING_PULSE_AMOUNT = 0.05f;

	private const float PP_BODY_ALPHA = 0.82f;

	private const float PP_SPARK_INTERVAL_MIN = 0.03f;

	private const float PP_SPARK_INTERVAL_MAX = 0.07f;

	private const float PP_SPARK_RELATIVE_SIZE_MIN = 0.03f;

	private const float PP_SPARK_RELATIVE_SIZE_MAX = 0.07f;

	private const float PP_SPARK_LIFE_MIN = 0.25f;

	private const float PP_SPARK_LIFE_MAX = 0.6f;

	private const float PP_ARC_INTERVAL_MIN = 0.1f;

	private const float PP_ARC_INTERVAL_MAX = 0.28f;

	private const float PP_ARC_LIFE_MIN = 0.05f;

	private const float PP_ARC_LIFE_MAX = 0.12f;

	private const float PP_ARC_LENGTH_MIN = 1.4f;

	private const float PP_ARC_LENGTH_MAX = 2.6f;

	private const float PP_ARC_BOOST_SHOOT = 2.2f;

	private const float PP_ARC_BOOST_GROW_MIN = 1.5f;

	private const float PP_ARC_BOOST_GROW_MAX = 3f;

	private const int PP_EXPLOSION_ARC_COUNT = 10;

	private const float PP_MOVE_PARTICLE_INTERVAL = 0.03f;

	private static readonly Color PP_BODY_COLOR = new Color(0.72f, 0.15f, 1f, 0.82f);

	private static readonly Color PP_GLOW_COLOR = new Color(0.62f, 0.18f, 1f, 1f);

	private static readonly Color PP_RING_COLOR = new Color(0.25f, 0.45f, 1f, 1f);

	private static readonly Color PP_SPARK_COLOR = new Color(0.55f, 0.42f, 0.62f, 0.9f);

	private static readonly Color PP_ARC_START = new Color(0.55f, 0.48f, 0.62f, 0.9f);

	private static readonly Color PP_ARC_END = new Color(0.7f, 0.2f, 1f, 0f);

	private static readonly Color PP_ARC_EDGE_START = new Color(0.38f, 0.15f, 0.5f, 0.5f);

	private static readonly Color PP_ARC_EDGE_END = new Color(0.38f, 0.15f, 0.5f, 0f);

	private static readonly Color BLUE_FLASH_COLOR = new Color(0.3f, 0.6f, 1f, 1f);

	private static readonly Color RED_FLASH_COLOR = new Color(1f, 0.25f, 0.25f, 1f);

	private const float GP_COOLDOWN = 20f;

	private const float GP_HAND_DISTANCE = 0.18f;

	private const float GP_ORBIT_RADIUS = 0.35f;

	private const float GP_CENTER_DISTANCE = 1.2f;

	private const float GP_CENTER_HEIGHT_OFFSET = 0f;

	private const float GP_MAX_ANGULAR_SPEED = 9.42f;

	private const float GP_MOVE_TO_HAND_TIME = 0.3f;

	private const float GP_BALL_SIZE_HAND = 0.05f;

	private const float GP_BALL_SIZE_FIRED = 0.8f;

	private const float GP_BALL_SPEED = 20f;

	private const float GP_BALL_MAX_DISTANCE = 100f;

	private const float GP_FRACTURE_DAMAGE = 120f;

	private const float GP_PUSH_FORCE = 40f;

	private const float GP_OVERLAP_RADIUS = 0.5f;

	private const float GP_ORBIT_BALL_SIZE = 0.09f;

	private const float PURPLE_FLIGHT_PARTICLE_INTERVAL = 0.035f;

	private const int GP_MAX_FRACTURE_COUNT = 6;

	private const float GP_SCATTER_RADIUS = 0.9f;

	private const float GP_SCATTER_FORCE_MIN = 1.5f;

	private const float GP_SCATTER_FORCE_MAX = 4.5f;

	private const float GP_T_BLUE = 2.04f;

	private const float GP_T_RED = 4.22f;

	private const float GP_T_ORBIT = 5.18f;

	private const float GP_T_MERGED = 12f;

	private const float GP_FLASH_LEAD = 0.2f;

	private const float GP_ORBIT_ACCEL = 1.2f;

	private const float GP_ORBIT_APPROACH = 2f;

	private GesturePhase gesturePhase = GesturePhase.None;

	private bool gesturePurpleActive = false;

	private float gestureCooldownEnd = -1f;

	private GameObject gesturePurpleBall;

	private Transform chestTransform;

	private Transform playerRigRoot;

	private bool wasGestureCombined;

	private bool wasRightStickGesture;

	private float purpleLightningBoost = 1f;

	private readonly List<ArcEntry> activeArcs = new List<ArcEntry>();

	private int sweepKilled;

	private bool sweepLogged;

	private static readonly string[] GP_BODY_PARTS = new string[18]
	{
		"Neck", "Head", "Jaw", "UpperChest", "MiddleChest", "Pelvis", "Shoulder_R", "Shoulder_L", "Elbow_R", "Elbow_L",
		"Hip_R", "Hip_L", "Knee_R", "Knee_L", "Foot_R", "Foot_L", "Hand_R", "Hand_L"
	};

	public override void OnInitializeMelon()
	{
		((MelonBase)this).LoggerInstance.Msg("RedBlueMod v4.29.0 — RO Beam: звук синхронизирован, отталкивание объектов.");
	}

	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;
		}
		playerRigRoot = val.transform;
		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("Руки не найдены!");
			return;
		}
		chestTransform = FindChestTransform(val.transform);
		PurplePostFX.Init();
		string text = null;
		try
		{
			text = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		}
		catch
		{
		}
		RBSound.Init(new string[2]
		{
			(text != null) ? Path.Combine(text, "Sounds", "RedBlue") : null,
			(text != null) ? Path.Combine(text, "Sounds") : null
		});
		((MelonBase)this).LoggerInstance.Msg("RedBlueMod v4.29.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);
		}
		if ((Object)(object)purpleSparkMaterial != (Object)null)
		{
			Object.Destroy((Object)(object)purpleSparkMaterial);
		}
		if ((Object)(object)purpleGlowMat != (Object)null)
		{
			Object.Destroy((Object)(object)purpleGlowMat);
		}
		if ((Object)(object)blueRingMat != (Object)null)
		{
			Object.Destroy((Object)(object)blueRingMat);
		}
		redParticleMaterial = null;
		blueParticleMaterial = null;
		purpleParticleMaterial = null;
		purpleSparkMaterial = null;
		purpleGlowMat = null;
		blueRingMat = null;
		for (int i = 0; i < activeArcs.Count; i++)
		{
			ArcEntry arcEntry = activeArcs[i];
			if (arcEntry != null && (Object)(object)arcEntry.obj != (Object)null)
			{
				Object.Destroy((Object)(object)arcEntry.obj);
			}
		}
		activeArcs.Clear();
		purpleFusionActive = false;
		purpleCooldownEndTime = -1f;
		activeBlueHoles.Clear();
		fusionLockedRedBalls.Clear();
		fusionLockedBlueBalls.Clear();
		gesturePhase = GesturePhase.None;
		gesturePurpleActive = false;
		gestureCooldownEnd = -1f;
		gesturePurpleBall = null;
		chestTransform = null;
		wasGestureCombined = false;
		wasRightStickGesture = false;
		purpleLightningBoost = 1f;
		redMaxOutputMode = false;
		wasSecondaryRight = false;
		redMaxOutputCharge = 0f;
		beamPreparing = false;
		DestroyAimLine();
		RBSound.StopAll();
		PurplePostFX.Cleanup();
	}

	private void CreateAimLine()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Expected O, but got Unknown
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Expected O, but got Unknown
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		DestroyAimLine();
		aimLineObj = new GameObject("RedBeamAimLine");
		aimLine = aimLineObj.AddComponent<LineRenderer>();
		if ((Object)(object)aimLine == (Object)null)
		{
			Object.Destroy((Object)(object)aimLineObj);
			aimLineObj = null;
			return;
		}
		aimLine.positionCount = 2;
		aimLine.startWidth = 0.002f;
		aimLine.endWidth = 0.001f;
		aimLine.startColor = new Color(1f, 0.1f, 0.1f, 0.6f);
		aimLine.endColor = new Color(1f, 0.05f, 0.05f, 0.1f);
		((Renderer)aimLine).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)aimLine).receiveShadows = false;
		aimLine.numCapVertices = 2;
		Shader spriteAdditiveShader = GetSpriteAdditiveShader();
		if ((Object)(object)spriteAdditiveShader != (Object)null)
		{
			((Renderer)aimLine).material = new Material(spriteAdditiveShader);
			SetMatColor(((Renderer)aimLine).material, Color.white);
			SetupAdditiveSprite(((Renderer)aimLine).material, 3017);
		}
	}

	private void UpdateAimLine()
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: 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_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: 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_008c: 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_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: 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_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)aimLine == (Object)null) && !((Object)(object)rightHand == (Object)null))
		{
			Transform transform = ((Component)rightHand).transform;
			Vector3 val = -transform.right;
			if (((Vector3)(ref val)).sqrMagnitude < 0.001f)
			{
				val = Vector3.forward;
			}
			((Vector3)(ref val)).Normalize();
			Vector3 val2 = transform.position + transform.forward * -0.04f + transform.up * -0.05f + transform.right * -0.05f;
			Vector3 val3 = val2 + val * 30f;
			aimLine.SetPosition(0, val2);
			aimLine.SetPosition(1, val3);
		}
	}

	private void DestroyAimLine()
	{
		if ((Object)(object)aimLineObj != (Object)null)
		{
			Object.Destroy((Object)(object)aimLineObj);
			aimLineObj = null;
		}
		aimLine = null;
	}

	public override void OnUpdate()
	{
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_035d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0364: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_037a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0384: Unknown result type (might be due to invalid IL or missing references)
		//IL_0389: Unknown result type (might be due to invalid IL or missing references)
		//IL_0390: Unknown result type (might be due to invalid IL or missing references)
		//IL_039a: Unknown result type (might be due to invalid IL or missing references)
		//IL_039f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0428: Unknown result type (might be due to invalid IL or missing references)
		//IL_042d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0431: Unknown result type (might be due to invalid IL or missing references)
		//IL_0452: Unknown result type (might be due to invalid IL or missing references)
		//IL_0459: Unknown result type (might be due to invalid IL or missing references)
		//IL_0460: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03da: Unknown result type (might be due to invalid IL or missing references)
		PurplePostFX.Update();
		SweepArcs();
		if ((Object)(object)playerInputs == (Object)null || (Object)(object)playerInputs.LeftController == (Object)null || (Object)(object)playerInputs.RightController == (Object)null)
		{
			return;
		}
		HVRController leftController = playerInputs.LeftController;
		HVRController rightController = playerInputs.RightController;
		bool active = leftController.JoystickButtonState.Active;
		bool active2 = rightController.JoystickButtonState.Active;
		bool active3 = rightController.SecondaryButtonState.Active;
		bool flag = active3 && !wasSecondaryRight;
		bool flag2 = GestureComboHeld(leftController, rightController);
		bool flag3 = (Object)(object)leftHand != (Object)null && (Object)(object)rightHand != (Object)null && Vector3.Distance(((Component)leftHand).transform.position, ((Component)rightHand).transform.position) <= 0.18f;
		bool flag4 = flag2 && flag3;
		if (!gesturePurpleActive && flag4 && !wasGestureCombined && CanStartGestureNow())
		{
			StartGesturePurple();
		}
		wasGestureCombined = flag4;
		if (gesturePurpleActive && gesturePhase == GesturePhase.InHand && active2 && !wasRightStickGesture)
		{
			ShootGesturePurple();
		}
		wasRightStickGesture = active2;
		if (!gesturePurpleActive)
		{
			ProcessHand(isLeft: true, active, wasLeftStick, ref leftState, ref leftBall, ref leftCharge, leftHand, OrbType.Blue);
			if (redMaxOutputMode)
			{
				if (flag && !beamPreparing)
				{
					CancelRedMaxOutput();
					rightState = State.Ready;
					((MelonBase)this).LoggerInstance.Msg("RedBlueMod: Reversal Red отменён.");
				}
				else if (active2 && !wasRightStick && !beamPreparing)
				{
					StartBeamSequence();
				}
			}
			else
			{
				ProcessHand(isLeft: false, active2, wasRightStick, ref rightState, ref rightBall, ref rightCharge, rightHand, OrbType.Red);
				if (flag && rightState == State.Ready && (Object)(object)rightBall != (Object)null)
				{
					redMaxOutputMode = true;
					redMaxOutputCharge = rightCharge;
					CreateAimLine();
					((MelonBase)this).LoggerInstance.Msg($"RedBlueMod: Reversal Red Maximum Output! Заряд={redMaxOutputCharge:F2}");
				}
			}
			UpdateHandChargeParticles(leftBall, leftState, leftCharge, OrbType.Blue, ref leftChargeParticleTimer);
			if (!redMaxOutputMode)
			{
				UpdateHandChargeParticles(rightBall, rightState, rightCharge, OrbType.Red, ref rightChargeParticleTimer);
			}
		}
		UpdateBallFollow(leftBall, leftHand);
		if (redMaxOutputMode && (Object)(object)rightBall != (Object)null && (Object)(object)rightHand != (Object)null)
		{
			Transform transform = ((Component)rightHand).transform;
			Vector3 val = transform.position + transform.forward * -0.04f + transform.up * -0.05f + transform.right * -0.05f;
			if (beamPreparing)
			{
				Vector3 val2 = -transform.right;
				if (((Vector3)(ref val2)).sqrMagnitude < 0.001f)
				{
					val2 = Vector3.forward;
				}
				((Vector3)(ref val2)).Normalize();
				val += val2 * 0.03f;
			}
			float num = 1f - Mathf.Exp(-12f * Time.deltaTime);
			rightBall.transform.position = Vector3.Lerp(rightBall.transform.position, val, num);
			rightBall.transform.rotation = Quaternion.Slerp(rightBall.transform.rotation, transform.rotation, num);
			UpdateAimLine();
		}
		else if (!beamPreparing)
		{
			UpdateBallFollow(rightBall, rightHand);
		}
		if (gesturePurpleActive && gesturePhase == GesturePhase.InHand)
		{
			UpdateBallFollow(gesturePurpleBall, rightHand);
		}
		wasLeftStick = active;
		wasRightStick = active2;
		wasSecondaryRight = active3;
	}

	private void StartBeamSequence()
	{
		if ((Object)(object)rightHand == (Object)null || (Object)(object)rightBall == (Object)null)
		{
			CancelRedMaxOutput();
			return;
		}
		beamPreparing = true;
		RBSound.Play("red_loud");
		MelonCoroutines.Start(BeamSequenceRoutine());
	}

	private IEnumerator BeamSequenceRoutine()
	{
		Transform ht = (((Object)(object)rightHand != (Object)null) ? ((Component)rightHand).transform : null);
		if ((Object)(object)ht == (Object)null || (Object)(object)rightBall == (Object)null)
		{
			beamPreparing = false;
			CancelRedMaxOutput();
			yield break;
		}
		Vector3 beamDir = -ht.right;
		if (((Vector3)(ref beamDir)).sqrMagnitude < 0.001f)
		{
			beamDir = Vector3.forward;
		}
		((Vector3)(ref beamDir)).Normalize();
		Light ballLight = rightBall.GetComponent<Light>();
		Renderer ballRend = rightBall.GetComponent<Renderer>();
		float startIntensity = (((Object)(object)ballLight != (Object)null) ? ballLight.intensity : 1.2f);
		float startRange = (((Object)(object)ballLight != (Object)null) ? ballLight.range : 0.6f);
		for (int i = 0; i < 24; i++)
		{
			if (activeParticles >= 400)
			{
				break;
			}
			GameObject p = GameObject.CreatePrimitive((PrimitiveType)0);
			if (!((Object)(object)p == (Object)null))
			{
				activeParticles++;
				Object.Destroy((Object)(object)p.GetComponent<Collider>());
				((Object)p).name = "PrepSpiral";
				float spawnRadius = Random.Range(0.06f, 0.14f);
				Vector3 spawnDir = Random.onUnitSphere;
				p.transform.position = rightBall.transform.position + spawnDir * spawnRadius;
				p.transform.localScale = Vector3.one * Random.Range(0.004f, 0.01f);
				SetupParticleRenderer(p, GetRedParticleMaterial());
				MelonCoroutines.Start(PrepSpiralRoutine(p, rightBall, spawnRadius, 1.1f * Random.Range(0.5f, 0.9f)));
			}
		}
		for (int j = 0; j < 3; j++)
		{
			float delay = (float)j * 0.3f;
			float ringStartRadius = 0.1f + (float)j * 0.04f;
			MelonCoroutines.Start(EnergyRingDelayed(rightBall, ht, ringStartRadius, delay, 0.6f));
		}
		float elapsed = 0f;
		while (elapsed < 1.1f)
		{
			if ((Object)(object)rightBall == (Object)null || (Object)(object)rightHand == (Object)null)
			{
				beamPreparing = false;
				yield break;
			}
			float t = elapsed / 1.1f;
			float easeT = t * t;
			if ((Object)(object)ballLight != (Object)null)
			{
				ballLight.intensity = Mathf.Lerp(startIntensity, 5f, easeT);
				ballLight.range = Mathf.Lerp(startRange, 2f, easeT);
			}
			if ((Object)(object)ballRend != (Object)null && (Object)(object)ballRend.material != (Object)null)
			{
				SetMatColor(c: Color.Lerp(RED_BALL_FULL, new Color(1.5f, 0.3f, 0.2f, 1f), easeT), m: ballRend.material);
			}
			elapsed += Time.deltaTime;
			yield return null;
		}
		if ((Object)(object)rightBall == (Object)null || (Object)(object)rightHand == (Object)null)
		{
			beamPreparing = false;
			yield break;
		}
		ExecuteBeamFire();
		beamPreparing = false;
	}

	private IEnumerator PrepSpiralRoutine(GameObject particle, GameObject followBall, float startRadius, float life)
	{
		if ((Object)(object)particle == (Object)null)
		{
			if (activeParticles > 0)
			{
				activeParticles--;
			}
			yield break;
		}
		Vector3 startScale = particle.transform.localScale;
		float angle = Random.Range(0f, (float)Math.PI * 2f);
		float angularSpeed = Random.Range(6f, 12f) * ((Random.value > 0.5f) ? 1f : (-1f));
		float vertOff = Random.Range(-0.02f, 0.02f);
		float elapsed = 0f;
		while ((Object)(object)particle != (Object)null && (Object)(object)followBall != (Object)null && elapsed < life)
		{
			float t = elapsed / life;
			float radius = Mathf.Lerp(startRadius, 0.005f, t * t);
			angle += angularSpeed * Time.deltaTime;
			Vector3 center = followBall.transform.position;
			Vector3 offset = new Vector3(Mathf.Cos(angle) * radius, vertOff * (1f - t), Mathf.Sin(angle) * radius);
			particle.transform.position = center + offset;
			particle.transform.localScale = startScale * Mathf.Lerp(1f, 0.3f, t);
			elapsed += Time.deltaTime;
			yield return null;
		}
		if ((Object)(object)particle != (Object)null)
		{
			Object.Destroy((Object)(object)particle);
		}
		if (activeParticles > 0)
		{
			activeParticles--;
		}
	}

	private IEnumerator EnergyRingDelayed(GameObject followBall, Transform hand, float startRadius, float delay, float life)
	{
		yield return (object)new WaitForSeconds(delay);
		if ((Object)(object)followBall == (Object)null || (Object)(object)hand == (Object)null)
		{
			yield break;
		}
		GameObject ringObj = new GameObject("EnergyRing");
		LineRenderer lr = ringObj.AddComponent<LineRenderer>();
		if ((Object)(object)lr == (Object)null)
		{
			Object.Destroy((Object)(object)ringObj);
			yield break;
		}
		lr.positionCount = 33;
		lr.loop = true;
		lr.startWidth = 0.004f;
		lr.endWidth = 0.004f;
		lr.startColor = new Color(1f, 0.2f, 0.1f, 0.8f);
		lr.endColor = new Color(1f, 0.2f, 0.1f, 0.8f);
		((Renderer)lr).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)lr).receiveShadows = false;
		Shader s = GetSpriteAdditiveShader();
		if ((Object)(object)s != (Object)null)
		{
			((Renderer)lr).material = new Material(s);
			SetMatColor(((Renderer)lr).material, Color.white);
			SetupAdditiveSprite(((Renderer)lr).material, 3018);
		}
		float elapsed = 0f;
		while ((Object)(object)ringObj != (Object)null && (Object)(object)followBall != (Object)null && elapsed < life)
		{
			float t = elapsed / life;
			float smoothT = t * t * (3f - 2f * t);
			float radius = Mathf.Lerp(startRadius, startRadius * 0.15f, smoothT);
			float alpha = Mathf.Lerp(0.8f, 0f, smoothT);
			Vector3 center = followBall.transform.position;
			Vector3 beamDir = -hand.right;
			if (((Vector3)(ref beamDir)).sqrMagnitude < 0.001f)
			{
				beamDir = Vector3.forward;
			}
			((Vector3)(ref beamDir)).Normalize();
			Vector3 perp1 = Vector3.Cross(beamDir, Vector3.up);
			if (((Vector3)(ref perp1)).sqrMagnitude < 0.01f)
			{
				perp1 = Vector3.Cross(beamDir, Vector3.forward);
			}
			((Vector3)(ref perp1)).Normalize();
			Vector3 val = Vector3.Cross(beamDir, perp1);
			Vector3 perp2 = ((Vector3)(ref val)).normalized;
			for (int i = 0; i <= 32; i++)
			{
				float a = (float)i / 32f * (float)Math.PI * 2f;
				Vector3 point = center + (perp1 * Mathf.Cos(a) + perp2 * Mathf.Sin(a)) * radius;
				lr.SetPosition(i, point);
			}
			lr.startColor = new Color(1f, 0.2f, 0.1f, alpha);
			lr.endColor = new Color(1f, 0.2f, 0.1f, alpha);
			lr.startWidth = 0.004f * (1f - smoothT * 0.5f);
			lr.endWidth = 0.004f * (1f - smoothT * 0.5f);
			elapsed += Time.deltaTime;
			yield return null;
		}
		if ((Object)(object)ringObj != (Object)null)
		{
			Object.Destroy((Object)(object)ringObj);
		}
	}

	private void ExecuteBeamFire()
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: 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_0074: 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_0083: 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_0093: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: 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_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: 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_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: 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_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_0307: Unknown result type (might be due to invalid IL or missing references)
		//IL_0318: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_0334: Unknown result type (might be due to invalid IL or missing references)
		//IL_0335: Unknown result type (might be due to invalid IL or missing references)
		//IL_0340: Unknown result type (might be due to invalid IL or missing references)
		//IL_034b: Unknown result type (might be due to invalid IL or missing references)
		//IL_034c: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)rightHand == (Object)null)
		{
			CancelRedMaxOutput();
			return;
		}
		Transform transform = ((Component)rightHand).transform;
		Vector3 val = -transform.right;
		if (((Vector3)(ref val)).sqrMagnitude < 0.001f)
		{
			val = Vector3.forward;
		}
		((Vector3)(ref val)).Normalize();
		Vector3 val2 = transform.position + transform.forward * -0.04f + transform.up * -0.05f + transform.right * -0.05f + val * 0.03f;
		float num = redMaxOutputCharge;
		int value;
		float num2;
		if (num >= 0.75f)
		{
			value = 3;
			num2 = 0.083f;
		}
		else if (num >= 0.5f)
		{
			value = 2;
			num2 = 0.053f;
		}
		else
		{
			value = 1;
			num2 = 0.027f;
		}
		((MelonBase)this).LoggerInstance.Msg($"RedBlueMod: RO Beam! Стадия={value}, ширина={num2:F3}");
		RBSound.Play("red_splou");
		Vector3 val3 = val2 + val * 30f;
		HashSet<GameObject> hashSet = new HashSet<GameObject>();
		Vector3 val4 = val2 + val * 0.1f;
		Vector3 val5 = val2 + val * 29.9f;
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapCapsule(val4, val5, 0.1f));
		Collider[] array2 = array;
		foreach (Collider val6 in array2)
		{
			if (!((Object)(object)val6 == (Object)null) && !((Object)(object)((Component)val6).gameObject == (Object)null) && !IsPlayer(((Component)val6).gameObject))
			{
				HVRGrabbable componentInParent = ((Component)val6).GetComponentInParent<HVRGrabbable>();
				if (!((Object)(object)componentInParent == (Object)null) && IsGestureBodyPart(((Object)((Component)componentInParent).gameObject).name) && !hashSet.Contains(((Component)componentInParent).gameObject))
				{
					hashSet.Add(((Component)componentInParent).gameObject);
					GestureFractureBodyPart(((Component)componentInParent).gameObject);
					ScatterFractureChunks(val6.ClosestPoint(val2), val, null);
				}
			}
		}
		((MelonBase)this).LoggerInstance.Msg($"RedBlueMod: RO Beam разорвал {hashSet.Count} конечностей.");
		ApplyBeamPushForce(val2, val, 30f, num2);
		CreateBeamLineSquish(val2, val3, num2 * 0.4f, RO_BEAM_CORE_COLOR, 3020);
		CreateBeamLineSquish(val2, val3, num2, RO_BEAM_MID_COLOR, 3019);
		CreateBeamLineSquish(val2, val3, num2 * 2.2f, RO_BEAM_OUTER_COLOR, 3018);
		SpawnBeamParticlesDiverse(val2, val3, num2);
		SpawnRedBeamImpactFlash(val3, num2);
		SpawnAppearFlash(val2, RED_FLASH_COLOR);
		DestroyAimLine();
		if ((Object)(object)rightBall != (Object)null)
		{
			Object.Destroy((Object)(object)rightBall);
			rightBall = null;
		}
		redMaxOutputMode = false;
		rightState = State.Cooldown;
		rightCharge = 0f;
		MelonCoroutines.Start(ResetAfterCooldown(isLeft: false));
	}

	private void ApplyBeamPushForce(Vector3 origin, Vector3 direction, float beamLength, float beamWidth)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: 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)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: 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_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: 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_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: 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_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = origin + direction * 0.1f;
		Vector3 val2 = origin + direction * (beamLength - 0.1f);
		float num = beamWidth * 2f + 0.4f;
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapCapsule(val, val2, num));
		Collider[] array2 = array;
		foreach (Collider val3 in array2)
		{
			if ((Object)(object)val3 == (Object)null || (Object)(object)((Component)val3).gameObject == (Object)null || IsPlayer(((Component)val3).gameObject))
			{
				continue;
			}
			Rigidbody val4 = ((Component)val3).GetComponent<Rigidbody>();
			if ((Object)(object)val4 == (Object)null)
			{
				val4 = ((Component)val3).GetComponentInParent<Rigidbody>();
			}
			if ((Object)(object)val4 == (Object)null || val4.isKinematic)
			{
				continue;
			}
			float num2 = Vector3.Dot(val4.position - origin, direction);
			if (num2 < 0f || num2 > beamLength)
			{
				continue;
			}
			Vector3 val5 = origin + direction * num2;
			float num3 = Vector3.Distance(val4.position, val5);
			float num4 = Mathf.Clamp01(1f - num3 / num);
			float num5 = Mathf.Clamp01(1f - num2 / beamLength * 0.6f);
			float num6 = 18f * num4 * num5;
			if (!(num6 < 0.5f))
			{
				Vector3 val6 = direction;
				if (num3 > 0.01f)
				{
					Vector3 val7 = val6;
					Vector3 val8 = val4.position - val5;
					val6 = val7 + ((Vector3)(ref val8)).normalized * 0.25f;
				}
				val6.y += 0.15f;
				((Vector3)(ref val6)).Normalize();
				val4.AddForce(val6 * num6, (ForceMode)1);
			}
		}
	}

	private void CancelRedMaxOutput()
	{
		redMaxOutputMode = false;
		redMaxOutputCharge = 0f;
		beamPreparing = false;
		DestroyAimLine();
	}

	private void CreateBeamLineSquish(Vector3 start, Vector3 end, float baseWidth, Color color, int queue)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: 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_0089: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: 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_00cd: Expected O, but got Unknown
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("RedBeamLine");
		LineRenderer val2 = val.AddComponent<LineRenderer>();
		if ((Object)(object)val2 == (Object)null)
		{
			Object.Destroy((Object)(object)val);
			return;
		}
		val2.positionCount = 2;
		val2.SetPosition(0, start);
		val2.SetPosition(1, start);
		val2.startWidth = 0.001f;
		val2.endWidth = 0.001f;
		val2.startColor = color;
		val2.endColor = new Color(color.r, color.g, color.b, color.a * 0.3f);
		((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)val2).receiveShadows = false;
		val2.numCapVertices = 4;
		Shader spriteAdditiveShader = GetSpriteAdditiveShader();
		if ((Object)(object)spriteAdditiveShader != (Object)null)
		{
			((Renderer)val2).material = new Material(spriteAdditiveShader);
			SetMatColor(((Renderer)val2).material, Color.white);
			SetupAdditiveSprite(((Renderer)val2).material, queue);
		}
		MelonCoroutines.Start(BeamLifeRoutine(val, val2, start, end, baseWidth, color));
	}

	private IEnumerator BeamLifeRoutine(GameObject beamObj, LineRenderer lr, Vector3 start, Vector3 end, float baseWidth, Color color)
	{
		//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)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: 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_0035: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)beamObj == (Object)null || (Object)(object)lr == (Object)null)
		{
			yield break;
		}
		float elapsed = 0f;
		while ((Object)(object)beamObj != (Object)null && elapsed < 0.15f)
		{
			float t = elapsed / 0.15f;
			float smoothT = t * t * (3f - 2f * t);
			Vector3 currentEnd = Vector3.Lerp(start, end, smoothT);
			lr.SetPosition(1, currentEnd);
			lr.startWidth = Mathf.Max(0.001f, baseWidth * smoothT);
			lr.endWidth = Mathf.Max(0.001f, baseWidth * 0.6f * smoothT);
			elapsed += Time.deltaTime;
			yield return null;
		}
		if (!((Object)(object)beamObj == (Object)null))
		{
			lr.SetPosition(1, end);
			lr.startWidth = baseWidth;
			lr.endWidth = baseWidth * 0.6f;
			elapsed = 0f;
			while ((Object)(object)beamObj != (Object)null && elapsed < 0.8f)
			{
				elapsed += Time.deltaTime;
				yield return null;
			}
			elapsed = 0f;
			while ((Object)(object)beamObj != (Object)null && elapsed < 1.13f)
			{
				float t2 = elapsed / 1.13f;
				float smoothT2 = t2 * t2 * (3f - 2f * t2);
				float w = baseWidth * (1f - smoothT2);
				lr.startWidth = Mathf.Max(0.0005f, w);
				lr.endWidth = Mathf.Max(0.0005f, w * 0.6f);
				float alpha = 1f - smoothT2;
				lr.startColor = new Color(color.r, color.g, color.b, color.a * alpha);
				lr.endColor = new Color(color.r, color.g, color.b, color.a * 0.3f * alpha);
				elapsed += Time.deltaTime;
				yield return null;
			}
			if ((Object)(object)beamObj != (Object)null)
			{
				Object.Destroy((Object)(object)beamObj);
			}
		}
	}

	private void SpawnBeamParticlesDiverse(Vector3 start, Vector3 end, float width)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: 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_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: 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_0084: 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_0093: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: 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)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: Unknown result type (might be due to invalid IL or missing references)
		float num = Vector3.Distance(start, end);
		int num2 = Math.Max(Math.Min((int)Mathf.Ceil(num * 2.5f), 100), 30);
		Material val = GetRedParticleMaterial();
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		for (int i = 0; i < num2; i++)
		{
			if (activeParticles >= 400)
			{
				break;
			}
			float num3 = Random.Range(0.03f, 0.97f);
			Vector3 val2 = Vector3.Lerp(start, end, num3);
			val2 += Random.insideUnitSphere * width * 4f;
			int num4 = Random.Range(0, 10);
			GameObject val3;
			bool isSmall;
			if (num4 < 6)
			{
				val3 = GameObject.CreatePrimitive((PrimitiveType)0);
				float num5 = Random.Range(0.004f, 0.014f);
				val3.transform.localScale = Vector3.one * num5;
				isSmall = num5 < 0.008f;
			}
			else if (num4 < 8)
			{
				val3 = GameObject.CreatePrimitive((PrimitiveType)3);
				float num6 = Random.Range(0.01f, 0.028f);
				val3.transform.localScale = Vector3.one * num6;
				isSmall = false;
			}
			else
			{
				val3 = GameObject.CreatePrimitive((PrimitiveType)3);
				val3.transform.localScale = new Vector3(Random.Range(0.005f, 0.01f), Random.Range(0.018f, 0.04f), Random.Range(0.005f, 0.01f));
				isSmall = false;
			}
			if (!((Object)(object)val3 == (Object)null))
			{
				activeParticles++;
				Object.Destroy((Object)(object)val3.GetComponent<Collider>());
				((Object)val3).name = "BeamParticle";
				val3.transform.position = val2;
				val3.transform.rotation = Random.rotation;
				SetupParticleRenderer(val3, val);
				Vector3 val4 = Vector3.Lerp(start, end, num3);
				Vector3 val5 = val2 - val4;
				if (((Vector3)(ref val5)).sqrMagnitude < 0.001f)
				{
					val5 = Random.onUnitSphere;
				}
				((Vector3)(ref val5)).Normalize();
				Vector3 drift = val5 * Random.Range(0.8f, 2.5f) + Random.insideUnitSphere * 0.6f;
				MelonCoroutines.Start(BeamParticleRoutine(val3, drift, isSmall));
			}
		}
	}

	private IEnumerator BeamParticleRoutine(GameObject particle, Vector3 drift, bool isSmall)
	{
		//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 totalLife = 0.93599993f;
		float absorbStart = totalLife * 0.55f;
		float elapsed = 0f;
		while ((Object)(object)particle != (Object)null && elapsed < absorbStart)
		{
			float dt = Time.deltaTime;
			Transform transform = particle.transform;
			transform.position += drift * dt;
			drift *= 0.96f;
			particle.transform.Rotate(Random.insideUnitSphere * 120f * dt);
			elapsed += dt;
			yield return null;
		}
		if ((Object)(object)particle == (Object)null)
		{
			if (activeParticles > 0)
			{
				activeParticles--;
			}
			yield break;
		}
		if (isSmall)
		{
			float fadeTime = 0.12f;
			elapsed = 0f;
			while ((Object)(object)particle != (Object)null && elapsed < fadeTime)
			{
				float t = elapsed / fadeTime;
				particle.transform.localScale = startScale * Mathf.Max(0.001f, 1f - t);
				elapsed += Time.deltaTime;
				yield return null;
			}
		}
		else
		{
			float absorbTime = totalLife - absorbStart;
			elapsed = 0f;
			while ((Object)(object)particle != (Object)null && elapsed < absorbTime)
			{
				float t2 = elapsed / absorbTime;
				float smoothT = t2 * t2;
				particle.transform.localScale = startScale * Mathf.Max(0.001f, 1f - smoothT);
				Transform transform2 = particle.transform;
				transform2.position += drift * Time.deltaTime * -0.3f;
				particle.transform.Rotate(Random.insideUnitSphere * 200f * Time.deltaTime);
				elapsed += Time.deltaTime;
				yield return null;
			}
		}
		if ((Object)(object)particle != (Object)null)
		{
			Object.Destroy((Object)(object)particle);
		}
		if (activeParticles > 0)
		{
			activeParticles--;
		}
	}

	private void SpawnRedBeamImpactFlash(Vector3 position, float width)
	{
		//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_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: 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_0093: Expected O, but got Unknown
		//IL_00ae: 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 = "RedBeamImpact";
		val.transform.position = position;
		val.transform.localScale = Vector3.one * (width * 4f);
		Renderer component = val.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader spriteAdditiveShader = GetSpriteAdditiveShader();
			if ((Object)(object)spriteAdditiveShader != (Object)null)
			{
				component.material = new Material(spriteAdditiveShader);
				SetMatColor(component.material, new Color(1f, 0.2f, 0.1f, 0.9f));
				SetupAdditiveSprite(component.material, 3020);
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
		Light val2 = val.AddComponent<Light>();
		val2.type = (LightType)2;
		val2.color = new Color(1f, 0.15f, 0.1f);
		val2.intensity = 8f;
		val2.range = 3f;
		MelonCoroutines.Start(RedBeamImpactRoutine(val, val2));
	}

	private IEnumerator RedBeamImpactRoutine(GameObject flash, Light light)
	{
		float elapsed = 0f;
		Vector3 startScale = flash.transform.localScale;
		while ((Object)(object)flash != (Object)null && elapsed < 0.5f)
		{
			float t = elapsed / 0.5f;
			flash.transform.localScale = startScale * Mathf.Lerp(1f, 3f, t);
			if ((Object)(object)light != (Object)null)
			{
				light.intensity = Mathf.Lerp(8f, 0f, t * t);
			}
			Renderer r = flash.GetComponent<Renderer>();
			if ((Object)(object)r != (Object)null && (Object)(object)r.material != (Object)null)
			{
				Color c = r.material.color;
				c.a = Mathf.Lerp(0.9f, 0f, t);
				SetMatColor(r.material, c);
			}
			elapsed += Time.deltaTime;
			yield return null;
		}
		if ((Object)(object)flash != (Object)null)
		{
			Object.Destroy((Object)(object)flash);
		}
	}

	private void SweepArcs()
	{
		if (activeArcs.Count == 0)
		{
			return;
		}
		for (int num = activeArcs.Count - 1; num >= 0; num--)
		{
			ArcEntry arcEntry = activeArcs[num];
			if (arcEntry == null || (Object)(object)arcEntry.obj == (Object)null)
			{
				activeArcs.RemoveAt(num);
			}
			else if (Time.time >= arcEntry.deathTime)
			{
				try
				{
					Object.Destroy((Object)(object)arcEntry.obj);
				}
				catch
				{
				}
				activeArcs.RemoveAt(num);
				sweepKilled++;
			}
		}
		if (sweepKilled > 0 && !sweepLogged)
		{
			sweepLogged = true;
			((MelonBase)this).LoggerInstance.Msg($"RedBlueMod: чистилка: {sweepKilled}");
		}
	}

	private void UpdateBallFollow(GameObject ball, HVRHandGrabber hand)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: 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_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: 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_007d: 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_0096: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)ball == (Object)null) && !((Object)(object)hand == (Object)null))
		{
			Transform transform = ((Component)hand).transform;
			Vector3 val = transform.position + transform.up * 0.05f + transform.forward * 0.12f;
			float num = 1f - Mathf.Exp(-12f * Time.deltaTime);
			ball.transform.position = Vector3.Lerp(ball.transform.position, val, num);
			ball.transform.rotation = Quaternion.Slerp(ball.transform.rotation, transform.rotation, num);
		}
	}

	private static void SetMatColor(Material m, Color c)
	{
		//IL_0025: 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)
		if ((Object)(object)m == (Object)null)
		{
			return;
		}
		try
		{
			if (m.HasProperty("_TintColor"))
			{
				m.SetColor("_TintColor", c);
			}
			if (m.HasProperty("_BaseColor"))
			{
				m.SetColor("_BaseColor", c);
			}
			if (m.HasProperty("_Color"))
			{
				m.SetColor("_Color", c);
			}
		}
		catch
		{
		}
	}

	private static void SetupAdditiveSprite(Material m, int renderQueue)
	{
		if ((Object)(object)m == (Object)null)
		{
			return;
		}
		try
		{
			if (m.HasProperty("_Surface"))
			{
				m.SetFloat("_Surface", 1f);
				m.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
			}
			if (m.HasProperty("_Blend"))
			{
				m.SetFloat("_Blend", 2f);
			}
			if (m.HasProperty("_SrcBlend"))
			{
				m.SetFloat("_SrcBlend", 5f);
			}
			if (m.HasProperty("_DstBlend"))
			{
				m.SetFloat("_DstBlend", 1f);
			}
			if (m.HasProperty("_ZWrite"))
			{
				m.SetFloat("_ZWrite", 0f);
			}
			if (m.HasProperty("_Cull"))
			{
				m.SetFloat("_Cull", 0f);
			}
			m.renderQueue = renderQueue;
		}
		catch
		{
		}
	}

	private Shader GetOrbShader()
	{
		return Shader.Find("Universal Render Pipeline/Unlit") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard");
	}

	private Shader GetAdditiveShader()
	{
		return Shader.Find("Legacy Shaders/Particles/Additive") ?? Shader.Find("Mobile/Particles/Additive") ?? Shader.Find("Sprites/Default");
	}

	private Shader GetSpriteAdditiveShader()
	{
		return Shader.Find("Universal Render Pipeline/Particles/Unlit") ?? Shader.Find("Universal Render Pipeline/Unlit") ?? Shader.Find("Sprites/Default");
	}

	private Shader GetArcShader()
	{
		return Shader.Find("Universal Render Pipeline/Particles/Unlit") ?? Shader.Find("Universal Render Pipeline/Unlit") ?? Shader.Find("Sprites/Default");
	}

	private void SetupTransparentURP(Material m)
	{
		if ((Object)(object)m == (Object)null)
		{
			return;
		}
		try
		{
			if (m.HasProperty("_Surface"))
			{
				m.SetFloat("_Surface", 1f);
				m.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
			}
			if (m.HasProperty("_Mode"))
			{
				m.SetFloat("_Mode", 3f);
			}
			if (m.HasProperty("_SrcBlend"))
			{
				m.SetFloat("_SrcBlend", 5f);
			}
			if (m.HasProperty("_DstBlend"))
			{
				m.SetFloat("_DstBlend", 10f);
			}
			if (m.HasProperty("_ZWrite"))
			{
				m.SetFloat("_ZWrite", 0f);
			}
			if (m.HasProperty("_Cull"))
			{
				m.SetFloat("_Cull", 0f);
			}
			m.renderQueue = 3000;
		}
		catch
		{
		}
	}

	private Material GetPurpleGlowMat()
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		//IL_003e: 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_0056: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)purpleGlowMat != (Object)null)
		{
			return purpleGlowMat;
		}
		Shader spriteAdditiveShader = GetSpriteAdditiveShader();
		if ((Object)(object)spriteAdditiveShader == (Object)null)
		{
			return null;
		}
		purpleGlowMat = new Material(spriteAdditiveShader);
		Color pP_GLOW_COLOR = PP_GLOW_COLOR;
		pP_GLOW_COLOR.a = 0.3f;
		SetMatColor(purpleGlowMat, pP_GLOW_COLOR);
		SetupAdditiveSprite(purpleGlowMat, 3010);
		return purpleGlowMat;
	}

	private Material GetBlueRingMat()
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		//IL_003e: 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_0056: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)blueRingMat != (Object)null)
		{
			return blueRingMat;
		}
		Shader spriteAdditiveShader = GetSpriteAdditiveShader();
		if ((Object)(object)spriteAdditiveShader == (Object)null)
		{
			return null;
		}
		blueRingMat = new Material(spriteAdditiveShader);
		Color pP_RING_COLOR = PP_RING_COLOR;
		pP_RING_COLOR.a = 0.35f;
		SetMatColor(blueRingMat, pP_RING_COLOR);
		SetupAdditiveSprite(blueRingMat, 3011);
		return blueRingMat;
	}

	private void SetupHollowPurpleVisual(GameObject ball)
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Expected O, but got Unknown
		//IL_004c: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Expected O, but got Unknown
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ball == (Object)null)
		{
			return;
		}
		Renderer component = ball.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader orbShader = GetOrbShader();
			if ((Object)(object)orbShader != (Object)null)
			{
				component.material = new Material(orbShader);
				SetMatColor(component.material, PP_BODY_COLOR);
				SetupTransparentURP(component.material);
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
		if (PP_ENABLE_CORE)
		{
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)val.GetComponent<Collider>());
				((Object)val).name = "PurpleCore";
				val.transform.SetParent(ball.transform);
				val.transform.localPosition = Vector3.zero;
				val.transform.localRotation = Quaternion.identity;
				val.transform.localScale = Vector3.one * 0.5f;
				Renderer component2 = val.GetComponent<Renderer>();
				if ((Object)(object)component2 != (Object)null)
				{
					Shader orbShader2 = GetOrbShader();
					if ((Object)(object)orbShader2 != (Object)null)
					{
						component2.material = new Material(orbShader2);
						SetMatColor(component2.material, new Color(3.5f, 3.5f, 3.5f, 1f));
					}
					component2.shadowCastingMode = (ShadowCastingMode)0;
					component2.receiveShadows = false;
				}
			}
		}
		if (PP_ENABLE_GLOW_SHELL)
		{
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0);
			if ((Object)(object)val2 != (Object)null)
			{
				Object.Destroy((Object)(object)val2.GetComponent<Collider>());
				((Object)val2).name = "PurpleGlowShell";
				val2.transform.SetParent(ball.transform);
				val2.transform.localPosition = Vector3.zero;
				val2.transform.localRotation = Quaternion.identity;
				val2.transform.localScale = Vector3.one * 1.45f;
				Renderer component3 = val2.GetComponent<Renderer>();
				if ((Object)(object)component3 != (Object)null)
				{
					Material val3 = GetPurpleGlowMat();
					if ((Object)(object)val3 != (Object)null)
					{
						component3.material = val3;
					}
					else
					{
						component3.enabled = false;
					}
					component3.shadowCastingMode = (ShadowCastingMode)0;
					component3.receiveShadows = false;
				}
			}
		}
		if (PP_ENABLE_RIM_SHELL)
		{
			GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)0);
			if ((Object)(object)val4 != (Object)null)
			{
				Object.Destroy((Object)(object)val4.GetComponent<Collider>());
				((Object)val4).name = "PurpleRimShell";
				val4.transform.SetParent(ball.transform);
				val4.transform.localPosition = Vector3.zero;
				val4.transform.localRotation = Quaternion.identity;
				val4.transform.localScale = Vector3.one * 1.18f;
				Renderer component4 = val4.GetComponent<Renderer>();
				if ((Object)(object)component4 != (Object)null)
				{
					Material val5 = GetBlueRingMat();
					if ((Object)(object)val5 != (Object)null)
					{
						component4.material = val5;
					}
					else
					{
						component4.enabled = false;
					}
					component4.shadowCastingMode = (ShadowCastingMode)0;
					component4.receiveShadows = false;
				}
			}
		}
		MelonCoroutines.Start(HollowPurpleVisualRoutine(ball));
	}

	private IEnumerator HollowPurpleVisualRoutine(GameObject ball)
	{
		if ((Object)(object)ball == (Object)null)
		{
			yield break;
		}
		Transform coreT = ball.transform.Find("PurpleCore");
		Transform rimT = ball.transform.Find("PurpleRimShell");
		float time = Random.Range(0f, 20f);
		float sparkTimer = 0f;
		float arcTimer = 0f;
		while ((Object)(object)ball != (Object)null)
		{
			time += Time.deltaTime;
			float ballScale = ball.transform.localScale.x;
			if ((Object)(object)coreT != (Object)null)
			{
				coreT.localScale = Vector3.one * (0.5f * (1f + Mathf.Sin(time * 7f) * 0.06f));
			}
			if ((Object)(object)rimT != (Object)null)
			{
				rimT.localScale = Vector3.one * (1.18f * (1f + Mathf.Sin(time * 5f + 1.3f) * 0.05f));
			}
			if (PP_ENABLE_SPARKS)
			{
				sparkTimer -= Time.deltaTime;
				if (sparkTimer <= 0f)
				{
					SpawnHollowSpark(ball);
					SpawnHollowSpark(ball);
					sparkTimer = Random.Range(0.03f, 0.07f);
				}
			}
			if (PP_ENABLE_LIGHTNING)
			{
				arcTimer -= Time.deltaTime;
				if (arcTimer <= 0f)
				{
					SpawnPurpleLightning(ball.transform.position, ballScale);
					arcTimer = Random.Range(0.1f, 0.28f) / Mathf.Max(1f, purpleLightningBoost);
				}
			}
			yield return null;
		}
	}

	private void SpawnHollowSpark(GameObject ball)
	{
		//IL_0086: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: 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)
		if ((Object)(object)ball == (Object)null || activeParticles >= 400)
		{
			return;
		}
		Material val = GetPurpleSparkMaterial();
		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 = "HollowPurpleSpark";
			float x = ball.transform.localScale.x;
			val2.transform.position = ball.transform.position + Random.insideUnitSphere * (x * 0.42f);
			float num = x * Random.Range(0.03f, 0.07f);
			if (num < 0.002f)
			{
				num = 0.002f;
			}
			val2.transform.localScale = Vector3.one * num;
			SetupParticleRenderer(val2, val);
			MelonCoroutines.Start(HollowSparkRoutine(val2, Random.insideUnitSphere * (x * 0.15f), Random.Range(0.25f, 0.6f)));
		}
	}

	private IEnumerator HollowSparkRoutine(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;
			Transform transform = particle.transform;
			transform.position += drift * dt;
			drift *= 0.92f;
			elapsed += dt;
			float t = elapsed / life;
			particle.transform.localScale = startScale * Mathf.Clamp01(1f - t) * (0.85f + 0.15f * Mathf.Sin(elapsed * 8f));
			yield return null;
		}
		if ((Object)(object)particle != (Object)null)
		{
			Object.Destroy((Object)(object)particle);
		}
		if (activeParticles > 0)
		{
			activeParticles--;
		}
	}

	private void SpawnPurpleLightning(Vector3 center, float ballScale)
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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_0088: 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_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Expected O, but got Unknown
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: 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_00b0: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Expected O, but got Unknown
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			float num = Mathf.Max(1f, purpleLightningBoost);
			float num2 = ballScale * Random.Range(1.4f, 2.6f) * num;
			float num3 = Mathf.Max(0.004f, ballScale * 0.03f) * Mathf.Sqrt(num);
			Vector3 onUnitSphere = Random.onUnitSphere;
			Vector3 val = center + onUnitSphere * (ballScale * 0.45f);
			Vector3 val2 = center + onUnitSphere * (ballScale * 0.45f + num2);
			int num4 = 4;
			Vector3[] array = (Vector3[])(object)new Vector3[num4 + 1];
			for (int i = 0; i <= num4; i++)
			{
				Vector3 val3 = Vector3.Lerp(val, val2, (float)i / (float)num4);
				if (i != 0 && i != num4)
				{
					val3 += Random.insideUnitSphere * (ballScale * 0.15f * num);
				}
				array[i] = val3;
			}
			for (int j = 0; j <= num4; j++)
			{
				if (float.IsNaN(array[j].x) || float.IsNaN(array[j].y) || float.IsNaN(array[j].z) || ((Vector3)(ref array[j])).magnitude > 1000f)
				{
					return;
				}
			}
			GameObject val4 = new GameObject("HollowPurpleArc");
			LineRenderer val5 = val4.AddComponent<LineRenderer>();
			if ((Object)(object)val5 == (Object)null)
			{
				Object.Destroy((Object)(object)val4);
				return;
			}
			val5.startWidth = num3;
			val5.endWidth = num3 * 0.4f;
			val5.startColor = PP_ARC_START;
			val5.endColor = PP_ARC_END;
			Shader arcShader = GetArcShader();
			if ((Object)(object)arcShader != (Object)null)
			{
				((Renderer)val5).material = new Material(arcShader);
				SetMatColor(((Renderer)val5).material, Color.white);
				SetupAdditiveSprite(((Renderer)val5).material, 3015);
			}
			((Renderer)val5).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)val5).receiveShadows = false;
			val5.positionCount = array.Length;
			val5.SetPositions(Il2CppStructArray<Vector3>.op_Implicit(array));
			float num5 = Random.Range(0.05f, 0.12f) * Mathf.Sqrt(num);
			activeArcs.Add(new ArcEntry
			{
				obj = val4,
				deathTime = Time.time + num5
			});
			Object.Destroy((Object)(object)val4, num5);
		}
		catch
		{
		}
	}

	private void SpawnPurpleLightningBurst(Vector3 center, float scale)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		float num = purpleLightningBoost;
		purpleLightningBoost = Mathf.Max(num, 2.5f);
		for (int i = 0; i < 10; i++)
		{
			SpawnPurpleLightning(center, scale);
		}
		purpleLightningBoost = num;
	}

	private void SpawnAppearFlash(Vector3 pos, Color c)
	{
		//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_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Expected O, but got Unknown
		//IL_0096: 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 = "AppearFlash";
		val.transform.position = pos;
		val.transform.localScale = Vector3.one * 0.1f;
		Renderer component = val.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader spriteAdditiveShader = GetSpriteAdditiveShader();
			if ((Object)(object)spriteAdditiveShader != (Object)null)
			{
				component.material = new Material(spriteAdditiveShader);
				SetMatColor(component.material, c);
				SetupAdditiveSprite(component.material, 3020);
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
		MelonCoroutines.Start(AppearFlashRoutine(val, c));
	}

	private IEnumerator AppearFlashRoutine(GameObject flash, Color c)
	{
		//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)flash == (Object)null)
		{
			yield break;
		}
		Renderer r = flash.GetComponent<Renderer>();
		Material m = (((Object)(object)r != (Object)null) ? r.material : null);
		float elapsed = 0f;
		while ((Object)(object)flash != (Object)null && elapsed < 0.3f)
		{
			float t = elapsed / 0.3f;
			flash.transform.localScale = Vector3.one * Mathf.Lerp(0.1f, 0.7f, t);
			if ((Object)(object)m != (Object)null)
			{
				Color cc = c;
				cc.a = Mathf.Lerp(0.9f, 0f, t);
				SetMatColor(m, cc);
			}
			elapsed += Time.deltaTime;
			yield return null;
		}
		if ((Object)(object)flash != (Object)null)
		{
			if ((Object)(object)m != (Object)null)
			{
				Object.Destroy((Object)(object)m);
			}
			Object.Destroy((Object)(object)flash);
		}
	}

	private void SpawnSideBurst(Vector3 pos, Vector3 dir, OrbType type)
	{
		//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_0096: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: 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_00eb: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
		Material val = ((type == OrbType.Red) ? GetRedParticleMaterial() : GetBlueParticleMaterial());
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		for (int i = 0; i < 12; i++)
		{
			if (activeParticles >= 400)
			{
				break;
			}
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0);
			if (!((Object)(object)val2 == (Object)null))
			{
				activeParticles++;
				Object.Destroy((Object)(object)val2.GetComponent<Collider>());
				((Object)val2).name = "AppearBurstParticle";
				val2.transform.position = pos + Random.insideUnitSphere * 0.03f;
				val2.transform.localScale = Vector3.one * Random.Range(0.006f, 0.016f);
				SetupParticleRenderer(val2, val);
				MelonCoroutines.Start(OutwardParticleRoutine(val2, dir * Random.Range(1.2f, 2.6f) + Random.onUnitSphere * 0.5f, Random.Range(0.4f, 0.8f)));
			}
		}
	}

	private bool GestureComboHeld(HVRController lc, HVRController rc)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: 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)
		if ((Object)(object)leftHand == (Object)null || (Object)(object)rightHand == (Object)null)
		{
			return false;
		}
		if (lc.TriggerButtonState.Active || lc.GripButtonState.Active)
		{
			return false;
		}
		if (!lc.SecondaryButtonState.Active)
		{
			return false;
		}
		if (!rc.TriggerButtonState.Active || !rc.GripButtonState.Active)
		{
			return false;
		}
		if (!rc.SecondaryButtonState.Active)
		{
			return false;
		}
		return true;
	}

	private bool CanStartGestureNow()
	{
		if (Time.time < gestureCooldownEnd)
		{
			return false;
		}
		if (purpleFusionActive)
		{
			return false;
		}
		if (leftState != State.Idle || rightState != State.Idle)
		{
			return false;
		}
		if (redMaxOutputMode)
		{
			return false;
		}
		return true;
	}

	private void StartGesturePurple()
	{
		gesturePurpleActive = true;
		gesturePhase = GesturePhase.Orbiting;
		MelonCoroutines.Start(GestureOrbitRoutine());
	}

	private Transform FindChestTransform(Transform rig)
	{
		if ((Object)(object)rig == (Object)null)
		{
			return null;
		}
		Transform[] array = Il2CppArrayBase<Transform>.op_Implicit(((Component)rig).GetComponentsInChildren<Transform>(true));
		if (array == null)
		{
			return null;
		}
		Transform val = null;
		Transform val2 = null;
		Transform val3 = null;
		Transform val4 = null;
		Transform val5 = null;
		Transform[] array2 = array;
		foreach (Transform val6 in array2)
		{
			if (!((Object)(object)val6 == (Object)null))
			{
				string name = ((Object)val6).name;
				if ((Object)(object)val == (Object)null && name == "PlayerUpperChest")
				{
					val = val6;
				}
				else if ((Object)(object)val2 == (Object)null && name == "UpperChestPoint")
				{
					val2 = val6;
				}
				else if ((Object)(object)val3 == (Object)null && name == "MiddleChest")
				{
					val3 = val6;
				}
				else if ((Object)(object)val4 == (Object)null && name == "MiddleChestPoint")
				{
					val4 = val6;
				}
				else if ((Object)(object)val5 == (Object)null && name == "Chest")
				{
					val5 = val6;
				}
			}
		}
		return val ?? val2 ?? val3 ?? val4 ?? val5;
	}

	private Vector3 GetGestureForward()
	{
		//IL_0018: 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)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		Camera main = Camera.main;
		Vector3 result = (((Object)(object)main != (Object)null) ? ((Component)main).transform.forward : ((!((Object)(object)rightHand != (Object)null)) ? Vector3.forward : ((Component)rightHand).transform.forward));
		result.y = 0f;
		if (((Vector3)(ref result)).sqrMagnitude < 0.001f)
		{
			result = Vector3.forward;
		}
		((Vector3)(ref result)).Normalize();
		return result;
	}

	private Vector3 GetGestureCenter()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: 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_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: 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)
		Vector3 gestureForward = GetGestureForward();
		Camera main = Camera.main;
		Vector3 position;
		float num;
		if ((Object)(object)chestTransform != (Object)null)
		{
			position = chestTransform.position;
			num = position.y;
		}
		else if ((Object)(object)main != (Object)null)
		{
			position = ((Component)main).transform.position;
			num = position.y - 0.35f;
		}
		else
		{
			if (!((Object)(object)rightHand != (Object)null))
			{
				return Vector3.zero;
			}
			position = ((Component)rightHand).transform.position;
			num = position.y;
		}
		Vector3 result = position + gestureForward * 1.2f;
		result.y = num + 0f;
		return result;
	}

	private IEnumerator GestureOrbitRoutine()
	{
		RBSound.Play("gesture_theme");
		float t0 = Time.time;
		GameObject blueOrb = null;
		GameObject redOrb = null;
		bool blueFlash = false;
		bool blueSpawn = false;
		bool redFlash = false;
		bool redSpawn = false;
		float angle = 0f;
		float linkArcTimer = 0f;
		float orbArcTimer = 0f;
		float outArcTimer = 0f;
		bool merged = false;
		while (!merged)
		{
			float t1 = Time.time - t0;
			Vector3 center = GetGestureCenter();
			Vector3 fwd = GetGestureForward();
			Vector3 val = Vector3.Cross(Vector3.up, fwd);
			Vector3 rightAxis = ((Vector3)(ref val)).normalized;
			Vector3 blueHome = center - rightAxis * 0.35f;
			Vector3 redHome = center + rightAxis * 0.35f;
			if (!blueFlash && t1 >= 1.8399999f)
			{
				blueFlash = true;
				SpawnAppearFlash(blueHome, BLUE_FLASH_COLOR);
			}
			if (!blueSpawn && t1 >= 2.04f)
			{
				blueSpawn = true;
				blueOrb = CreateGestureOrb(blueHome, OrbType.Blue);
				SpawnSideBurst(blueHome, -rightAxis, OrbType.Blue);
				if ((Object)(object)blueOrb == (Object)null)
				{
					CleanupGestureOrbs(blueOrb, redOrb);
					yield break;
				}
			}
			if (!redFlash && t1 >= 4.02f)
			{
				redFlash = true;
				SpawnAppearFlash(redHome, RED_FLASH_COLOR);
			}
			if (!redSpawn && t1 >= 4.22f)
			{
				redSpawn = true;
				redOrb = CreateGestureOrb(redHome, OrbType.Red);
				SpawnSideBurst(redHome, rightAxis, OrbType.Red);
				if ((Object)(object)redOrb == (Object)null)
				{
					CleanupGestureOrbs(blueOrb, redOrb);
					yield break;
				}
			}
			if (t1 < 5.18f)
			{
				if ((Object)(object)blueOrb != (Object)null)
				{
					blueOrb.transform.position = blueHome + Vector3.up * Mathf.Sin(t1 * 3f) * 0.01f;
				}
				if ((Object)(object)redOrb != (Object)null)
				{
					redOrb.transform.position = redHome + Vector3.up * Mathf.Sin(t1 * 3f + 1.7f) * 0.01f;
				}
			}
			else
			{
				float ot = t1 - 5.18f;
				float mergeWindow = 6.82f;
				float radius = 0.35f;
				float angular;
				if (ot < 1.2f)
				{
					angular = Mathf.Lerp(0f, 9.42f, Mathf.SmoothStep(0f, 1f, ot / 1.2f));
				}
				else if (ot < mergeWindow - 2f)
				{
					angular = 9.42f;
				}
				else
				{
					float at = Mathf.Clamp01((ot - (mergeWindow - 2f)) / 2f);
					float sm = Mathf.Smoo