Decompiled source of BlackFlash v4.0.0

BlackFlash.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 BlackFlashMod;
using Il2Cpp;
using Il2CppActiveRagdoll;
using Il2CppHurricaneVR.Framework.Core;
using Il2CppHurricaneVR.Framework.Core.Grabbers;
using Il2CppHurricaneVR.Framework.Shared;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "BlackFlash", "2.0.0", "coope", null)]
[assembly: MelonGame("Kubunautilus", "BrutalistickVR")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BlackFlash")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BlackFlash")]
[assembly: AssemblyTitle("BlackFlash")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BlackFlashMod
{
	public static class Mci
	{
		public const string Alias = "blackflash_snd";

		public static bool Opened;

		public static string LastError;

		[DllImport("winmm.dll", CharSet = CharSet.Ansi, EntryPoint = "mciSendStringA")]
		private static extern int mciSendString(string cmd, StringBuilder buf, int bufSize, IntPtr cb);

		private static int Send(string cmd)
		{
			StringBuilder stringBuilder = new StringBuilder(256);
			int num = mciSendString(cmd, stringBuilder, stringBuilder.Capacity, IntPtr.Zero);
			if (num != 0)
			{
				LastError = cmd.Trim() + " -> " + num;
			}
			return num;
		}

		public static void Open(string path, int volumePercent)
		{
			if (!Opened)
			{
				if (Send("close blackflash_snd") == 0)
				{
				}
				if (Send("open \"" + path + "\" type waveaudio alias blackflash_snd") != 0)
				{
					Opened = false;
					return;
				}
				Send("set blackflash_snd time format milliseconds");
				Send("setaudio blackflash_snd volume to " + volumePercent);
				Send("set blackflash_snd repeat off");
				Send("seek blackflash_snd to start");
				Opened = true;
			}
		}

		public static void Play()
		{
			if (Opened)
			{
				Send("seek blackflash_snd to start");
				Send("play blackflash_snd");
			}
		}

		public static void Close()
		{
			if (Opened)
			{
				Send("close blackflash_snd");
				Opened = false;
			}
		}
	}
	public class Core : MelonMod
	{
		private enum StrikeState
		{
			Idle,
			Charging,
			Armed,
			Cooldown
		}

		private class HandState
		{
			public HVRHandGrabber hand;

			public StrikeState state = StrikeState.Idle;

			public float chargeAmount;

			public bool wasComboActive;

			public float armedTimer;

			public GameObject auraLightObj;

			public Light auraLight;

			public float flameSpawnTimer;

			public float emberSpawnTimer;

			public float flickerTime;
		}

		private const string RigName = "Hexa4Rig26.10.23";

		private const string LeftHandPath = "Physics LeftHand";

		private const string RightHandPath = "Physics RightHand";

		private const float CHARGE_SPEED = 0.8f;

		private const float MAX_CHARGE = 1f;

		private const float ARMED_DURATION = 2.5f;

		private const float FIST_CHECK_RADIUS = 0.18f;

		private const int MAX_PARTICLES = 250;

		private int _activeParticles;

		private const float FLAME_SIZE_SCALE = 1.2f;

		private const float FLAME_SPAWN_INTERVAL = 0.03f;

		private const float FLAME_LIFETIME_MIN = 0.35f;

		private const float FLAME_LIFETIME_MAX = 0.7f;

		private const float FLAME_STRETCH = 1.8f;

		private const float EMBER_SPAWN_INTERVAL_MIN = 0.08f;

		private const float EMBER_SPAWN_INTERVAL_MAX = 0.2f;

		private const float LIGHT_INTENSITY_MIN = 1f;

		private const float LIGHT_INTENSITY_MAX = 3.5f;

		private const float LIGHT_RANGE_MIN = 1f;

		private const float LIGHT_RANGE_MAX = 2.5f;

		private const float FLASH_DAMAGE = 150f;

		private const float FLASH_RADIUS = 3.5f;

		private const float FLASH_FORCE = 140f;

		private const string SoundFolder = "BlackFlashSounds";

		private const string SoundFile = "Blach_Flash.wav";

		private const int SoundVolume = 100;

		private static readonly Color BlueStart = new Color(0.55f, 0.75f, 1f, 1f);

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

		private static readonly Color BlueDeep = new Color(0f, 0.08f, 0.55f, 1f);

		public static HVRHexaBodyInputs playerInputs;

		public static HVRHandGrabber rightHand;

		private readonly HandState _left = new HandState();

		private readonly HandState _right = new HandState();

		private Transform _rig;

		private Shader _flameShader;

		private Material _additiveMat;

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

		private int _flashCount;

		private int _killHits;

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

		private float _logTimer;

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("========================================");
			((MelonBase)this).LoggerInstance.Msg("BLACK FLASH v2.0.0");
			((MelonBase)this).LoggerInstance.Msg("Кулак + Trigger + B -> зарядка (синяя)");
			((MelonBase)this).LoggerInstance.Msg("Отпусти -> удар по врагу = ЧЕРНАЯ ВСПЫШКА");
			((MelonBase)this).LoggerInstance.Msg("========================================");
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			_left.hand = null;
			_right.hand = null;
			_left.state = StrikeState.Idle;
			_right.state = StrikeState.Idle;
			playerInputs = null;
			rightHand = null;
			_rig = null;
			_flashCount = 0;
			_killHits = 0;
			_activeParticles = 0;
			_flameShader = null;
			_additiveMat = null;
			GetFlameShader();
			GetAdditiveMaterial();
			InitSound();
			if (sceneName == "MainMenuScene" || sceneName == "IntroScene")
			{
				return;
			}
			GameObject val = GameObject.Find("Hexa4Rig26.10.23");
			if ((Object)(object)val == (Object)null)
			{
				val = FindRigByPrefix();
			}
			if ((Object)(object)val != (Object)null)
			{
				_rig = val.transform;
				Transform val2 = _rig.Find("Physics LeftHand");
				Transform val3 = _rig.Find("Physics RightHand");
				if ((Object)(object)val2 != (Object)null)
				{
					_left.hand = ((Component)val2).GetComponent<HVRHandGrabber>();
				}
				if ((Object)(object)val3 != (Object)null)
				{
					_right.hand = ((Component)val3).GetComponent<HVRHandGrabber>();
				}
				rightHand = _right.hand;
				playerInputs = val.GetComponentInChildren<HVRHexaBodyInputs>();
			}
			((MelonBase)this).LoggerInstance.Msg("Scene " + sceneName + " L=" + ((Object)(object)_left.hand != (Object)null) + " R=" + ((Object)(object)_right.hand != (Object)null) + " inputs=" + ((Object)(object)playerInputs != (Object)null));
		}

		private void InitSound()
		{
			try
			{
				string path = Path.Combine(AppContext.BaseDirectory, "BlackFlashSounds");
				string text = Path.Combine(path, "Blach_Flash.wav");
				if (!File.Exists(text))
				{
					((MelonBase)this).LoggerInstance.Warning("Sound not found: " + text);
					return;
				}
				Mci.Open(text, 100);
				if (Mci.Opened)
				{
					((MelonBase)this).LoggerInstance.Msg("MCI sound ready: " + text);
				}
				else
				{
					((MelonBase)this).LoggerInstance.Warning("MCI open failed: " + Mci.LastError);
				}
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("Sound init error: " + ex.Message);
			}
		}

		private GameObject FindRigByPrefix()
		{
			Il2CppArrayBase<Transform> val = Object.FindObjectsOfType<Transform>(false);
			for (int i = 0; i < val.Length; i++)
			{
				Transform val2 = val[i];
				if (!((Object)(object)val2 == (Object)null) && ((Object)val2).name.StartsWith("Hexa4Rig", StringComparison.OrdinalIgnoreCase))
				{
					return ((Component)val2).gameObject;
				}
			}
			return null;
		}

		public override void OnUpdate()
		{
			//IL_005f: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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)playerInputs == (Object)null) && !((Object)(object)_right.hand == (Object)null))
			{
				HVRController leftController = playerInputs.LeftController;
				HVRController rightController = playerInputs.RightController;
				if (!((Object)(object)leftController == (Object)null) && !((Object)(object)rightController == (Object)null))
				{
					bool comboActive = leftController.TriggerButtonState.Active && leftController.GripButtonState.Active && leftController.SecondaryButtonState.Active;
					bool comboActive2 = rightController.TriggerButtonState.Active && rightController.GripButtonState.Active && rightController.SecondaryButtonState.Active;
					ProcessHand(_left, comboActive);
					ProcessHand(_right, comboActive2);
					CleanupFlash();
				}
			}
		}

		private void ProcessHand(HandState hs, bool comboActive)
		{
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)hs.hand == (Object)null)
			{
				return;
			}
			if (hs.state == StrikeState.Idle)
			{
				if (comboActive && !hs.wasComboActive)
				{
					StartCharging(hs);
				}
			}
			else if (hs.state == StrikeState.Charging)
			{
				if (!comboActive)
				{
					hs.state = StrikeState.Armed;
					hs.armedTimer = 2.5f;
					((MelonBase)this).LoggerInstance.Msg("ARMED charge=" + hs.chargeAmount.ToString("F2"));
				}
				else
				{
					hs.chargeAmount = Mathf.Min(hs.chargeAmount + Time.deltaTime * 0.8f, 1f);
					UpdateAura(hs);
					UpdateAuraSpawns(hs);
					if (FistTouchesEnemy(hs))
					{
						PerformStrike(hs);
					}
				}
			}
			else if (hs.state == StrikeState.Armed)
			{
				if (comboActive && !hs.wasComboActive)
				{
					hs.state = StrikeState.Charging;
				}
				else
				{
					hs.armedTimer -= Time.deltaTime;
					if (hs.armedTimer <= 0f)
					{
						CleanupAura(hs);
						hs.state = StrikeState.Cooldown;
						MelonCoroutines.Start(ResetAfterCooldown(hs));
						((MelonBase)this).LoggerInstance.Msg("EXPIRED charge=" + hs.chargeAmount.ToString("F2"));
					}
					else
					{
						UpdateAura(hs);
						UpdateAuraSpawns(hs);
						if (FistTouchesEnemy(hs))
						{
							PerformStrike(hs);
						}
						_logTimer += Time.deltaTime;
						if (_logTimer > 0.5f)
						{
							_logTimer = 0f;
							((MelonBase)this).LoggerInstance.Msg("ARMED... parts near fist=" + FindBodyPositions(((Component)hs.hand).transform.position, 0.6f));
						}
					}
				}
			}
			hs.wasComboActive = comboActive;
		}

		private void StartCharging(HandState hs)
		{
			hs.state = StrikeState.Charging;
			hs.chargeAmount = 0f;
			hs.flameSpawnTimer = 0f;
			hs.emberSpawnTimer = 0f;
			((MelonBase)this).LoggerInstance.Msg("Charge started");
		}

		private IEnumerator ResetAfterCooldown(HandState hs)
		{
			yield return (object)new WaitForSeconds(0.5f);
			hs.state = StrikeState.Idle;
		}

		private static bool IsBodyPart(string name)
		{
			for (int i = 0; i < BodyPartNames.Length; i++)
			{
				if (name == BodyPartNames[i])
				{
					return true;
				}
			}
			return false;
		}

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

		private bool FistTouchesEnemy(HandState hs)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)hs.hand == (Object)null)
			{
				return false;
			}
			return FindBodyParts(((Component)hs.hand).transform.position, 0.18f).Count > 0;
		}

		private List<GameObject> FindBodyParts(Vector3 center, float radius)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			List<GameObject> list = new List<GameObject>();
			HashSet<string> hashSet = new HashSet<string>();
			Il2CppReferenceArray<Collider> val = Physics.OverlapSphere(center, radius);
			if (val == null)
			{
				return list;
			}
			for (int i = 0; i < ((Il2CppArrayBase<Collider>)(object)val).Length; i++)
			{
				Collider val2 = ((Il2CppArrayBase<Collider>)(object)val)[i];
				if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).gameObject == (Object)null || IsPlayer(((Component)val2).gameObject))
				{
					continue;
				}
				HVRGrabbable componentInParent = ((Component)val2).GetComponentInParent<HVRGrabbable>();
				if (!((Object)(object)componentInParent == (Object)null) && IsBodyPart(((Object)((Component)componentInParent).gameObject).name))
				{
					string name = ((Object)((Component)componentInParent).gameObject).name;
					if (hashSet.Add(name))
					{
						list.Add(((Component)val2).gameObject);
					}
				}
			}
			return list;
		}

		private string FindBodyPositions(Vector3 center, float radius)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Il2CppReferenceArray<Collider> val = Physics.OverlapSphere(center, radius);
			if (val == null)
			{
				return "0";
			}
			int num = 0;
			for (int i = 0; i < ((Il2CppArrayBase<Collider>)(object)val).Length; i++)
			{
				Collider val2 = ((Il2CppArrayBase<Collider>)(object)val)[i];
				if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).gameObject == (Object)null) && !IsPlayer(((Component)val2).gameObject))
				{
					HVRGrabbable componentInParent = ((Component)val2).GetComponentInParent<HVRGrabbable>();
					if ((Object)(object)componentInParent != (Object)null && IsBodyPart(((Object)((Component)componentInParent).gameObject).name))
					{
						num++;
					}
				}
			}
			return num.ToString();
		}

		private void CreateAuraLight(HandState hs)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0055: 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)
			if (!((Object)(object)hs.hand == (Object)null))
			{
				CleanupAura(hs);
				hs.auraLightObj = new GameObject("BfAuraLight");
				hs.auraLightObj.transform.SetParent(((Component)hs.hand).transform);
				hs.auraLightObj.transform.localPosition = Vector3.zero;
				hs.auraLight = hs.auraLightObj.AddComponent<Light>();
				hs.auraLight.type = (LightType)2;
				hs.auraLight.color = BlueMid;
				hs.auraLight.intensity = 1f;
				hs.auraLight.range = 1f;
				hs.auraLight.shadows = (LightShadows)0;
			}
		}

		private void UpdateAura(HandState hs)
		{
			if (!((Object)(object)hs.auraLight == (Object)null))
			{
				hs.flickerTime += Time.deltaTime;
				float num = Mathf.Sin(hs.flickerTime * 25f) * 0.5f + Mathf.Sin(hs.flickerTime * 41f + 1.7f) * 0.5f;
				num = num * 0.5f + 0.5f;
				hs.auraLight.intensity = Mathf.Lerp(1f, 3.5f, hs.chargeAmount) + num * 0.8f;
				hs.auraLight.range = Mathf.Lerp(1f, 2.5f, hs.chargeAmount);
			}
		}

		private void UpdateAuraSpawns(HandState hs)
		{
			hs.flameSpawnTimer -= Time.deltaTime;
			if (hs.flameSpawnTimer <= 0f)
			{
				hs.flameSpawnTimer = 0.03f;
				SpawnFlameParticle(hs);
			}
			hs.emberSpawnTimer -= Time.deltaTime;
			if (hs.emberSpawnTimer <= 0f)
			{
				hs.emberSpawnTimer = Random.Range(0.08f, 0.2f);
				SpawnEmber(hs);
			}
		}

		private void SpawnFlameParticle(HandState hs)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: 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_0187: 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_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)hs.hand == (Object)null || _activeParticles >= 250)
			{
				return;
			}
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)5);
			if (!((Object)(object)val == (Object)null))
			{
				_activeParticles++;
				Object.Destroy((Object)(object)val.GetComponent<Collider>());
				((Object)val).name = "BfFlame";
				Transform transform = ((Component)hs.hand).transform;
				Vector3 val2 = Random.insideUnitSphere * (0.05f + hs.chargeAmount * 0.07f);
				val2.y += 0.02f;
				val.transform.position = transform.position + val2;
				float num = Random.Range(0.02f, 0.05f) * (0.7f + hs.chargeAmount * 0.8f) / 1.2f;
				val.transform.localScale = new Vector3(num, num * 1.8f, num);
				Renderer component = val.GetComponent<Renderer>();
				if ((Object)(object)component != (Object)null)
				{
					Material val3 = new Material(GetFlameShader());
					SetupTransparent(val3);
					val3.color = BlueMid;
					component.material = val3;
					component.shadowCastingMode = (ShadowCastingMode)0;
					component.receiveShadows = false;
					component.sortingOrder = 150;
				}
				Vector3 vel = Vector3.up * Random.Range(0.35f, 0.8f) + Random.insideUnitSphere * 0.15f + transform.forward * 0.1f;
				float life = Random.Range(0.35f, 0.7f);
				MelonCoroutines.Start(FlameRoutine(val, vel, life, num));
			}
		}

		private IEnumerator FlameRoutine(GameObject particle, Vector3 vel, float life, float size)
		{
			//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;
			}
			Renderer r = particle.GetComponent<Renderer>();
			float elapsed = 0f;
			while ((Object)(object)particle != (Object)null && elapsed < life)
			{
				float dt = Time.deltaTime;
				try
				{
					particle.transform.position = particle.transform.position + vel * dt;
				}
				catch
				{
					break;
				}
				vel = new Vector3(vel.x * 0.95f, vel.y + 1.5f * dt, vel.z * 0.95f);
				elapsed += dt;
				float t = elapsed / life;
				float s = size * (1f - t);
				if (s <= 0.001f)
				{
					break;
				}
				try
				{
					particle.transform.localScale = new Vector3(s, s * 1.8f, s);
					if ((Object)(object)r != (Object)null && (Object)(object)r.material != (Object)null)
					{
						Color c = ((t < 0.4f) ? Color.Lerp(BlueStart, BlueMid, t / 0.4f) : Color.Lerp(BlueMid, BlueDeep, (t - 0.4f) / 0.6f));
						c.a = (1f - t) * 0.85f;
						r.material.color = c;
					}
				}
				catch
				{
					break;
				}
				yield return null;
			}
			if ((Object)(object)particle != (Object)null)
			{
				Object.Destroy((Object)(object)particle);
			}
			if (_activeParticles > 0)
			{
				_activeParticles--;
			}
		}

		private void SpawnEmber(HandState hs)
		{
			//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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: 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_00e2: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)hs.hand == (Object)null || _activeParticles >= 250)
			{
				return;
			}
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)5);
			if (!((Object)(object)val == (Object)null))
			{
				_activeParticles++;
				Object.Destroy((Object)(object)val.GetComponent<Collider>());
				((Object)val).name = "BfEmber";
				val.transform.position = ((Component)hs.hand).transform.position + Random.insideUnitSphere * 0.1f;
				float num = Random.Range(0.012f, 0.028f);
				val.transform.localScale = new Vector3(num, num, num);
				Renderer component = val.GetComponent<Renderer>();
				if ((Object)(object)component != (Object)null)
				{
					Material val2 = new Material(GetAdditiveMaterial());
					val2.color = new Color(0.25f, 0.55f, 1f, 0.35f);
					component.material = val2;
					component.shadowCastingMode = (ShadowCastingMode)0;
					component.receiveShadows = false;
					component.sortingOrder = 151;
				}
				Vector3 vel = Vector3.up * Random.Range(0.8f, 1.8f);
				MelonCoroutines.Start(EmberRoutine(val, vel, 0.5f, num));
			}
		}

		private IEnumerator EmberRoutine(GameObject go, Vector3 vel, float life, float size)
		{
			//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)go == (Object)null)
			{
				if (_activeParticles > 0)
				{
					_activeParticles--;
				}
				yield break;
			}
			Renderer r = go.GetComponent<Renderer>();
			float e = 0f;
			while ((Object)(object)go != (Object)null && e < life)
			{
				float dt = Time.deltaTime;
				go.transform.position = go.transform.position + vel * dt;
				vel = new Vector3(vel.x * 0.97f, vel.y + 0.6f * dt, vel.z * 0.97f);
				e += dt;
				float t = e / life;
				float s = size * (1f - t * 0.7f);
				if (s <= 0.001f)
				{
					break;
				}
				go.transform.localScale = new Vector3(s, s, s);
				if ((Object)(object)r != (Object)null && (Object)(object)r.material != (Object)null)
				{
					Color c = BlueMid;
					c.a = (1f - t) * 0.6f;
					r.material.color = c;
				}
				yield return null;
			}
			if ((Object)(object)go != (Object)null)
			{
				Object.Destroy((Object)(object)go);
			}
			if (_activeParticles > 0)
			{
				_activeParticles--;
			}
		}

		private Shader GetFlameShader()
		{
			if ((Object)(object)_flameShader != (Object)null)
			{
				return _flameShader;
			}
			string[] array = new string[6] { "Universal Render Pipeline/Particles/Unlit", "Sprites/Default", "Unlit/Texture", "UI/Default", "Unlit/Color", "Standard" };
			for (int i = 0; i < array.Length; i++)
			{
				Shader val = Shader.Find(array[i]);
				if ((Object)(object)val != (Object)null)
				{
					_flameShader = val;
					((MelonBase)this).LoggerInstance.Msg("Shader(main) = " + array[i]);
					return val;
				}
			}
			_flameShader = Shader.Find("Standard");
			((MelonBase)this).LoggerInstance.Warning("Shader(main) fallback=Standard");
			return _flameShader;
		}

		private Material GetAdditiveMaterial()
		{
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_additiveMat != (Object)null)
			{
				return _additiveMat;
			}
			string[] array = new string[4] { "Legacy Shaders/Particles/Additive", "Mobile/Particles/Additive", "Universal Render Pipeline/Particles/Unlit", "Sprites/Default" };
			for (int i = 0; i < array.Length; i++)
			{
				Shader val = Shader.Find(array[i]);
				if (!((Object)(object)val == (Object)null))
				{
					Material val2 = new Material(val);
					if (val2.HasProperty("_Mode"))
					{
						val2.SetFloat("_Mode", 1f);
					}
					if (val2.HasProperty("_SrcBlend"))
					{
						val2.SetFloat("_SrcBlend", 1f);
					}
					if (val2.HasProperty("_DstBlend"))
					{
						val2.SetFloat("_DstBlend", 1f);
					}
					if (val2.HasProperty("_ZWrite"))
					{
						val2.SetFloat("_ZWrite", 0f);
					}
					val2.SetColor("_BaseColor", Color.white);
					val2.SetColor("_Color", Color.white);
					val2.renderQueue = 3050;
					_additiveMat = val2;
					((MelonBase)this).LoggerInstance.Msg("Shader(additive) = " + array[i]);
					return val2;
				}
			}
			_additiveMat = new Material(GetFlameShader());
			SetupTransparent(_additiveMat);
			((MelonBase)this).LoggerInstance.Warning("Additive shader not found, using main");
			return _additiveMat;
		}

		private void SetupTransparent(Material m)
		{
			if (!((Object)(object)m == (Object)null))
			{
				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);
				}
				m.renderQueue = 3000;
			}
		}

		private void PerformStrike(HandState hs)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)hs.hand).transform.position;
			_flashCount++;
			List<GameObject> list = FindBodyParts(position, 0.18f);
			SpawnBlackFlash(position);
			Mci.Play();
			int num = ApplyFlashDamage(position, hs.chargeAmount, list);
			_killHits += num;
			CleanupAura(hs);
			hs.state = StrikeState.Cooldown;
			MelonCoroutines.Start(ResetAfterCooldown(hs));
			((MelonBase)this).LoggerInstance.Msg("BLACK FLASH #" + _flashCount + " charge=" + hs.chargeAmount.ToString("F2") + " touched=" + list.Count + " victims=" + num);
		}

		private void SpawnBlackFlash(Vector3 pos)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: 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_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("BfFlashCore");
			val.transform.position = pos;
			Light val2 = val.AddComponent<Light>();
			val2.type = (LightType)2;
			val2.color = new Color(0.05f, 0.02f, 0.05f, 1f);
			val2.intensity = 0f;
			val2.range = 1.5f;
			val2.shadows = (LightShadows)0;
			GameObject val3 = new GameObject("BfFlashEdge");
			val3.transform.position = pos;
			Light val4 = val3.AddComponent<Light>();
			val4.type = (LightType)2;
			val4.color = new Color(1f, 0.05f, 0.06f, 1f);
			val4.intensity = 0f;
			val4.range = 2.2f;
			val4.shadows = (LightShadows)0;
			Vector3 val5;
			for (int i = 0; i < 18; i++)
			{
				float num = Random.value * 6.2832f;
				float value = Random.value;
				float num2 = Random.Range(-0.6f, 0.6f);
				val5 = new Vector3(Mathf.Cos(num) * value, num2, Mathf.Sin(num) * value);
				Vector3 normalized = ((Vector3)(ref val5)).normalized;
				MakeShard(pos + normalized * 0.06f, normalized * Random.Range(1.5f, 4f), Random.Range(0.18f, 0.38f), Random.Range(0.35f, 0.6f), new Color(0.03f, 0.03f, 0.04f, 0.95f), "BfBlack", stretch: false, additive: false);
			}
			for (int j = 0; j < 28; j++)
			{
				float num3 = Random.value * 6.2832f;
				float value2 = Random.value;
				float num4 = Random.Range(-0.5f, 0.9f);
				val5 = new Vector3(Mathf.Cos(num3) * value2, num4, Mathf.Sin(num3) * value2);
				Vector3 normalized2 = ((Vector3)(ref val5)).normalized;
				MakeShard(pos, normalized2 * Random.Range(3f, 9f), Random.Range(0.08f, 0.22f), Random.Range(0.3f, 0.55f), new Color(0.85f, 0.04f, 0.05f, 0.95f), "BfRed", stretch: true, additive: false);
			}
			MakeShard(pos, Vector3.zero, 0.35f, 0.55f, new Color(0.01f, 0.01f, 0.02f, 0.8f), "BfSphere", stretch: false, additive: false);
			MakeShard(pos, Vector3.zero, 0.5f, 0.35f, new Color(0.3f, 0.01f, 0.02f, 0.35f), "BfSphereGlow", stretch: true, additive: true);
			_flashFx.Add(val);
			_flashFx.Add(val3);
			MelonCoroutines.Start(FlashRoutine(val, val3, val2, val4));
		}

		private void MakeShard(Vector3 pos, Vector3 vel, float size, float life, Color col, string name, bool stretch, bool additive)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_006f: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_00c9: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)5);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Object.Destroy((Object)(object)val.GetComponent<Collider>());
			((Object)val).name = name;
			val.transform.position = pos;
			val.transform.localScale = (stretch ? new Vector3(size * 0.35f, size * 2.2f, size) : new Vector3(size, size, size));
			val.transform.rotation = Quaternion.LookRotation(-vel, Vector3.up);
			Renderer component = val.GetComponent<Renderer>();
			if ((Object)(object)component != (Object)null)
			{
				Material val2 = (additive ? GetAdditiveMaterial() : null);
				Material val3 = (((Object)(object)val2 != (Object)null) ? new Material(val2) : new Material(GetFlameShader()));
				if ((Object)(object)val2 == (Object)null)
				{
					SetupTransparent(val3);
				}
				val3.color = col;
				component.material = val3;
				component.shadowCastingMode = (ShadowCastingMode)0;
				component.receiveShadows = false;
				component.sortingOrder = (additive ? 230 : 220);
			}
			_activeParticles++;
			MelonCoroutines.Start(ShardRoutine(val, vel, life, size, stretch, name));
		}

		private IEnumerator ShardRoutine(GameObject go, Vector3 vel, float life, float size, bool stretch, string name)
		{
			//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)go == (Object)null)
			{
				if (_activeParticles > 0)
				{
					_activeParticles--;
				}
				yield break;
			}
			Renderer r = go.GetComponent<Renderer>();
			float e = 0f;
			while ((Object)(object)go != (Object)null && e < life)
			{
				float dt = Time.deltaTime;
				go.transform.position = go.transform.position + vel * dt;
				vel *= 0.95f;
				e += dt;
				float t = e / life;
				float s = size * (1f - t * 0.7f);
				if (s <= 0.001f)
				{
					break;
				}
				go.transform.localScale = (stretch ? new Vector3(s * 0.35f, s * 2.2f, s) : new Vector3(s, s, s));
				if ((Object)(object)r != (Object)null && (Object)(object)r.material != (Object)null)
				{
					Color c = r.material.color;
					c.a = (1f - t) * 0.9f;
					r.material.color = c;
				}
				yield return null;
			}
			if ((Object)(object)go != (Object)null)
			{
				Object.Destroy((Object)(object)go);
			}
			if (_activeParticles > 0)
			{
				_activeParticles--;
			}
		}

		private IEnumerator FlashRoutine(GameObject core, GameObject edge, Light coreR, Light edgeR)
		{
			float t = 0f;
			float dur = 0.6f;
			while (t < dur)
			{
				t += Time.deltaTime;
				float k = t / dur;
				if ((Object)(object)coreR != (Object)null)
				{
					coreR.intensity = 3.5f * (1f - k);
				}
				if ((Object)(object)edgeR != (Object)null)
				{
					edgeR.intensity = 5f * (1f - k);
				}
				yield return null;
			}
			if ((Object)(object)core != (Object)null)
			{
				Object.Destroy((Object)(object)core);
			}
			if ((Object)(object)edge != (Object)null)
			{
				Object.Destroy((Object)(object)edge);
			}
		}

		private int ApplyFlashDamage(Vector3 pos, float charge, List<GameObject> direct)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			HashSet<Component> seen = new HashSet<Component>();
			float num2 = 0.35f + charge * 0.65f;
			if (direct != null)
			{
				for (int i = 0; i < direct.Count; i++)
				{
					if (ApplyTo(direct[i], pos, 150f * num2, 140f * num2, seen))
					{
						num++;
					}
				}
			}
			List<GameObject> list = FindBodyParts(pos, 3.5f);
			for (int j = 0; j < list.Count; j++)
			{
				float num3 = Vector3.Distance(pos, list[j].transform.position);
				float num4 = Mathf.Clamp01(1f - num3 / 3.5f);
				if (!(num4 <= 0.01f) && ApplyTo(list[j], pos, 150f * num4 * num2, 140f * num4 * num2, seen))
				{
					num++;
				}
			}
			return num;
		}

		private bool ApplyTo(GameObject part, Vector3 from, float dmg, float force, HashSet<Component> seen)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_004e: 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_0057: 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_0063: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)part == (Object)null)
			{
				return false;
			}
			Component componentInParent = (Component)(object)part.GetComponentInParent<StickHealth>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				return false;
			}
			if (!seen.Add(componentInParent))
			{
				return false;
			}
			Vector3 position = componentInParent.transform.position;
			Vector3 val = position - from;
			Vector3 push = ((Vector3)(ref val)).normalized * force;
			ApplyDamageTo(componentInParent, position, dmg, push);
			return true;
		}

		private void ApplyDamageTo(Component sh, Vector3 hitPos, float dmg, Vector3 push)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)sh == (Object)null)
			{
				return;
			}
			Type type = ((object)sh).GetType();
			MethodInfo method = type.GetMethod("HitByBullet");
			if (method != null)
			{
				try
				{
					method.Invoke(sh, new object[3] { hitPos, dmg, false });
				}
				catch
				{
				}
			}
			MethodInfo method2 = type.GetMethod("ReceivedGeneralDamage");
			if (method2 != null)
			{
				try
				{
					Type nestedType = type.GetNestedType("DamageType");
					object obj2 = 1;
					if (nestedType != null && nestedType.IsEnum)
					{
						try
						{
							obj2 = Enum.Parse(nestedType, "Explosion");
						}
						catch
						{
							obj2 = Convert.ChangeType(1, nestedType);
						}
					}
					method2.Invoke(sh, new object[4]
					{
						dmg * 0.5f,
						obj2,
						"torso",
						null
					});
				}
				catch
				{
				}
			}
			Il2CppArrayBase<Rigidbody> componentsInChildren = sh.GetComponentsInChildren<Rigidbody>();
			if (componentsInChildren == null)
			{
				return;
			}
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Rigidbody val = componentsInChildren[i];
				if (!((Object)(object)val == (Object)null))
				{
					val.AddForce(push, (ForceMode)1);
				}
			}
		}

		private void ApplyDamage(GameObject go, Vector3 hitPos, float dmg, Vector3 push)
		{
			//IL_008b: 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)
			Component val = FindComponent(go, "StickHealth");
			if ((Object)(object)val == (Object)null && (Object)(object)go.transform.parent != (Object)null)
			{
				val = FindComponent(((Component)go.transform.parent).gameObject, "StickHealth");
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Type type = ((object)val).GetType();
			MethodInfo method = type.GetMethod("HitByBullet");
			if (method != null)
			{
				try
				{
					method.Invoke(val, new object[3] { hitPos, dmg, false });
				}
				catch
				{
				}
			}
			MethodInfo method2 = type.GetMethod("ReceivedGeneralDamage");
			if (method2 != null)
			{
				try
				{
					Type nestedType = type.GetNestedType("DamageType");
					object obj2 = 1;
					if (nestedType != null && nestedType.IsEnum)
					{
						try
						{
							obj2 = Enum.Parse(nestedType, "Explosion");
						}
						catch
						{
							obj2 = Convert.ChangeType(1, nestedType);
						}
					}
					method2.Invoke(val, new object[4]
					{
						dmg * 0.5f,
						obj2,
						"torso",
						null
					});
				}
				catch
				{
				}
			}
			Il2CppArrayBase<Rigidbody> componentsInChildren = go.GetComponentsInChildren<Rigidbody>();
			if (componentsInChildren == null)
			{
				return;
			}
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Rigidbody val2 = componentsInChildren[i];
				if (!((Object)(object)val2 == (Object)null))
				{
					val2.AddForce(push, (ForceMode)1);
				}
			}
		}

		private Component FindComponent(GameObject go, string typeName)
		{
			if ((Object)(object)go == (Object)null)
			{
				return null;
			}
			Il2CppArrayBase<Component> components = go.GetComponents<Component>();
			if (components == null)
			{
				return null;
			}
			for (int i = 0; i < components.Length; i++)
			{
				Component val = components[i];
				if (!((Object)(object)val == (Object)null) && ((object)val).GetType().Name == typeName)
				{
					return val;
				}
			}
			return null;
		}

		private void CleanupAura(HandState hs)
		{
			if ((Object)(object)hs.auraLightObj != (Object)null)
			{
				Object.Destroy((Object)(object)hs.auraLightObj);
				hs.auraLightObj = null;
				hs.auraLight = null;
			}
		}

		private void CleanupFlash()
		{
			for (int num = _flashFx.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)_flashFx[num] == (Object)null)
				{
					_flashFx.RemoveAt(num);
				}
			}
		}
	}
}