Decompiled source of TrueCurse v1.0.2

TrueCursedSounds.dll

Decompiled a week 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 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.Collections.Generic;
using Il2CppSystem.Reflection;
using MahitoAbilitiesMod;
using MelonLoader;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[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), "MahitoAbilitiesMod", "1.0.0", "YourName", null)]
[assembly: MelonGame("Kubunautilus", "BrutalistickVR")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("TrueCursedSounds")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TrueCursedSounds")]
[assembly: AssemblyTitle("TrueCursedSounds")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MahitoAbilitiesMod;

public class Core : MelonMod
{
	private enum WeaponType
	{
		None,
		Blade,
		Chainsaw,
		Hammer
	}

	private enum DeployState
	{
		Deploying,
		Deployed
	}

	private enum CursedPhase
	{
		Idle,
		Charging,
		Armed,
		Striking,
		Cooldown
	}

	private enum AbilityMode
	{
		None,
		Weapon,
		CursedEnergy
	}

	private class OutgrowthData
	{
		public GameObject ball;

		public float currentSize;

		public float targetSize;
	}

	private class LightningBranch
	{
		public GameObject obj;

		public LineRenderer coreLR;

		public LineRenderer edgeLR;

		public Vector3[] points;

		public int totalPoints;

		public List<GameObject> endOrbs = new List<GameObject>();

		public bool orbsSpawned = false;
	}

	private class HandState
	{
		public HVRHandGrabber grabber;

		public bool isLeft;

		public AbilityMode currentMode = AbilityMode.None;

		public WeaponType weaponType = WeaponType.None;

		public int weaponPhase = 0;

		public bool wasSecondaryWeapon;

		public bool wasTriggerWeapon;

		public GameObject weaponInstance;

		public Rigidbody weaponRb;

		public List<Collider> weaponColliders = new List<Collider>();

		public Vector3 currentPos;

		public Quaternion currentRot;

		public DeployState deployState;

		public float deployProgress;

		public ChainsawManager chainsawManager;

		public AudioSource idleAudio;

		public AudioSource revvedAudio;

		public AudioClip startSoundClip;

		public AudioClip stopSoundClip;

		public CursedPhase cursedPhase = CursedPhase.Idle;

		public float armedTimer = 0f;

		public bool wasTriggerCursed;

		public bool wasGripCursed;

		public bool wasSecondaryCursed;

		public bool wasComboActive;

		public GameObject auraLightObj;

		public Light auraLight;

		public float flameSpawnTimer;

		public float emberSpawnTimer;

		public float lightningTimer;

		public float flickerTime;

		public float lastBlackLightningTime = -100f;

		public bool isProcessingBlackLightning = false;

		public bool IsWeaponActive => currentMode == AbilityMode.Weapon && (Object)(object)weaponInstance != (Object)null;
	}

	private const float BLADE_LERP_SPEED = 50f;

	private const float BLADE_MAX_SPEED = 50f;

	private const float BLADE_MAX_ANGULAR_SPEED = 3600f;

	private const float BLADE_DEPLOY_DISTANCE = 0.5f;

	private const float BLADE_DEPLOY_DURATION = 0.1f;

	private const float HANDLE_CUT_THRESHOLD = 0.4f;

	private const float CHAINSAW_LERP_SPEED = 84f;

	private const float CHAINSAW_MAX_SPEED = 84f;

	private const float CHAINSAW_MAX_ANGULAR_SPEED = 5400f;

	private const float CHAINSAW_DEPLOY_DISTANCE = 0.4f;

	private const float CHAINSAW_DEPLOY_DURATION = 0.15f;

	private const float HAMMER_LERP_SPEED = 180f;

	private const float HAMMER_MAX_SPEED = 180f;

	private const float HAMMER_MAX_ANGULAR_SPEED = 7200f;

	private const float HAMMER_DEPLOY_DISTANCE = 0.3f;

	private const float HAMMER_DEPLOY_DURATION = 0.25f;

	private const float HAMMER_HANDLE_CUT_THRESHOLD = 0.87f;

	private const float CHAINSAW_IDLE_VOLUME = 1f;

	private const float CHAINSAW_REVVED_VOLUME = 0.5f;

	private const float CHAINSAW_START_VOLUME = 1f;

	private const float CHAINSAW_STOP_VOLUME = 1f;

	private static readonly Vector3 GRIP_OFFSET = new Vector3(0f, -0.05f, -0.6f);

	private static readonly Quaternion GRIP_ROT_RIGHT = Quaternion.Euler(90f, 0f, 0f);

	private static readonly Quaternion GRIP_ROT_LEFT = Quaternion.Euler(90f, 0f, 0f) * Quaternion.Euler(0f, 180f, 0f);

	private static readonly Vector3 CHAINSAW_OFFSET_RIGHT = new Vector3(0f, 0.06f, -0.03f);

	private static readonly Vector3 CHAINSAW_OFFSET_LEFT = new Vector3(0f, -0.14f, -0.03f);

	private static readonly Quaternion CHAINSAW_ROT_RIGHT = Quaternion.Euler(0f, 180f, 90f);

	private static readonly Quaternion CHAINSAW_ROT_LEFT = Quaternion.Euler(0f, 180f, -90f);

	private static readonly Vector3 HAMMER_OFFSET_RIGHT = new Vector3(0.03f, -0.04f, -0.77f);

	private static readonly Vector3 HAMMER_OFFSET_LEFT = new Vector3(-0.03f, -0.04f, -0.77f);

	private static readonly Quaternion HAMMER_ROT_RIGHT = Quaternion.Euler(90f, 0f, 0f);

	private static readonly Quaternion HAMMER_ROT_LEFT = Quaternion.Euler(90f, 0f, 0f) * Quaternion.Euler(0f, 180f, 0f);

	private const float ARMED_DURATION = 4f;

	private const float STRIKE_COOLDOWN = 0.6f;

	private const float MUTATION_DURATION = 2f;

	private const int BL_MAIN_BRANCHES = 14;

	private const float BL_MAIN_LENGTH_MIN = 3f;

	private const float BL_MAIN_LENGTH_MAX = 5f;

	private const float BL_MAIN_WIDTH_START = 0.1f;

	private const float BL_MAIN_WIDTH_END = 0.008f;

	private const float BL_GROW_END_TIME = 0.7f;

	private const float BL_COLLAPSE_START_TIME = 0.28f;

	private const float BL_TOTAL_DURATION = 0.98f;

	private const float BL_END_ORB_SIZE = 0.015f;

	private const int BL_CUBE_FRAGMENTS = 15;

	private const float BL_CUBE_LIFETIME = 0.5f;

	private const float BL_FORCE = 250f;

	private const float BL_STRIKE_RADIUS = 2f;

	private const float BL_COOLDOWN = 1.2f;

	private const int BL_MID_BRANCHES = 8;

	private const float BL_MID_LENGTH_MIN = 1.2f;

	private const float BL_MID_LENGTH_MAX = 2.5f;

	private const float BL_MID_WIDTH_START = 0.05f;

	private const float BL_MID_WIDTH_END = 0.004f;

	private const float BL_MID_SCATTER_MIN = 0.8f;

	private const float BL_MID_SCATTER_MAX = 2f;

	private const int BL_SMALL_BRANCHES = 12;

	private const float BL_SMALL_LENGTH_MIN = 0.5f;

	private const float BL_SMALL_LENGTH_MAX = 1.1f;

	private const float BL_SMALL_WIDTH_START = 0.025f;

	private const float BL_SMALL_WIDTH_END = 0.002f;

	private const float BL_SMALL_SCATTER_MIN = 2f;

	private const float BL_SMALL_SCATTER_MAX = 4f;

	private const float BL_SMALL_COLLAPSE_DELAY = 0.3f;

	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 FLAME_SIZE_SCALE = 1.2f;

	private const int MAX_PARTICLES = 250;

	private int activeParticles;

	private const float EMBER_SPAWN_INTERVAL_MIN = 0.08f;

	private const float EMBER_SPAWN_INTERVAL_MAX = 0.2f;

	private const float LIGHTNING_INTERVAL_MAX_CHARGE = 0.12f;

	private const float LIGHT_INTENSITY_MIN = 0.15f;

	private const float LIGHT_INTENSITY_MAX = 0.4f;

	private const float LIGHT_RANGE_MIN = 0.1f;

	private const float LIGHT_RANGE_MAX = 0.25f;

	private const float LAUNCH_FORCE = 10f;

	private const float LAUNCH_SEARCH_RADIUS = 1.5f;

	private const float DISMEMBER_DAMAGE = 120f;

	private const float TOUCH_DETECT_RADIUS = 0.15f;

	private const int OUTGROWTH_COUNT = 12;

	private const float OUTGROWTH_GROW_DURATION = 0.4f;

	private const string SOUND_FOLDER_NAME = "MahitoSounds";

	private const string TRANSFORMATION_FILE = "transformation.wav";

	private const string DETRANSFORMATION_FILE = "detransformation.wav";

	private const string CURSED_ENERGY_FILE = "Cursed_Energy.wav";

	private const string BLACK_FLASH_FILE = "Blach_Flash.wav";

	private const string MUTATION_FILE = "mutation.wav";

	private const float SOUND_MASTER_VOLUME = 1f;

	private const float TRANSFORMATION_VOLUME = 1f;

	private const float DETRANSFORMATION_VOLUME = 1f;

	private const float CURSED_ENERGY_VOLUME = 1f;

	private const float BLACK_FLASH_VOLUME = 1f;

	private const float MUTATION_VOLUME = 1f;

	private string transformationSoundPath;

	private string detransformationSoundPath;

	private string cursedEnergySoundPath;

	private string blackFlashSoundPath;

	private string mutationSoundPath;

	private const int SND_ASYNC = 1;

	private const int SND_NODEFAULT = 2;

	private const int SND_FILENAME = 131072;

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

	private static readonly Color AURA_LIGHT_COLOR = new Color(0.6f, 0.2f, 1f);

	private static readonly Color FLAME_START_COLOR = new Color(0.85f, 0.6f, 1f);

	private static readonly Color FLAME_MID_COLOR = new Color(0.55f, 0.1f, 0.95f);

	private static readonly Color FLAME_END_COLOR = new Color(0.25f, 0f, 0.55f);

	private static readonly Color EMBER_COLOR = new Color(0.75f, 0.45f, 1f, 0.9f);

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

	private static readonly Color LIGHTNING_END_COLOR = new Color(0.65f, 0.3f, 1f, 0f);

	private static readonly Color BL_CORE_COLOR = new Color(0.08f, 0.02f, 0.12f, 1f);

	private static readonly Color BL_EDGE_COLOR = new Color(1f, 0.08f, 0.05f, 0.9f);

	private static readonly Color BL_INNER_GLOW = new Color(0.4f, 0f, 0.6f, 1f);

	private static readonly Color BL_ORB_COLOR = new Color(0.15f, 0f, 0.2f, 1f);

	private static readonly Color BL_CUBE_COLOR = new Color(0.05f, 0.01f, 0.08f, 1f);

	private HVRHexaBodyInputs playerInputs;

	private HandState leftHand = new HandState
	{
		isLeft = true
	};

	private HandState rightHand = new HandState
	{
		isLeft = false
	};

	private GameObject katanaPrefab;

	private GameObject chainsawPrefab;

	private GameObject hammerPrefab;

	private float searchTimer = 0f;

	private const float SEARCH_INTERVAL = 2f;

	private GameObject savedBloodPrefab;

	private GameObject savedFleshPrefab;

	private bool bloodSaved = false;

	private Material greyMaterial;

	private Shader cachedFlameShader;

	private bool isProcessingFracture = false;

	private static readonly HashSet<string> LIMB_NAMES = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
	{
		"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"
	};

	private static readonly HashSet<string> LIMB_BLACKLIST = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Eyeball_R", "Eyeball_L", "Eye_R", "Eye_L" };

	private static readonly string[] AUTO_GRAB_KEYWORDS = new string[6] { "Elbow", "Shoulder", "Knee", "Hip", "Foot", "Jaw" };

	private static readonly HashSet<string> UPPER_BODY_NAMES = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Head", "Jaw", "Neck", "UpperChest", "MiddleChest", "Shoulder_L", "Shoulder_R", "Elbow_L", "Elbow_R" };

	private static readonly HashSet<string> TINY_PARTS = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Neck", "Jaw", "Foot_R", "Foot_L" };

	private static readonly HashSet<string> THIN_PARTS = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Shoulder_R", "Shoulder_L", "Elbow_R", "Elbow_L", "Hip_R", "Hip_L", "Knee_R", "Knee_L" };

	private static readonly HashSet<string> MEDIUM_PARTS = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Head" };

	private static readonly HashSet<string> WIDE_PARTS = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "UpperChest", "MiddleChest", "Pelvis" };

	[DllImport("winmm.dll", SetLastError = true)]
	private static extern bool PlaySound(string szSound, IntPtr hMod, int fFlags);

	[DllImport("winmm.dll", SetLastError = true)]
	private static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);

	public override void OnInitializeMelon()
	{
		((MelonBase)this).LoggerInstance.Msg("MahitoAbilitiesMod v1.0.0 — объединённые способности Махито.");
		InitSounds();
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		DestroyWeapon(leftHand);
		DestroyWeapon(rightHand);
		ResetCursedHand(leftHand);
		ResetCursedHand(rightHand);
		playerInputs = null;
		katanaPrefab = null;
		chainsawPrefab = null;
		hammerPrefab = null;
		searchTimer = 1f;
		greyMaterial = null;
		cachedFlameShader = null;
		isProcessingFracture = false;
		leftHand = new HandState
		{
			isLeft = true
		};
		rightHand = new HandState
		{
			isLeft = false
		};
		if (!(sceneName == "MainMenuScene"))
		{
			GameObject val = GameObject.Find("Hexa4Rig26.10.23");
			if (!((Object)(object)val == (Object)null))
			{
				playerInputs = val.GetComponentInChildren<HVRHexaBodyInputs>();
				HandState handState = leftHand;
				Transform obj = val.transform.Find("Physics LeftHand");
				handState.grabber = ((obj != null) ? ((Component)obj).GetComponent<HVRHandGrabber>() : null);
				HandState handState2 = rightHand;
				Transform obj2 = val.transform.Find("Physics RightHand");
				handState2.grabber = ((obj2 != null) ? ((Component)obj2).GetComponent<HVRHandGrabber>() : null);
			}
		}
	}

	public override void OnUpdate()
	{
		if ((Object)(object)playerInputs == (Object)null)
		{
			return;
		}
		searchTimer -= Time.deltaTime;
		if (searchTimer <= 0f)
		{
			searchTimer = 2f;
			if ((Object)(object)katanaPrefab == (Object)null)
			{
				FindKatanaPrefab();
			}
			if ((Object)(object)chainsawPrefab == (Object)null)
			{
				FindChainsawPrefab();
			}
			if ((Object)(object)hammerPrefab == (Object)null)
			{
				FindHammerPrefab();
			}
			if (!bloodSaved)
			{
				SaveBloodPrefabs();
			}
			if ((Object)(object)greyMaterial == (Object)null)
			{
				FindGreyMaterial();
			}
		}
		HVRController leftController = playerInputs.LeftController;
		HVRController rightController = playerInputs.RightController;
		if (!((Object)(object)leftController == (Object)null) && !((Object)(object)rightController == (Object)null))
		{
			ProcessHand(leftHand, leftController);
			ProcessHand(rightHand, rightController);
		}
	}

	public override void OnFixedUpdate()
	{
		if (leftHand.currentMode == AbilityMode.Weapon)
		{
			UpdateWeaponPosition(leftHand);
		}
		if (rightHand.currentMode == AbilityMode.Weapon)
		{
			UpdateWeaponPosition(rightHand);
		}
	}

	private void ProcessHand(HandState hs, HVRController ctrl)
	{
		//IL_0025: 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_003d: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)hs.grabber == (Object)null || (Object)(object)ctrl == (Object)null)
		{
			return;
		}
		bool active = ctrl.TriggerButtonState.Active;
		bool active2 = ctrl.GripButtonState.Active;
		bool active3 = ctrl.SecondaryButtonState.Active;
		bool flag = active && active2 && active3;
		bool flag2 = active3 && !hs.wasSecondaryWeapon;
		bool flag3 = flag && !hs.wasComboActive;
		switch (hs.currentMode)
		{
		case AbilityMode.None:
			if (flag2 && !((HVRGrabberBase)hs.grabber).IsGrabbing && !active2)
			{
				ActivateWeapon(hs);
			}
			else if (flag3)
			{
				ActivateCursedEnergy(hs);
			}
			break;
		case AbilityMode.Weapon:
			ProcessWeapon(hs, active, active2, active3);
			break;
		case AbilityMode.CursedEnergy:
			ProcessCursedEnergy(hs, active, active2, active3, flag);
			break;
		}
		hs.wasSecondaryWeapon = active3;
		hs.wasTriggerWeapon = active;
		hs.wasGripCursed = active2;
		hs.wasSecondaryCursed = active3;
		hs.wasComboActive = flag;
	}

	private void ActivateWeapon(HandState hs)
	{
		if (hs.currentMode != AbilityMode.CursedEnergy)
		{
			switch (hs.weaponPhase = (hs.weaponPhase + 1) % 6)
			{
			case 1:
				SpawnBlade(hs);
				break;
			case 2:
				DestroyWeapon(hs);
				break;
			case 3:
				SpawnChainsaw(hs);
				break;
			case 4:
				DestroyWeapon(hs);
				break;
			case 5:
				SpawnHammer(hs);
				break;
			case 0:
				DestroyWeapon(hs);
				break;
			}
		}
	}

	private void ActivateCursedEnergy(HandState hs)
	{
		if (hs.currentMode != AbilityMode.Weapon)
		{
			hs.cursedPhase = CursedPhase.Charging;
			CreateAuraLight(hs);
			hs.currentMode = AbilityMode.CursedEnergy;
			PlayWav(cursedEnergySoundPath, 1f);
		}
	}

	private void DeactivateWeapon(HandState hs)
	{
		DestroyWeapon(hs);
		hs.currentMode = AbilityMode.None;
		hs.weaponPhase = 0;
	}

	private void DeactivateCursedEnergy(HandState hs)
	{
		ResetCursedHand(hs);
		hs.currentMode = AbilityMode.None;
	}

	private void ProcessWeapon(HandState hs, bool trigger, bool grip, bool secondary)
	{
		if (hs.weaponType == WeaponType.Chainsaw && (Object)(object)hs.chainsawManager != (Object)null && hs.IsWeaponActive)
		{
			bool flag = trigger && !hs.wasTriggerWeapon;
			bool flag2 = !trigger && hs.wasTriggerWeapon;
			if (flag)
			{
				try
				{
					hs.chainsawManager.isRevved = true;
				}
				catch
				{
				}
				if ((Object)(object)hs.revvedAudio != (Object)null)
				{
					if (!hs.revvedAudio.isPlaying)
					{
						try
						{
							hs.revvedAudio.Play();
						}
						catch
						{
						}
					}
					hs.revvedAudio.volume = 0.5f;
				}
				if ((Object)(object)hs.idleAudio != (Object)null)
				{
					hs.idleAudio.volume = 0f;
				}
			}
			else if (flag2)
			{
				try
				{
					hs.chainsawManager.isRevved = false;
				}
				catch
				{
				}
				if ((Object)(object)hs.idleAudio != (Object)null)
				{
					if (!hs.idleAudio.isPlaying)
					{
						try
						{
							hs.idleAudio.Play();
						}
						catch
						{
						}
					}
					hs.idleAudio.volume = 1f;
				}
				if ((Object)(object)hs.revvedAudio != (Object)null)
				{
					hs.revvedAudio.volume = 0f;
				}
			}
		}
		if (secondary && !hs.wasSecondaryWeapon && !((HVRGrabberBase)hs.grabber).IsGrabbing && !grip)
		{
			switch (hs.weaponPhase = (hs.weaponPhase + 1) % 6)
			{
			case 1:
				SpawnBlade(hs);
				break;
			case 2:
				DestroyWeapon(hs);
				break;
			case 3:
				SpawnChainsaw(hs);
				break;
			case 4:
				DestroyWeapon(hs);
				break;
			case 5:
				SpawnHammer(hs);
				break;
			case 0:
				DestroyWeapon(hs);
				break;
			}
		}
	}

	private void ProcessCursedEnergy(HandState hs, bool trigger, bool grip, bool secondary, bool comboActive)
	{
		bool flag = grip && trigger;
		bool flag2 = !grip && !trigger;
		switch (hs.cursedPhase)
		{
		case CursedPhase.Charging:
			if (comboActive)
			{
				UpdateAura(hs);
				UpdateAuraSpawns(hs);
				if (!(!isProcessingFracture && !hs.isProcessingBlackLightning && flag))
				{
					break;
				}
				float num2 = Time.time - hs.lastBlackLightningTime;
				if (num2 >= 1.2f)
				{
					HVRGrabbable val3 = FindTouchedLimb(hs.grabber);
					if ((Object)(object)val3 != (Object)null)
					{
						hs.lastBlackLightningTime = Time.time;
						hs.isProcessingBlackLightning = true;
						MelonCoroutines.Start(PerformBlackLightningV9(((Component)val3).gameObject, hs.grabber, hs));
					}
				}
			}
			else
			{
				hs.cursedPhase = CursedPhase.Armed;
				hs.armedTimer = 4f;
			}
			break;
		case CursedPhase.Armed:
			hs.armedTimer -= Time.deltaTime;
			UpdateAura(hs);
			UpdateAuraSpawns(hs);
			if (comboActive && !hs.wasComboActive)
			{
				hs.cursedPhase = CursedPhase.Charging;
				PlayWav(cursedEnergySoundPath, 1f);
				break;
			}
			if (!isProcessingFracture)
			{
				if (flag2)
				{
					HVRGrabbable val = FindTouchedLimb(hs.grabber);
					if ((Object)(object)val != (Object)null)
					{
						MelonCoroutines.Start(PerformCursedTear(val, hs.grabber, hs));
						break;
					}
				}
				if (!hs.isProcessingBlackLightning && flag)
				{
					float num = Time.time - hs.lastBlackLightningTime;
					if (num >= 1.2f)
					{
						HVRGrabbable val2 = FindTouchedLimb(hs.grabber);
						if ((Object)(object)val2 != (Object)null)
						{
							hs.lastBlackLightningTime = Time.time;
							hs.isProcessingBlackLightning = true;
							MelonCoroutines.Start(PerformBlackLightningV9(((Component)val2).gameObject, hs.grabber, hs));
							break;
						}
					}
				}
			}
			if (hs.armedTimer <= 0f)
			{
				CleanupAura(hs);
				hs.cursedPhase = CursedPhase.Cooldown;
				MelonCoroutines.Start(ResetCursedAfterCooldown(hs));
			}
			break;
		case CursedPhase.Striking:
		case CursedPhase.Cooldown:
			break;
		}
	}

	private IEnumerator ResetCursedAfterCooldown(HandState hs)
	{
		yield return (object)new WaitForSeconds(0.6f);
		hs.cursedPhase = CursedPhase.Idle;
		DeactivateCursedEnergy(hs);
	}

	private void FindKatanaPrefab()
	{
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Il2CppArrayBase<GameObject> val = Resources.FindObjectsOfTypeAll<GameObject>();
			if (val == null)
			{
				return;
			}
			GameObject val2 = null;
			GameObject val3 = null;
			foreach (GameObject item in val)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				string name = ((Object)item).name;
				if (!name.StartsWith("Katana3") || name.Contains("SpawnableItemInfo"))
				{
					continue;
				}
				string value = "";
				try
				{
					Scene scene = item.scene;
					value = ((Scene)(ref scene)).name ?? "";
				}
				catch
				{
				}
				SharpWeaponManager component = item.GetComponent<SharpWeaponManager>();
				if ((Object)(object)component == (Object)null)
				{
					continue;
				}
				Rigidbody component2 = item.GetComponent<Rigidbody>();
				if (!((Object)(object)component2 == (Object)null))
				{
					if (string.IsNullOrEmpty(value))
					{
						val2 = item;
						break;
					}
					if ((Object)(object)val3 == (Object)null && !IsChildOfShopStand(item.transform))
					{
						val3 = item;
					}
				}
			}
			if ((Object)(object)val2 != (Object)null)
			{
				katanaPrefab = val2;
			}
			else if ((Object)(object)val3 != (Object)null)
			{
				katanaPrefab = val3;
			}
		}
		catch
		{
		}
	}

	private void FindChainsawPrefab()
	{
		//IL_007f: 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)
		try
		{
			Il2CppArrayBase<GameObject> val = Resources.FindObjectsOfTypeAll<GameObject>();
			if (val == null)
			{
				return;
			}
			GameObject val2 = null;
			GameObject val3 = null;
			foreach (GameObject item in val)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				string name = ((Object)item).name;
				if (name != "Chainsaw" && name != "Chainsaw(Clone)")
				{
					continue;
				}
				string value = "";
				try
				{
					Scene scene = item.scene;
					value = ((Scene)(ref scene)).name ?? "";
				}
				catch
				{
				}
				string text = (((Object)(object)item.transform.parent != (Object)null) ? ((Object)item.transform.parent).name : "ROOT");
				string text2 = (((Object)(object)item.transform.root != (Object)null) ? ((Object)item.transform.root).name : "?");
				ChainsawManager component = item.GetComponent<ChainsawManager>();
				if (!((Object)(object)component == (Object)null) && !IsChildOfShopStand(item.transform) && !text.Contains("Variant") && !text.Contains("itemTab"))
				{
					if (string.IsNullOrEmpty(value) && text == "ROOT")
					{
						val2 = item;
						break;
					}
					if ((Object)(object)val3 == (Object)null && text == "ROOT" && text2 == name)
					{
						val3 = item;
					}
				}
			}
			if ((Object)(object)val2 != (Object)null)
			{
				chainsawPrefab = val2;
			}
			else if ((Object)(object)val3 != (Object)null)
			{
				chainsawPrefab = val3;
			}
		}
		catch
		{
		}
	}

	private void FindHammerPrefab()
	{
		//IL_0064: 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)
		try
		{
			Il2CppArrayBase<GameObject> val = Resources.FindObjectsOfTypeAll<GameObject>();
			if (val == null)
			{
				return;
			}
			foreach (GameObject item in val)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				string name = ((Object)item).name;
				if (name != "Warhammer")
				{
					continue;
				}
				string value = "";
				try
				{
					Scene scene = item.scene;
					value = ((Scene)(ref scene)).name ?? "";
				}
				catch
				{
				}
				string text = (((Object)(object)item.transform.parent != (Object)null) ? ((Object)item.transform.parent).name : "ROOT");
				BluntForceManager component = item.GetComponent<BluntForceManager>();
				if (!((Object)(object)component == (Object)null))
				{
					Rigidbody component2 = item.GetComponent<Rigidbody>();
					if (!((Object)(object)component2 == (Object)null) && string.IsNullOrEmpty(value) && text == "ROOT")
					{
						hammerPrefab = item;
						break;
					}
				}
			}
		}
		catch
		{
		}
	}

	private bool IsChildOfShopStand(Transform t)
	{
		Transform val = t;
		int num = 0;
		while ((Object)(object)val != (Object)null && num < 20)
		{
			string name = ((Object)val).name;
			if (name.Contains("ShopStand") || name.Contains("WallSocket") || name.Contains("WeaponWall") || name.Contains("MeleeWall") || name.Contains("itemTab") || name.Contains("modItemTab"))
			{
				return true;
			}
			val = val.parent;
			num++;
		}
		return false;
	}

	private void SpawnBlade(HandState hs)
	{
		//IL_0086: 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_01e6: 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_01f6: 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_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: 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_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: 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_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0283: 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_029a: Unknown result type (might be due to invalid IL or missing references)
		//IL_029c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a2: 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_02d0: 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)
		if ((Object)(object)katanaPrefab == (Object)null)
		{
			FindKatanaPrefab();
			if ((Object)(object)katanaPrefab == (Object)null)
			{
				return;
			}
		}
		GameObject val = Object.Instantiate<GameObject>(katanaPrefab);
		((Object)val).name = "MahitoBlade_" + (hs.isLeft ? "L" : "R");
		val.transform.SetParent((Transform)null);
		val.transform.localScale = new Vector3(1f, 1f, 1f);
		DestroyComponentByName(val, "HVRTagSocketable");
		DestroyComponentByName(val, "HVRStringSocketable");
		DisableComponentByName(val, "HVRGrabbable");
		DisableComponentByName(val, "HVRGrabbableImpactHaptics");
		CutHandleOffMesh(val);
		DisableHandleColliders(val);
		Rigidbody val2 = val.GetComponent<Rigidbody>();
		if ((Object)(object)val2 == (Object)null)
		{
			val2 = val.AddComponent<Rigidbody>();
		}
		val2.isKinematic = true;
		val2.useGravity = false;
		val2.detectCollisions = true;
		val2.interpolation = (RigidbodyInterpolation)1;
		val2.mass = 1.5f;
		val2.collisionDetectionMode = (CollisionDetectionMode)3;
		hs.weaponRb = val2;
		hs.weaponColliders.Clear();
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit(val.GetComponentsInChildren<Collider>(true));
		if (array != null)
		{
			Collider[] array2 = array;
			foreach (Collider val3 in array2)
			{
				if (!((Object)(object)val3 == (Object)null) && val3.enabled)
				{
					hs.weaponColliders.Add(val3);
				}
			}
		}
		SharpWeaponManager component = val.GetComponent<SharpWeaponManager>();
		if ((Object)(object)component != (Object)null)
		{
			((Behaviour)component).enabled = true;
		}
		DisableCollisionWithPlayer(hs);
		hs.deployState = DeployState.Deploying;
		hs.deployProgress = 0f;
		Transform transform = ((Component)hs.grabber).transform;
		Quaternion val4 = (hs.isLeft ? GRIP_ROT_LEFT : GRIP_ROT_RIGHT);
		Vector3 val5 = -transform.forward * 0.5f;
		Vector3 val6 = transform.position + transform.right * GRIP_OFFSET.x + transform.up * GRIP_OFFSET.y + transform.forward * GRIP_OFFSET.z + val5;
		Quaternion val7 = transform.rotation * val4;
		val.transform.position = val6;
		val.transform.rotation = val7;
		hs.currentPos = val6;
		hs.currentRot = val7;
		val.SetActive(true);
		hs.weaponInstance = val;
		hs.weaponType = WeaponType.Blade;
		hs.wasTriggerWeapon = false;
		hs.currentMode = AbilityMode.Weapon;
		SpawnMutationParticles(transform.position, transform.rotation);
		PlayWav(transformationSoundPath, 1f);
	}

	private void SpawnChainsaw(HandState hs)
	{
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_050a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0696: Unknown result type (might be due to invalid IL or missing references)
		//IL_068f: Unknown result type (might be due to invalid IL or missing references)
		//IL_069b: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0704: Unknown result type (might be due to invalid IL or missing references)
		//IL_0709: Unknown result type (might be due to invalid IL or missing references)
		//IL_0710: Unknown result type (might be due to invalid IL or missing references)
		//IL_0715: Unknown result type (might be due to invalid IL or missing references)
		//IL_071a: Unknown result type (might be due to invalid IL or missing references)
		//IL_071e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0723: Unknown result type (might be due to invalid IL or missing references)
		//IL_0725: Unknown result type (might be due to invalid IL or missing references)
		//IL_072a: Unknown result type (might be due to invalid IL or missing references)
		//IL_072c: Unknown result type (might be due to invalid IL or missing references)
		//IL_072e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0730: Unknown result type (might be due to invalid IL or missing references)
		//IL_0735: Unknown result type (might be due to invalid IL or missing references)
		//IL_0737: Unknown result type (might be due to invalid IL or missing references)
		//IL_0739: Unknown result type (might be due to invalid IL or missing references)
		//IL_0741: Unknown result type (might be due to invalid IL or missing references)
		//IL_074f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0758: Unknown result type (might be due to invalid IL or missing references)
		//IL_075a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0760: Unknown result type (might be due to invalid IL or missing references)
		//IL_0762: Unknown result type (might be due to invalid IL or missing references)
		//IL_078e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0795: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)chainsawPrefab == (Object)null)
		{
			FindChainsawPrefab();
			if ((Object)(object)chainsawPrefab == (Object)null)
			{
				((MelonBase)this).LoggerInstance.Warning("MahitoAbilitiesMod: бензопила не найдена!");
				return;
			}
		}
		GameObject val;
		try
		{
			val = Object.Instantiate<GameObject>(chainsawPrefab);
		}
		catch (Exception ex)
		{
			((MelonBase)this).LoggerInstance.Msg("MahitoAbilitiesMod: ошибка Instantiate бензопилы: " + ex.Message);
			return;
		}
		((Object)val).name = "MahitoChainsaw_" + (hs.isLeft ? "L" : "R");
		val.transform.SetParent((Transform)null);
		val.transform.localScale = new Vector3(1f, 1f, 1f);
		DestroyComponentByName(val, "HVRTagSocketable");
		DestroyComponentByName(val, "HVRStringSocketable");
		DisableComponentByName(val, "HVRGrabbable");
		DisableComponentByName(val, "HVRGrabbableImpactHaptics");
		DisableComponentByName(val, "StabilizerGrabbable");
		DisableComponentByName(val, "ImpactObjectRigidbody");
		DisableComponentByName(val, "ImpactCollisionTrigger3D");
		DisableComponentByName(val, "ImpactSlideAndRollTrigger3D");
		ChainsawManager component = val.GetComponent<ChainsawManager>();
		if ((Object)(object)component == (Object)null)
		{
			((MelonBase)this).LoggerInstance.Warning("MahitoAbilitiesMod: ChainsawManager не найден!");
			Object.Destroy((Object)(object)val);
			return;
		}
		try
		{
			ParticleSystem smokeParticleSystem = component.smokeParticleSystem;
			if ((Object)(object)smokeParticleSystem != (Object)null)
			{
				try
				{
					smokeParticleSystem.Stop(true, (ParticleSystemStopBehavior)0);
					((Component)smokeParticleSystem).gameObject.SetActive(false);
				}
				catch
				{
				}
			}
		}
		catch
		{
		}
		Il2CppArrayBase<ParticleSystem> componentsInChildren = val.GetComponentsInChildren<ParticleSystem>(true);
		if (componentsInChildren != null)
		{
			foreach (ParticleSystem item in componentsInChildren)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				string text = ((Object)((Component)item).gameObject).name.ToLower();
				if (text.Contains("smoke"))
				{
					try
					{
						item.Stop(true, (ParticleSystemStopBehavior)0);
						((Component)item).gameObject.SetActive(false);
					}
					catch
					{
					}
				}
			}
		}
		hs.chainsawManager = component;
		try
		{
			component.StartChainsaw();
		}
		catch (Exception ex2)
		{
			((MelonBase)this).LoggerInstance.Msg("MahitoAbilitiesMod: ошибка StartChainsaw: " + ex2.Message);
			try
			{
				component.isRunning = true;
			}
			catch
			{
			}
		}
		Rigidbody val2 = val.GetComponent<Rigidbody>();
		if ((Object)(object)val2 == (Object)null)
		{
			val2 = val.AddComponent<Rigidbody>();
		}
		val2.isKinematic = true;
		val2.useGravity = false;
		val2.detectCollisions = true;
		val2.interpolation = (RigidbodyInterpolation)1;
		val2.mass = 1.5f;
		val2.collisionDetectionMode = (CollisionDetectionMode)3;
		hs.weaponRb = val2;
		hs.startSoundClip = component.chainsawStartSound;
		hs.stopSoundClip = component.chainsawStopSound;
		AudioClip chainsawIdle = component.chainsawIdle;
		AudioClip chainsawRevved = component.chainsawRevved;
		Il2CppArrayBase<AudioSource> components = val.GetComponents<AudioSource>();
		if (components != null)
		{
			foreach (AudioSource item2 in components)
			{
				if ((Object)(object)item2 != (Object)null)
				{
					try
					{
						item2.Stop();
					}
					catch
					{
					}
					try
					{
						((Behaviour)item2).enabled = false;
					}
					catch
					{
					}
				}
			}
		}
		if ((Object)(object)chainsawIdle != (Object)null)
		{
			hs.idleAudio = val.AddComponent<AudioSource>();
			hs.idleAudio.clip = chainsawIdle;
			hs.idleAudio.loop = true;
			hs.idleAudio.playOnAwake = false;
			hs.idleAudio.spatialBlend = 0.8f;
			hs.idleAudio.minDistance = 0.3f;
			hs.idleAudio.maxDistance = 20f;
			hs.idleAudio.rolloffMode = (AudioRolloffMode)1;
			hs.idleAudio.volume = 1f;
			hs.idleAudio.pitch = 1f;
			try
			{
				hs.idleAudio.Play();
			}
			catch
			{
			}
		}
		if ((Object)(object)chainsawRevved != (Object)null)
		{
			hs.revvedAudio = val.AddComponent<AudioSource>();
			hs.revvedAudio.clip = chainsawRevved;
			hs.revvedAudio.loop = true;
			hs.revvedAudio.playOnAwake = false;
			hs.revvedAudio.spatialBlend = 0.8f;
			hs.revvedAudio.minDistance = 0.3f;
			hs.revvedAudio.maxDistance = 20f;
			hs.revvedAudio.rolloffMode = (AudioRolloffMode)1;
			hs.revvedAudio.volume = 0f;
			hs.revvedAudio.pitch = 1f;
		}
		if ((Object)(object)hs.startSoundClip != (Object)null)
		{
			try
			{
				AudioSource.PlayClipAtPoint(hs.startSoundClip, val.transform.position, 1f);
			}
			catch
			{
			}
		}
		hs.weaponColliders.Clear();
		int num = 0;
		int num2 = 0;
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit(val.GetComponentsInChildren<Collider>(true));
		if (array != null)
		{
			Collider[] array2 = array;
			foreach (Collider val3 in array2)
			{
				if ((Object)(object)val3 == (Object)null)
				{
					continue;
				}
				if (IsCuttingPart(((Component)val3).transform))
				{
					if (val3.enabled)
					{
						hs.weaponColliders.Add(val3);
						num++;
					}
				}
				else
				{
					try
					{
						val3.enabled = false;
						num2++;
					}
					catch
					{
					}
				}
			}
		}
		int num3 = 0;
		Il2CppArrayBase<MeshRenderer> componentsInChildren2 = val.GetComponentsInChildren<MeshRenderer>(true);
		if (componentsInChildren2 != null)
		{
			foreach (MeshRenderer item3 in componentsInChildren2)
			{
				if (!((Object)(object)item3 == (Object)null) && !IsCuttingPart(((Component)item3).transform))
				{
					try
					{
						((Renderer)item3).enabled = false;
						num3++;
					}
					catch
					{
					}
				}
			}
		}
		DisableCollisionWithPlayer(hs);
		hs.deployState = DeployState.Deploying;
		hs.deployProgress = 0f;
		Transform transform = ((Component)hs.grabber).transform;
		Quaternion val4 = (hs.isLeft ? CHAINSAW_ROT_LEFT : CHAINSAW_ROT_RIGHT);
		Vector3 val5 = (hs.isLeft ? CHAINSAW_OFFSET_LEFT : CHAINSAW_OFFSET_RIGHT);
		Vector3 val6 = -transform.forward * 0.4f;
		Vector3 val7 = transform.position + transform.right * val5.x + transform.up * val5.y + transform.forward * val5.z;
		Quaternion val8 = transform.rotation * val4;
		Vector3 val9 = val7 + val6;
		Quaternion val10 = val8;
		val.transform.position = val9;
		val.transform.rotation = val10;
		hs.currentPos = val9;
		hs.currentRot = val10;
		val.SetActive(true);
		hs.weaponInstance = val;
		hs.weaponType = WeaponType.Chainsaw;
		hs.wasTriggerWeapon = false;
		hs.currentMode = AbilityMode.Weapon;
		SpawnMutationParticles(transform.position, transform.rotation);
		PlayWav(transformationSoundPath, 1f);
	}

	private void SpawnHammer(HandState hs)
	{
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: 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)
		//IL_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0294: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: 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_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c1: 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)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f3: 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_02fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0300: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: 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_0309: Unknown result type (might be due to invalid IL or missing references)
		//IL_0311: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0328: Unknown result type (might be due to invalid IL or missing references)
		//IL_032a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_035e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0365: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)hammerPrefab == (Object)null)
		{
			FindHammerPrefab();
			if ((Object)(object)hammerPrefab == (Object)null)
			{
				((MelonBase)this).LoggerInstance.Warning("MahitoAbilitiesMod: Warhammer префаб не найден!");
				return;
			}
		}
		GameObject val;
		try
		{
			val = Object.Instantiate<GameObject>(hammerPrefab);
		}
		catch (Exception ex)
		{
			((MelonBase)this).LoggerInstance.Msg("MahitoAbilitiesMod: ошибка Instantiate молота: " + ex.Message);
			return;
		}
		((Object)val).name = "MahitoHammer_" + (hs.isLeft ? "L" : "R");
		val.transform.SetParent((Transform)null);
		val.transform.localScale = new Vector3(1f, 1f, 1f);
		DestroyComponentByName(val, "HVRTagSocketable");
		DestroyComponentByName(val, "HVRStringSocketable");
		DisableComponentByName(val, "HVRGrabbable");
		DisableComponentByName(val, "HVRGrabbableImpactHaptics");
		DisableComponentByName(val, "ImpactSlideAndRollTrigger3D");
		CutHammerHandleMesh(val);
		Rigidbody val2 = val.GetComponent<Rigidbody>();
		if ((Object)(object)val2 == (Object)null)
		{
			val2 = val.AddComponent<Rigidbody>();
		}
		val2.isKinematic = true;
		val2.useGravity = false;
		val2.detectCollisions = true;
		val2.interpolation = (RigidbodyInterpolation)1;
		val2.mass = 15f;
		val2.collisionDetectionMode = (CollisionDetectionMode)3;
		hs.weaponRb = val2;
		hs.weaponColliders.Clear();
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit(val.GetComponentsInChildren<Collider>(true));
		int num = 0;
		int num2 = 0;
		if (array != null)
		{
			Collider[] array2 = array;
			foreach (Collider val3 in array2)
			{
				if ((Object)(object)val3 == (Object)null)
				{
					continue;
				}
				string text = ((Object)((Component)val3).gameObject).name.ToLower();
				if (text.Contains("handle"))
				{
					try
					{
						val3.enabled = false;
						num2++;
					}
					catch
					{
					}
				}
				else if (val3.enabled)
				{
					hs.weaponColliders.Add(val3);
					num++;
				}
			}
		}
		DisableCollisionWithPlayer(hs);
		hs.deployState = DeployState.Deploying;
		hs.deployProgress = 0f;
		Transform transform = ((Component)hs.grabber).transform;
		Quaternion val4 = (hs.isLeft ? HAMMER_ROT_LEFT : HAMMER_ROT_RIGHT);
		Vector3 val5 = (hs.isLeft ? HAMMER_OFFSET_LEFT : HAMMER_OFFSET_RIGHT);
		Vector3 val6 = -transform.forward * 0.3f;
		Vector3 val7 = transform.position + transform.right * val5.x + transform.up * val5.y + transform.forward * val5.z;
		Quaternion val8 = transform.rotation * val4;
		Vector3 val9 = val7 + val6;
		Quaternion val10 = val8;
		val.transform.position = val9;
		val.transform.rotation = val10;
		hs.currentPos = val9;
		hs.currentRot = val10;
		val.SetActive(true);
		hs.weaponInstance = val;
		hs.weaponType = WeaponType.Hammer;
		hs.wasTriggerWeapon = false;
		hs.currentMode = AbilityMode.Weapon;
		SpawnMutationParticles(transform.position, transform.rotation);
		PlayWav(transformationSoundPath, 1f);
	}

	private bool IsCuttingPart(Transform t)
	{
		Transform val = t;
		int num = 0;
		while ((Object)(object)val != (Object)null && num < 20)
		{
			string text = ((Object)val).name.ToLower();
			if (text == "bar" || text.Contains("chainsawchain"))
			{
				return true;
			}
			val = val.parent;
			num++;
		}
		return false;
	}

	private void CutHandleOffMesh(GameObject katanaInstance)
	{
		//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)
		try
		{
			MeshFilter val = katanaInstance.GetComponent<MeshFilter>();
			if ((Object)(object)val == (Object)null)
			{
				val = katanaInstance.GetComponentInChildren<MeshFilter>();
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Mesh mesh = val.mesh;
			if ((Object)(object)mesh == (Object)null)
			{
				return;
			}
			Il2CppStructArray<Vector3> vertices = mesh.vertices;
			Vector3[] array = (Vector3[])(object)new Vector3[((Il2CppArrayBase<Vector3>)(object)vertices).Length];
			for (int i = 0; i < ((Il2CppArrayBase<Vector3>)(object)vertices).Length; i++)
			{
				array[i] = ((Il2CppArrayBase<Vector3>)(object)vertices)[i];
			}
			int subMeshCount = mesh.subMeshCount;
			for (int j = 0; j < subMeshCount; j++)
			{
				Il2CppStructArray<int> triangles = mesh.GetTriangles(j);
				List<int> list = new List<int>();
				for (int k = 0; k < ((Il2CppArrayBase<int>)(object)triangles).Length; k++)
				{
					list.Add(((Il2CppArrayBase<int>)(object)triangles)[k]);
				}
				List<int> list2 = new List<int>();
				for (int l = 0; l < list.Count; l += 3)
				{
					int num = list[l];
					int num2 = list[l + 1];
					int num3 = list[l + 2];
					if (!(array[num].y < 0.4f) || !(array[num2].y < 0.4f) || !(array[num3].y < 0.4f))
					{
						list2.Add(num);
						list2.Add(num2);
						list2.Add(num3);
					}
				}
				Il2CppStructArray<int> val2 = new Il2CppStructArray<int>((long)list2.Count);
				for (int m = 0; m < list2.Count; m++)
				{
					((Il2CppArrayBase<int>)(object)val2)[m] = list2[m];
				}
				mesh.SetTriangles(val2, j);
			}
			mesh.RecalculateNormals();
			mesh.RecalculateBounds();
		}
		catch
		{
		}
	}

	private void CutHammerHandleMesh(GameObject hammerInstance)
	{
		//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_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_00a9: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			MeshFilter val = hammerInstance.GetComponent<MeshFilter>();
			if ((Object)(object)val == (Object)null)
			{
				val = hammerInstance.GetComponentInChildren<MeshFilter>();
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Mesh mesh = val.mesh;
			if ((Object)(object)mesh == (Object)null)
			{
				return;
			}
			Il2CppStructArray<Vector3> vertices = mesh.vertices;
			Vector3[] array = (Vector3[])(object)new Vector3[((Il2CppArrayBase<Vector3>)(object)vertices).Length];
			for (int i = 0; i < ((Il2CppArrayBase<Vector3>)(object)vertices).Length; i++)
			{
				array[i] = ((Il2CppArrayBase<Vector3>)(object)vertices)[i];
			}
			float num = float.MaxValue;
			float num2 = float.MinValue;
			Vector3[] array2 = array;
			foreach (Vector3 val2 in array2)
			{
				if (val2.y < num)
				{
					num = val2.y;
				}
				if (val2.y > num2)
				{
					num2 = val2.y;
				}
			}
			float num3 = num2 - num;
			float num4 = num + num3 * 0.87f;
			int subMeshCount = mesh.subMeshCount;
			for (int k = 0; k < subMeshCount; k++)
			{
				Il2CppStructArray<int> triangles = mesh.GetTriangles(k);
				List<int> list = new List<int>();
				for (int l = 0; l < ((Il2CppArrayBase<int>)(object)triangles).Length; l++)
				{
					list.Add(((Il2CppArrayBase<int>)(object)triangles)[l]);
				}
				List<int> list2 = new List<int>();
				for (int m = 0; m < list.Count; m += 3)
				{
					int num5 = list[m];
					int num6 = list[m + 1];
					int num7 = list[m + 2];
					if (!(array[num5].y < num4) || !(array[num6].y < num4) || !(array[num7].y < num4))
					{
						list2.Add(num5);
						list2.Add(num6);
						list2.Add(num7);
					}
				}
				Il2CppStructArray<int> val3 = new Il2CppStructArray<int>((long)list2.Count);
				for (int n = 0; n < list2.Count; n++)
				{
					((Il2CppArrayBase<int>)(object)val3)[n] = list2[n];
				}
				mesh.SetTriangles(val3, k);
			}
			mesh.RecalculateNormals();
			mesh.RecalculateBounds();
		}
		catch
		{
		}
	}

	private void DisableHandleColliders(GameObject katanaInstance)
	{
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit(katanaInstance.GetComponentsInChildren<Collider>(true));
		if (array == null)
		{
			return;
		}
		Collider[] array2 = array;
		foreach (Collider val in array2)
		{
			if (!((Object)(object)val == (Object)null))
			{
				string name = ((Object)((Component)val).gameObject).name;
				bool flag = false;
				if (name == "Grab" || name == "Guard")
				{
					flag = true;
				}
				if ((Object)(object)((Component)val).gameObject == (Object)(object)katanaInstance && val is CapsuleCollider)
				{
					flag = true;
				}
				if (flag)
				{
					val.enabled = false;
				}
			}
		}
	}

	private void UpdateWeaponPosition(HandState hs)
	{
		//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_00a2: 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_00dd: 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_012b: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: 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_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: 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_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: 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_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c3: 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)
		//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0294: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: 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_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_031c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)hs.weaponInstance == (Object)null || (Object)(object)hs.weaponRb == (Object)null || (Object)(object)hs.grabber == (Object)null)
		{
			DestroyWeapon(hs);
			return;
		}
		float fixedDeltaTime = Time.fixedDeltaTime;
		float num;
		float num2;
		float num3;
		float num4;
		float num5;
		Vector3 val;
		Quaternion val2;
		switch (hs.weaponType)
		{
		default:
			return;
		case WeaponType.Blade:
			num = 50f;
			num2 = 50f;
			num3 = 3600f;
			num4 = 0.5f;
			num5 = 0.1f;
			val = GRIP_OFFSET;
			val2 = (hs.isLeft ? GRIP_ROT_LEFT : GRIP_ROT_RIGHT);
			break;
		case WeaponType.Chainsaw:
			num = 84f;
			num2 = 84f;
			num3 = 5400f;
			num4 = 0.4f;
			num5 = 0.15f;
			val = (hs.isLeft ? CHAINSAW_OFFSET_LEFT : CHAINSAW_OFFSET_RIGHT);
			val2 = (hs.isLeft ? CHAINSAW_ROT_LEFT : CHAINSAW_ROT_RIGHT);
			break;
		case WeaponType.Hammer:
			num = 180f;
			num2 = 180f;
			num3 = 7200f;
			num4 = 0.3f;
			num5 = 0.25f;
			val = (hs.isLeft ? HAMMER_OFFSET_LEFT : HAMMER_OFFSET_RIGHT);
			val2 = (hs.isLeft ? HAMMER_ROT_LEFT : HAMMER_ROT_RIGHT);
			break;
		}
		if (hs.deployState == DeployState.Deploying)
		{
			hs.deployProgress += fixedDeltaTime / num5;
			if (hs.deployProgress >= 1f)
			{
				hs.deployProgress = 1f;
				hs.deployState = DeployState.Deployed;
			}
		}
		float deployProgress = hs.deployProgress;
		float num6 = deployProgress * deployProgress * (3f - 2f * deployProgress);
		Transform transform = ((Component)hs.grabber).transform;
		Vector3 val3 = transform.position + transform.right * val.x + transform.up * val.y + transform.forward * val.z;
		Quaternion val4 = transform.rotation * val2;
		Vector3 val5 = -transform.forward * (num4 * (1f - num6));
		Vector3 val6 = val3 + val5;
		Quaternion val7 = val4;
		Vector3 val8 = Vector3.Lerp(hs.currentPos, val6, num * fixedDeltaTime);
		float num7 = Vector3.Distance(hs.currentPos, val8);
		float num8 = num2 * fixedDeltaTime;
		if (num7 > num8)
		{
			Vector3 currentPos = hs.currentPos;
			Vector3 val9 = val8 - hs.currentPos;
			val8 = currentPos + ((Vector3)(ref val9)).normalized * num8;
		}
		hs.currentPos = val8;
		Quaternion val10 = Quaternion.Slerp(hs.currentRot, val7, num * fixedDeltaTime);
		float num9 = Quaternion.Angle(hs.currentRot, val10);
		float num10 = num3 * fixedDeltaTime;
		if (num9 > num10)
		{
			val10 = Quaternion.RotateTowards(hs.currentRot, val10, num10);
		}
		hs.currentRot = val10;
		hs.weaponRb.MovePosition(hs.currentPos);
		hs.weaponRb.MoveRotation(hs.currentRot);
	}

	private void DestroyWeapon(HandState hs)
	{
		//IL_013f: 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)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: 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)
		if (hs.weaponType != WeaponType.None && (Object)(object)hs.weaponInstance != (Object)null)
		{
			PlayWav(detransformationSoundPath, 1f);
		}
		if (hs.weaponType == WeaponType.Chainsaw)
		{
			if ((Object)(object)hs.stopSoundClip != (Object)null && (Object)(object)hs.weaponInstance != (Object)null)
			{
				try
				{
					AudioSource.PlayClipAtPoint(hs.stopSoundClip, hs.weaponInstance.transform.position, 1f);
				}
				catch
				{
				}
			}
			if ((Object)(object)hs.idleAudio != (Object)null)
			{
				try
				{
					hs.idleAudio.Stop();
				}
				catch
				{
				}
			}
			if ((Object)(object)hs.revvedAudio != (Object)null)
			{
				try
				{
					hs.revvedAudio.Stop();
				}
				catch
				{
				}
			}
		}
		if (hs.weaponType == WeaponType.Chainsaw && (Object)(object)hs.chainsawManager != (Object)null)
		{
			try
			{
				hs.chainsawManager.StopChainsaw();
				hs.chainsawManager.isRevved = false;
			}
			catch
			{
			}
		}
		if ((Object)(object)hs.weaponInstance != (Object)null)
		{
			Vector3 position = hs.weaponInstance.transform.position;
			Quaternion rotation = hs.weaponInstance.transform.rotation;
			SpawnDestroyParticles(position, rotation);
		}
		if (hs.weaponColliders.Count > 0)
		{
			GameObject val = GameObject.Find("Hexa4Rig26.10.23");
			if ((Object)(object)val != (Object)null)
			{
				Collider[] array = Il2CppArrayBase<Collider>.op_Implicit(val.GetComponentsInChildren<Collider>(true));
				if (array != null)
				{
					foreach (Collider weaponCollider in hs.weaponColliders)
					{
						if ((Object)(object)weaponCollider == (Object)null)
						{
							continue;
						}
						Collider[] array2 = array;
						foreach (Collider val2 in array2)
						{
							if (!((Object)(object)val2 == (Object)null))
							{
								try
								{
									Physics.IgnoreCollision(weaponCollider, val2, false);
								}
								catch
								{
								}
							}
						}
					}
				}
			}
		}
		if ((Object)(object)hs.weaponInstance != (Object)null)
		{
			Object.Destroy((Object)(object)hs.weaponInstance);
		}
		hs.weaponInstance = null;
		hs.weaponRb = null;
		hs.chainsawManager = null;
		hs.weaponColliders.Clear();
		hs.weaponType = WeaponType.None;
		hs.deployProgress = 0f;
		hs.deployState = DeployState.Deployed;
		hs.wasTriggerWeapon = false;
		hs.idleAudio = null;
		hs.revvedAudio = null;
		hs.startSoundClip = null;
		hs.stopSoundClip = null;
		hs.currentMode = AbilityMode.None;
	}

	private void DestroyComponentByName(GameObject obj, string componentName)
	{
		try
		{
			Il2CppArrayBase<Component> components = obj.GetComponents<Component>();
			if (components == null)
			{
				return;
			}
			foreach (Component item in components)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				string text = "";
				try
				{
					Type il2CppType = ((Object)item).GetIl2CppType();
					text = ((il2CppType != null) ? ((MemberInfo)il2CppType).Name : null) ?? ((object)item).GetType().Name;
				}
				catch
				{
				}
				if (text == componentName)
				{
					try
					{
						Object.Destroy((Object)(object)item);
					}
					catch
					{
					}
				}
			}
		}
		catch
		{
		}
	}

	private void DisableComponentByName(GameObject obj, string componentName)
	{
		try
		{
			Il2CppArrayBase<Component> components = obj.GetComponents<Component>();
			if (components == null)
			{
				return;
			}
			foreach (Component item in components)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				string text = "";
				try
				{
					Type il2CppType = ((Object)item).GetIl2CppType();
					text = ((il2CppType != null) ? ((MemberInfo)il2CppType).Name : null) ?? ((object)item).GetType().Name;
				}
				catch
				{
				}
				if (!(text == componentName))
				{
					continue;
				}
				try
				{
					PropertyInfo property = ((object)item).GetType().GetProperty("enabled");
					if (property != null && property.CanWrite)
					{
						property.SetValue(item, false);
					}
				}
				catch
				{
				}
			}
		}
		catch
		{
		}
	}

	private void DisableCollisionWithPlayer(HandState hs)
	{
		if (hs.weaponColliders.Count == 0)
		{
			return;
		}
		GameObject val = GameObject.Find("Hexa4Rig26.10.23");
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit(val.GetComponentsInChildren<Collider>(true));
		if (array == null)
		{
			return;
		}
		foreach (Collider weaponCollider in hs.weaponColliders)
		{
			if ((Object)(object)weaponCollider == (Object)null)
			{
				continue;
			}
			Collider[] array2 = array;
			foreach (Collider val2 in array2)
			{
				if (!((Object)(object)val2 == (Object)null))
				{
					try
					{
						Physics.IgnoreCollision(weaponCollider, val2, true);
					}
					catch
					{
					}
				}
			}
		}
	}

	private void SpawnMutationParticles(Vector3 position, Quaternion rotation)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: 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_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_00f6: 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_00bb: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		GameObject bloodPrefab = GetBloodPrefab();
		GameObject fleshPrefab = GetFleshPrefab();
		if ((Object)(object)bloodPrefab != (Object)null)
		{
			SpawnGameBloodPS(bloodPrefab, position, rotation, 1.5f);
			Vector3 val = rotation * new Vector3(Random.Range(-0.03f, 0.03f), Random.Range(0f, 0.1f), Random.Range(-0.03f, 0.03f));
			SpawnGameBloodPS(bloodPrefab, position + val, rotation, 1.5f);
		}
		if ((Object)(object)fleshPrefab != (Object)null)
		{
			for (int i = 0; i < 2; i++)
			{
				Vector3 val2 = rotation * new Vector3(Random.Range(-0.03f, 0.03f), Random.Range(0f, 0.1f), Random.Range(-0.03f, 0.03f));
				SpawnGameBloodPS(fleshPrefab, position + val2, rotation);
			}
		}
		for (int j = 0; j < 15; j++)
		{
			CreateSkinPiece(position);
		}
	}

	private void SpawnDestroyParticles(Vector3 position, Quaternion rotation)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: 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_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: 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_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: 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)
		//IL_0145: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
		GameObject fleshPrefab = GetFleshPrefab();
		GameObject bloodPrefab = GetBloodPrefab();
		if ((Object)(object)fleshPrefab != (Object)null)
		{
			for (int i = 0; i < 4; i++)
			{
				float num = Random.Range(0f, 0.8f);
				Vector3 val = rotation * new Vector3(Random.Range(-0.02f, 0.02f), num, Random.Range(-0.01f, 0.01f));
				SpawnGameBloodPS(fleshPrefab, position + val, rotation);
			}
		}
		if ((Object)(object)bloodPrefab != (Object)null)
		{
			for (int j = 0; j < 4; j++)
			{
				float num2 = Random.Range(0f, 0.8f);
				Vector3 val2 = rotation * new Vector3(Random.Range(-0.02f, 0.02f), num2, Random.Range(-0.01f, 0.01f));
				SpawnGameBloodPS(bloodPrefab, position + val2, rotation);
			}
		}
		for (int k = 0; k < 20; k++)
		{
			float num3 = Random.Range(0f, 0.8f);
			Vector3 val3 = rotation * new Vector3(Random.Range(-0.02f, 0.02f), num3, Random.Range(-0.01f, 0.01f));
			CreateSkinPiece(position + val3);
		}
	}

	private void CreateSkinPiece(Vector3 position)
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Expected O, but got Unknown
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
		((Object)val).name = "MahitoSkin";
		val.layer = 20;
		Collider component = val.GetComponent<Collider>();
		if ((Object)(object)component != (Object)null)
		{
			Object.Destroy((Object)(object)component);
		}
		val.transform.position = position + Random.insideUnitSphere * 0.02f;
		float num = Random.Range(0.008f, 0.02f);
		if (Random.value > 0.5f)
		{
			val.transform.localScale = new Vector3(num, num * Random.Range(0.4f, 0.7f), num * Random.Range(2f, 4f));
		}
		else
		{
			val.transform.localScale = new Vector3(num, num * Random.Range(0.5f, 1f), num * Random.Range(0.7f, 1.3f));
		}
		val.transform.rotation = Random.rotation;
		Renderer component2 = val.GetComponent<Renderer>();
		if ((Object)(object)component2 != (Object)null)
		{
			if ((Object)(object)greyMaterial != (Object)null)
			{
				component2.material = new Material(greyMaterial);
				try
				{
					component2.material.color = SKIN_COLOR;
				}
				catch
				{
				}
			}
			else
			{
				try
				{
					component2.material.color = SKIN_COLOR;
				}
				catch
				{
				}
			}
		}
		Rigidbody val2 = val.AddComponent<Rigidbody>();
		val2.useGravity = true;
		val2.mass = 0.002f;
		val2.drag = 2.5f;
		val2.angularDrag = 2f;
		Vector3 onUnitSphere = Random.onUnitSphere;
		onUnitSphere.y = Mathf.Abs(onUnitSphere.y) * 0.15f;
		((Vector3)(ref onUnitSphere)).Normalize();
		val2.AddForce(onUnitSphere * Random.Range(0.002f, 0.008f), (ForceMode)1);
		val2.AddTorque(Random.Range(-0.2f, 0.2f), Random.Range(-0.2f, 0.2f), Random.Range(-0.2f, 0.2f), (ForceMode)1);
		Object.Destroy((Object)(object)val, Random.Range(2f, 3.5f));
	}

	private void SpawnGameBloodPS(GameObject psPrefab, Vector3 position, Quaternion rotation, float lifeTime = 2f)
	{
		//IL_0044: 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)
		if ((Object)(object)psPrefab == (Object)null)
		{
			return;
		}
		try
		{
			GameObject val = Object.Instantiate<GameObject>(psPrefab);
			((Object)val).name = "MahitoBlood_" + ((Object)psPrefab).name;
			val.transform.SetParent((Transform)null);
			val.transform.position = position;
			val.transform.rotation = rotation;
			val.layer = 20;
			val.SetActive(true);
			ParticleSystem component = val.GetComponent<ParticleSystem>();
			if ((Object)(object)component != (Object)null)
			{
				try
				{
					component.Play();
				}
				catch
				{
				}
			}
			Object.Destroy((Object)(object)val, lifeTime);
		}
		catch
		{
		}
	}

	private void SaveBloodPrefabs()
	{
		try
		{
			Il2CppArrayBase<ParticleSystem> val = Object.FindObjectsOfType<ParticleSystem>();
			if (val == null)
			{
				return;
			}
			foreach (ParticleSystem item in val)
			{
				if (!((Object)(object)item == (Object)null) && !((Object)(object)((Component)item).gameObject == (Object)null))
				{
					string name = ((Object)((Component)item).gameObject).name;
					if ((Object)(object)savedBloodPrefab == (Object)null && name == "SplashConfetti")
					{
						GameObject val2 = Object.Instantiate<GameObject>(((Component)item).gameObject);
						((Object)val2).name = "MahitoAbilities_SavedBlood";
						val2.SetActive(false);
						Object.DontDestroyOnLoad((Object)(object)val2);
						savedBloodPrefab = val2;
					}
					if ((Object)(object)savedFleshPrefab == (Object)null && name == "FleshChunkEmitter")
					{
						GameObject val3 = Object.Instantiate<GameObject>(((Component)item).gameObject);
						((Object)val3).name = "MahitoAbilities_SavedFlesh";
						val3.SetActive(false);
						Object.DontDestroyOnLoad((Object)(object)val3);
						savedFleshPrefab = val3;
					}
					if ((Object)(object)savedBloodPrefab != (Object)null && (Object)(object)savedFleshPrefab != (Object)null)
					{
						bloodSaved = true;
						break;
					}
				}
			}
			if ((Object)(object)savedBloodPrefab != (Object)null || (Object)(object)savedFleshPrefab != (Object)null)
			{
				bloodSaved = true;
			}
		}
		catch
		{
		}
	}

	private GameObject GetBloodPrefab()
	{
		return ((Object)(object)savedBloodPrefab != (Object)null) ? savedBloodPrefab : null;
	}

	private GameObject GetFleshPrefab()
	{
		return ((Object)(object)savedFleshPrefab != (Object)null) ? savedFleshPrefab : null;
	}

	private void FindGreyMaterial()
	{
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Expected O, but got Unknown
		//IL_011d: 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_0099: Expected O, but got Unknown
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Il2CppArrayBase<Renderer> val = Object.FindObjectsOfType<Renderer>();
			if (val == null)
			{
				return;
			}
			foreach (Renderer item in val)
			{
				if ((Object)(object)item == (Object)null || (Object)(object)item.material == (Object)null)
				{
					continue;
				}
				string text = ((Object)item.material).name.ToLower();
				if (!text.Contains("lit") || text.Contains("katana"))
				{
					continue;
				}
				greyMaterial = new Material(item.material);
				greyMaterial.color = SKIN_COLOR;
				try
				{
					greyMaterial.SetColor("_Color", SKIN_COLOR);
					return;
				}
				catch
				{
					return;
				}
			}
			Shader val2 = Shader.Find("Standard") ?? Shader.Find("Unlit/Color");
			if ((Object)(object)val2 != (Object)null)
			{
				greyMaterial = new Material(val2);
				greyMaterial.color = SKIN_COLOR;
			}
		}
		catch
		{
		}
	}

	private Shader GetFlameShader()
	{
		if ((Object)(object)cachedFlameShader != (Object)null)
		{
			return cachedFlameShader;
		}
		cachedFlameShader = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard");
		return cachedFlameShader;
	}

	private void SetupTransparent(Material material)
	{
		if ((Object)(object)material == (Object)null)
		{
			return;
		}
		try
		{
			if (material.HasProperty("_Mode"))
			{
				material.SetFloat("_Mode", 3f);
			}
			if (material.HasProperty("_SrcBlend"))
			{
				material.SetFloat("_SrcBlend", 5f);
			}
			if (material.HasProperty("_DstBlend"))
			{
				material.SetFloat("_DstBlend", 10f);
			}
			if (material.HasProperty("_ZWrite"))
			{
				material.SetFloat("_ZWrite", 0f);
			}
			material.renderQueue = 3000;
		}
		catch
		{
		}
	}

	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.grabber == (Object)null))
		{
			CleanupAura(hs);
			hs.auraLightObj = new GameObject("CursedAuraLight");
			hs.auraLightObj.transform.SetParent(((Component)hs.grabber).transform);
			hs.auraLightObj.transform.localPosition = Vector3.zero;
			hs.auraLight = hs.auraLightObj.AddComponent<Light>();
			hs.auraLight.type = (LightType)2;
			hs.auraLight.color = AURA_LIGHT_COLOR;
			hs.auraLight.intensity = 0.15f;
			hs.auraLight.range = 0.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(0.15f, 0.4f, 1f) + num * 0.08f;
			hs.auraLight.range = Mathf.Lerp(0.1f, 0.25f, 1f);
		}
	}

	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 UpdateAuraSpawns(HandState hs)
	{
		hs.flameSpawnTimer -= Time.deltaTime;
		if (hs.flameSpawnTimer <= 0f)
		{
			for (int i = 0; i < 3; i++)
			{
				SpawnFlameParticle(hs);
			}
			hs.flameSpawnTimer = 0.03f;
		}
		hs.emberSpawnTimer -= Time.deltaTime;
		if (hs.emberSpawnTimer <= 0f)
		{
			SpawnEmber(hs);
			hs.emberSpawnTimer = Random.Range(0.08f, 0.2f);
		}
		hs.lightningTimer -= Time.deltaTime;
		if (hs.lightningTimer <= 0f)
		{
			SpawnLightningBolt(hs);
			hs.lightningTimer = 0.12f * Random.Range(0.7f, 1.3f);
		}
	}

	private void SpawnFlameParticle(HandState hs)
	{
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: 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_00ae: 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_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: 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_0179: 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_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: 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_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: 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_0126: Expected O, but got Unknown
		if ((Object)(object)hs.grabber == (Object)null || activeParticles >= 250)
		{
			return;
		}
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		activeParticles++;
		try
		{
			Object.Destroy((Object)(object)val.GetComponent<Collider>());
		}
		catch
		{
		}
		((Object)val).name = "CursedFlame";
		Transform transform = ((Component)hs.grabber).transform;
		Vector3 val2 = Random.insideUnitSphere * 0.08f;
		val2.y += 0.02f;
		val.transform.position = transform.position + val2;
		float num = Random.Range(0.02f, 0.05f) / 1.2f;
		val.transform.localScale = new Vector3(num, num * 1.8f, num);
		Renderer component = val.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader flameShader = GetFlameShader();
			if ((Object)(object)flameShader != (Object)null)
			{
				try
				{
					component.material = new Material(flameShader);
					SetupTransparent(component.material);
				}
				catch
				{
				}
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
		Vector3 val3 = Vector3.up * Random.Range(0.35f, 0.8f) + Random.insideUnitSphere * 0.15f;
		val3 += transform.forward * 0.1f;
		float life = Random.Range(0.35f, 0.7f);
		MelonCoroutines.Start(FlameRoutine(val, val3, life, num));
	}

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

	private void SpawnEmber(HandState hs)
	{
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: 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_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: 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_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Expected O, but got Unknown
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)hs.grabber == (Object)null || activeParticles >= 250)
		{
			return;
		}
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		activeParticles++;
		try
		{
			Object.Destroy((Object)(object)val.GetComponent<Collider>());
		}
		catch
		{
		}
		((Object)val).name = "CursedEmber";
		val.transform.position = ((Component)hs.grabber).transform.position + Random.insideUnitSphere * 0.06f;
		float num = Random.Range(0.008f, 0.02f);
		val.transform.localScale = Vector3.one * num;
		Renderer component = val.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader flameShader = GetFlameShader();
			if ((Object)(object)flameShader != (Object)null)
			{
				try
				{
					component.material = new Material(flameShader);
					component.material.color = EMBER_COLOR;
					SetupTransparent(component.material);
				}
				catch
				{
				}
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
		Vector3 velocity = Random.onUnitSphere * Random.Range(0.6f, 1.4f) + Vector3.up * 0.3f;
		float life = Random.Range(0.4f, 0.8f);
		MelonCoroutines.Start(EmberRoutine(val, velocity, life, num));
	}

	private IEnumerator EmberRoutine(GameObject particle, Vector3 velocity, 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;
			Transform transform = particle.transform;
			transform.position += velocity * dt;
			velocity *= 0.96f;
			elapsed += dt;
			float t = elapsed / life;
			particle.transform.localScale = Vector3.one * (size * (1f - t));
			if ((Object)(object)r != (Object)null && (Object)(object)r.material != (Object)null)
			{
				try
				{
					Color c = r.material.color;
					c.a = (1f - t) * 0.9f;
					r.material.color = c;
				}
				catch
				{
				}
			}
			yield return null;
		}
		if ((Object)(object)particle != (Object)null)
		{
			Object.Destroy((Object)(object)particle);
		}
		if (activeParticles > 0)
		{
			activeParticles--;
		}
	}

	private void SpawnLightningBolt(HandState hs)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		//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_0055: 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)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: 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_0076: 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_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: 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_0093: 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_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_00c7: 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_00d1: 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_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Expected O, but got Unknown
		//IL_0183: 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_00ee: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)hs.grabber == (Object)null)
		{
			return;
		}
		GameObject val = new GameObject("CursedLightning");
		LineRenderer val2 = val.AddComponent<LineRenderer>();
		if ((Object)(object)val2 == (Object)null)
		{
			Object.Destroy((Object)(object)val);
			return;
		}
		Vector3 position = ((Component)hs.grabber).transform.position;
		Vector3 val3 = position + Random.onUnitSphere * 0.05f;
		Vector3 val4 = Random.onUnitSphere * 0.6f + Vector3.up * 0.4f;
		Vector3 val5 = val3 + ((Vector3)(ref val4)).normalized * Random.Range(0.15f, 0.3f);
		int num = 5;
		val2.positionCount = num + 1;
		for (int i = 0; i <= num; i++)
		{
			Vector3 val6 = Vector3.Lerp(val3, val5, (float)i / (float)num);
			if (i != 0 && i != num)
			{
				val6 += Random.insideUnitSphere * 0.03f;
			}
			val2.SetPosition(i, val6);
		}
		val2.startWidth = 0.01f;
		val2.endWidth = 0.003f;
		val2.startColor = LIGHTNING_START_COLOR;
		val2.endColor = LIGHTNING_END_COLOR;
		try
		{
			Shader flameShader = GetFlameShader();
			if ((Object)(object)flameShader != (Object)null)
			{
				((Renderer)val2).material = new Material(flameShader);
				((Renderer)val2).material.color = Color.white;
			}
		}
		catch
		{
		}
		((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)val2).receiveShadows = false;
		MelonCoroutines.Start(LightningRoutine(val));
	}

	private IEnumerator LightningRoutine(GameObject boltObj)
	{
		yield return (object)new WaitForSeconds(Random.Range(0.06f, 0.12f));
		if ((Object)(object)boltObj != (Object)null)
		{
			Object.Destroy((Object)(object)boltObj);
		}
	}

	private bool IsLimb(GameObject obj)
	{
		if ((Object)(object)obj == (Object)null)
		{
			return false;
		}
		if (LIMB_NAMES.Contains(((Object)obj).name))
		{
			return true;
		}
		Transform parent = obj.transform.parent;
		int num = 0;
		while ((Object)(object)parent != (Object)null && num < 5)
		{
			if (LIMB_NAMES.Contains(((Object)parent).name))
			{
				return true;
			}
			parent = parent.parent;
			num++;
		}
		return false;
	}

	private HVRGrabbable FindTouchedLimb(HVRHandGrabber grabber)
	{
		//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_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: 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)
		try
		{
			Vector3 position = ((Component)grabber).transform.position;
			Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(position, 0.15f));
			if (array == null || array.Length == 0)
			{
				return null;
			}
			float num = float.MaxValue;
			HVRGrabbable result = null;
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Transform root = ((Component)val).transform.root;
				if ((Object)(object)root != (Object)null && (((Object)root).name.Contains("Hexa4Rig") || ((Object)root).name.Contains("Player")))
				{
					continue;
				}
				HVRGrabbable val2 = ((Component)val).GetComponent<HVRGrabbable>();
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = ((Component)val).GetComponentInParent<HVRGrabbable>();
				}
				if ((Object)(object)val2 == (Object)null || !IsLimb(((Component)val2).gameObject) || LIMB_BLACKLIST.Contains(((Object)((Component)val2).gameObject).name))
				{
					continue;
				}
				bool flag = false;
				try
				{
					if (val2.Grabbers != null)
					{
						Enumerator<HVRGrabberBase> enumerator = val2.Grabbers.GetEnumerator();
						while (enumerator.MoveNext())
						{
							HVRGrabberBase current = enumerator.Current;
							if ((Object)(object)current != (Object)null)
							{
								flag = true;
								break;
							}
						}
					}
				}
				catch
				{
				}
				if (!flag)
				{
					float num2 = Vector3.Distance(position, ((Component)val).transform.position);
					if (num2 < num)
					{
						num = num2;
						result = val2;
					}
				}
			}
			return result;
		}
		catch
		{
			return null;
		}
	}

	private IEnumerator PerformBlackLightningV9(GameObject targetLimb, HVRHandGrabber hand, HandState hs)
	{
		Vector3 contactPoint = ((Component)hand).transform.position;
		Vector3 forward = ((Component)hand).transform.forward;
		((MelonBase)this).LoggerInstance.Msg($"MahitoAbilitiesMod: ЧЁРНАЯ МОЛНИЯ V4.9 в точке {contactPoint}");
		PlayWav(blackFlashSoundPath, 1f);
		ApplyBlackLightningForce(contactPoint);
		SpawnBlackCubeFragments(contactPoint);
		GameObject originSphere = SpawnOriginSphere(contactPoint);
		List<LightningBranch> mainBranches = new List<LightningBranch>();
		for (int i = 0; i < 14; i++)
		{
			Vector3 direction = Random.onUnitSphere;
			Vector3 val = direction * 0.85f + forward * 0.15f;
			direction = ((Vector3)(ref val)).normalized;
			float length = Random.Range(3f, 5f);
			LightningBranch branch = CreateLightningBranch(contactPoint, direction, length, isMain: true, i);
			if (branch != null)
			{
				mainBranches.Add(branch);
			}
		}
		List<LightningBranch> midBranches = new List<LightningBranch>();
		for (int j = 0; j < 8; j++)
		{
			Vector3 scatterPos = contactPoint + Random.onUnitSphere * Random.Range(0.8f, 2f);
			Vector3 direction2 = Random.onUnitSphere;
			float length2 = Random.Range(1.2f, 2.5f);
			LightningBranch branch2 = CreateLightningBranchCustom(scatterPos, direction2, length2, 0.05f, 0.004f, j + 100);
			if (branch2 != null)
			{
				midBranches.Add(branch2);
			}
		}
		List<LightningBranch> smallBranches = new List<LightningBranch>();
		for (int k = 0; k < 12; k++)
		{
			Vector3 scatterPos2 = contactPoint + Random.onUnitSphere * Random.Range(2f, 4f);
			Vector3 direction3 = Random.onUnitSphere;
			float length3 = Random.Range(0.5f, 1.1f);
			LightningBranch branch3 = CreateLightningBranchCustom(scatterPos2, direction3, length3, 0.025f, 0.002f, k + 200);
			if (branch3 != null)
			{
				smallBranches.Add(branch3);
			}
		}
		float totalDuration = 1.28f;
		float elapsed = 0f;
		while (elapsed < totalDuration)
		{
			elapsed += Time.deltaTime;
			float growRaw = Mathf.Clamp01(elapsed / 0.7f);
			float growProgress = growRaw * growRaw * (3f - 2f * growRaw);
			float collapseRaw = Mathf.Clamp01((elapsed - 0.28f) / 0.70000005f);
			float collapseProgress = collapseRaw * collapseRaw * (3f - 2f * collapseRaw);
			float smallCollapseRaw = Mathf.Clamp01((elapsed - 0.28f - 0.3f) / 0.70000005f);
			float smallCollapseProgress = smallCollapseRaw * smallCollapseRaw * (3f - 2f * smallCollapseRaw);
			float smallGrowRaw = Mathf.Clamp01(elapsed / 0.84000003f);
			float smallGrowProgress = smallGrowRaw * smallGrowRaw * (3f - 2f * smallGrowRaw);
			foreach (LightningBranch branch4 in mainBranches)
			{
				if (branch4 != null && !((Object)(object)branch4.obj == (Object)null))
				{
					if (collapseProgress <= 0f)
					{
						AnimateBranchGrowth(branch4, growProgress);
					}
					else
					{
						AnimateBranchGrowthAndCollapse(branch4, growProgress, collapseProgress);
					}
				}
			}
			foreach (LightningBranch branch5 in midBranches)
			{
				if (branch5 != null && !((Object)(object)branch5.obj == (Object)null))
				{
					if (collapseProgress <= 0f)
					{
						AnimateBranchGrowth(branch5, growProgr