Decompiled source of ArmBlade v1.0.0

ArmBlade.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Il2Cpp;
using Il2CppHurricaneVR.Framework.Core;
using Il2CppHurricaneVR.Framework.Core.Grabbers;
using Il2CppHurricaneVR.Framework.Core.Sockets;
using Il2CppHurricaneVR.Framework.Shared;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MahitoMod;
using MelonLoader;
using UnityEngine;
using UnityEngine.SceneManagement;

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

public class Core : MelonMod
{
	private enum DeployState
	{
		Deploying,
		Deployed,
		Retracting
	}

	private class BladeState
	{
		public HVRHandGrabber hand;

		public bool wasSecondary;

		public GameObject weaponInstance;

		public Rigidbody weaponRb;

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

		public bool active;

		public bool isLeftHand;

		public Vector3 currentPos;

		public Quaternion currentRot;

		public DeployState deployState;

		public float deployProgress;
	}

	private const int SND_ASYNC = 1;

	private const int SND_FILENAME = 131072;

	public static HVRHexaBodyInputs playerInputs;

	private BladeState leftBlade = new BladeState();

	private BladeState rightBlade = new BladeState();

	private GameObject katanaPrefab;

	private float searchTimer = 0f;

	private const float SEARCH_INTERVAL = 2f;

	private const float HANDLE_CUT_THRESHOLD = 0.4f;

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

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

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

	private const float BLADE_LERP_SPEED = 50f;

	private const float MAX_BLADE_SPEED = 36f;

	private const float MAX_ANGULAR_SPEED = 3600f;

	private const float DEPLOY_DISTANCE = 0.5f;

	private const float DEPLOY_ANIM_DURATION = 0.18f;

	private string deploySoundPath;

	private string retractSoundPath;

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

	public override void OnInitializeMelon()
	{
		((MelonBase)this).LoggerInstance.Msg("MahitoMod v3.12.0 — скрытый клинок + звуки.");
		InitSounds();
	}

	private void InitSounds()
	{
		try
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string text = Path.Combine(directoryName, "Sounds");
			deploySoundPath = Path.Combine(text, "DTS.wav");
			retractSoundPath = Path.Combine(text, "TS.wav");
			bool flag = File.Exists(deploySoundPath);
			bool flag2 = File.Exists(retractSoundPath);
			((MelonBase)this).LoggerInstance.Msg("MahitoMod: звук доставания (DTS.wav): " + (flag ? "НАЙДЕН" : "НЕ НАЙДЕН"));
			((MelonBase)this).LoggerInstance.Msg("MahitoMod: звук убирания (TS.wav): " + (flag2 ? "НАЙДЕН" : "НЕ НАЙДЕН"));
			if (!flag || !flag2)
			{
				((MelonBase)this).LoggerInstance.Msg("MahitoMod: ожидаемая папка: " + text);
			}
		}
		catch (Exception ex)
		{
			((MelonBase)this).LoggerInstance.Msg("MahitoMod: ошибка инициализации звуков: " + ex.Message);
		}
	}

	private void PlaySoundFile(string path)
	{
		if (string.IsNullOrEmpty(path))
		{
			return;
		}
		try
		{
			if (File.Exists(path))
			{
				PlaySound(path, IntPtr.Zero, 131073);
			}
		}
		catch
		{
		}
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		DestroyBlade(leftBlade);
		DestroyBlade(rightBlade);
		playerInputs = null;
		katanaPrefab = null;
		searchTimer = 1f;
		leftBlade.isLeftHand = true;
		rightBlade.isLeftHand = false;
		if (!(sceneName == "MainMenuScene"))
		{
			GameObject val = GameObject.Find("Hexa4Rig26.10.23");
			if (!((Object)(object)val == (Object)null))
			{
				playerInputs = val.GetComponentInChildren<HVRHexaBodyInputs>();
				BladeState bladeState = leftBlade;
				Transform obj = val.transform.Find("Physics LeftHand");
				bladeState.hand = ((obj != null) ? ((Component)obj).GetComponent<HVRHandGrabber>() : null);
				BladeState bladeState2 = rightBlade;
				Transform obj2 = val.transform.Find("Physics RightHand");
				bladeState2.hand = ((obj2 != null) ? ((Component)obj2).GetComponent<HVRHandGrabber>() : null);
				((MelonBase)this).LoggerInstance.Msg("MahitoMod: руки найдены. Ищу внутриигровую катану...");
			}
		}
	}

	public override void OnUpdate()
	{
		if (!((Object)(object)playerInputs == (Object)null))
		{
			searchTimer -= Time.deltaTime;
			if (searchTimer <= 0f && (Object)(object)katanaPrefab == (Object)null)
			{
				searchTimer = 2f;
				FindKatanaPrefab();
			}
			HVRController leftController = playerInputs.LeftController;
			HVRController rightController = playerInputs.RightController;
			if (!((Object)(object)leftController == (Object)null) && !((Object)(object)rightController == (Object)null))
			{
				ProcessBlade(leftBlade, leftController);
				ProcessBlade(rightBlade, rightController);
			}
		}
	}

	public override void OnFixedUpdate()
	{
		if (leftBlade.active)
		{
			UpdateWeaponPosition(leftBlade);
		}
		if (rightBlade.active)
		{
			UpdateWeaponPosition(rightBlade);
		}
	}

	private void FindKatanaPrefab()
	{
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Il2CppArrayBase<GameObject> val = Resources.FindObjectsOfTypeAll<GameObject>();
			if (val == null)
			{
				return;
			}
			GameObject val2 = null;
			GameObject val3 = null;
			foreach (GameObject item in val)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				string name = ((Object)item).name;
				if (!name.StartsWith("Katana3") || name.Contains("SpawnableItemInfo"))
				{
					continue;
				}
				string value = "";
				try
				{
					Scene scene = item.scene;
					value = ((Scene)(ref scene)).name ?? "";
				}
				catch
				{
				}
				SharpWeaponManager component = item.GetComponent<SharpWeaponManager>();
				if ((Object)(object)component == (Object)null)
				{
					continue;
				}
				Rigidbody component2 = item.GetComponent<Rigidbody>();
				if (!((Object)(object)component2 == (Object)null))
				{
					if (string.IsNullOrEmpty(value))
					{
						val2 = item;
						break;
					}
					if ((Object)(object)val3 == (Object)null && !IsChildOfShopStand(item.transform))
					{
						val3 = item;
					}
				}
			}
			if ((Object)(object)val2 != (Object)null)
			{
				katanaPrefab = val2;
				((MelonBase)this).LoggerInstance.Msg("MahitoMod: беру ПРЕФАБ Katana3! (" + ((Object)val2).name + ")");
			}
			else if ((Object)(object)val3 != (Object)null)
			{
				katanaPrefab = val3;
				((MelonBase)this).LoggerInstance.Msg("MahitoMod: беру экземпляр Katana3 со сцены (" + ((Object)val3).name + ")");
			}
		}
		catch (Exception ex)
		{
			((MelonBase)this).LoggerInstance.Msg("MahitoMod: ошибка поиска: " + ex.Message);
		}
	}

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

	private void ProcessBlade(BladeState bs, HVRController ctrl)
	{
		//IL_0019: 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_0031: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)bs.hand == (Object)null)
		{
			return;
		}
		bool active = ctrl.TriggerButtonState.Active;
		bool active2 = ctrl.GripButtonState.Active;
		bool active3 = ctrl.SecondaryButtonState.Active;
		bool flag = active3 && !bs.wasSecondary;
		bs.wasSecondary = active3;
		if (!(!flag || ((HVRGrabberBase)bs.hand).IsGrabbing || active || active2))
		{
			if (!bs.active)
			{
				SpawnWeapon(bs);
				PlaySoundFile(deploySoundPath);
			}
			else if (bs.deployState == DeployState.Deployed || bs.deployState == DeployState.Deploying)
			{
				bs.deployState = DeployState.Retracting;
				PlaySoundFile(retractSoundPath);
			}
		}
	}

	private void SpawnWeapon(BladeState bs)
	{
		//IL_0098: 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_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: 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_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_02af: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)katanaPrefab == (Object)null)
		{
			FindKatanaPrefab();
			if ((Object)(object)katanaPrefab == (Object)null)
			{
				((MelonBase)this).LoggerInstance.Warning("MahitoMod: Katana3 не найдена!");
				return;
			}
		}
		GameObject val = Object.Instantiate<GameObject>(katanaPrefab);
		((Object)val).name = "MahitoBlade_" + (bs.isLeftHand ? "L" : "R");
		val.transform.SetParent((Transform)null);
		val.transform.localScale = new Vector3(1f, 1f, 1f);
		HVRTagSocketable component = val.GetComponent<HVRTagSocketable>();
		if ((Object)(object)component != (Object)null)
		{
			Object.Destroy((Object)(object)component);
		}
		HVRStringSocketable component2 = val.GetComponent<HVRStringSocketable>();
		if ((Object)(object)component2 != (Object)null)
		{
			Object.Destroy((Object)(object)component2);
		}
		CutHandleOffMesh(val);
		DisableHandleColliders(val);
		Rigidbody val2 = val.GetComponent<Rigidbody>();
		if ((Object)(object)val2 == (Object)null)
		{
			val2 = val.AddComponent<Rigidbody>();
		}
		val2.isKinematic = true;
		val2.useGravity = false;
		val2.detectCollisions = true;
		val2.interpolation = (RigidbodyInterpolation)1;
		val2.mass = 1.5f;
		val2.collisionDetectionMode = (CollisionDetectionMode)3;
		bs.weaponRb = val2;
		bs.weaponColliders.Clear();
		Collider[] array = Il2CppArrayBase<Collider>.op_Implicit(val.GetComponentsInChildren<Collider>(true));
		if (array != null)
		{
			Collider[] array2 = array;
			foreach (Collider val3 in array2)
			{
				if (!((Object)(object)val3 == (Object)null) && val3.enabled)
				{
					bs.weaponColliders.Add(val3);
				}
			}
		}
		SharpWeaponManager component3 = val.GetComponent<SharpWeaponManager>();
		if ((Object)(object)component3 != (Object)null)
		{
			((Behaviour)component3).enabled = true;
		}
		HVRGrabbable component4 = val.GetComponent<HVRGrabbable>();
		if ((Object)(object)component4 != (Object)null)
		{
			((Behaviour)component4).enabled = false;
		}
		DisableCollisionWithPlayer(bs);
		bs.deployState = DeployState.Deploying;
		bs.deployProgress = 0f;
		Transform transform = ((Component)bs.hand).transform;
		Quaternion val4 = (bs.isLeftHand ? GRIP_ROT_LEFT : GRIP_ROT_RIGHT);
		Vector3 val5 = -transform.forward * 0.5f;
		Vector3 val6 = transform.position + transform.right * GRIP_OFFSET.x + transform.up * GRIP_OFFSET.y + transform.forward * GRIP_OFFSET.z + val5;
		Quaternion val7 = transform.rotation * val4;
		val.transform.position = val6;
		val.transform.rotation = val7;
		bs.currentPos = val6;
		bs.currentRot = val7;
		val.SetActive(true);
		bs.weaponInstance = val;
		bs.active = true;
	}

	private void CutHandleOffMesh(GameObject katanaInstance)
	{
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			MeshFilter val = katanaInstance.GetComponent<MeshFilter>();
			if ((Object)(object)val == (Object)null)
			{
				val = katanaInstance.GetComponentInChildren<MeshFilter>();
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Mesh mesh = val.mesh;
			if ((Object)(object)mesh == (Object)null)
			{
				return;
			}
			Il2CppStructArray<Vector3> vertices = mesh.vertices;
			Vector3[] array = (Vector3[])(object)new Vector3[((Il2CppArrayBase<Vector3>)(object)vertices).Length];
			for (int i = 0; i < ((Il2CppArrayBase<Vector3>)(object)vertices).Length; i++)
			{
				array[i] = ((Il2CppArrayBase<Vector3>)(object)vertices)[i];
			}
			int subMeshCount = mesh.subMeshCount;
			for (int j = 0; j < subMeshCount; j++)
			{
				Il2CppStructArray<int> triangles = mesh.GetTriangles(j);
				List<int> list = new List<int>();
				for (int k = 0; k < ((Il2CppArrayBase<int>)(object)triangles).Length; k++)
				{
					list.Add(((Il2CppArrayBase<int>)(object)triangles)[k]);
				}
				List<int> list2 = new List<int>();
				for (int l = 0; l < list.Count; l += 3)
				{
					int num = list[l];
					int num2 = list[l + 1];
					int num3 = list[l + 2];
					if (!(array[num].y < 0.4f) || !(array[num2].y < 0.4f) || !(array[num3].y < 0.4f))
					{
						list2.Add(num);
						list2.Add(num2);
						list2.Add(num3);
					}
				}
				Il2CppStructArray<int> val2 = new Il2CppStructArray<int>((long)list2.Count);
				for (int m = 0; m < list2.Count; m++)
				{
					((Il2CppArrayBase<int>)(object)val2)[m] = list2[m];
				}
				mesh.SetTriangles(val2, j);
			}
			mesh.RecalculateNormals();
			mesh.RecalculateBounds();
		}
		catch (Exception ex)
		{
			((MelonBase)this).LoggerInstance.Msg("MahitoMod: ошибка выреза меша: " + ex.Message);
		}
	}

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

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

	private void UpdateWeaponPosition(BladeState bs)
	{
		//IL_011f: 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_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: 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_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: 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)
		//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_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: Unknown result type (might be due to invalid IL or missing references)
		//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_022c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: 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_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_0289: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)bs.weaponInstance == (Object)null || (Object)(object)bs.weaponRb == (Object)null || (Object)(object)bs.hand == (Object)null)
		{
			DestroyBlade(bs);
			return;
		}
		float fixedDeltaTime = Time.fixedDeltaTime;
		if (bs.deployState == DeployState.Deploying)
		{
			bs.deployProgress += fixedDeltaTime / 0.18f;
			if (bs.deployProgress >= 1f)
			{
				bs.deployProgress = 1f;
				bs.deployState = DeployState.Deployed;
			}
		}
		else if (bs.deployState == DeployState.Retracting)
		{
			bs.deployProgress -= fixedDeltaTime / 0.18f;
			if (bs.deployProgress <= 0f)
			{
				bs.deployProgress = 0f;
				DestroyBlade(bs);
				return;
			}
		}
		float deployProgress = bs.deployProgress;
		float num = deployProgress * deployProgress * (3f - 2f * deployProgress);
		Transform transform = ((Component)bs.hand).transform;
		Quaternion val = (bs.isLeftHand ? GRIP_ROT_LEFT : GRIP_ROT_RIGHT);
		Vector3 val2 = -transform.forward * (0.5f * (1f - num));
		Vector3 val3 = transform.position + transform.right * GRIP_OFFSET.x + transform.up * GRIP_OFFSET.y + transform.forward * GRIP_OFFSET.z + val2;
		Quaternion val4 = transform.rotation * val;
		Vector3 val5 = Vector3.Lerp(bs.currentPos, val3, 50f * fixedDeltaTime);
		float num2 = Vector3.Distance(bs.currentPos, val5);
		float num3 = 36f * fixedDeltaTime;
		if (num2 > num3)
		{
			Vector3 currentPos = bs.currentPos;
			Vector3 val6 = val5 - bs.currentPos;
			val5 = currentPos + ((Vector3)(ref val6)).normalized * num3;
		}
		bs.currentPos = val5;
		Quaternion val7 = Quaternion.Slerp(bs.currentRot, val4, 50f * fixedDeltaTime);
		float num4 = Quaternion.Angle(bs.currentRot, val7);
		float num5 = 3600f * fixedDeltaTime;
		if (num4 > num5)
		{
			val7 = Quaternion.RotateTowards(bs.currentRot, val7, num5);
		}
		bs.currentRot = val7;
		bs.weaponRb.MovePosition(bs.currentPos);
		bs.weaponRb.MoveRotation(bs.currentRot);
	}

	private void DestroyBlade(BladeState bs)
	{
		if (bs.weaponColliders.Count > 0)
		{
			GameObject val = GameObject.Find("Hexa4Rig26.10.23");
			if ((Object)(object)val != (Object)null)
			{
				Collider[] array = Il2CppArrayBase<Collider>.op_Implicit(val.GetComponentsInChildren<Collider>(true));
				if (array != null)
				{
					foreach (Collider weaponCollider in bs.weaponColliders)
					{
						if ((Object)(object)weaponCollider == (Object)null)
						{
							continue;
						}
						Collider[] array2 = array;
						foreach (Collider val2 in array2)
						{
							if (!((Object)(object)val2 == (Object)null))
							{
								try
								{
									Physics.IgnoreCollision(weaponCollider, val2, false);
								}
								catch
								{
								}
							}
						}
					}
				}
			}
		}
		if ((Object)(object)bs.weaponInstance != (Object)null)
		{
			Object.Destroy((Object)(object)bs.weaponInstance);
		}
		bs.weaponInstance = null;
		bs.weaponRb = null;
		bs.weaponColliders.Clear();
		bs.active = false;
		bs.deployProgress = 0f;
		bs.deployState = DeployState.Deployed;
	}
}