Decompiled source of Telekinesis v0.1.2

Telekinesis.dll

Decompiled 6 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using Il2Cpp;
using Il2CppActiveRagdoll;
using Il2CppDinoFracture;
using Il2CppHexabodyVR.PlayerController;
using Il2CppHurricaneVR.Framework.Core;
using Il2CppHurricaneVR.Framework.Core.Grabbers;
using Il2CppHurricaneVR.Framework.Core.HandPoser;
using Il2CppHurricaneVR.Framework.Core.HandPoser.Data;
using Il2CppHurricaneVR.Framework.Shared;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using Telekinesis;
using UnityEngine;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Telekinesis
{
	internal static class Mci
	{
		public static string LastError;

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

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

		public static bool Open(string alias, string path, float volume)
		{
			Send("close " + alias);
			if (Send("open \"" + path + "\" type waveaudio alias " + alias) != 0)
			{
				return false;
			}
			float num = volume;
			if (num < 0f)
			{
				num = 0f;
			}
			if (num > 1f)
			{
				num = 1f;
			}
			Send("setaudio " + alias + " volume to " + (int)Math.Round(num * 1000f));
			return true;
		}

		public static bool Play(string alias)
		{
			if (Send("seek " + alias + " to start") != 0)
			{
				return false;
			}
			return Send("play " + alias) == 0;
		}

		public static void Close(string alias)
		{
			Send("close " + alias);
		}
	}
	public class Core : MelonMod
	{
		private sealed class Flying
		{
			public StickHealth enemy;

			public Rigidbody rb;

			public Rigidbody[] rbs;

			public float life;
		}

		private sealed class Hold
		{
			public bool active;

			public StickHealth enemy;

			public Rigidbody[] rbs;

			public Vector3[] offsets;

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

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

			public Material bubbleMat;

			public float releaseTimer;
		}

		private const string LogPath = "D:\\BrutalistickVrWork\\Probe\\telekinesis.log";

		private MelonPreferences_Category _cfg;

		private MelonPreferences_Entry<bool> _enabled;

		private MelonPreferences_Entry<float> _range;

		private MelonPreferences_Entry<float> _distance;

		private MelonPreferences_Entry<float> _stiffness;

		private MelonPreferences_Entry<float> _throwForce;

		private MelonPreferences_Entry<bool> _stickDistance;

		private HVRHexaBodyInputs _inputs;

		private HVRHandGrabber _leftHand;

		private HVRHandGrabber _rightHand;

		private Camera _cam;

		private bool _wasGripLeft;

		private bool _wasGripRight;

		private bool _wasTriggerLeft;

		private bool _wasTriggerRight;

		private bool _wasBLeft;

		private bool _wasBRight;

		private readonly Hold _left = new Hold();

		private readonly Hold _right = new Hold();

		private readonly List<Collider> _playerCols = new List<Collider>();

		private float _distLeft = -1f;

		private float _distRight = -1f;

		private Vector3 _lastOriginLeft;

		private Vector3 _lastOriginRight;

		private bool _hasLastLeft;

		private bool _hasLastRight;

		private Vector3 _aimOriginLeft;

		private Vector3 _aimDirLeft = Vector3.forward;

		private Quaternion _aimRotLeft = Quaternion.identity;

		private Vector3 _aimOriginRight;

		private Vector3 _aimDirRight = Vector3.forward;

		private Quaternion _aimRotRight = Quaternion.identity;

		private bool _crouchOff;

		private bool _canCrouchSaved;

		private readonly List<Flying> _flying = new List<Flying>();

		private bool _grabReady;

		private bool _throwReady;

		private static readonly HashSet<string> BodyNames = new HashSet<string>
		{
			"head", "jaw", "neck", "upperchest", "middlechest", "pelvis", "shoulder", "elbow", "hip", "knee",
			"foot", "arm", "leg", "thigh", "calf", "shin"
		};

		public override void OnInitializeMelon()
		{
			_cfg = MelonPreferences.CreateCategory("Telekinesis", "Telekinesis");
			_enabled = _cfg.CreateEntry<bool>("Enabled", true, "Включить телекинез", (string)null, false, false, (ValueValidator)null, (string)null);
			_range = _cfg.CreateEntry<float>("Range", 14f, "Дальность захвата", (string)null, false, false, (ValueValidator)null, (string)null);
			_distance = _cfg.CreateEntry<float>("HoldDistance", 1.4f, "Расстояние удержания", (string)null, false, false, (ValueValidator)null, (string)null);
			_stiffness = _cfg.CreateEntry<float>("Stiffness", 14f, "Жёсткость удержания", (string)null, false, false, (ValueValidator)null, (string)null);
			_throwForce = _cfg.CreateEntry<float>("ThrowForce", 26f, "Сила броска", (string)null, false, false, (ValueValidator)null, (string)null);
			_stickDistance = _cfg.CreateEntry<bool>("StickDistance", true, "Стик меняет дистанцию", (string)null, false, false, (ValueValidator)null, (string)null);
			_cfg.SaveToFile(false);
			string text = Path.Combine(Application.dataPath, "..", "Mods", "Telekinesis");
			Directory.CreateDirectory(text);
			_grabReady = LoadSound(text, "grab.wav", "tele_grab");
			_throwReady = LoadSound(text, "throw.wav", "tele_throw");
			Write("init grab=" + _grabReady + " throw=" + _throwReady);
		}

		private bool LoadSound(string dir, string file, string alias)
		{
			string path = Path.Combine(dir, file);
			if (!File.Exists(path))
			{
				return false;
			}
			bool num = Mci.Open(alias, path, 0.9f);
			if (!num)
			{
				Write("sound open failed " + file + " " + Mci.LastError);
			}
			return num;
		}

		public override void OnApplicationQuit()
		{
			if (_crouchOff)
			{
				try
				{
					((HexaBodyInputsBase)_inputs).CanCrouch = _canCrouchSaved;
				}
				catch
				{
				}
			}
			Mci.Close("tele_grab");
			Mci.Close("tele_throw");
		}

		public override void OnUpdate()
		{
			if (!_enabled.Value)
			{
				return;
			}
			FindPlayer();
			if (!((Object)(object)_inputs == (Object)null))
			{
				if (_playerCols.Count == 0)
				{
					CachePlayerCols();
				}
				HVRController leftController = _inputs.LeftController;
				HVRController rightController = _inputs.RightController;
				bool flag = Button(leftController, grip: true);
				bool flag2 = Button(rightController, grip: true);
				bool flag3 = Button(leftController, grip: false);
				bool flag4 = Button(rightController, grip: false);
				Aim(left: true, out _aimOriginLeft, out _aimDirLeft, out _aimRotLeft);
				Aim(left: false, out _aimOriginRight, out _aimDirRight, out _aimRotRight);
				if (flag && !_wasGripLeft && !flag3 && !_wasTriggerLeft && HandFree(_leftHand))
				{
					_left.releaseTimer = 0f;
					TryGrab(left: true);
				}
				if (flag2 && !_wasGripRight && !flag4 && !_wasTriggerRight && HandFree(_rightHand))
				{
					_right.releaseTimer = 0f;
					TryGrab(left: false);
				}
				if (!flag && _wasGripLeft && _left.active)
				{
					_left.releaseTimer = 0.5f;
				}
				if (!flag2 && _wasGripRight && _right.active)
				{
					_right.releaseTimer = 0.5f;
				}
				if (flag3 && !_wasTriggerLeft && _left.active)
				{
					Launch(left: true, leftController);
				}
				if (flag4 && !_wasTriggerRight && _right.active)
				{
					Launch(left: false, rightController);
				}
				bool flag5 = BButton(leftController);
				bool flag6 = BButton(rightController);
				if (flag5 && !_wasBLeft && _left.active)
				{
					Crush(left: true);
				}
				if (flag6 && !_wasBRight && _right.active)
				{
					Crush(left: false);
				}
				_wasBLeft = flag5;
				_wasBRight = flag6;
				TickRelease(_left, left: true);
				TickRelease(_right, left: false);
				if (_left.active)
				{
					UpdateDistance(left: true, leftController);
				}
				if (_right.active)
				{
					UpdateDistance(left: false, rightController);
				}
				UpdateCrouch(_left.active || _right.active);
				UpdateFlying();
				_wasGripLeft = flag;
				_wasGripRight = flag2;
				_wasTriggerLeft = flag3;
				_wasTriggerRight = flag4;
			}
		}

		public override void OnFixedUpdate()
		{
			if (_enabled.Value)
			{
				HoldFixed(_left, left: true);
				HoldFixed(_right, left: false);
			}
		}

		private void TickRelease(Hold state, bool left)
		{
			if (state.active && !(state.releaseTimer <= 0f))
			{
				state.releaseTimer -= Time.deltaTime;
				if (state.releaseTimer <= 0f)
				{
					Drop(left, launched: false);
				}
			}
		}

		private static bool BButton(HVRController c)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_003a: 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)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)c == (Object)null)
			{
				return false;
			}
			try
			{
				if ((int)c.ControllerType == 3)
				{
					return c.TrackpadButtonState.Active || c.MenuButtonState.Active;
				}
			}
			catch
			{
			}
			try
			{
				return c.SecondaryButtonState.Active;
			}
			catch
			{
				return false;
			}
		}

		private void Crush(bool left)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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)
			Hold hold = State(left);
			if (!hold.active || (Object)(object)hold.enemy == (Object)null)
			{
				return;
			}
			Vector3 center = (((Object)(object)hold.enemy.upperChest != (Object)null) ? hold.enemy.upperChest.transform.position : ((Component)hold.enemy).transform.position);
			Il2CppArrayBase<SliceOnInputCustom> componentsInChildren = ((Component)hold.enemy).GetComponentsInChildren<SliceOnInputCustom>(true);
			int num = 0;
			if (componentsInChildren != null)
			{
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					if (num >= 10)
					{
						break;
					}
					SliceOnInputCustom val = componentsInChildren[i];
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					try
					{
						TransferJointsOnFractureCustom componentInParent = ((Component)val).GetComponentInParent<TransferJointsOnFractureCustom>();
						if ((Object)(object)componentInParent != (Object)null)
						{
							componentInParent.DistanceTolerance = 0f;
						}
						val.ForceFracture();
						num++;
					}
					catch
					{
					}
				}
			}
			string name = ((Object)((Component)hold.enemy).gameObject).name;
			BloodBurst(center);
			Restore(hold);
			Clear(hold);
			if (_throwReady)
			{
				Mci.Play("tele_throw");
			}
			Write("crush " + name + " parts=" + num);
		}

		private static void BloodBurst(Vector3 center)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a2: 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)
			try
			{
				Shader val = Shader.Find("Sprites/Default");
				if (!((Object)(object)val == (Object)null))
				{
					for (int i = 0; i < 14; i++)
					{
						GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
						Object.Destroy((Object)(object)obj.GetComponent<Collider>());
						Material val2 = new Material(val);
						val2.color = new Color(0.45f, 0.01f, 0.01f, 0.85f);
						obj.GetComponent<Renderer>().material = val2;
						obj.transform.position = center + Random.insideUnitSphere * 0.2f;
						obj.transform.localScale = new Vector3(0.012f, Random.Range(0.08f, 0.26f), 0.012f);
						obj.transform.rotation = Random.rotation;
						MelonCoroutines.Start(FadeBlood(obj, val2, 0.7f));
					}
				}
			}
			catch
			{
			}
		}

		private static IEnumerator FadeBlood(GameObject go, Material mat, float dur)
		{
			float t = 0f;
			while ((Object)(object)go != (Object)null && t < dur)
			{
				t += Time.unscaledDeltaTime;
				float num = Mathf.Clamp01(t / dur);
				Color color = mat.color;
				color.a = 0.85f * (1f - num);
				mat.color = color;
				yield return null;
			}
			if ((Object)(object)go != (Object)null)
			{
				Object.Destroy((Object)(object)go);
			}
		}

		private void UpdateCrouch(bool holding)
		{
			if ((Object)(object)_inputs == (Object)null)
			{
				return;
			}
			try
			{
				HexaBodyInputsBase inputs = (HexaBodyInputsBase)(object)_inputs;
				if (holding && !_crouchOff)
				{
					_canCrouchSaved = inputs.CanCrouch;
					inputs.CanCrouch = false;
					_crouchOff = true;
				}
				else if (!holding && _crouchOff)
				{
					inputs.CanCrouch = _canCrouchSaved;
					_crouchOff = false;
				}
			}
			catch
			{
			}
		}

		private void UpdateFlying()
		{
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: 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_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)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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 (_flying.Count == 0)
			{
				return;
			}
			RaycastHit val2 = default(RaycastHit);
			for (int num = _flying.Count - 1; num >= 0; num--)
			{
				Flying flying = _flying[num];
				if (flying == null || (Object)(object)flying.enemy == (Object)null || (Object)(object)flying.rb == (Object)null)
				{
					_flying.RemoveAt(num);
				}
				else
				{
					flying.life -= Time.deltaTime;
					if (flying.life <= 0f)
					{
						_flying.RemoveAt(num);
					}
					else
					{
						Vector3 velocity = flying.rb.velocity;
						float magnitude = ((Vector3)(ref velocity)).magnitude;
						if (!(magnitude < 8f))
						{
							Vector3 val = flying.rb.velocity / magnitude;
							if (Physics.Raycast(flying.rb.position, val, ref val2, 0.6f, -1, (QueryTriggerInteraction)1) && !((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<StickHealth>() == (Object)(object)flying.enemy))
							{
								string text = ((((Object)((RaycastHit)(ref val2)).collider).name == null) ? "" : ((Object)((RaycastHit)(ref val2)).collider).name);
								if (!text.Contains("Player") && !text.Contains("Hand"))
								{
									float num2 = Mathf.Clamp(magnitude * 12f, 120f, 700f);
									try
									{
										flying.enemy.ReceivedGeneralDamage(num2, (DamageType)4, "torso", (ColliderBridge)null);
										Write("slam " + ((Object)((Component)flying.enemy).gameObject).name + " dmg=" + num2.ToString("F0"));
									}
									catch (Exception ex)
									{
										Write("slam failed " + ex.Message);
									}
									if (flying.rbs != null)
									{
										Vector3 velocity2 = Vector3.Reflect(flying.rb.velocity, ((RaycastHit)(ref val2)).normal) * 0.35f + ((RaycastHit)(ref val2)).normal * 3f;
										for (int i = 0; i < flying.rbs.Length; i++)
										{
											Rigidbody val3 = flying.rbs[i];
											if (!((Object)(object)val3 == (Object)null))
											{
												val3.velocity = velocity2;
												val3.angularVelocity *= 0.15f;
											}
										}
									}
									_flying.RemoveAt(num);
								}
							}
						}
					}
				}
			}
		}

		private static Vector2 Stick(HVRController c)
		{
			//IL_0032: 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_0009: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_0029: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)c == (Object)null)
			{
				return Vector2.zero;
			}
			try
			{
				if ((int)c.ControllerType == 3)
				{
					return c.TrackpadAxis;
				}
			}
			catch
			{
			}
			try
			{
				return c.JoystickAxis;
			}
			catch
			{
				return Vector2.zero;
			}
		}

		private void UpdateDistance(bool left, HVRController ctrl)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			if (_stickDistance == null || !_stickDistance.Value)
			{
				return;
			}
			Vector2 val = Stick(ctrl);
			if (!(Mathf.Abs(val.y) < 0.15f))
			{
				float num = (left ? _distLeft : _distRight);
				if (num < 0f)
				{
					num = HoldDistance();
				}
				num = Mathf.Clamp(num + val.y * 4f * Time.deltaTime, 0.6f, 8f);
				if (left)
				{
					_distLeft = num;
				}
				else
				{
					_distRight = num;
				}
			}
		}

		private static bool Button(HVRController c, bool grip)
		{
			//IL_001d: 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)
			if ((Object)(object)c == (Object)null)
			{
				return false;
			}
			try
			{
				return grip ? c.GripButtonState.Active : c.TriggerButtonState.Active;
			}
			catch
			{
				return false;
			}
		}

		private void FindPlayer()
		{
			if ((Object)(object)_inputs == (Object)null)
			{
				try
				{
					_inputs = PlayerStaticReferences.hexaInputs;
				}
				catch
				{
				}
			}
			if ((Object)(object)_leftHand != (Object)null && (Object)(object)_rightHand != (Object)null)
			{
				return;
			}
			Il2CppArrayBase<HVRHandGrabber> val = Object.FindObjectsOfType<HVRHandGrabber>();
			if (val == null)
			{
				return;
			}
			for (int i = 0; i < val.Length; i++)
			{
				HVRHandGrabber val2 = val[i];
				if (!((Object)(object)val2 == (Object)null))
				{
					string text = ((((Object)val2).name == null) ? "" : ((Object)val2).name);
					if ((Object)(object)_leftHand == (Object)null && text.Contains("LeftHand"))
					{
						_leftHand = val2;
					}
					if ((Object)(object)_rightHand == (Object)null && text.Contains("RightHand"))
					{
						_rightHand = val2;
					}
				}
			}
		}

		private static bool HandFree(HVRHandGrabber hand)
		{
			if ((Object)(object)hand == (Object)null)
			{
				return false;
			}
			try
			{
				HVRGrabbable heldObject = ((HVRGrabberBase)hand).HeldObject;
				if ((Object)(object)heldObject != (Object)null && heldObject.IsBeingHeld && ((Component)heldObject).gameObject.activeInHierarchy)
				{
					return false;
				}
			}
			catch
			{
			}
			try
			{
				HVRGrabbable grabbedTarget = ((HVRGrabberBase)hand).GrabbedTarget;
				if ((Object)(object)grabbedTarget != (Object)null && grabbedTarget.IsBeingHeld && ((Component)grabbedTarget).gameObject.activeInHierarchy)
				{
					return false;
				}
			}
			catch
			{
			}
			return true;
		}

		private void CachePlayerCols()
		{
			string[] array = new string[6] { "PlayerUpperChest", "PlayerPelvis", "PlayerHexaPelvis", "LocoBall", "Physics LeftHand", "Physics RightHand" };
			for (int i = 0; i < array.Length; i++)
			{
				GameObject val = GameObject.Find(array[i]);
				if (!((Object)(object)val == (Object)null))
				{
					Collider component = val.GetComponent<Collider>();
					if ((Object)(object)component != (Object)null && !_playerCols.Contains(component))
					{
						_playerCols.Add(component);
					}
				}
			}
		}

		private HVRHandGrabber Hand(bool left)
		{
			if (!left)
			{
				return _rightHand;
			}
			return _leftHand;
		}

		private Hold State(bool left)
		{
			if (!left)
			{
				return _right;
			}
			return _left;
		}

		private Camera GetCam()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Invalid comparison between Unknown and I4
			if ((Object)(object)_cam != (Object)null)
			{
				return _cam;
			}
			Il2CppReferenceArray<Camera> allCameras = Camera.allCameras;
			if (allCameras == null)
			{
				return null;
			}
			for (int i = 0; i < ((Il2CppArrayBase<Camera>)(object)allCameras).Length; i++)
			{
				if (!((Object)(object)((Il2CppArrayBase<Camera>)(object)allCameras)[i] == (Object)null) && (int)((Il2CppArrayBase<Camera>)(object)allCameras)[i].stereoTargetEye == 3)
				{
					_cam = ((Il2CppArrayBase<Camera>)(object)allCameras)[i];
					break;
				}
			}
			if ((Object)(object)_cam == (Object)null && ((Il2CppArrayBase<Camera>)(object)allCameras).Length > 0)
			{
				_cam = ((Il2CppArrayBase<Camera>)(object)allCameras)[0];
			}
			return _cam;
		}

		private static bool TryFinger(HVRHandGrabber hand, out Vector3 tip, out Quaternion rot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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)
			//IL_009c: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			tip = Vector3.zero;
			rot = Quaternion.identity;
			if ((Object)(object)hand == (Object)null)
			{
				return false;
			}
			try
			{
				HVRHandAnimator handAnimator = hand.HandAnimator;
				if ((Object)(object)handAnimator == (Object)null)
				{
					return false;
				}
				HVRHandPoseData currentPose = handAnimator.CurrentPose;
				if (currentPose == null)
				{
					return false;
				}
				HVRPosableFingerData index = currentPose.Index;
				if (index == null)
				{
					return false;
				}
				List<HVRPosableBoneData> bones = index.Bones;
				if (bones == null || bones.Count == 0)
				{
					return false;
				}
				HVRPosableBoneData val = bones[bones.Count - 1];
				if (val == null)
				{
					return false;
				}
				Vector3 handWorldPosition = hand.HandWorldPosition;
				Quaternion handWorldRotation = hand.HandWorldRotation;
				tip = handWorldPosition + handWorldRotation * val.Position;
				rot = handWorldRotation * val.Rotation;
				return true;
			}
			catch
			{
				return false;
			}
		}

		private void Aim(bool left, out Vector3 origin, out Vector3 dir, out Quaternion rot)
		{
			//IL_001a: 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_001f: 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_0039: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			HVRHandGrabber val = Hand(left);
			origin = (((Object)(object)val != (Object)null) ? val.HandWorldPosition : Vector3.zero);
			Camera cam = GetCam();
			if (TryFinger(val, out var tip, out var rot2))
			{
				origin = tip;
				rot = rot2;
				dir = -(rot * Vector3.forward);
			}
			else if ((Object)(object)cam != (Object)null)
			{
				dir = ((Component)cam).transform.forward;
				rot = ((Component)cam).transform.rotation;
			}
			else
			{
				rot = Quaternion.identity;
				dir = Vector3.forward;
			}
			if (((Vector3)(ref dir)).sqrMagnitude < 0.01f)
			{
				dir = Vector3.forward;
			}
			((Vector3)(ref dir)).Normalize();
		}

		private static bool IsBodyPart(Rigidbody rb)
		{
			if ((Object)(object)rb == (Object)null)
			{
				return false;
			}
			if ((Object)(object)((Component)rb).GetComponentInParent<SliceableBodyPart>() != (Object)null)
			{
				return true;
			}
			string text = ((((Object)rb).name == null) ? "" : ((Object)rb).name.ToLowerInvariant());
			foreach (string bodyName in BodyNames)
			{
				if (text.Contains(bodyName))
				{
					return true;
				}
			}
			return false;
		}

		private StickHealth PickEnemy(Vector3 origin, Vector3 dir)
		{
			//IL_00b4: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			StickHealth[] array;
			try
			{
				array = Il2CppArrayBase<StickHealth>.op_Implicit(Object.FindObjectsOfType<StickHealth>());
			}
			catch
			{
				return null;
			}
			if (array == null)
			{
				return null;
			}
			float num = Mathf.Max(4f, _range.Value);
			StickHealth result = null;
			float num2 = float.MaxValue;
			foreach (StickHealth val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				try
				{
					if (val.isDead)
					{
						continue;
					}
				}
				catch
				{
					continue;
				}
				if ((Object)(object)((Component)val).gameObject == (Object)null || !((Component)val).gameObject.activeInHierarchy)
				{
					continue;
				}
				Vector3 val2 = (((Object)(object)val.upperChest != (Object)null) ? val.upperChest.transform.position : ((Component)val).transform.position) - origin;
				float magnitude = ((Vector3)(ref val2)).magnitude;
				if (magnitude < 0.5f || magnitude > num)
				{
					continue;
				}
				float num3 = Vector3.Angle(dir, val2);
				if (!(num3 > 45f))
				{
					float num4 = num3 * 2f + magnitude;
					if (!(num4 >= num2))
					{
						num2 = num4;
						result = val;
					}
				}
			}
			return result;
		}

		private void TryGrab(bool left)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: 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_01c5: 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_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			Hold hold = State(left);
			if (hold.active)
			{
				return;
			}
			Vector3 origin = (left ? _aimOriginLeft : _aimOriginRight);
			Vector3 dir = (left ? _aimDirLeft : _aimDirRight);
			Camera cam = GetCam();
			StickHealth val = (((Object)(object)cam != (Object)null) ? PickEnemy(((Component)cam).transform.position, ((Component)cam).transform.forward) : null);
			if ((Object)(object)val == (Object)null)
			{
				val = PickEnemy(origin, dir);
			}
			if ((Object)(object)val == (Object)null)
			{
				Write("grab miss " + (left ? "left" : "right"));
			}
			else
			{
				if ((_left.active && (Object)(object)_left.enemy == (Object)(object)val) || (_right.active && (Object)(object)_right.enemy == (Object)(object)val))
				{
					return;
				}
				Il2CppArrayBase<Rigidbody> componentsInChildren = ((Component)val).GetComponentsInChildren<Rigidbody>(true);
				if (componentsInChildren == null || componentsInChildren.Length == 0)
				{
					Write("grab no rigidbody");
					return;
				}
				List<Rigidbody> list = new List<Rigidbody>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					if (IsBodyPart(componentsInChildren[i]))
					{
						list.Add(componentsInChildren[i]);
					}
				}
				Rigidbody[] array = ((list.Count > 0) ? list.ToArray() : Il2CppArrayBase<Rigidbody>.op_Implicit(componentsInChildren));
				Vector3 val2 = (((Object)(object)val.upperChest != (Object)null) ? val.upperChest.transform.position : ((Component)val).transform.position);
				Vector3[] array2 = (Vector3[])(object)new Vector3[array.Length];
				for (int j = 0; j < array.Length; j++)
				{
					array2[j] = (((Object)(object)array[j] == (Object)null) ? Vector3.zero : (array[j].position - val2));
					if ((Object)(object)array[j] != (Object)null)
					{
						array[j].useGravity = false;
						Rigidbody obj = array[j];
						obj.angularVelocity *= 0.2f;
					}
				}
				hold.active = true;
				hold.enemy = val;
				hold.rbs = array;
				hold.offsets = array2;
				if (left)
				{
					_distLeft = HoldDistance();
					_hasLastLeft = false;
				}
				else
				{
					_distRight = HoldDistance();
					_hasLastRight = false;
				}
				hold.cols.Clear();
				Il2CppArrayBase<Collider> componentsInChildren2 = ((Component)val).GetComponentsInChildren<Collider>(true);
				if (componentsInChildren2 != null)
				{
					for (int k = 0; k < componentsInChildren2.Length && k < 12; k++)
					{
						if ((Object)(object)componentsInChildren2[k] == (Object)null)
						{
							continue;
						}
						hold.cols.Add(componentsInChildren2[k]);
						for (int l = 0; l < _playerCols.Count; l++)
						{
							try
							{
								Physics.IgnoreCollision(componentsInChildren2[k], _playerCols[l], true);
							}
							catch
							{
							}
						}
					}
				}
				CreateBubbles(hold);
				if (_grabReady)
				{
					Mci.Play("tele_grab");
				}
				Write("grab " + (left ? "left" : "right") + " " + ((Object)((Component)val).gameObject).name + " parts=" + array.Length);
			}
		}

		private float HoldDistance()
		{
			return Mathf.Max(1.2f, _distance.Value);
		}

		private void CreateBubbles(Hold state)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_003f: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Shader val = Shader.Find("Sprites/Default");
				if (!((Object)(object)val == (Object)null))
				{
					state.bubbleMat = new Material(val);
					state.bubbleMat.color = new Color(1f, 1f, 1f, 0.22f);
					for (int i = 0; i < 8; i++)
					{
						GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0);
						Object.Destroy((Object)(object)val2.GetComponent<Collider>());
						val2.GetComponent<Renderer>().material = state.bubbleMat;
						val2.transform.localScale = Vector3.one * 0.03f;
						state.bubbles.Add(val2);
					}
				}
			}
			catch
			{
			}
		}

		private static void UpdateBubbles(Hold state, Vector3 center)
		{
			//IL_005b: 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_00c7: 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)
			for (int i = 0; i < state.bubbles.Count; i++)
			{
				GameObject val = state.bubbles[i];
				if (!((Object)(object)val == (Object)null))
				{
					float num = Time.time * 1.4f + (float)i * 0.79f;
					float num2 = 0.22f + 0.08f * Mathf.Sin(Time.time * 2f + (float)i);
					val.transform.position = center + new Vector3(Mathf.Cos(num) * num2, Mathf.Sin(Time.time * 0.8f + (float)i) * 0.28f, Mathf.Sin(num) * num2);
					float num3 = 0.018f + 0.012f * (1f + Mathf.Sin(Time.time * 3f + (float)i)) * 0.5f;
					val.transform.localScale = Vector3.one * num3;
				}
			}
		}

		private void HoldFixed(Hold state, bool left)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0057: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_00ba: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: 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_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: 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)
			if (!state.active || state.rbs == null)
			{
				return;
			}
			Vector3 val = (left ? _aimOriginLeft : _aimOriginRight);
			Vector3 val2 = (left ? _aimDirLeft : _aimDirRight);
			float num = (left ? _distLeft : _distRight);
			if (num < 0f)
			{
				num = HoldDistance();
			}
			Vector3 val3 = val + val2 * num + Vector3.up * 0.15f;
			UpdateBubbles(state, val3);
			float num2 = Mathf.Clamp(Mathf.Max(_stiffness.Value, 6f), 1f, 14f);
			bool num3 = (left ? _hasLastLeft : _hasLastRight);
			Vector3 val4 = (left ? _lastOriginLeft : _lastOriginRight);
			Vector3 val5 = (num3 ? ((val - val4) / Mathf.Max(Time.fixedDeltaTime, 0.001f)) : Vector3.zero);
			val5 = Vector3.ClampMagnitude(val5, 5f);
			if (left)
			{
				_lastOriginLeft = val;
				_hasLastLeft = true;
			}
			else
			{
				_lastOriginRight = val;
				_hasLastRight = true;
			}
			float time = Time.time;
			Vector3 val7 = default(Vector3);
			for (int i = 0; i < state.rbs.Length; i++)
			{
				Rigidbody val6 = state.rbs[i];
				if (!((Object)(object)val6 == (Object)null))
				{
					val6.useGravity = false;
					val6.detectCollisions = true;
					((Vector3)(ref val7))..ctor(Mathf.Sin(time * 2f + (float)i * 0.7f) * 0.022f, Mathf.Cos(time * 1.7f + (float)i * 0.9f) * 0.028f, Mathf.Sin(time * 1.3f + (float)i * 0.5f) * 0.02f);
					Vector3 val8 = -val5 * (0.025f + (float)(i % 5) * 0.006f);
					val8 = Vector3.ClampMagnitude(val8, 0.25f);
					Vector3 val9 = (val3 + state.offsets[i] + val7 + val8 - val6.position) * num2;
					val6.velocity = Vector3.ClampMagnitude(val9, 18f);
					val6.angularVelocity = Vector3.zero;
				}
			}
		}

		private void Drop(bool left, bool launched)
		{
			Hold hold = State(left);
			if (hold.active)
			{
				Restore(hold);
				Clear(hold);
				Write("drop " + (left ? "left" : "right") + " launched=" + launched);
			}
		}

		private void Launch(bool left, HVRController ctrl)
		{
			//IL_006b: 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_0025: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_00a3: 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_00aa: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			Hold hold = State(left);
			if (!hold.active || hold.rbs == null)
			{
				return;
			}
			Vector3 val = (left ? _aimDirLeft : _aimDirRight);
			float num = Mathf.Clamp(Mathf.Max(_throwForce.Value, 30f), 1f, 80f);
			Vector3 val2 = Vector3.zero;
			if ((Object)(object)ctrl != (Object)null)
			{
				try
				{
					val2 = ctrl.Velocity;
				}
				catch
				{
				}
				val2 = Vector3.ClampMagnitude(val2, 6f);
			}
			for (int i = 0; i < hold.rbs.Length; i++)
			{
				Rigidbody val3 = hold.rbs[i];
				if (!((Object)(object)val3 == (Object)null))
				{
					val3.useGravity = true;
					val3.detectCollisions = true;
					val3.velocity = val * num + val2 * 0.5f + Vector3.up * 2f;
					val3.angularVelocity = Vector3.Cross(val, Vector3.up) * 6f;
				}
			}
			Rigidbody val4 = null;
			for (int j = 0; j < hold.rbs.Length; j++)
			{
				if ((Object)(object)hold.rbs[j] != (Object)null)
				{
					val4 = hold.rbs[j];
					break;
				}
			}
			if ((Object)(object)val4 != (Object)null)
			{
				_flying.Add(new Flying
				{
					enemy = hold.enemy,
					rb = val4,
					rbs = hold.rbs,
					life = 1.5f
				});
			}
			if (_throwReady)
			{
				Mci.Play("tele_throw");
			}
			Write("launch " + (left ? "left" : "right") + " force=" + num);
			Clear(hold);
		}

		private void Restore(Hold state)
		{
			if (state.rbs != null)
			{
				for (int i = 0; i < state.rbs.Length; i++)
				{
					Rigidbody val = state.rbs[i];
					if (!((Object)(object)val == (Object)null))
					{
						val.useGravity = true;
						val.detectCollisions = true;
					}
				}
			}
			for (int j = 0; j < state.cols.Count; j++)
			{
				if ((Object)(object)state.cols[j] == (Object)null)
				{
					continue;
				}
				for (int k = 0; k < _playerCols.Count; k++)
				{
					try
					{
						Physics.IgnoreCollision(state.cols[j], _playerCols[k], false);
					}
					catch
					{
					}
				}
			}
		}

		private static void Clear(Hold state)
		{
			state.active = false;
			state.enemy = null;
			state.rbs = null;
			state.offsets = null;
			state.cols.Clear();
			for (int i = 0; i < state.bubbles.Count; i++)
			{
				if ((Object)(object)state.bubbles[i] != (Object)null)
				{
					try
					{
						Object.Destroy((Object)(object)state.bubbles[i]);
					}
					catch
					{
					}
				}
			}
			state.bubbles.Clear();
			if ((Object)(object)state.bubbleMat != (Object)null)
			{
				try
				{
					Object.Destroy((Object)(object)state.bubbleMat);
				}
				catch
				{
				}
			}
			state.bubbleMat = null;
			state.releaseTimer = 0f;
		}

		private static void Write(string s)
		{
			try
			{
				File.AppendAllText("D:\\BrutalistickVrWork\\Probe\\telekinesis.log", "[" + DateTime.Now.ToString("HH:mm:ss") + "] " + s + "\n");
			}
			catch
			{
			}
		}
	}
}