Decompiled source of HakariTechniques v1.0.0

HakariMod.dll

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

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

public class Core : MelonMod
{
	private enum StrikeState
	{
		Idle,
		Charging,
		Armed,
		Striking,
		Cooldown
	}

	private class HandState
	{
		public HVRHandGrabber hand;

		public StrikeState state = StrikeState.Idle;

		public float chargeAmount;

		public bool wasComboActive;

		public float armedTimer;

		public GameObject auraLightObj;

		public Light auraLight;

		public float flameSpawnTimer;

		public float emberSpawnTimer;

		public float lightningTimer;

		public float flickerTime;
	}

	public static HVRHexaBodyInputs playerInputs;

	public static HVRHandGrabber rightHand;

	private readonly HandState leftState = new HandState();

	private readonly HandState rightState = new HandState();

	private const float CHARGE_SPEED = 0.8f;

	private const float MAX_CHARGE = 1f;

	private const float STRIKE_COOLDOWN = 0.6f;

	private const float ARMED_DURATION = 2.5f;

	private const float FIST_CHECK_RADIUS = 0.18f;

	private const float STRIKE_RADIUS_MIN = 0.5f;

	private const float STRIKE_RADIUS_MAX = 2f;

	private const float STRIKE_FORCE_MIN = 50f;

	private const float STRIKE_FORCE_MAX = 200f;

	private const float STRIKE_DAMAGE_MIN = 5f;

	private const float STRIKE_DAMAGE_MAX = 25f;

	private const int MAX_PARTICLES = 250;

	private int activeParticles;

	private const float FLAME_SIZE_SCALE = 1.2f;

	private const float FLAME_SPAWN_INTERVAL = 0.03f;

	private const float FLAME_LIFETIME_MIN = 0.35f;

	private const float FLAME_LIFETIME_MAX = 0.7f;

	private const float FLAME_STRETCH = 1.8f;

	private const float EMBER_SPAWN_INTERVAL_MIN = 0.08f;

	private const float EMBER_SPAWN_INTERVAL_MAX = 0.2f;

	private const float LIGHTNING_INTERVAL_MAX_CHARGE = 0.12f;

	private const float LIGHTNING_INTERVAL_NO_CHARGE = 0.35f;

	private const float LIGHT_INTENSITY_MIN = 1f;

	private const float LIGHT_INTENSITY_MAX = 3.5f;

	private const float LIGHT_RANGE_MIN = 1f;

	private const float LIGHT_RANGE_MAX = 2.5f;

	private Shader cachedFlameShader;

	private const string SOUND_FOLDER_NAME = "HakariSounds";

	private const string CHARGE_START_FILE = "charge_start.wav";

	private const string DOORS_SOUND_FILE = "Doors.wav";

	private const string BALL_SOUND_FILE = "Ball.wav";

	private string chargeSoundPath;

	private string doorSoundPath;

	private string ballSoundPath;

	private const int SND_ASYNC = 1;

	private const int SND_NODEFAULT = 2;

	private const int SND_FILENAME = 131072;

	private bool wasRightStick;

	private bool doorActive;

	private const float DOOR_SPAWN_DISTANCE = 1.6f;

	private const float DOOR_WIDTH = 0.05f;

	private const float DOOR_LENGTH = 2.2f;

	private const float DOOR_DEPTH = 0.8f;

	private const float DOOR_OFFSET = 1.5f;

	private const float DOOR_Y_OFFSET = -0.1f;

	private const float DOOR_ALPHA = 1f;

	private const float DOOR_CLOSE_TIME = 0.4f;

	private const float DOOR_HOLD_TIME = 0.5f;

	private const float DOOR_OPEN_TIME = 0.2f;

	private const float DOOR_SLICE_DAMAGE = 120f;

	private const float DOOR_WAIT_TIME = 5f;

	private const float HITBOX_LENGTH = 1.5f;

	private const float HITBOX_HEIGHT = 0.3f;

	private const float HITBOX_DEPTH = 0.6f;

	private const float DOOR_FRACTURE_TRIGGER_POINT = 0.75f;

	private const int MAX_FRACTURE_COUNT = 3;

	private const int MAX_TORSO_FRACTURE_COUNT = 1;

	private const float LAUNCH_FORCE = 10f;

	private const float LAUNCH_SEARCH_RADIUS = 1.5f;

	private const float HANDLE_OFFSET_Y = 0.9f;

	private bool wasSecondaryButton;

	private GameObject heldBall;

	private const float BALL_SIZE = 0.07f;

	private const float BALL_SPEED = 60f;

	private const float BALL_MASS = 6f;

	private const float BALL_DAMAGE_MULTIPLIER = 1.67f;

	private const float BALL_PUSH_FORCE = 3f;

	private const float BALL_MIN_SPEED_FOR_DAMAGE = 2f;

	private const float BALL_LIFETIME = 3f;

	private const float BALL_HIT_COOLDOWN = 0.3f;

	private const float BALL_SPAWN_OFFSET = 0.15f;

	private const float BALL_SPAWN_COOLDOWN = 3f;

	private float lastBallSpawnTime = -100f;

	private const float GOLDEN_BALL_CHANCE = 0.2f;

	private List<GameObject> activeBalls = new List<GameObject>();

	private Dictionary<GameObject, float> ballCreationTimes = new Dictionary<GameObject, float>();

	private Dictionary<GameObject, float> ballLastHitTimes = new Dictionary<GameObject, float>();

	private HashSet<int> goldenBallIds = new HashSet<int>();

	private const float BALL_TRAIL_INTERVAL = 0.1f;

	private const float BALL_TRAIL_SIZE = 0.035f;

	private const float BALL_TRAIL_LIFETIME = 0.5f;

	private const float BALL_TRAIL_FADE_IN_TIME = 0.05f;

	private const float BALL_TRAIL_FADE_OUT_TIME = 0.3f;

	private Dictionary<GameObject, float> ballTrailLastSpawnTimes = new Dictionary<GameObject, float>();

	private Texture2D cachedStarTexture;

	private List<Renderer> activeSparkRenderers = new List<Renderer>();

	private List<float> sparkPhaseOffsets = new List<float>();

	private List<GameObject> activeSparkObjects = new List<GameObject>();

	private List<float> sparkCreationTimes = new List<float>();

	private List<int> sparkTypes = new List<int>();

	private List<Vector3> sparkStretchDirs = new List<Vector3>();

	private const int SPARK_TYPE_DOOR = 0;

	private const int SPARK_TYPE_BALL = 1;

	private const int SPARK_TYPE_TRAIL = 2;

	private static readonly Color DOOR_SPARK_COLOR = new Color(1f, 0.98f, 0.98f, 1f);

	private static readonly Color SILVER_SPARK_COLOR = new Color(0.8f, 0.8f, 0.85f, 1f);

	private static readonly Color GOLDEN_SPARK_COLOR = new Color(0.9f, 0.75f, 0.3f, 1f);

	private const int BALL_SPARK_COUNT = 3;

	private const float BALL_SPARK_SIZE = 0.05f;

	private const float BALL_SPARK_LIFETIME = 0.5f;

	private const float BALL_SPARK_FADE_IN_TIME = 0.05f;

	private const float BALL_SPARK_FADE_OUT_TIME = 0.3f;

	private const int DOOR_SPARK_COUNT = 40;

	private const float DOOR_SPARK_SIZE = 0.07f;

	private const float DOOR_SPARK_LIFETIME = 0.7f;

	private const float DOOR_SPARK_FADE_IN_TIME = 0.05f;

	private const float DOOR_SPARK_FADE_OUT_TIME = 0.4f;

	private const float SPARK_LIGHT_INTENSITY = 0.15f;

	private const float SPARK_LIGHT_RANGE = 0.25f;

	private const float SPARK_FLICKER_SPEED = 8f;

	private const float SPARK_SWAY_SPEED = 2f;

	private const float SPARK_SWAY_AMPLITUDE = 0.1f;

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

	private static readonly string[] TorsoPartNames = new string[3] { "UpperChest", "MiddleChest", "Pelvis" };

	private static readonly string[] UpperBodyPartNames = new string[9] { "Head", "Jaw", "Neck", "UpperChest", "MiddleChest", "Shoulder_L", "Shoulder_R", "Elbow_L", "Elbow_R" };

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

	public override void OnInitializeMelon()
	{
		((MelonBase)this).LoggerInstance.Msg("HakariMod v1.4.2 — двери, шарики, заряженный удар и звуки.");
		InitSounds();
	}

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

	private void ResetState()
	{
		playerInputs = null;
		rightHand = null;
		wasRightStick = false;
		doorActive = false;
		wasSecondaryButton = false;
		heldBall = null;
		lastBallSpawnTime = -100f;
		cachedStarTexture = null;
		ResetHand(leftState);
		ResetHand(rightState);
		if (activeBalls != null)
		{
			foreach (GameObject activeBall in activeBalls)
			{
				if ((Object)(object)activeBall != (Object)null)
				{
					Object.Destroy((Object)(object)activeBall);
				}
			}
			activeBalls.Clear();
		}
		ballCreationTimes.Clear();
		ballLastHitTimes.Clear();
		goldenBallIds.Clear();
		ballTrailLastSpawnTimes.Clear();
		activeSparkRenderers.Clear();
		sparkPhaseOffsets.Clear();
		activeSparkObjects.Clear();
		sparkCreationTimes.Clear();
		sparkTypes.Clear();
		sparkStretchDirs.Clear();
	}

	private void ResetHand(HandState hs)
	{
		hs.hand = null;
		hs.state = StrikeState.Idle;
		hs.chargeAmount = 0f;
		hs.wasComboActive = false;
		hs.armedTimer = 0f;
		hs.flameSpawnTimer = 0f;
		hs.emberSpawnTimer = 0f;
		hs.lightningTimer = 0f;
		hs.flickerTime = 0f;
		CleanupAura(hs);
	}

	public override void OnUpdate()
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: 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_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: 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_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: 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_0223: 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)
		if ((Object)(object)playerInputs == (Object)null || (Object)(object)rightHand == (Object)null || (Object)(object)playerInputs.LeftController == (Object)null || (Object)(object)playerInputs.RightController == (Object)null)
		{
			return;
		}
		HVRController leftController = playerInputs.LeftController;
		HVRController rightController = playerInputs.RightController;
		bool active = rightController.JoystickButtonState.Active;
		if (active && !wasRightStick && !doorActive)
		{
			ActivateDoors();
		}
		wasRightStick = active;
		bool comboActive = leftController.TriggerButtonState.Active && leftController.GripButtonState.Active && leftController.SecondaryButtonState.Active;
		bool comboActive2 = rightController.TriggerButtonState.Active && rightController.GripButtonState.Active && rightController.SecondaryButtonState.Active;
		ProcessHand(leftState, comboActive);
		ProcessHand(rightState, comboActive2);
		bool active2 = rightController.SecondaryButtonState.Active;
		bool flag = active2 && !wasSecondaryButton;
		bool flag2 = rightController.TriggerButtonState.Active && rightController.GripButtonState.Active;
		bool flag3 = rightState.state == StrikeState.Charging || rightState.state == StrikeState.Armed || rightState.state == StrikeState.Striking;
		if (flag && !flag2 && !flag3 && !((HVRGrabberBase)rightHand).IsGrabbing)
		{
			if ((Object)(object)heldBall != (Object)null)
			{
				ThrowHakariBall();
			}
			else
			{
				SpawnHakariBall();
			}
		}
		wasSecondaryButton = active2;
		if ((Object)(object)heldBall != (Object)null && (Object)(object)rightHand != (Object)null)
		{
			heldBall.transform.position = ((Component)rightHand).transform.position + ((Component)rightHand).transform.forward * 0.15f;
			heldBall.transform.rotation = ((Component)rightHand).transform.rotation;
		}
		UpdateActiveBalls();
		UpdateSparks();
	}

	private void ProcessHand(HandState hs, bool comboActive)
	{
		if ((Object)(object)hs.hand == (Object)null)
		{
			return;
		}
		if (hs.state == StrikeState.Idle)
		{
			if (comboActive && !hs.wasComboActive)
			{
				StartCharging(hs);
			}
		}
		else if (hs.state == StrikeState.Charging)
		{
			if (!comboActive)
			{
				hs.state = StrikeState.Armed;
				hs.armedTimer = 2.5f;
			}
			else
			{
				hs.chargeAmount = Mathf.Min(hs.chargeAmount + Time.deltaTime * 0.8f, 1f);
				UpdateAura(hs);
				UpdateAuraSpawns(hs);
				if (FistTouchesEnemy(hs))
				{
					PerformStrike(hs);
				}
			}
		}
		else if (hs.state == StrikeState.Armed)
		{
			if (comboActive && !hs.wasComboActive)
			{
				hs.state = StrikeState.Charging;
			}
			else
			{
				hs.armedTimer -= Time.deltaTime;
				if (hs.armedTimer <= 0f)
				{
					CleanupAura(hs);
					hs.state = StrikeState.Cooldown;
					MelonCoroutines.Start(ResetAfterCooldown(hs));
				}
				else
				{
					UpdateAura(hs);
					UpdateAuraSpawns(hs);
					if (FistTouchesEnemy(hs))
					{
						PerformStrike(hs);
					}
				}
			}
		}
		hs.wasComboActive = comboActive;
	}

	private void StartCharging(HandState hs)
	{
		hs.state = StrikeState.Charging;
		hs.chargeAmount = 0f;
		CreateAuraLight(hs);
		PlayWav(chargeSoundPath);
	}

	private bool FistTouchesEnemy(HandState hs)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)hs.hand == (Object)null)
		{
			return false;
		}
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(((Component)hs.hand).transform.position, 0.18f));
		Collider[] array2 = array;
		foreach (Collider val in array2)
		{
			if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null) && !IsPlayer(((Component)val).gameObject))
			{
				HVRGrabbable componentInParent = ((Component)val).GetComponentInParent<HVRGrabbable>();
				if (!((Object)(object)componentInParent == (Object)null) && IsBodyPart(((Object)((Component)componentInParent).gameObject).name))
				{
					return true;
				}
			}
		}
		return false;
	}

	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_0093: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)hs.hand == (Object)null))
		{
			CleanupAura(hs);
			hs.auraLightObj = new GameObject("CurseAuraLight");
			hs.auraLightObj.transform.SetParent(((Component)hs.hand).transform);
			hs.auraLightObj.transform.localPosition = Vector3.zero;
			hs.auraLight = hs.auraLightObj.AddComponent<Light>();
			hs.auraLight.type = (LightType)2;
			hs.auraLight.color = new Color(0.3f, 1f, 0.4f);
			hs.auraLight.intensity = 1f;
			hs.auraLight.range = 1f;
		}
	}

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

	private void UpdateAuraSpawns(HandState hs)
	{
		hs.flameSpawnTimer -= Time.deltaTime;
		if (hs.flameSpawnTimer <= 0f)
		{
			int num = 2 + Mathf.RoundToInt(hs.chargeAmount * 3f);
			for (int i = 0; i < num; 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);
			float num2 = Mathf.Lerp(0.35f, 0.12f, hs.chargeAmount);
			hs.lightningTimer = num2 * Random.Range(0.7f, 1.3f);
		}
	}

	private void SpawnFlameParticle(HandState hs)
	{
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Expected O, but got Unknown
		if ((Object)(object)hs.hand == (Object)null || activeParticles >= 250)
		{
			return;
		}
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		activeParticles++;
		Object.Destroy((Object)(object)val.GetComponent<Collider>());
		((Object)val).name = "CurseFlame";
		Transform transform = ((Component)hs.hand).transform;
		Vector3 val2 = Random.insideUnitSphere * (0.05f + hs.chargeAmount * 0.07f);
		val2.y += 0.02f;
		val.transform.position = transform.position + val2;
		float num = Random.Range(0.02f, 0.05f) * (0.7f + hs.chargeAmount * 0.8f) / 1.2f;
		val.transform.localScale = new Vector3(num, num * 1.8f, num);
		Renderer component = val.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader flameShader = GetFlameShader();
			if ((Object)(object)flameShader != (Object)null)
			{
				component.material = new Material(flameShader);
				SetupTransparent(component.material);
			}
			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;
			Vector3 pos = particle.transform.position;
			particle.transform.position = pos + 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)
			{
				Color c = ((!(t < 0.4f)) ? Color.Lerp(new Color(0.15f, 1f, 0.3f), new Color(0f, 0.45f, 0.2f), (t - 0.4f) / 0.6f) : Color.Lerp(new Color(0.7f, 1f, 0.6f), new Color(0.15f, 1f, 0.3f), t / 0.4f));
				c.a = (1f - t) * 0.85f;
				r.material.color = c;
			}
			yield return null;
		}
		if ((Object)(object)particle != (Object)null)
		{
			Object.Destroy((Object)(object)particle);
		}
		if (activeParticles > 0)
		{
			activeParticles--;
		}
	}

	private void SpawnEmber(HandState hs)
	{
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Expected O, but got Unknown
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)hs.hand == (Object)null || activeParticles >= 250)
		{
			return;
		}
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		activeParticles++;
		Object.Destroy((Object)(object)val.GetComponent<Collider>());
		((Object)val).name = "CurseEmber";
		val.transform.position = ((Component)hs.hand).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)
			{
				component.material = new Material(flameShader);
				component.material.color = new Color(0.6f, 1f, 0.5f, 0.9f);
				SetupTransparent(component.material);
			}
			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)
			{
				Color c = r.material.color;
				c.a = (1f - t) * 0.9f;
				r.material.color = c;
			}
			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_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Expected O, but got Unknown
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)hs.hand == (Object)null)
		{
			return;
		}
		GameObject val = new GameObject("CurseLightning");
		LineRenderer val2 = val.AddComponent<LineRenderer>();
		if ((Object)(object)val2 == (Object)null)
		{
			Object.Destroy((Object)(object)val);
			return;
		}
		Vector3 position = ((Component)hs.hand).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 * Mathf.Lerp(0.12f, 0.3f, hs.chargeAmount);
		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 = new Color(1f, 1f, 1f, 0.9f);
		val2.endColor = new Color(0.4f, 1f, 0.5f, 0f);
		Shader flameShader = GetFlameShader();
		if ((Object)(object)flameShader != (Object)null)
		{
			((Renderer)val2).material = new Material(flameShader);
			((Renderer)val2).material.color = Color.white;
		}
		((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 void PerformStrike(HandState hs)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: 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_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		hs.state = StrikeState.Striking;
		Transform transform = ((Component)hs.hand).transform;
		Vector3 val = transform.position + transform.forward * 0.1f;
		float num = hs.chargeAmount / 1f;
		float num2 = Mathf.Lerp(0.5f, 2f, num);
		float num3 = Mathf.Lerp(50f, 200f, num);
		float damage = Mathf.Lerp(5f, 25f, num);
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(val, num2));
		Collider[] array2 = array;
		foreach (Collider val2 in array2)
		{
			if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).gameObject == (Object)null || IsPlayer(((Component)val2).gameObject))
			{
				continue;
			}
			Rigidbody component = ((Component)val2).GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null && !component.isKinematic)
			{
				Vector3 val3 = component.position - val;
				if (((Vector3)(ref val3)).sqrMagnitude < 0.001f)
				{
					val3 = transform.forward;
				}
				((Vector3)(ref val3)).Normalize();
				val3.y += 0.3f;
				((Vector3)(ref val3)).Normalize();
				component.AddForce(val3 * num3, (ForceMode)1);
			}
			ApplyStrikeDamage(((Component)val2).gameObject, val, damage, num2);
		}
		SpawnStrikeWave(val, num2);
		SpawnStrikeFlameBurst(val, transform.forward);
		CleanupAura(hs);
		hs.state = StrikeState.Cooldown;
		MelonCoroutines.Start(ResetAfterCooldown(hs));
	}

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

	private void SpawnStrikeWave(Vector3 position, float radius)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Expected O, but got Unknown
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		Object.Destroy((Object)(object)val.GetComponent<Collider>());
		((Object)val).name = "StrikeWave";
		val.transform.position = position;
		val.transform.localScale = Vector3.one * 0.1f;
		Renderer component = val.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader flameShader = GetFlameShader();
			if ((Object)(object)flameShader != (Object)null)
			{
				component.material = new Material(flameShader);
				component.material.color = new Color(0.4f, 1f, 0.5f, 0.35f);
				SetupTransparent(component.material);
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
		MelonCoroutines.Start(StrikeWaveRoutine(val, radius));
	}

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

	private void SpawnStrikeFlameBurst(Vector3 position, Vector3 forward)
	{
		//IL_0069: 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_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: 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_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Expected O, but got Unknown
		for (int i = 0; i < 15; i++)
		{
			if (activeParticles >= 250)
			{
				break;
			}
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			activeParticles++;
			Object.Destroy((Object)(object)val.GetComponent<Collider>());
			((Object)val).name = "StrikeFlame";
			val.transform.position = position + Random.insideUnitSphere * 0.1f;
			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)
				{
					component.material = new Material(flameShader);
					SetupTransparent(component.material);
				}
				component.shadowCastingMode = (ShadowCastingMode)0;
				component.receiveShadows = false;
			}
			Vector3 val2 = forward + Random.insideUnitSphere * 0.8f;
			Vector3 velocity = ((Vector3)(ref val2)).normalized * Random.Range(1f, 2.5f);
			float life = Random.Range(0.3f, 0.6f);
			MelonCoroutines.Start(FlameRoutine(val, velocity, life, num));
		}
	}

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

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

	private void InitSounds()
	{
		string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		string text = Path.Combine(directoryName, "HakariSounds");
		((MelonBase)this).LoggerInstance.Msg("HakariMod: DLL лежит здесь: " + directoryName);
		((MelonBase)this).LoggerInstance.Msg("HakariMod: ищу звуки в: " + text);
		if (!Directory.Exists(text))
		{
			Directory.CreateDirectory(text);
			((MelonBase)this).LoggerInstance.Warning("HakariMod: папка HakariSounds отсутствовала, создана пустая.");
		}
		string text2 = Path.Combine(text, "charge_start.wav");
		if (File.Exists(text2))
		{
			chargeSoundPath = text2;
			((MelonBase)this).LoggerInstance.Msg("HakariMod: звук заряда найден: " + text2);
		}
		else
		{
			((MelonBase)this).LoggerInstance.Warning("HakariMod: charge_start.wav не найден в " + text + ". Звука заряда не будет.");
		}
		string text3 = Path.Combine(text, "Doors.wav");
		if (File.Exists(text3))
		{
			doorSoundPath = text3;
			((MelonBase)this).LoggerInstance.Msg("HakariMod: звук дверей найден: " + text3);
		}
		else
		{
			((MelonBase)this).LoggerInstance.Warning("HakariMod: Doors.wav не найден в " + text + ". Звука дверей не будет.");
		}
		string text4 = Path.Combine(text, "Ball.wav");
		if (File.Exists(text4))
		{
			ballSoundPath = text4;
			((MelonBase)this).LoggerInstance.Msg("HakariMod: звук шарика найден: " + text4);
		}
		else
		{
			((MelonBase)this).LoggerInstance.Warning("HakariMod: Ball.wav не найден в " + text + ". Звука шарика не будет.");
		}
	}

	private void PlayWav(string path)
	{
		if (string.IsNullOrEmpty(path))
		{
			return;
		}
		try
		{
			PlaySound(path, IntPtr.Zero, 131075);
		}
		catch (Exception ex)
		{
			((MelonBase)this).LoggerInstance.Warning("HakariMod: ошибка PlaySound: " + ex.Message);
		}
	}

	private void ActivateDoors()
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: 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_00c2: 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_00cc: 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_00d5: 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)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: 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_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: 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_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)rightHand == (Object)null))
		{
			doorActive = true;
			PlayWav(doorSoundPath);
			Transform transform = ((Component)rightHand).transform;
			Vector3 forward = transform.forward;
			forward.y = 0f;
			if (((Vector3)(ref forward)).sqrMagnitude < 0.001f)
			{
				forward = Vector3.forward;
			}
			((Vector3)(ref forward)).Normalize();
			Vector3 val = Vector3.Cross(Vector3.up, forward);
			Vector3 val2 = ((Vector3)(ref val)).normalized;
			if (((Vector3)(ref val2)).sqrMagnitude < 0.001f)
			{
				val2 = Vector3.right;
			}
			Vector3 val3 = transform.position + forward * 1.6f;
			val3.y += -0.1f;
			Quaternion val4 = Quaternion.LookRotation(val2, Vector3.up);
			GameObject leftDoor = CreateDoor("TrainDoorLeft", val3 - val2 * 1.5f, val4, isLeftDoor: true);
			GameObject rightDoor = CreateDoor("TrainDoorRight", val3 + val2 * 1.5f, val4, isLeftDoor: false);
			MelonCoroutines.Start(DoorLifecycleRoutine(leftDoor, rightDoor, val3, val2, val4));
		}
	}

	private GameObject CreateDoor(string name, Vector3 position, Quaternion rotation, bool isLeftDoor)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.transform.position = position;
		val.transform.rotation = rotation;
		val.transform.localScale = new Vector3(2.2f, 0.05f, 0.8f);
		Rigidbody val2 = val.AddComponent<Rigidbody>();
		val2.isKinematic = true;
		val2.useGravity = false;
		BoxCollider val3 = val.AddComponent<BoxCollider>();
		val3.size = Vector3.one;
		((Collider)val3).isTrigger = false;
		AddDoorParts(val);
		AddDoorHandles(val, isLeftDoor);
		AddGreenStripes(val);
		return val;
	}

	private void AddDoorParts(GameObject door)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: 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_00b1: 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)
		AddDoorPart(door, new Vector3(-0.45f, 0f, 0f), new Vector3(0.1f, 1f, 1f), "DoorPart_EndBar");
		AddDoorPart(door, new Vector3(-0.1f, 0f, -0.375f), new Vector3(0.6f, 1f, 0.25f), "DoorPart_WindowLeft");
		AddDoorPart(door, new Vector3(-0.1f, 0f, 0.375f), new Vector3(0.6f, 1f, 0.25f), "DoorPart_WindowRight");
		AddDoorPart(door, new Vector3(0.35f, 0f, 0f), new Vector3(0.3f, 1f, 1f), "DoorPart_Bottom");
	}

	private void AddDoorPart(GameObject door, Vector3 localPosition, Vector3 localScale, string partName)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Expected O, but got Unknown
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
		((Object)val).name = partName;
		val.transform.SetParent(door.transform);
		val.transform.localPosition = localPosition;
		val.transform.localRotation = Quaternion.identity;
		val.transform.localScale = localScale;
		Renderer component = val.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader val2 = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard");
			if ((Object)(object)val2 != (Object)null)
			{
				component.material = new Material(val2);
				component.material.color = new Color(0.45f, 0.45f, 0.45f, 0f);
				SetupTransparent(component.material);
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
		Collider component2 = val.GetComponent<Collider>();
		if ((Object)(object)component2 != (Object)null)
		{
			Object.Destroy((Object)(object)component2);
		}
	}

	private void AddDoorHandles(GameObject door, bool isLeftDoor)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		float num = (isLeftDoor ? 0.35f : (-0.35f));
		AddDoorHandle(door, new Vector3(-0.1f, 0.9f, num), new Vector3(0.15f, 0.2f, 0.08f));
	}

	private void AddDoorHandle(GameObject door, Vector3 localPosition, Vector3 localScale)
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: 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_00ab: Expected O, but got Unknown
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
		((Object)val).name = "DoorHandle";
		val.transform.SetParent(door.transform);
		val.transform.localPosition = localPosition;
		val.transform.localRotation = Quaternion.identity;
		val.transform.localScale = localScale;
		Renderer component = val.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader val2 = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard");
			if ((Object)(object)val2 != (Object)null)
			{
				component.material = new Material(val2);
				component.material.color = new Color(0.05f, 0.05f, 0.05f, 0f);
				SetupTransparent(component.material);
				component.material.renderQueue = 3100;
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
		Collider component2 = val.GetComponent<Collider>();
		if ((Object)(object)component2 != (Object)null)
		{
			Object.Destroy((Object)(object)component2);
		}
	}

	private void AddGreenStripes(GameObject door)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: 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_00b1: 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)
		AddGreenStripe(door, new Vector3(0.45f, 0.55f, 0f), new Vector3(0.1f, 0.1f, 1f), "Stripe_Top");
		AddGreenStripe(door, new Vector3(0.45f, -0.55f, 0f), new Vector3(0.1f, 0.1f, 1f), "Stripe_Bottom");
		AddGreenStripe(door, new Vector3(0.45f, 0f, -0.45f), new Vector3(0.1f, 1f, 0.1f), "Stripe_Left");
		AddGreenStripe(door, new Vector3(0.45f, 0f, 0.45f), new Vector3(0.1f, 1f, 0.1f), "Stripe_Right");
	}

	private void AddGreenStripe(GameObject door, Vector3 localPosition, Vector3 localScale, string stripeName)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Expected O, but got Unknown
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
		((Object)val).name = stripeName;
		val.transform.SetParent(door.transform);
		val.transform.localPosition = localPosition;
		val.transform.localRotation = Quaternion.identity;
		val.transform.localScale = localScale;
		Renderer component = val.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader val2 = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard");
			if ((Object)(object)val2 != (Object)null)
			{
				component.material = new Material(val2);
				component.material.color = new Color(0.1f, 0.6f, 0.1f, 0f);
				SetupTransparent(component.material);
				component.material.renderQueue = 3100;
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
		Collider component2 = val.GetComponent<Collider>();
		if ((Object)(object)component2 != (Object)null)
		{
			Object.Destroy((Object)(object)component2);
		}
	}

	private void SetDoorsTransparency(GameObject leftDoor, GameObject rightDoor, float alpha)
	{
		SetDoorTransparency(leftDoor, alpha);
		SetDoorTransparency(rightDoor, alpha);
	}

	private void SetDoorTransparency(GameObject door, float alpha)
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)door == (Object)null)
		{
			return;
		}
		for (int i = 0; i < door.transform.childCount; i++)
		{
			Transform child = door.transform.GetChild(i);
			Renderer component = ((Component)child).GetComponent<Renderer>();
			if ((Object)(object)component != (Object)null && (Object)(object)component.material != (Object)null)
			{
				Color color = component.material.color;
				color.a = alpha;
				component.material.color = color;
			}
		}
	}

	private IEnumerator DoorLifecycleRoutine(GameObject leftDoor, GameObject rightDoor, Vector3 doorCenter, Vector3 rightDirection, Quaternion doorRotation)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)leftDoor == (Object)null || (Object)(object)rightDoor == (Object)null)
		{
			doorActive = false;
			yield break;
		}
		Rigidbody leftRb = leftDoor.GetComponent<Rigidbody>();
		Rigidbody rightRb = rightDoor.GetComponent<Rigidbody>();
		HashSet<Rigidbody> doorRigidbodies = new HashSet<Rigidbody>();
		if ((Object)(object)leftRb != (Object)null)
		{
			doorRigidbodies.Add(leftRb);
		}
		if ((Object)(object)rightRb != (Object)null)
		{
			doorRigidbodies.Add(rightRb);
		}
		Vector3 leftStart = leftDoor.transform.position;
		Vector3 rightStart = rightDoor.transform.position;
		float halfDepth = 0.4f;
		Vector3 leftTarget = doorCenter - rightDirection * halfDepth;
		Vector3 rightTarget = doorCenter + rightDirection * halfDepth;
		bool hasFractured = false;
		SpawnDoorSparksForDoor(leftStart, doorRotation);
		SpawnDoorSparksForDoor(rightStart, doorRotation);
		float elapsed = 0f;
		while (elapsed < 0.4f && (Object)(object)leftDoor != (Object)null && (Object)(object)rightDoor != (Object)null)
		{
			float t = Mathf.Clamp01(elapsed / 0.4f);
			Vector3 leftPos = Vector3.Lerp(leftStart, leftTarget, t);
			Vector3 rightPos = Vector3.Lerp(rightStart, rightTarget, t);
			if ((Object)(object)leftRb != (Object)null)
			{
				leftRb.MovePosition(leftPos);
			}
			if ((Object)(object)rightRb != (Object)null)
			{
				rightRb.MovePosition(rightPos);
			}
			leftDoor.transform.rotation = doorRotation;
			rightDoor.transform.rotation = doorRotation;
			float alpha = Mathf.Lerp(0f, 1f, t);
			SetDoorsTransparency(leftDoor, rightDoor, alpha);
			if (!hasFractured && t >= 0.75f)
			{
				int fracturedCount = FractureBodyPartsInZone(doorCenter, doorRotation, doorRigidbodies);
				hasFractured = fracturedCount > 0;
			}
			elapsed += Time.deltaTime;
			yield return null;
		}
		if ((Object)(object)leftDoor != (Object)null && (Object)(object)rightDoor != (Object)null)
		{
			SetDoorsTransparency(leftDoor, rightDoor, 1f);
			if ((Object)(object)leftRb != (Object)null)
			{
				leftRb.MovePosition(leftTarget);
			}
			if ((Object)(object)rightRb != (Object)null)
			{
				rightRb.MovePosition(rightTarget);
			}
			leftDoor.transform.rotation = doorRotation;
			rightDoor.transform.rotation = doorRotation;
		}
		float holdTime = (hasFractured ? 0.5f : 5f);
		elapsed = 0f;
		while (elapsed < holdTime && (Object)(object)leftDoor != (Object)null && (Object)(object)rightDoor != (Object)null)
		{
			elapsed += Time.deltaTime;
			yield return null;
		}
		elapsed = 0f;
		while (elapsed < 0.2f && (Object)(object)leftDoor != (Object)null && (Object)(object)rightDoor != (Object)null)
		{
			float t2 = Mathf.Clamp01(elapsed / 0.2f);
			Vector3 leftPos2 = Vector3.Lerp(leftTarget, leftStart, t2);
			Vector3 rightPos2 = Vector3.Lerp(rightTarget, rightStart, t2);
			if ((Object)(object)leftRb != (Object)null)
			{
				leftRb.MovePosition(leftPos2);
			}
			if ((Object)(object)rightRb != (Object)null)
			{
				rightRb.MovePosition(rightPos2);
			}
			leftDoor.transform.rotation = doorRotation;
			rightDoor.transform.rotation = doorRotation;
			float alpha2 = Mathf.Lerp(1f, 0f, t2);
			SetDoorsTransparency(leftDoor, rightDoor, alpha2);
			elapsed += Time.deltaTime;
			yield return null;
		}
		if ((Object)(object)leftDoor != (Object)null)
		{
			Object.Destroy((Object)(object)leftDoor);
		}
		if ((Object)(object)rightDoor != (Object)null)
		{
			Object.Destroy((Object)(object)rightDoor);
		}
		doorActive = false;
	}

	private int FractureBodyPartsInZone(Vector3 center, Quaternion doorRotation, HashSet<Rigidbody> doorRigidbodies)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(0.75f, 0.15f, 0.3f);
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapBox(center, val, doorRotation));
		if (array.Length == 0)
		{
			return 0;
		}
		HashSet<GameObject> hashSet = new HashSet<GameObject>();
		List<GameObject> list = new List<GameObject>();
		List<GameObject> list2 = new List<GameObject>();
		Collider[] array2 = array;
		foreach (Collider val2 in array2)
		{
			if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).gameObject == (Object)null)
			{
				continue;
			}
			try
			{
				HVRGrabbable componentInParent = ((Component)val2).GetComponentInParent<HVRGrabbable>();
				if ((Object)(object)componentInParent == (Object)null)
				{
					continue;
				}
				GameObject gameObject = ((Component)componentInParent).gameObject;
				if (hashSet.Contains(gameObject))
				{
					continue;
				}
				string name = ((Object)gameObject).name;
				if (IsBodyPart(name) && IsPositionInsideDoorZone(gameObject.transform.position, center, doorRotation, val))
				{
					hashSet.Add(gameObject);
					if (IsTorsoPart(name))
					{
						list.Add(gameObject);
					}
					else
					{
						list2.Add(gameObject);
					}
				}
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("HakariMod: FractureBodyPartsInZone error: " + ex.Message);
			}
		}
		List<GameObject> list3 = new List<GameObject>();
		if (list.Count > 0)
		{
			ShuffleList(list);
			int num = Mathf.Min(1, list.Count);
			for (int j = 0; j < num; j++)
			{
				list3.Add(list[j]);
			}
		}
		int num2 = 3 - list3.Count;
		if (num2 > 0 && list2.Count > 0)
		{
			ShuffleList(list2);
			int num3 = Mathf.Min(num2, list2.Count);
			for (int k = 0; k < num3; k++)
			{
				list3.Add(list2[k]);
			}
		}
		int num4 = 0;
		foreach (GameObject item in list3)
		{
			if (!((Object)(object)item == (Object)null))
			{
				string name2 = ((Object)item).name;
				FractureBodyPart(item, name2, center, doorRigidbodies);
				num4++;
			}
		}
		return num4;
	}

	private void FractureBodyPart(GameObject grabbableObj, string partName, Vector3 fractureCenter, HashSet<Rigidbody> doorRigidbodies)
	{
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			SliceOnInputCustom component = grabbableObj.GetComponent<SliceOnInputCustom>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			if (partName != "Head" && partName != "Pelvis")
			{
				TransferJointsOnFractureCustom componentInParent = ((Component)component).GetComponentInParent<TransferJointsOnFractureCustom>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					componentInParent.DistanceTolerance = 0f;
				}
			}
			component.ForceFracture();
			if (IsUpperBodyPart(partName))
			{
				LaunchUpperBodyUp(fractureCenter, doorRigidbodies);
			}
			ApplyDamageToEnemy(grabbableObj, partName);
		}
		catch (Exception ex)
		{
			((MelonBase)this).LoggerInstance.Warning("HakariMod: FractureBodyPart error для " + partName + ": " + ex.Message);
		}
	}

	private void LaunchUpperBodyUp(Vector3 fractureCenter, HashSet<Rigidbody> doorRigidbodies)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(fractureCenter, 1.5f));
			HashSet<Rigidbody> hashSet = new HashSet<Rigidbody>();
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null))
				{
					Rigidbody val2 = ((Component)val).GetComponent<Rigidbody>();
					if ((Object)(object)val2 == (Object)null)
					{
						val2 = ((Component)val).GetComponentInParent<Rigidbody>();
					}
					if (!((Object)(object)val2 == (Object)null) && (doorRigidbodies == null || !doorRigidbodies.Contains(val2)) && !hashSet.Contains(val2) && !val2.isKinematic && !(val2.position.y <= fractureCenter.y))
					{
						hashSet.Add(val2);
						Vector3 val3 = Vector3.up + new Vector3(Random.Range(-0.15f, 0.15f), 0f, Random.Range(-0.15f, 0.15f));
						((Vector3)(ref val3)).Normalize();
						val2.AddForce(val3 * 10f, (ForceMode)1);
					}
				}
			}
		}
		catch (Exception ex)
		{
			((MelonBase)this).LoggerInstance.Warning("HakariMod: LaunchUpperBodyUp error: " + ex.Message);
		}
	}

	private void SpawnHakariBall()
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: 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_005b: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)rightHand == (Object)null || Time.time - lastBallSpawnTime < 3f)
		{
			return;
		}
		Transform transform = ((Component)rightHand).transform;
		Vector3 position = transform.position + transform.forward * 0.15f;
		bool flag = Random.value < 0.2f;
		GameObject val = CreateHakariBall(position, flag);
		if ((Object)(object)val != (Object)null)
		{
			Rigidbody component = val.GetComponent<Rigidbody>();
			Collider component2 = val.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				component.isKinematic = true;
				component.velocity = Vector3.zero;
			}
			if ((Object)(object)component2 != (Object)null)
			{
				component2.enabled = false;
			}
			if (flag)
			{
				goldenBallIds.Add(((Object)val).GetInstanceID());
			}
			heldBall = val;
			activeBalls.Add(val);
			SpawnBallSparks(position, flag);
			lastBallSpawnTime = Time.time;
		}
	}

	private void ThrowHakariBall()
	{
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)heldBall == (Object)null)
		{
			return;
		}
		Rigidbody component = heldBall.GetComponent<Rigidbody>();
		Collider component2 = heldBall.GetComponent<Collider>();
		if ((Object)(object)component == (Object)null || (Object)(object)rightHand == (Object)null)
		{
			heldBall = null;
			return;
		}
		PlayWav(ballSoundPath);
		Transform transform = ((Component)rightHand).transform;
		Vector3 forward = transform.forward;
		if (((Vector3)(ref forward)).sqrMagnitude < 0.001f)
		{
			forward = Vector3.forward;
		}
		((Vector3)(ref forward)).Normalize();
		if ((Object)(object)component2 != (Object)null)
		{
			component2.enabled = true;
		}
		component.isKinematic = false;
		component.mass = 6f;
		component.velocity = forward * 60f;
		ballCreationTimes[heldBall] = Time.time;
		ballTrailLastSpawnTimes[heldBall] = Time.time;
		Object.Destroy((Object)(object)heldBall, 3f);
		heldBall = null;
	}

	private GameObject CreateHakariBall(Vector3 position, bool isGolden)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Expected O, but got Unknown
		//IL_00ee: 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)
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
		((Object)val).name = (isGolden ? "HakariBall_Golden" : "HakariBall");
		val.transform.position = position;
		val.transform.localScale = new Vector3(0.07f, 0.07f, 0.07f);
		Renderer component = val.GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Shader val2 = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard");
			if ((Object)(object)val2 != (Object)null)
			{
				component.material = new Material(val2);
				if (isGolden)
				{
					component.material.color = new Color(1f, 0.84f, 0f, 1f);
				}
				else
				{
					component.material.color = new Color(0.75f, 0.75f, 0.8f, 1f);
				}
			}
			component.shadowCastingMode = (ShadowCastingMode)0;
			component.receiveShadows = false;
		}
		Rigidbody val3 = val.AddComponent<Rigidbody>();
		val3.useGravity = true;
		val3.mass = 6f;
		val3.collisionDetectionMode = (CollisionDetectionMode)2;
		val3.interpolation = (RigidbodyInterpolation)1;
		return val;
	}

	private void UpdateActiveBalls()
	{
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_0298: 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)
		//IL_0348: Unknown result type (might be due to invalid IL or missing references)
		if (activeBalls == null || activeBalls.Count == 0)
		{
			return;
		}
		List<GameObject> list = new List<GameObject>(activeBalls);
		foreach (GameObject item in list)
		{
			if ((Object)(object)item == (Object)null)
			{
				activeBalls.Remove(item);
				ballCreationTimes.Remove(item);
				ballLastHitTimes.Remove(item);
				ballTrailLastSpawnTimes.Remove(item);
				if ((Object)(object)heldBall == (Object)(object)item)
				{
					heldBall = null;
				}
			}
			else
			{
				if ((Object)(object)item == (Object)(object)heldBall)
				{
					continue;
				}
				Rigidbody component = item.GetComponent<Rigidbody>();
				if ((Object)(object)component == (Object)null)
				{
					goldenBallIds.Remove(((Object)item).GetInstanceID());
					activeBalls.Remove(item);
					ballCreationTimes.Remove(item);
					ballLastHitTimes.Remove(item);
					ballTrailLastSpawnTimes.Remove(item);
					continue;
				}
				float num = (ballCreationTimes.ContainsKey(item) ? ballCreationTimes[item] : Time.time);
				if (Time.time - num > 3f)
				{
					goldenBallIds.Remove(((Object)item).GetInstanceID());
					Object.Destroy((Object)(object)item);
					activeBalls.Remove(item);
					ballCreationTimes.Remove(item);
					ballLastHitTimes.Remove(item);
					ballTrailLastSpawnTimes.Remove(item);
					continue;
				}
				bool flag = goldenBallIds.Contains(((Object)item).GetInstanceID());
				float num2 = (ballTrailLastSpawnTimes.ContainsKey(item) ? ballTrailLastSpawnTimes[item] : Time.time);
				if (Time.time - num2 >= 0.1f)
				{
					ballTrailLastSpawnTimes[item] = Time.time;
					SpawnTrailSpark(item.transform.position, flag);
				}
				Vector3 velocity = component.velocity;
				float magnitude = ((Vector3)(ref velocity)).magnitude;
				if (!(magnitude > 2f))
				{
					continue;
				}
				float num3 = (ballLastHitTimes.ContainsKey(item) ? ballLastHitTimes[item] : (-1f));
				if (!(Time.time - num3 > 0.3f))
				{
					continue;
				}
				float num4 = (flag ? 0.285f : 0.135f);
				Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(item.transform.position, num4));
				Collider[] array2 = array;
				foreach (Collider val in array2)
				{
					if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null || IsPlayer(((Component)val).gameObject))
					{
						continue;
					}
					HVRGrabbable componentInParent = ((Component)val).GetComponentInParent<HVRGrabbable>();
					if ((Object)(object)componentInParent == (Object)null)
					{
						continue;
					}
					GameObject gameObject = ((Component)componentInParent).gameObject;
					if (IsBodyPart(((Object)gameObject).name))
					{
						if (flag)
						{
							ApplyGoldenBallDamage(gameObject, item.transform.position);
						}
						else
						{
							ApplyBallDamageToEnemy(gameObject, item.transform.position, component.velocity);
						}
						ballLastHitTimes[item] = Time.time;
						break;
					}
				}
			}
		}
	}

	private void ApplyBallDamageToEnemy(GameObject bodyPartObj, Vector3 hitPosition, Vector3 ballVelocity)
	{
		//IL_0091: 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)
		try
		{
			StickHealth componentInParent = bodyPartObj.GetComponentInParent<StickHealth>();
			if (!((Object)(object)componentInParent == (Object)null))
			{
				ColliderBridge component = bodyPartObj.GetComponent<ColliderBridge>();
				string text = "torso";
				if ((Object)(object)component != (Object)null && !string.IsNullOrEmpty(component.damageRegion))
				{
					text = component.damageRegion;
				}
				float num = ((Vector3)(ref ballVelocity)).magnitude * 1.67f;
				componentInParent.ReceivedGeneralDamage(num, (DamageType)4, text, component);
				Rigidbody component2 = bodyPartObj.GetComponent<Rigidbody>();
				if ((Object)(object)component2 != (Object)null && !component2.isKinematic)
				{
					component2.AddForce(((Vector3)(ref ballVelocity)).normalized * 3f, (ForceMode)1);
				}
			}
		}
		catch (Exception ex)
		{
			((MelonBase)this).LoggerInstance.Warning("HakariMod: ApplyBallDamageToEnemy error: " + ex.Message);
		}
	}

	private void ApplyGoldenBallDamage(GameObject bodyPartObj, Vector3 hitPosition)
	{
		try
		{
			string name = ((Object)bodyPartObj).name;
			SliceOnInputCustom val = FindSliceOnInputCustom(bodyPartObj);
			if ((Object)(object)val != (Object)null)
			{
				if (name != "Head" && name != "Pelvis")
				{
					TransferJointsOnFractureCustom componentInParent = ((Component)val).GetComponentInParent<TransferJointsOnFractureCustom>();
					if ((Object)(object)componentInParent != (Object)null)
					{
						componentInParent.DistanceTolerance = 0f;
					}
				}
				val.ForceFracture();
			}
			else
			{
				TryAlternativeFracture(bodyPartObj);
			}
			StickHealth componentInParent2 = bodyPartObj.GetComponentInParent<StickHealth>();
			if ((Object)(object)componentInParent2 != (Object)null)
			{
				ColliderBridge component = bodyPartObj.GetComponent<ColliderBridge>();
				string text = "torso";
				if ((Object)(object)component != (Object)null && !string.IsNullOrEmpty(component.damageRegion))
				{
					text = component.damageRegion;
				}
				componentInParent2.DismemberDetected(120f, (DamageType)1, text, component);
			}
		}
		catch (Exception ex)
		{
			((MelonBase)this).LoggerInstance.Warning("HakariMod: ApplyGoldenBallDamage error: " + ex.Message);
		}
	}

	private SliceOnInputCustom FindSliceOnInputCustom(GameObject obj)
	{
		if ((Object)(object)obj == (Object)null)
		{
			return null;
		}
		SliceOnInputCustom component = obj.GetComponent<SliceOnInputCustom>();
		if ((Object)(object)component != (Object)null)
		{
			return component;
		}
		component = obj.GetComponentInParent<SliceOnInputCustom>();
		if ((Object)(object)component != (Object)null)
		{
			return component;
		}
		component = obj.GetComponentInChildren<SliceOnInputCustom>();
		if ((Object)(object)component != (Object)null)
		{
			return component;
		}
		return null;
	}

	private void TryAlternativeFracture(GameObject bodyPartObj)
	{
		try
		{
			SliceOnInputCustom[] array = Il2CppArrayBase<SliceOnInputCustom>.op_Implicit(bodyPartObj.GetComponentsInChildren<SliceOnInputCustom>());
			if (array == null || array.Length == 0)
			{
				return;
			}
			SliceOnInputCustom val = array[0];
			string name = ((Object)((Component)val).gameObject).name;
			if (name != "Head" && name != "Pelvis")
			{
				TransferJointsOnFractureCustom componentInParent = ((Component)val).GetComponentInParent<TransferJointsOnFractureCustom>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					componentInParent.DistanceTolerance = 0f;
				}
			}
			val.ForceFracture();
		}
		catch (Exception ex)
		{
			((MelonBase)this).LoggerInstance.Warning("HakariMod: TryAlternativeFracture error: " + ex.Message);
		}
	}

	private void UpdateSparks()
	{
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: 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)
		if (activeSparkRenderers == null || activeSparkRenderers.Count == 0)
		{
			return;
		}
		Camera main = Camera.main;
		Transform val = (((Object)(object)main != (Object)null) ? ((Component)main).transform : null);
		for (int num = activeSparkRenderers.Count - 1; num >= 0; num--)
		{
			Renderer val2 = activeSparkRenderers[num];
			if ((Object)(object)val2 == (Object)null || (Object)(object)val2.material == (Object)null)
			{
				RemoveSparkAt(num);
			}
			else
			{
				float num2 = sparkPhaseOffsets[num];
				float num3 = sparkCreationTimes[num];
				int num4 = sparkTypes[num];
				float num5 = Time.time - num3;
				float num6;
				float num7;
				float num8;
				switch (num4)
				{
				case 0:
					num6 = 0.05f;
					num7 = 0.4f;
					num8 = 0.7f;
					break;
				case 2:
					num6 = 0.05f;
					num7 = 0.3f;
					num8 = 0.5f;
					break;
				default:
					num6 = 0.05f;
					num7 = 0.3f;
					num8 = 0.5f;
					break;
				}
				float num9;
				if (num5 < num6)
				{
					num9 = num5 / num6;
				}
				else if (num5 > num8 - num7)
				{
					float num10 = (num5 - (num8 - num7)) / num7;
					num9 = 1f - Mathf.Clamp01(num10);
				}
				else
				{
					num9 = 1f;
				}
				float num11 = 0.7f + 0.3f * Mathf.Sin(Time.time * 8f + num2);
				num9 *= num11;
				Color color = val2.material.color;
				color.a = num9;
				val2.material.color = color;
				if (num < activeSparkObjects.Count)
				{
					GameObject val3 = activeSparkObjects[num];
					if ((Object)(object)val3 != (Object)null)
					{
						Transform transform = val3.transform;
						if ((Object)(object)val != (Object)null)
						{
							transform.LookAt(val.position);
						}
						if (num4 != 2)
						{
							float num12 = Mathf.Sin(Time.time * 2f + num2) * 0.1f * Time.deltaTime;
							float num13 = Mathf.Cos(Time.time * 2f * 0.7f + num2) * 0.1f * Time.deltaTime;
							transform.position += new Vector3(num12, 0f, num13);
						}
					}
					else
					{
						RemoveSparkAt(num);
					}
				}
			}
		}
	}

	private void RemoveSparkAt(int index)
	{
		if (index < activeSparkRenderers.Count)
		{
			activeSparkRenderers.RemoveAt(index);
		}
		if (index < sparkPhaseOffsets.Count)
		{
			sparkPhaseOffsets.RemoveAt(index);
		}
		if (index < activeSparkObjects.Count)
		{
			activeSparkObjects.RemoveAt(index);
		}
		if (index < sparkCreationTimes.Count)
		{
			sparkCreationTimes.RemoveAt(index);
		}
		if (index < sparkTypes.Count)
		{
			sparkTypes.RemoveAt(index);
		}
		if (index < sparkStretchDirs.Count)
		{
			sparkStretchDirs.RemoveAt(index);
		}
	}

	private Texture2D CreateStarTexture(int size)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
		for (int i = 0; i < size; i++)
		{
			for (int j = 0; j < size; j++)
			{
				float num = (float)i / (float)size - 0.5f;
				float num2 = (float)j / (float)size - 0.5f;
				float num3 = Mathf.Sqrt(num * num + num2 * num2);
				float num4 = Mathf.Atan2(num2, num);
				float num5 = 0.5f;
				float num6 = Mathf.Abs(Mathf.Cos(num4));
				float num7 = Mathf.Abs(Mathf.Sin(num4));
				float num8 = 1f / Mathf.Pow(Mathf.Pow(num6, num5) + Mathf.Pow(num7, num5), 1f / num5);
				float num9 = num8 * 0.5f;
				float num10 = Mathf.Abs(num) + Mathf.Abs(num2);
				float num11 = 0.15f;
				float num12 = Mathf.Clamp01((num9 - num3) / 0.03f);
				float num13 = Mathf.Clamp01((num11 - num10) / 0.03f);
				float num14 = Mathf.Max(num12, num13);
				float num15 = ((num13 > 0.5f) ? 1f : 0.85f);
				val.SetPixel(i, j, new Color(num15, num15, num15, num14));
			}
		}
		val.Apply();
		return val;
	}

	private void CreateSparkAtPosition(Vector3 position, Quaternion rotation, Color sparkColor, float sparkSize, float sparkLifetime, int sparkType, Vector3 stretchDir, bool createLight)
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: 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_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02db: Expected O, but got Unknown
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Expected O, but got Unknown
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if ((Object)(object)cachedStarTexture == (Object)null)
			{
				cachedStarTexture = CreateStarTexture(128);
			}
			GameObject val = new GameObject("StarSpark");
			val.transform.position = position;
			val.transform.rotation = rotation;
			Rigidbody val2 = val.AddComponent<Rigidbody>();
			val2.useGravity = false;
			val2.mass = 0.01f;
			val2.drag = 5f;
			val2.velocity = new Vector3(0f, -0.02f, 0f);
			GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)5);
			((Object)val3).name = "StarQuad";
			val3.transform.SetParent(val.transform);
			val3.transform.localPosition = Vector3.zero;
			val3.transform.localRotation = Quaternion.identity;
			val3.transform.localScale = new Vector3(sparkSize, sparkSize, sparkSize);
			Collider component = val3.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			Renderer component2 = val3.GetComponent<Renderer>();
			if ((Object)(object)component2 != (Object)null)
			{
				Shader val4 = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Transparent") ?? Shader.Find("Standard");
				if ((Object)(object)val4 != (Object)null)
				{
					component2.material = new Material(val4);
					component2.material.mainTexture = (Texture)(object)cachedStarTexture;
					component2.material.color = new Color(sparkColor.r, sparkColor.g, sparkColor.b, 0f);
					if (component2.material.HasProperty("_SrcBlend"))
					{
						component2.material.SetInt("_SrcBlend", 1);
					}
					if (component2.material.HasProperty("_DstBlend"))
					{
						component2.material.SetInt("_DstBlend", 1);
					}
					if (component2.material.HasProperty("_ZWrite"))
					{
						component2.material.SetInt("_ZWrite", 0);
					}
					if (component2.material.HasProperty("_Cull"))
					{
						component2.material.SetInt("_Cull", 0);
					}
				}
				component2.shadowCastingMode = (ShadowCastingMode)0;
				component2.receiveShadows = false;
				activeSparkRenderers.Add(component2);
				sparkPhaseOffsets.Add(Random.Range(0f, (float)Math.PI * 2f));
				activeSparkObjects.Add(val);
				sparkCreationTimes.Add(Time.time);
				sparkTypes.Add(sparkType);
				sparkStretchDirs.Add(stretchDir);
			}
			if (createLight)
			{
				GameObject val5 = new GameObject("SparkLight");
				val5.transform.SetParent(val.transform);
				val5.transform.localPosition = Vector3.zero;
				Light val6 = val5.AddComponent<Light>();
				if ((Object)(object)val6 != (Object)null)
				{
					val6.type = (LightType)2;
					val6.color = sparkColor;
					val6.intensity = 0.15f;
					val6.range = 0.25f;
					val6.shadows = (LightShadows)0;
				}
			}
			Object.Destroy((Object)(object)val, sparkLifetime);
		}
		catch (Exception ex)
		{
			((MelonBase)this).LoggerInstance.Warning("HakariMod: CreateSparkAtPosition error: " + ex.Message);
		}
	}

	private void SpawnDoorSparksForDoor(Vector3 doorPosition, Quaternion doorRotation)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: 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_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = default(Vector3);
		for (int i = 0; i < 20; i++)
		{
			float num = Random.Range(-1.1f, 1.1f);
			float num2 = Random.Range(-0.4f, 0.4f);
			float num3 = 0.045f;
			((Vector3)(ref val))..ctor(num, num3, num2);
			Vector3 position = doorPosition + doorRotation * val;
			CreateSparkAtPosition(position, doorRotation, DOOR_SPARK_COLOR, 0.07f, 0.7f, 0, Vector3.zero, createLight: false);
		}
	}

	private void SpawnBallSparks(Vector3 position, bool isGolden)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		Color sparkColor = (isGolden ? GOLDEN_SPARK_COLOR : SILVER_SPARK_COLOR);
		Vector3 val = default(Vector3);
		for (int i = 0; i < 3; i++)
		{
			((Vector3)(ref val))..ctor(Random.Range(-0.05f, 0.05f), Random.Range(-0.05f, 0.05f), Random.Range(-0.05f, 0.05f));
			Vector3 position2 = position + val;
			CreateSparkAtPosition(position2, Quaternion.identity, sparkColor, 0.05f, 0.5f, 1, Vector3.zero, createLight: true);
		}
	}

	private void SpawnTrailSpark(Vector3 position, bool isGolden)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		Color sparkColor = (isGolden ? GOLDEN_SPARK_COLOR : SILVER_SPARK_COLOR);
		CreateSparkAtPosition(position, Quaternion.identity, sparkColor, 0.035f, 0.5f, 2, Vector3.zero, createLight: false);
	}

	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))
		{
			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;
		}
	}

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

	private bool IsBodyPart(string name)
	{
		string[] bodyPartNames = BodyPartNames;
		foreach (string text in bodyPartNames)
		{
			if (name == text)
			{
				return true;
			}
		}
		return false;
	}

	private bool IsTorsoPart(string name)
	{
		string[] torsoPartNames = TorsoPartNames;
		foreach (string text in torsoPartNames)
		{
			if (name == text)
			{
				return true;
			}
		}
		return false;
	}

	private bool IsUpperBodyPart(string name)
	{
		string[] upperBodyPartNames = UpperBodyPartNames;
		foreach (string text in upperBodyPartNames)
		{
			if (name == text)
			{
				return true;
			}
		}
		return false;
	}

	private bool IsPositionInsideDoorZone(Vector3 worldPosition, Vector3 zoneCenter, Quaternion zoneRotation, Vector3 halfExtents)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: 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_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = Quaternion.Inverse(zoneRotation) * (worldPosition - zoneCenter);
		float num = 0.1f;
		float num2 = halfExtents.x + num;
		float num3 = halfExtents.y + num;
		float num4 = halfExtents.z + num;
		bool flag = Mathf.Abs(val.x) <= num2;
		bool flag2 = Mathf.Abs(val.y) <= num3;
		bool flag3 = Mathf.Abs(val.z) <= num4;
		return flag && flag2 && flag3;
	}

	private void ShuffleList(List<GameObject> list)
	{
		for (int num = list.Count - 1; num > 0; num--)
		{
			int index = Random.Range(0, num + 1);
			GameObject value = list[num];
			list[num] = list[index];
			list[index] = value;
		}
	}

	private void ApplyDamageToEnemy(GameObject bodyPartObj, string partName)
	{
		try
		{
			StickHealth componentInParent = bodyPartObj.GetComponentInParent<StickHealth>();
			if (!((Object)(object)componentInParent == (Object)null))
			{
				ColliderBridge component = bodyPartObj.GetComponent<ColliderBridge>();
				string text = "torso";
				if ((Object)(object)component != (Object)null && !string.IsNullOrEmpty(component.damageRegion))
				{
					text = component.damageRegion;
				}
				componentInParent.DismemberDetected(120f, (DamageType)1, text, component);
			}
		}
		catch (Exception ex)
		{
			((MelonBase)this).LoggerInstance.Warning("HakariMod: ApplyDamageToEnemy error для " + partName + ": " + ex.Message);
		}
	}
}