Decompiled source of PochitaTrueForm v0.1.0

PochitaTrueForm.dll

Decompiled 14 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 HarmonyLib;
using Il2Cpp;
using Il2CppActiveRagdoll;
using Il2CppHexabodyVR.PlayerController;
using Il2CppHurricaneVR.Framework.Core;
using Il2CppHurricaneVR.Framework.Core.Grabbers;
using Il2CppHurricaneVR.Framework.Core.Player;
using Il2CppHurricaneVR.Framework.Core.ScriptableObjects;
using Il2CppHurricaneVR.Framework.Shared;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Reflection;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using PochitaTrueForm;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "PochitaTrueForm", "0.1.0", "coope", null)]
[assembly: MelonGame("Kubunautilus", "BrutalistickVR")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("PochitaTrueForm")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PochitaTrueForm")]
[assembly: AssemblyTitle("PochitaTrueForm")]
[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 PochitaTrueForm
{
	public class Core : MelonMod
	{
		private sealed class Chain
		{
			public LineRenderer line;

			public Material mat;

			public Material linkMat;

			public Material toothMat;

			public List<Transform> pieces = new List<Transform>();

			public StickHealth enemy;

			public Rigidbody[] rbs;

			public Vector3 origin;

			public Vector3 anchor;

			public bool wallHook;

			public bool rightSide;

			public float age;
		}

		private sealed class Saw
		{
			public bool isHead;

			public bool isElbow;

			public bool isLeft;

			public Transform hand;

			public Transform anchor;

			public GameObject go;

			public Rigidbody rb;

			public ChainsawManager mgr;

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

			public Vector3 offset;

			public Quaternion grip;

			public float deployDistance;

			public float progress;

			public Vector3 pos;

			public Quaternion rot;
		}

		private readonly List<Chain> _chains = new List<Chain>();

		private readonly List<Rigidbody> _playerRbs = new List<Rigidbody>();

		private bool _stickWas;

		private const string RigName = "Hexa4Rig26.10.23";

		private const string LeftHandPath = "Physics LeftHand";

		private const string RightHandPath = "Physics RightHand";

		private const string SoundFolder = "PochitaTrueForm";

		private const float DeployDistance = 0.4f;

		private const float DeployDuration = 0.15f;

		private const float LerpSpeed = 130f;

		private const float MaxSpeed = 150f;

		private const float MaxAngularSpeed = 9000f;

		private const float SearchInterval = 2f;

		private const int ModeOff = 0;

		private const int ModeOn = 1;

		private const int ModeRetract = 2;

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

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

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

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

		private MelonPreferences_Category _cfg;

		private MelonPreferences_Entry<float> _volIdle;

		private MelonPreferences_Entry<float> _volRev;

		private MelonPreferences_Entry<float> _volStart;

		private MelonPreferences_Entry<float> _volStop;

		private MelonPreferences_Entry<float> _headX;

		private MelonPreferences_Entry<float> _headY;

		private MelonPreferences_Entry<float> _headZ;

		private MelonPreferences_Entry<float> _headPitch;

		private MelonPreferences_Entry<float> _headYaw;

		private MelonPreferences_Entry<float> _headRoll;

		private MelonPreferences_Entry<float> _headScale;

		private MelonPreferences_Entry<float> _handScale;

		private MelonPreferences_Entry<bool> _movieSounds;

		private MelonPreferences_Entry<float> _voiceVolume;

		private MelonPreferences_Entry<bool> _starterEnabled;

		private MelonPreferences_Entry<float> _starterOut;

		private MelonPreferences_Entry<float> _starterDown;

		private MelonPreferences_Entry<float> _starterPull;

		private MelonPreferences_Entry<float> _starterScale;

		private MelonPreferences_Entry<float> _starterDelay;

		private MelonPreferences_Entry<bool> _tintEnabled;

		private MelonPreferences_Entry<bool> _bloodEnabled;

		private MelonPreferences_Entry<float> _bloodAmount;

		private MelonPreferences_Entry<float> _tintIntensity;

		private MelonPreferences_Entry<int> _cfgVer;

		private Transform _rig;

		private HVRHexaBodyInputs _inputs;

		private HVRHandGrabber _leftGrabber;

		private HVRHandGrabber _rightGrabber;

		private Transform _leftHand;

		private Transform _rightHand;

		private Transform _leftElbow;

		private Transform _rightElbow;

		private Camera _cam;

		private GameObject _prefab;

		private Saw _leftSaw;

		private Saw _rightSaw;

		private Saw _headSaw;

		private Saw _leftElbowSaw;

		private Saw _rightElbowSaw;

		private HexaBodyPlayer4 _player;

		private PlayerHealthManager _health;

		private float _savedWalk;

		private float _savedRun;

		private bool _speedBoosted;

		private const float HeightFactor = 1.2f;

		private bool _transition;

		private bool _scaled;

		private GameObject _fadeGo;

		private Material _fadeMat;

		private int _mode;

		private bool _rev;

		private bool _wasB;

		private float _bindTimer;

		private float _searchTimer;

		private float _camTimer;

		private GameObject _audioGo;

		private AudioSource _idleAudio;

		private AudioSource _revAudio;

		private AudioSource _oneShot;

		private AudioClip _startClip;

		private AudioClip _stopClip;

		private bool _voiceReady;

		private bool _musicReady;

		private bool _armorReady;

		private bool _screamPlayed;

		private bool _movieLoaded;

		private Transform _starterAnchor;

		private Transform _starterHandle;

		private Transform _cableStart;

		private Rigidbody _starterRb;

		private HVRGrabbable _starterGrab;

		private LineRenderer _starterCable;

		private Transform _cableEnd;

		private Transform _starterHand;

		private Quaternion _starterGrip;

		private bool _starterTried;

		private bool _starterHeld;

		private bool _pulled;

		private float _pullTimer;

		private Quaternion _starterBaseRot;

		private Vector3 _starterBasePos;

		private float _voiceDelay;

		private float _engineDelay;

		private GameObject _tintGo;

		private MeshRenderer _tintRenderer;

		private Material _tintMat;

		private Material _bloodMat;

		private float _tintAlpha;

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

		private static bool _dumpedProbe;

		private static string SoundDir
		{
			get
			{
				try
				{
					string location = Assembly.GetExecutingAssembly().Location;
					if (!string.IsNullOrEmpty(location))
					{
						string directoryName = Path.GetDirectoryName(location);
						if (!string.IsNullOrEmpty(directoryName))
						{
							return Path.Combine(directoryName, "PochitaTrueForm");
						}
					}
				}
				catch
				{
				}
				return Path.Combine(Application.persistentDataPath, "PochitaTrueForm");
			}
		}

		private static bool StickDown(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.JoystickButtonState.Active;
			}
			catch
			{
				return false;
			}
		}

		private void UpdateChains(float dt)
		{
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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_0170: 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_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_inputs == (Object)null || _mode != 1)
			{
				ReleaseChains();
				return;
			}
			bool flag = StickDown(_inputs.RightController);
			bool flag2 = StickDown(_inputs.LeftController);
			bool flag3 = flag || flag2;
			if (flag3 && !_stickWas && _chains.Count == 0)
			{
				FireChain(flag && !flag2);
			}
			if (!flag3 && _stickWas)
			{
				ReleaseChains();
			}
			_stickWas = flag3;
			if (_chains.Count == 0)
			{
				return;
			}
			for (int num = _chains.Count - 1; num >= 0; num--)
			{
				Chain chain = _chains[num];
				chain.age += dt;
				bool flag4 = false;
				try
				{
					flag4 = (Object)(object)chain.enemy == (Object)null || chain.enemy.isDead;
				}
				catch
				{
					flag4 = true;
				}
				bool flag5 = false;
				if (!flag4 && !chain.wallHook && (Object)(object)chain.enemy != (Object)null && (Object)(object)chain.enemy.upperChest != (Object)null && (Object)(object)_cam != (Object)null)
				{
					Vector3 val = ((Component)_cam).transform.position + ((Component)_cam).transform.forward * 1.2f + Vector3.up * -0.15f - chain.enemy.upperChest.transform.position;
					flag5 = ((Vector3)(ref val)).sqrMagnitude < 4f;
				}
				if (flag4 || flag5 || chain.age > 8f)
				{
					ReleaseChain(num);
				}
			}
		}

		private Vector3 SawOrigin(bool head, bool left, bool elbow)
		{
			//IL_004f: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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)
			Saw saw = (head ? _headSaw : ((!elbow) ? (left ? _leftSaw : _rightSaw) : (left ? _leftElbowSaw : _rightElbowSaw)));
			if (saw != null && (Object)(object)saw.go != (Object)null)
			{
				return saw.go.transform.position;
			}
			if (head && (Object)(object)_cam != (Object)null)
			{
				return ((Component)_cam).transform.position + ((Component)_cam).transform.forward * 0.4f;
			}
			Transform val = (left ? _leftHand : _rightHand);
			if (!((Object)(object)val != (Object)null))
			{
				return Vector3.zero;
			}
			return val.position;
		}

		private Vector3 SawDirection(bool head, bool left, bool elbow)
		{
			//IL_0022: 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_006c: 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_0082: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			if (head)
			{
				if (!((Object)(object)_cam != (Object)null))
				{
					return Vector3.forward;
				}
				return ((Component)_cam).transform.forward;
			}
			Saw saw = ((!elbow) ? (left ? _leftSaw : _rightSaw) : (left ? _leftElbowSaw : _rightElbowSaw));
			if (saw != null && (Object)(object)saw.go != (Object)null)
			{
				Vector3 forward = saw.go.transform.forward;
				if (((Vector3)(ref forward)).sqrMagnitude > 0.01f)
				{
					return ((Vector3)(ref forward)).normalized;
				}
			}
			Transform val = (left ? _leftHand : _rightHand);
			if (!((Object)(object)val != (Object)null))
			{
				return Vector3.forward;
			}
			return val.forward;
		}

		private StickHealth FindFreeEnemy(Vector3 origin, Vector3 dir, HashSet<StickHealth> used)
		{
			//IL_009d: 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_00a2: 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_00a8: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			Il2CppArrayBase<StickHealth> val = Object.FindObjectsOfType<StickHealth>();
			if (val == null)
			{
				return null;
			}
			StickHealth result = null;
			float num = float.MaxValue;
			for (int i = 0; i < val.Length; i++)
			{
				StickHealth val2 = val[i];
				if ((Object)(object)val2 == (Object)null || used.Contains(val2))
				{
					continue;
				}
				try
				{
					if (val2.isDead)
					{
						continue;
					}
				}
				catch
				{
					continue;
				}
				if ((Object)(object)((Component)val2).gameObject == (Object)null || !((Component)val2).gameObject.activeInHierarchy)
				{
					continue;
				}
				Vector3 val3 = (((Object)(object)val2.upperChest != (Object)null) ? val2.upperChest.transform.position : ((Component)val2).transform.position) - origin;
				float magnitude = ((Vector3)(ref val3)).magnitude;
				if (magnitude < 0.5f || magnitude > 50f)
				{
					continue;
				}
				float num2 = Vector3.Angle(dir, val3);
				if (!(num2 > 35f))
				{
					float num3 = num2 * 1.5f + magnitude;
					if (!(num3 >= num))
					{
						num = num3;
						result = val2;
					}
				}
			}
			return result;
		}

		private void FireChain(bool rightSide)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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_018b: Unknown result type (might be due to invalid IL or missing references)
			bool left = rightSide;
			Vector3 val = SawOrigin(head: false, left, elbow: false);
			Vector3 val2 = (((Object)(object)_cam != (Object)null) ? ((Component)_cam).transform.forward : SawDirection(head: false, left, elbow: false));
			HashSet<StickHealth> used = new HashSet<StickHealth>();
			StickHealth val3 = FindFreeEnemy(val, val2, used);
			if ((Object)(object)val3 != (Object)null)
			{
				MakeChain(val, val3);
				if (_chains.Count > 0)
				{
					_chains[_chains.Count - 1].rightSide = rightSide;
				}
				((MelonBase)this).LoggerInstance.Msg("chain fired " + (rightSide ? "right" : "left") + " enemy=" + ((Object)((Component)val3).gameObject).name);
				return;
			}
			Il2CppStructArray<RaycastHit> val4 = Physics.SphereCastAll(val, 0.1f, val2, 50f, -1, (QueryTriggerInteraction)2);
			if (val4 != null)
			{
				List<RaycastHit> list = new List<RaycastHit>();
				for (int i = 0; i < ((Il2CppArrayBase<RaycastHit>)(object)val4).Length; i++)
				{
					list.Add(((Il2CppArrayBase<RaycastHit>)(object)val4)[i]);
				}
				list.Sort((RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance));
				for (int num = 0; num < list.Count; num++)
				{
					RaycastHit val5 = list[num];
					Collider collider = ((RaycastHit)(ref val5)).collider;
					if (!((Object)(object)collider == (Object)null) && (!((Object)(object)_rig != (Object)null) || !((Object)(object)((Component)collider).transform.root == (Object)(object)_rig)))
					{
						val5 = list[num];
						MakeWallChain(val, ((RaycastHit)(ref val5)).point);
						if (_chains.Count > 0)
						{
							_chains[_chains.Count - 1].rightSide = rightSide;
						}
						((MelonBase)this).LoggerInstance.Msg("chain fired " + (rightSide ? "right" : "left") + " wall");
						return;
					}
				}
			}
			((MelonBase)this).LoggerInstance.Msg("chain miss " + (rightSide ? "right" : "left"));
		}

		private bool BuildVisual(Chain chain, Vector3 origin)
		{
			//IL_0020: 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)
			//IL_0069: Expected O, but got Unknown
			//IL_0083: 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_00aa: 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_00bc: Expected O, but got Unknown
			//IL_00d6: 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_00ec: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Shader val = Shader.Find("Sprites/Default");
				if ((Object)(object)val == (Object)null)
				{
					return false;
				}
				LineRenderer val2 = new GameObject("PochitaChain").AddComponent<LineRenderer>();
				val2.useWorldSpace = true;
				val2.positionCount = 2;
				val2.startWidth = 0.018f;
				val2.endWidth = 0.018f;
				val2.numCornerVertices = 2;
				val2.numCapVertices = 2;
				chain.mat = new Material(val);
				chain.mat.color = new Color(0.005f, 0.005f, 0.005f, 1f);
				((Renderer)val2).material = chain.mat;
				chain.line = val2;
				val2.SetPosition(0, origin);
				val2.SetPosition(1, origin);
				chain.linkMat = new Material(val);
				chain.linkMat.color = new Color(0.01f, 0.01f, 0.012f, 1f);
				chain.toothMat = new Material(val);
				chain.toothMat.color = new Color(0.08f, 0.08f, 0.09f, 1f);
				for (int i = 0; i < 16; i++)
				{
					GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)3);
					Object.Destroy((Object)(object)val3.GetComponent<Collider>());
					val3.GetComponent<Renderer>().sharedMaterial = ((i % 2 == 0) ? chain.linkMat : chain.toothMat);
					val3.transform.localScale = ((i % 2 == 0) ? new Vector3(0.045f, 0.02f, 0.022f) : new Vector3(0.022f, 0.022f, 0.02f));
					chain.pieces.Add(val3.transform);
				}
				return true;
			}
			catch
			{
				return false;
			}
		}

		private bool MakeChain(Vector3 origin, StickHealth enemy)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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)
			try
			{
				Chain chain = new Chain();
				if (!BuildVisual(chain, origin))
				{
					return false;
				}
				try
				{
					enemy.ForceUnbalance(true);
				}
				catch
				{
				}
				try
				{
					enemy.StartStaggering();
				}
				catch
				{
				}
				List<Rigidbody> list = new List<Rigidbody>();
				GameObject pelvisGo = enemy.pelvisGo;
				if ((Object)(object)pelvisGo != (Object)null)
				{
					Rigidbody component = pelvisGo.GetComponent<Rigidbody>();
					if ((Object)(object)component != (Object)null)
					{
						list.Add(component);
					}
				}
				GameObject upperChest = enemy.upperChest;
				if ((Object)(object)upperChest != (Object)null)
				{
					Rigidbody component2 = upperChest.GetComponent<Rigidbody>();
					if ((Object)(object)component2 != (Object)null && !list.Contains(component2))
					{
						list.Add(component2);
					}
				}
				if (list.Count == 0)
				{
					Il2CppArrayBase<Rigidbody> componentsInChildren = ((Component)enemy).GetComponentsInChildren<Rigidbody>(true);
					if (componentsInChildren != null && componentsInChildren.Length > 0)
					{
						list.Add(componentsInChildren[0]);
					}
				}
				Rigidbody[] rbs = list.ToArray();
				chain.enemy = enemy;
				chain.rbs = rbs;
				chain.origin = origin;
				chain.age = 0f;
				_chains.Add(chain);
				return true;
			}
			catch
			{
				return false;
			}
		}

		private void MakeWallChain(Vector3 origin, Vector3 point)
		{
			//IL_0008: 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_0014: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Chain chain = new Chain();
				if (BuildVisual(chain, origin))
				{
					chain.origin = origin;
					chain.anchor = point;
					chain.wallHook = true;
					chain.age = 0f;
					_chains.Add(chain);
				}
			}
			catch
			{
			}
		}

		private void FixedChains()
		{
			//IL_005d: 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_0077: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: 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_020e: 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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			if (_chains.Count == 0)
			{
				return;
			}
			Vector3 val = (((Object)(object)_cam != (Object)null) ? (((Component)_cam).transform.position + ((Component)_cam).transform.forward * 1.2f + Vector3.up * -0.15f) : (((Object)(object)_rig != (Object)null) ? (_rig.position + Vector3.up * 1.1f) : Vector3.zero));
			for (int num = _chains.Count - 1; num >= 0; num--)
			{
				Chain chain = _chains[num];
				if (chain != null)
				{
					if (chain.wallHook)
					{
						EnsurePlayerRbs();
						float num2 = float.MaxValue;
						for (int i = 0; i < _playerRbs.Count; i++)
						{
							Rigidbody val2 = _playerRbs[i];
							if (!((Object)(object)val2 == (Object)null))
							{
								float num3 = Vector3.Distance(val2.position, chain.anchor);
								if (num3 < num2)
								{
									num2 = num3;
								}
							}
						}
						if (num2 < 1.4f)
						{
							ReleaseChain(num);
						}
						else
						{
							for (int j = 0; j < _playerRbs.Count; j++)
							{
								Rigidbody val3 = _playerRbs[j];
								if (!((Object)(object)val3 == (Object)null) && !val3.isKinematic)
								{
									Vector3 val4 = chain.anchor - val3.position;
									if (!(((Vector3)(ref val4)).magnitude < 1.4f))
									{
										val3.velocity = Vector3.ClampMagnitude(((Vector3)(ref val4)).normalized * 7f, 7f);
									}
								}
							}
						}
					}
					else if (chain.rbs != null)
					{
						for (int k = 0; k < chain.rbs.Length; k++)
						{
							Rigidbody val5 = chain.rbs[k];
							if (!((Object)(object)val5 == (Object)null) && !val5.isKinematic)
							{
								Vector3 val6 = val - val5.position;
								if (!(((Vector3)(ref val6)).sqrMagnitude < 0.01f))
								{
									val5.velocity = Vector3.ClampMagnitude(((Vector3)(ref val6)).normalized * 10f, 10f);
								}
							}
						}
					}
				}
			}
		}

		private void EnsurePlayerRbs()
		{
			if (_playerRbs.Count > 0)
			{
				return;
			}
			string[] array = new string[5] { "PlayerUpperChest", "PlayerPelvis", "PlayerHexaPelvis", "LocoBall", "Knee" };
			for (int i = 0; i < array.Length; i++)
			{
				GameObject val = GameObject.Find(array[i]);
				if (!((Object)(object)val == (Object)null))
				{
					Rigidbody component = val.GetComponent<Rigidbody>();
					if ((Object)(object)component != (Object)null && !_playerRbs.Contains(component))
					{
						_playerRbs.Add(component);
					}
				}
			}
		}

		private void LateChains()
		{
			//IL_009c: 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_00a2: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: 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_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: 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_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: 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)
			if (_chains.Count == 0)
			{
				return;
			}
			for (int i = 0; i < _chains.Count; i++)
			{
				Chain chain = _chains[i];
				if (chain == null || (Object)(object)chain.line == (Object)null)
				{
					continue;
				}
				Vector3 val = (chain.wallHook ? chain.anchor : (((Object)(object)chain.enemy != (Object)null && (Object)(object)chain.enemy.upperChest != (Object)null) ? chain.enemy.upperChest.transform.position : (((Object)(object)_rig != (Object)null) ? _rig.position : Vector3.zero)));
				Vector3 val2 = val - chain.origin;
				float magnitude = ((Vector3)(ref val2)).magnitude;
				Vector3 val3 = ((magnitude > 0.001f) ? (val2 / magnitude) : Vector3.forward);
				Vector3 val4 = Vector3.Cross(val3, Vector3.up);
				if (((Vector3)(ref val4)).sqrMagnitude < 0.01f)
				{
					val4 = Vector3.Cross(val3, Vector3.right);
				}
				((Vector3)(ref val4)).Normalize();
				chain.origin = SawOrigin(head: false, chain.rightSide, elbow: false);
				chain.line.SetPosition(0, chain.origin);
				chain.line.SetPosition(1, val);
				Quaternion val5 = Quaternion.LookRotation(val3);
				for (int j = 0; j < chain.pieces.Count; j++)
				{
					Transform val6 = chain.pieces[j];
					if (!((Object)(object)val6 == (Object)null))
					{
						float num = ((float)j + 0.5f) / (float)chain.pieces.Count;
						Vector3 val7 = Vector3.Lerp(chain.origin, val, num);
						if (j % 2 == 1)
						{
							val7 += val4 * 0.026f;
						}
						val6.position = val7;
						val6.rotation = ((j % 2 == 1) ? (val5 * Quaternion.Euler(0f, 0f, 45f)) : val5);
					}
				}
			}
		}

		private void ReleaseChain(int index)
		{
			if (index < 0 || index >= _chains.Count)
			{
				return;
			}
			Chain chain = _chains[index];
			if (chain == null)
			{
				_chains.RemoveAt(index);
				return;
			}
			if ((Object)(object)chain.line != (Object)null)
			{
				try
				{
					Object.Destroy((Object)(object)((Component)chain.line).gameObject);
				}
				catch
				{
				}
			}
			for (int i = 0; i < chain.pieces.Count; i++)
			{
				if ((Object)(object)chain.pieces[i] != (Object)null)
				{
					try
					{
						Object.Destroy((Object)(object)((Component)chain.pieces[i]).gameObject);
					}
					catch
					{
					}
				}
			}
			chain.pieces.Clear();
			if ((Object)(object)chain.mat != (Object)null)
			{
				try
				{
					Object.Destroy((Object)(object)chain.mat);
				}
				catch
				{
				}
			}
			if ((Object)(object)chain.linkMat != (Object)null)
			{
				try
				{
					Object.Destroy((Object)(object)chain.linkMat);
				}
				catch
				{
				}
			}
			if ((Object)(object)chain.toothMat != (Object)null)
			{
				try
				{
					Object.Destroy((Object)(object)chain.toothMat);
				}
				catch
				{
				}
			}
			_chains.RemoveAt(index);
		}

		private void ReleaseChains()
		{
			for (int num = _chains.Count - 1; num >= 0; num--)
			{
				ReleaseChain(num);
			}
			_stickWas = false;
		}

		public override void OnInitializeMelon()
		{
			HeightCore.Init(((MelonBase)this).LoggerInstance);
			_cfg = MelonPreferences.CreateCategory("PochitaTrueForm", "Pochita True Form");
			_volIdle = _cfg.CreateEntry<float>("IdleVolume", 0f, "Громкость холостого хода", (string)null, false, false, (ValueValidator)null, (string)null);
			_volRev = _cfg.CreateEntry<float>("RevVolume", 0.75f, "Громкость газа", (string)null, false, false, (ValueValidator)null, (string)null);
			_volStart = _cfg.CreateEntry<float>("StartVolume", 0f, "Громкость запуска пилы", (string)null, false, false, (ValueValidator)null, (string)null);
			_volStop = _cfg.CreateEntry<float>("StopVolume", 0f, "Громкость остановки", (string)null, false, false, (ValueValidator)null, (string)null);
			_headX = _cfg.CreateEntry<float>("HeadOffsetX", 0f, "Пила на голове: сдвиг вправо", (string)null, false, false, (ValueValidator)null, (string)null);
			_headY = _cfg.CreateEntry<float>("HeadOffsetY", 0.05f, "Пила на голове: сдвиг вверх", (string)null, false, false, (ValueValidator)null, (string)null);
			_headZ = _cfg.CreateEntry<float>("HeadOffsetZ", 0.1f, "Пила на голове: сдвиг вперёд", (string)null, false, false, (ValueValidator)null, (string)null);
			_headPitch = _cfg.CreateEntry<float>("HeadPitch", -22f, "Пила на голове: наклон вверх, градусы", (string)null, false, false, (ValueValidator)null, (string)null);
			_headYaw = _cfg.CreateEntry<float>("HeadYaw", 0f, "Пила на голове: поворот, градусы", (string)null, false, false, (ValueValidator)null, (string)null);
			_headRoll = _cfg.CreateEntry<float>("HeadRoll", 90f, "Пила на голове: крен, градусы", (string)null, false, false, (ValueValidator)null, (string)null);
			_headScale = _cfg.CreateEntry<float>("HeadScale", 1f, "Р\u00a0азмер пилы РЅР° голове", (string)null, false, false, (ValueValidator)null, (string)null);
			_handScale = _cfg.CreateEntry<float>("HandScale", 1f, "Р\u00a0азмер РїРёР» РЅР° руках", (string)null, false, false, (ValueValidator)null, (string)null);
			_movieSounds = _cfg.CreateEntry<bool>("MovieSounds", true, "Фраза Денджи", (string)null, false, false, (ValueValidator)null, (string)null);
			_voiceVolume = _cfg.CreateEntry<float>("VoiceVolume", 0.95f, "Громкость фразы Денджи", (string)null, false, false, (ValueValidator)null, (string)null);
			_starterEnabled = _cfg.CreateEntry<bool>("StarterEnabled", true, "Стартер на груди (B только убирает пилы)", (string)null, false, false, (ValueValidator)null, (string)null);
			_starterOut = _cfg.CreateEntry<float>("StarterOut", 0.15f, "Стартер: вынос от тела", (string)null, false, false, (ValueValidator)null, (string)null);
			_starterDown = _cfg.CreateEntry<float>("StarterDown", 0.3f, "Стартер: высота от таза", (string)null, false, false, (ValueValidator)null, (string)null);
			_starterPull = _cfg.CreateEntry<float>("StarterPull", 0.22f, "Стартер: длина выдергивания", (string)null, false, false, (ValueValidator)null, (string)null);
			_starterScale = _cfg.CreateEntry<float>("StarterScale", 1f, "Стартер: размер", (string)null, false, false, (ValueValidator)null, (string)null);
			_starterDelay = _cfg.CreateEntry<float>("StarterDelay", 0.35f, "Стартер: задержка перед выпуском пил", (string)null, false, false, (ValueValidator)null, (string)null);
			_tintEnabled = _cfg.CreateEntry<bool>("TintEnabled", true, "Красный экран при включении", (string)null, false, false, (ValueValidator)null, (string)null);
			_bloodEnabled = _cfg.CreateEntry<bool>("BloodEnabled", true, "Кровь из рук и головы при выпуске", (string)null, false, false, (ValueValidator)null, (string)null);
			_bloodAmount = _cfg.CreateEntry<float>("BloodAmount", 1f, "Количество крови (множитель)", (string)null, false, false, (ValueValidator)null, (string)null);
			_tintIntensity = _cfg.CreateEntry<float>("TintIntensity", 0.2f, "Красный экран: сила 0-1", (string)null, false, false, (ValueValidator)null, (string)null);
			_cfgVer = _cfg.CreateEntry<int>("ConfigVersion", 1, "Версия конфига", (string)null, false, false, (ValueValidator)null, (string)null);
			if (_cfgVer.Value < 2)
			{
				_headX.Value = 0f;
				_headY.Value = 0.05f;
				_headZ.Value = 0.1f;
				_headPitch.Value = -22f;
				_headRoll.Value = 90f;
				_volStart.Value = 0.5f;
				_cfgVer.Value = 2;
			}
			if (_cfgVer.Value < 3)
			{
				_volStart.Value = 0.8f;
				_cfgVer.Value = 3;
			}
			if (_cfgVer.Value < 4)
			{
				_starterDown.Value = 0.3f;
				_starterOut.Value = 0.15f;
				_cfgVer.Value = 4;
			}
			if (_cfgVer.Value < 5)
			{
				_starterDelay.Value = 0.35f;
				_cfgVer.Value = 5;
			}
			((MelonBase)this).LoggerInstance.Msg("========================================");
			((MelonBase)this).LoggerInstance.Msg("Denji Chainsaws v0.3.0");
			((MelonBase)this).LoggerInstance.Msg("Стартер на груди - выпустить, B / Menu - убрать");
			((MelonBase)this).LoggerInstance.Msg("Курок - дать газу");
			((MelonBase)this).LoggerInstance.Msg("========================================");
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			CleanupAll();
			if (!(sceneName == "MainMenuScene") && !(sceneName == "IntroScene"))
			{
				_bindTimer = 0f;
				Bind();
			}
		}

		public override void OnDeinitializeMelon()
		{
			CleanupAll();
			Mci.Close("pochita_armor");
			Mci.Close("pochita_scream");
		}

		public override void OnUpdate()
		{
			float deltaTime = Time.deltaTime;
			UpdateCamera();
			if ((Object)(object)_rig == (Object)null)
			{
				_bindTimer -= deltaTime;
				if (_bindTimer <= 0f)
				{
					_bindTimer = 1f;
					Bind();
				}
			}
			if (!((Object)(object)_rig == (Object)null))
			{
				_searchTimer -= deltaTime;
				if ((Object)(object)_prefab == (Object)null && _searchTimer <= 0f)
				{
					_searchTimer = 2f;
					FindPrefab();
				}
				HandleToggle();
				HandleRev();
				UpdateAudio(deltaTime);
				UpdateTint(deltaTime);
				EnsureStarter();
				UpdateStarter();
				UpdateChains(deltaTime);
				UpdateRegen(deltaTime);
			}
		}

		public override void OnLateUpdate()
		{
			LateChains();
		}

		public override void OnFixedUpdate()
		{
			FixedChains();
			if (_mode != 0)
			{
				float fixedDeltaTime = Time.fixedDeltaTime;
				UpdateSaw(_leftSaw, fixedDeltaTime);
				UpdateSaw(_rightSaw, fixedDeltaTime);
				UpdateSaw(_headSaw, fixedDeltaTime);
				UpdateSaw(_leftElbowSaw, fixedDeltaTime);
				UpdateSaw(_rightElbowSaw, fixedDeltaTime);
				if (_mode == 2 && _leftSaw == null && _rightSaw == null && _headSaw == null && _leftElbowSaw == null && _rightElbowSaw == null)
				{
					_mode = 0;
					_rev = false;
				}
			}
		}

		private void Bind()
		{
			GameObject val = GameObject.Find("Hexa4Rig26.10.23");
			if ((Object)(object)val == (Object)null)
			{
				val = FindRigByPrefix();
			}
			if (!((Object)(object)val == (Object)null))
			{
				_rig = val.transform;
				_inputs = val.GetComponentInChildren<HVRHexaBodyInputs>();
				if ((Object)(object)_inputs == (Object)null)
				{
					_inputs = Object.FindObjectOfType<HVRHexaBodyInputs>();
				}
				_leftHand = FindDeep(_rig, "Physics LeftHand");
				_rightHand = FindDeep(_rig, "Physics RightHand");
				_leftElbow = FindDeep(_rig, "PlayerUpperChest");
				if ((Object)(object)_leftElbow == (Object)null)
				{
					_leftElbow = _rig;
				}
				_rightElbow = _leftElbow;
				_leftGrabber = (((Object)(object)_leftHand != (Object)null) ? ((Component)_leftHand).GetComponent<HVRHandGrabber>() : null);
				if ((Object)(object)_leftGrabber == (Object)null && (Object)(object)_leftHand != (Object)null)
				{
					_leftGrabber = ((Component)_leftHand).GetComponentInChildren<HVRHandGrabber>();
				}
				_rightGrabber = (((Object)(object)_rightHand != (Object)null) ? ((Component)_rightHand).GetComponent<HVRHandGrabber>() : null);
				if ((Object)(object)_rightGrabber == (Object)null && (Object)(object)_rightHand != (Object)null)
				{
					_rightGrabber = ((Component)_rightHand).GetComponentInChildren<HVRHandGrabber>();
				}
				((MelonBase)this).LoggerInstance.Msg("rig=" + ((Object)val).name + " inputs=" + ((Object)(object)_inputs != (Object)null) + " L=" + ((Object)(object)_leftHand != (Object)null) + " R=" + ((Object)(object)_rightHand != (Object)null));
			}
		}

		private void UpdateCamera()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Invalid comparison between Unknown and I4
			if ((Object)(object)_cam != (Object)null)
			{
				return;
			}
			_camTimer -= Time.deltaTime;
			if (_camTimer > 0f)
			{
				return;
			}
			_camTimer = 1f;
			_cam = Camera.main;
			if ((Object)(object)_cam != (Object)null)
			{
				return;
			}
			Camera[] array = Il2CppArrayBase<Camera>.op_Implicit((Il2CppArrayBase<Camera>)(object)Camera.allCameras);
			if (array == null)
			{
				return;
			}
			for (int i = 0; i < array.Length; i++)
			{
				if (!((Object)(object)array[i] == (Object)null) && (int)array[i].stereoTargetEye == 3)
				{
					_cam = array[i];
					break;
				}
			}
			if ((Object)(object)_cam == (Object)null && array.Length != 0)
			{
				_cam = array[0];
			}
		}

		private void HandleToggle()
		{
			if ((Object)(object)_inputs == (Object)null)
			{
				return;
			}
			HVRController leftController = _inputs.LeftController;
			HVRController rightController = _inputs.RightController;
			bool flag = IsTogglePressed(leftController) || IsTogglePressed(rightController);
			if (flag && !_wasB)
			{
				if (_starterEnabled.Value && (Object)(object)_starterHandle != (Object)null)
				{
					if (_mode == 1)
					{
						Toggle();
					}
				}
				else
				{
					Toggle();
				}
			}
			_wasB = flag;
		}

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

		private void Toggle()
		{
			if (_mode != 2)
			{
				if (_mode == 1)
				{
					RetractAll();
				}
				else if ((!((Object)(object)_leftGrabber != (Object)null) || !((HVRGrabberBase)_leftGrabber).IsGrabbing) && (!((Object)(object)_rightGrabber != (Object)null) || !((HVRGrabberBase)_rightGrabber).IsGrabbing))
				{
					SpawnAll();
				}
			}
		}

		private void HandleRev()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if (_mode == 1 && !((Object)(object)_inputs == (Object)null))
			{
				HVRController leftController = _inputs.LeftController;
				HVRController rightController = _inputs.RightController;
				bool flag = ((Object)(object)leftController != (Object)null && leftController.TriggerButtonState.Active) || ((Object)(object)rightController != (Object)null && rightController.TriggerButtonState.Active);
				if (flag != _rev)
				{
					_rev = flag;
					ApplyRev(flag);
				}
			}
		}

		private void ApplyRev(bool revved)
		{
			SetRev(_leftSaw, revved);
			SetRev(_rightSaw, revved);
			SetRev(_headSaw, revved);
		}

		private void SpawnBloodBurst(Vector3 pos)
		{
			//IL_002d: 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_0090: 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_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_00c6: 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_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: 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_0158: 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_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				int num = Mathf.RoundToInt(Mathf.Clamp(_bloodAmount.Value, 0.2f, 3f) * 52f);
				Material bloodMaterial = GetBloodMaterial();
				for (int i = 0; i < num; i++)
				{
					GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
					((Object)obj).name = "DenjiBloodDrop";
					Collider component = obj.GetComponent<Collider>();
					if ((Object)(object)component != (Object)null)
					{
						Object.Destroy((Object)(object)component);
					}
					float num2 = ((i % 3 != 0) ? Random.Range(0.022f, 0.048f) : Random.Range(0.01f, 0.022f));
					obj.transform.position = pos + Random.insideUnitSphere * 0.04f;
					obj.transform.localScale = new Vector3(num2, num2 * Random.Range(0.85f, 1.2f), num2);
					obj.transform.rotation = Random.rotation;
					Renderer component2 = obj.GetComponent<Renderer>();
					if ((Object)(object)component2 != (Object)null)
					{
						component2.sharedMaterial = bloodMaterial;
					}
					Rigidbody obj2 = obj.AddComponent<Rigidbody>();
					obj2.mass = 0.02f;
					obj2.useGravity = true;
					obj2.drag = 0.7f;
					obj2.angularDrag = 2f;
					Vector3 val = Random.onUnitSphere;
					val.y = Mathf.Abs(val.y) * 0.9f + 0.3f;
					val = ((Vector3)(ref val)).normalized;
					obj2.velocity = val * Random.Range(0.9f, 3.6f);
					obj2.angularVelocity = Random.onUnitSphere * 8f;
					Object.Destroy((Object)(object)obj, Random.Range(1.3f, 2.1f));
				}
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("blood failed: " + ex.Message);
			}
		}

		private Material GetBloodMaterial()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_bloodMat != (Object)null)
			{
				return _bloodMat;
			}
			Shader val = Shader.Find("Universal Render Pipeline/Unlit");
			if ((Object)(object)val == (Object)null)
			{
				val = Shader.Find("Unlit/Color");
			}
			if ((Object)(object)val == (Object)null)
			{
				val = Shader.Find("Standard");
			}
			_bloodMat = new Material(val);
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.78f, 0.05f, 0.05f, 1f);
			if (_bloodMat.HasProperty("_BaseColor"))
			{
				_bloodMat.SetColor("_BaseColor", val2);
			}
			if (_bloodMat.HasProperty("_Color"))
			{
				_bloodMat.SetColor("_Color", val2);
			}
			if (_bloodMat.HasProperty("_Smoothness"))
			{
				_bloodMat.SetFloat("_Smoothness", 0.75f);
			}
			return _bloodMat;
		}

		private static void SetRev(Saw s, bool revved)
		{
			if (s == null || (Object)(object)s.mgr == (Object)null)
			{
				return;
			}
			try
			{
				s.mgr.isRevved = revved;
			}
			catch
			{
			}
		}

		private void SpawnAll()
		{
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_prefab == (Object)null)
			{
				FindPrefab();
			}
			if ((Object)(object)_prefab == (Object)null)
			{
				((MelonBase)this).LoggerInstance.Warning("Chainsaw prefab not found");
				return;
			}
			CacheRigColliders();
			Saw saw = SpawnSaw(left: false, head: false);
			Saw saw2 = SpawnSaw(left: true, head: false);
			Saw saw3 = SpawnSaw(left: false, head: true);
			Saw saw4 = SpawnSaw(left: false, head: false, elbow: true);
			Saw saw5 = SpawnSaw(left: true, head: false, elbow: true);
			if (saw == null || saw2 == null || saw3 == null || saw4 == null || saw5 == null)
			{
				DestroySaw(saw);
				DestroySaw(saw2);
				DestroySaw(saw3);
				DestroySaw(saw4);
				DestroySaw(saw5);
				((MelonBase)this).LoggerInstance.Warning("Failed to spawn all chainsaws");
				return;
			}
			_leftSaw = saw;
			_rightSaw = saw2;
			_headSaw = saw3;
			_leftElbowSaw = saw4;
			_rightElbowSaw = saw5;
			_mode = 1;
			_rev = false;
			BoostSpeed();
			StartHeightTransition(up: true);
			if (_bloodEnabled.Value)
			{
				if ((Object)(object)_leftHand != (Object)null)
				{
					SpawnBloodBurst(_leftHand.position);
				}
				if ((Object)(object)_rightHand != (Object)null)
				{
					SpawnBloodBurst(_rightHand.position);
				}
				if (saw3 != null && (Object)(object)saw3.go != (Object)null)
				{
					SpawnBloodBurst(saw3.go.transform.position);
				}
			}
			ChainsawManager mgr = saw.mgr;
			if ((Object)(object)mgr != (Object)null)
			{
				_startClip = mgr.chainsawStartSound;
				_stopClip = mgr.chainsawStopSound;
			}
			EnsureMovieSounds();
			_screamPlayed = false;
			if (_armorReady)
			{
				Mci.Play("pochita_armor");
			}
			PlayRoar();
			PlayMusic();
			RoarKnockdown();
			_voiceDelay = 0.25f;
			AudioClip val = (((Object)(object)mgr != (Object)null) ? mgr.chainsawIdle : null);
			AudioClip val2 = (((Object)(object)mgr != (Object)null) ? mgr.chainsawRevved : null);
			if ((Object)(object)val == (Object)null && (Object)(object)mgr != (Object)null && (Object)(object)mgr.audioSourceA != (Object)null)
			{
				val = mgr.audioSourceA.clip;
			}
			if ((Object)(object)val2 == (Object)null && (Object)(object)mgr != (Object)null && (Object)(object)mgr.audioSourceB != (Object)null)
			{
				val2 = mgr.audioSourceB.clip;
			}
			SetupAudio(val, val2);
			ApplyRev(revved: false);
			_voiceDelay = 0.25f;
			_engineDelay = 0f;
			if ((Object)(object)_oneShot != (Object)null)
			{
				if ((Object)(object)_startClip != (Object)null)
				{
					try
					{
						_oneShot.PlayOneShot(_startClip, Mathf.Max(0f, _volStart.Value));
					}
					catch
					{
					}
				}
				if (_movieSounds.Value && _voiceReady)
				{
					_voiceDelay = 0.4f;
				}
			}
			EnsureTint();
			((MelonBase)this).LoggerInstance.Msg("Denji saws out");
		}

		private void PlayMusic()
		{
			try
			{
				string soundDir = SoundDir;
				string path = Path.Combine(soundDir, "kickback.wav");
				if (!File.Exists(path))
				{
					path = Path.Combine(soundDir, "Kick Back.wav");
				}
				if (!File.Exists(path))
				{
					((MelonBase)this).LoggerInstance.Msg("music file not found: " + Path.Combine(soundDir, "kickback.wav"));
					return;
				}
				_musicReady = Mci.Open("pochita_music", path, 0.7f);
				if (_musicReady)
				{
					Mci.Play("pochita_music");
				}
				else
				{
					((MelonBase)this).LoggerInstance.Warning("music mci failed: " + Mci.LastError);
				}
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("music failed: " + ex.Message);
			}
		}

		private void StopMusic()
		{
			if (!_musicReady)
			{
				return;
			}
			_musicReady = false;
			try
			{
				Mci.Close("pochita_music");
			}
			catch
			{
			}
		}

		private void PlayRoar()
		{
			if (!_voiceReady)
			{
				return;
			}
			try
			{
				Mci.Play("pochita_scream");
			}
			catch
			{
			}
		}

		private void RoarKnockdown()
		{
			//IL_003b: 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_0029: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_014b: 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_00ba: 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_00d4: 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)
			Vector3 val = (((Object)(object)_cam != (Object)null) ? ((Component)_cam).transform.position : (((Object)(object)_rig != (Object)null) ? _rig.position : Vector3.zero));
			Il2CppArrayBase<StickHealth> val2 = Object.FindObjectsOfType<StickHealth>();
			if (val2 == null)
			{
				return;
			}
			int num = 0;
			for (int i = 0; i < val2.Length; i++)
			{
				StickHealth val3 = val2[i];
				if ((Object)(object)val3 == (Object)null)
				{
					continue;
				}
				try
				{
					if (val3.isDead)
					{
						continue;
					}
				}
				catch
				{
					continue;
				}
				if ((Object)(object)((Component)val3).gameObject == (Object)null || !((Component)val3).gameObject.activeInHierarchy)
				{
					continue;
				}
				Vector3 val4 = (((Object)(object)val3.upperChest != (Object)null) ? val3.upperChest.transform.position : ((Component)val3).transform.position);
				if (Vector3.Distance(val4, val) > 50f)
				{
					continue;
				}
				try
				{
					val3.StartStaggering();
				}
				catch
				{
				}
				GameObject pelvisGo = val3.pelvisGo;
				if ((Object)(object)pelvisGo != (Object)null)
				{
					Rigidbody component = pelvisGo.GetComponent<Rigidbody>();
					if ((Object)(object)component != (Object)null && !component.isKinematic)
					{
						Vector3 val5 = val4 - val;
						val5.y = 0f;
						if (((Vector3)(ref val5)).sqrMagnitude < 0.01f)
						{
							val5 = Vector3.forward;
						}
						component.AddForce(((Vector3)(ref val5)).normalized * 5f + Vector3.up * 2.5f, (ForceMode)2);
					}
				}
				num++;
			}
			((MelonBase)this).LoggerInstance.Msg("roar knockdown enemies=" + num);
		}

		private void UpdateRegen(float dt)
		{
			if (_mode != 1)
			{
				return;
			}
			if ((Object)(object)_health == (Object)null)
			{
				try
				{
					_health = Object.FindFirstObjectByType<PlayerHealthManager>();
				}
				catch
				{
				}
			}
			if ((Object)(object)_health == (Object)null)
			{
				return;
			}
			float num = (((Object)(object)_health.playerStats != (Object)null) ? _health.playerStats.health : _health.startHealth);
			if (num <= 0f)
			{
				num = 100f;
			}
			if (_health.health >= num)
			{
				return;
			}
			_health.health = Mathf.Min(num, _health.health + 12f * dt);
			try
			{
				_health.healthBarCurrentValue = _health.health;
			}
			catch
			{
			}
		}

		private void StartHeightTransition(bool up)
		{
			if (!_transition && !((Object)(object)_player == (Object)null))
			{
				bool flag = Mathf.Abs(HeightCore.Current - 1.2f) < 0.01f;
				if (up != flag)
				{
					_transition = true;
					MelonCoroutines.Start(HeightTransition(up));
				}
			}
		}

		private IEnumerator HeightTransition(bool up)
		{
			try
			{
				EnsureFade();
				if ((Object)(object)_fadeGo != (Object)null)
				{
					_fadeGo.SetActive(true);
				}
				if ((Object)(object)_fadeMat != (Object)null)
				{
					_fadeMat.color = new Color(0f, 0f, 0f, 0f);
				}
				float t = 0f;
				while (t < 0.12f && (Object)(object)_fadeMat != (Object)null)
				{
					t += Time.unscaledDeltaTime;
					_fadeMat.color = new Color(0f, 0f, 0f, Mathf.Clamp01(t / 0.12f));
					yield return null;
				}
				HexaBodyPlayer4 val = HeightCore.FindBody();
				if ((Object)(object)val != (Object)null)
				{
					HeightCore.SetScale(val, up ? 1.2f : 1f);
				}
				_scaled = Mathf.Abs(HeightCore.Current - 1.2f) < 0.01f;
				yield return (object)new WaitForSeconds(1f);
				t = 0f;
				while (t < 0.16f && (Object)(object)_fadeMat != (Object)null)
				{
					t += Time.unscaledDeltaTime;
					_fadeMat.color = new Color(0f, 0f, 0f, 1f - Mathf.Clamp01(t / 0.16f));
					yield return null;
				}
			}
			finally
			{
				Core core = this;
				if ((Object)(object)core._fadeGo != (Object)null)
				{
					core._fadeGo.SetActive(false);
				}
				core._transition = false;
			}
		}

		private void EnsureFade()
		{
			//IL_009b: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_fadeGo != (Object)null)
			{
				return;
			}
			try
			{
				Camera cam = _cam;
				if (!((Object)(object)cam == (Object)null))
				{
					Shader val = Shader.Find("Sprites/Default");
					if (!((Object)(object)val == (Object)null))
					{
						_fadeGo = GameObject.CreatePrimitive((PrimitiveType)5);
						Object.Destroy((Object)(object)_fadeGo.GetComponent<Collider>());
						((Object)_fadeGo).name = "PochitaFade";
						_fadeGo.transform.SetParent(((Component)cam).transform, false);
						_fadeGo.transform.localPosition = new Vector3(0f, 0f, 0.2f);
						_fadeGo.transform.localRotation = Quaternion.identity;
						float num = ((cam.fieldOfView > 1f) ? cam.fieldOfView : 60f);
						float num2 = 0.4f * Mathf.Tan(num * 0.5f * ((float)Math.PI / 180f));
						_fadeGo.transform.localScale = new Vector3(num2 * cam.aspect * 1.4f, num2 * 1.4f, 1f);
						_fadeMat = new Material(val);
						_fadeMat.color = new Color(0f, 0f, 0f, 0f);
						_fadeGo.GetComponent<Renderer>().material = _fadeMat;
						_fadeGo.SetActive(true);
					}
				}
			}
			catch
			{
			}
		}

		private void BoostSpeed()
		{
			if (_speedBoosted)
			{
				return;
			}
			try
			{
				if ((Object)(object)_player == (Object)null)
				{
					_player = Object.FindFirstObjectByType<HexaBodyPlayer4>();
				}
				if (!((Object)(object)_player == (Object)null))
				{
					_savedWalk = _player.WalkSpeed;
					_savedRun = _player.RunSpeed;
					_player.WalkSpeed = _savedWalk * 1.4f;
					_player.RunSpeed = _savedRun * 1.4f;
					_speedBoosted = true;
					((MelonBase)this).LoggerInstance.Msg("speed boosted walk=" + _player.WalkSpeed.ToString("F2") + " run=" + _player.RunSpeed.ToString("F2"));
				}
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("speed boost failed: " + ex.Message);
			}
		}

		private void RestoreSpeed()
		{
			if (!_speedBoosted)
			{
				return;
			}
			_speedBoosted = false;
			try
			{
				if (!((Object)(object)_player == (Object)null))
				{
					_player.WalkSpeed = _savedWalk;
					_player.RunSpeed = _savedRun;
				}
			}
			catch
			{
			}
		}

		private Saw SpawnSaw(bool left, bool head, bool elbow = false)
		{
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_052e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0600: Unknown result type (might be due to invalid IL or missing references)
			//IL_0605: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_063e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0643: 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_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0574: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			GameObject val;
			try
			{
				val = Object.Instantiate<GameObject>(_prefab);
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("instantiate failed: " + ex.Message);
				return null;
			}
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			((Object)val).name = (head ? "PochitaHeadSaw" : ((!elbow) ? (left ? "PochitaLeftSaw" : "PochitaRightSaw") : (left ? "PochitaLeftElbowSaw" : "PochitaRightElbowSaw")));
			val.transform.SetParent((Transform)null, false);
			float num = Mathf.Max(0.2f, head ? _headScale.Value : _handScale.Value);
			num *= (head ? 1.9f : (elbow ? 1.45f : 1.65f));
			val.transform.localScale = Vector3.one * num;
			DestroyComponentByName(val, "HVRTagSocketable");
			DestroyComponentByName(val, "HVRStringSocketable");
			DisableComponentByName(val, "HVRGrabbable");
			DisableComponentByName(val, "HVRGrabbableImpactHaptics");
			DisableComponentByName(val, "StabilizerGrabbable");
			DisableComponentByName(val, "ImpactObjectRigidbody");
			DisableComponentByName(val, "ImpactCollisionTrigger3D");
			DisableComponentByName(val, "ImpactSlideAndRollTrigger3D");
			ChainsawManager component = val.GetComponent<ChainsawManager>();
			if ((Object)(object)component == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			try
			{
				ParticleSystem smokeParticleSystem = component.smokeParticleSystem;
				if ((Object)(object)smokeParticleSystem != (Object)null)
				{
					smokeParticleSystem.Stop(true, (ParticleSystemStopBehavior)0);
					((Component)smokeParticleSystem).gameObject.SetActive(false);
				}
			}
			catch
			{
			}
			ParticleSystem[] array = Il2CppArrayBase<ParticleSystem>.op_Implicit(val.GetComponentsInChildren<ParticleSystem>(true));
			if (array != null)
			{
				foreach (ParticleSystem val2 in array)
				{
					if (!((Object)(object)val2 == (Object)null) && ((Object)((Component)val2).gameObject).name.ToLower().Contains("smoke"))
					{
						try
						{
							val2.Stop(true, (ParticleSystemStopBehavior)0);
							((Component)val2).gameObject.SetActive(false);
						}
						catch
						{
						}
					}
				}
			}
			try
			{
				component.StartChainsaw();
			}
			catch
			{
				try
				{
					component.isRunning = true;
				}
				catch
				{
				}
			}
			Rigidbody val3 = val.GetComponent<Rigidbody>();
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = val.AddComponent<Rigidbody>();
			}
			val3.isKinematic = true;
			val3.useGravity = false;
			val3.detectCollisions = true;
			val3.interpolation = (RigidbodyInterpolation)1;
			val3.mass = 1.5f;
			val3.collisionDetectionMode = (CollisionDetectionMode)3;
			AudioSource[] array2 = Il2CppArrayBase<AudioSource>.op_Implicit(val.GetComponents<AudioSource>());
			if (array2 != null)
			{
				for (int j = 0; j < array2.Length; j++)
				{
					if (!((Object)(object)array2[j] == (Object)null))
					{
						try
						{
							array2[j].Stop();
						}
						catch
						{
						}
						try
						{
							((Behaviour)array2[j]).enabled = false;
						}
						catch
						{
						}
					}
				}
			}
			Saw saw = new Saw();
			saw.isHead = head;
			saw.isElbow = elbow;
			saw.isLeft = left;
			saw.hand = (left ? _leftHand : _rightHand);
			saw.anchor = ((!elbow) ? null : (left ? _leftElbow : _rightElbow));
			saw.go = val;
			saw.rb = val3;
			saw.mgr = component;
			saw.offset = (Vector3)(head ? new Vector3(_headX.Value, _headY.Value, _headZ.Value) : (elbow ? new Vector3(left ? (-0.3f) : 0.06f, -0.2f, 0.05f) : (left ? OffsetLeft : OffsetRight)));
			saw.grip = (head ? RotRight : (elbow ? Quaternion.Euler(0f, 180f, 0f) : (left ? RotLeft : RotRight)));
			saw.deployDistance = 0.4f;
			if (!GetAnchor(saw, out var pos, out var rot))
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			Vector3 val4 = pos + rot * saw.offset;
			if (!saw.isHead && !saw.isElbow)
			{
				val4 += Vector3.left * 0.05f;
			}
			Quaternion rot2 = rot * saw.grip;
			saw.pos = val4 - rot * Vector3.forward * saw.deployDistance;
			saw.rot = rot2;
			val.transform.SetPositionAndRotation(saw.pos, saw.rot);
			Collider[] array3 = Il2CppArrayBase<Collider>.op_Implicit(val.GetComponentsInChildren<Collider>(true));
			if (array3 != null)
			{
				foreach (Collider val5 in array3)
				{
					if ((Object)(object)val5 == (Object)null)
					{
						continue;
					}
					if (IsCuttingPart(((Component)val5).transform))
					{
						if (val5.enabled)
						{
							saw.colliders.Add(val5);
						}
					}
					else
					{
						try
						{
							val5.enabled = false;
						}
						catch
						{
						}
					}
				}
			}
			Renderer[] array4 = Il2CppArrayBase<Renderer>.op_Implicit(val.GetComponentsInChildren<Renderer>(true));
			if (array4 != null)
			{
				foreach (Renderer val6 in array4)
				{
					if (!((Object)(object)val6 == (Object)null) && !IsCuttingPart(((Component)val6).transform))
					{
						try
						{
							val6.enabled = false;
						}
						catch
						{
						}
					}
				}
			}
			if (head)
			{
				Bounds bounds = default(Bounds);
				((Bounds)(ref bounds))..ctor(val.transform.position, Vector3.zero);
				bool flag = false;
				if (array4 != null)
				{
					foreach (Renderer val7 in array4)
					{
						if (!((Object)(object)val7 == (Object)null) && val7.enabled)
						{
							if (!flag)
							{
								bounds = val7.bounds;
								flag = true;
							}
							else
							{
								((Bounds)(ref bounds)).Encapsulate(val7.bounds);
							}
						}
					}
				}
				Instance loggerInstance = ((MelonBase)this).LoggerInstance;
				string[] obj9 = new string[8] { "head saw pos=", null, null, null, null, null, null, null };
				Vector3 val8 = val.transform.position;
				obj9[1] = ((Vector3)(ref val8)).ToString("F2");
				obj9[2] = " rot=";
				Quaternion rotation = val.transform.rotation;
				val8 = ((Quaternion)(ref rotation)).eulerAngles;
				obj9[3] = ((Vector3)(ref val8)).ToString("F0");
				obj9[4] = " size=";
				object obj10;
				if (!flag)
				{
					obj10 = "none";
				}
				else
				{
					val8 = ((Bounds)(ref bounds)).size;
					obj10 = ((Vector3)(ref val8)).ToString("F2");
				}
				obj9[5] = (string)obj10;
				obj9[6] = " cam=";
				object obj11;
				if (!((Object)(object)_cam != (Object)null))
				{
					obj11 = "none";
				}
				else
				{
					val8 = ((Component)_cam).transform.position;
					obj11 = ((Vector3)(ref val8)).ToString("F2");
				}
				obj9[7] = (string)obj11;
				loggerInstance.Msg(string.Concat(obj9));
			}
			IgnoreRigCollisions(saw);
			val.SetActive(true);
			return saw;
		}

		private void UpdateSaw(Saw s, float dt)
		{
			//IL_00a6: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_00e2: 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_00e9: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: 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_0158: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: 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_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: 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_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: 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_01e5: 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_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: 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_0229: 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_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			if (s == null)
			{
				return;
			}
			if ((Object)(object)s.go == (Object)null)
			{
				DestroySaw(s);
				return;
			}
			if (!GetAnchor(s, out var pos, out var rot))
			{
				DestroySaw(s);
				return;
			}
			float num = Mathf.Max(0.02f, 0.15f);
			if (_mode == 2)
			{
				s.progress -= dt / num;
				if (s.progress <= 0f)
				{
					DestroySaw(s);
					return;
				}
			}
			else
			{
				s.progress = Mathf.Min(1f, s.progress + dt / num);
			}
			float num2 = Mathf.Clamp01(s.progress);
			float num3 = num2 * num2 * (3f - 2f * num2);
			Vector3 val = pos + rot * s.offset;
			if (!s.isHead && !s.isElbow)
			{
				val += Vector3.left * 0.05f;
			}
			Quaternion val2 = rot * s.grip;
			Vector3 val3 = val - rot * Vector3.forward * (s.deployDistance * (1f - num3));
			if (Vector3.Distance(s.pos, val3) > 0.45f)
			{
				s.pos = val3;
				s.rot = val2;
			}
			else
			{
				Vector3 val4 = Vector3.Lerp(s.pos, val3, 130f * dt);
				float num4 = Vector3.Distance(s.pos, val4);
				float num5 = 150f * dt;
				if (num4 > num5)
				{
					Vector3 pos2 = s.pos;
					Vector3 val5 = val4 - s.pos;
					val4 = pos2 + ((Vector3)(ref val5)).normalized * num5;
				}
				s.pos = val4;
				Quaternion val6 = Quaternion.Slerp(s.rot, val2, 130f * dt);
				float num6 = Quaternion.Angle(s.rot, val6);
				float num7 = 9000f * dt;
				if (num6 > num7)
				{
					val6 = Quaternion.RotateTowards(s.rot, val6, num7);
				}
				s.rot = val6;
			}
			if ((Object)(object)s.rb != (Object)null)
			{
				s.rb.MovePosition(s.pos);
				s.rb.MoveRotation(s.rot);
			}
			else
			{
				s.go.transform.SetPositionAndRotation(s.pos, s.rot);
			}
		}

		private bool GetAnchor(Saw s, out Vector3 pos, out Quaternion rot)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0046: 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_0112: 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)
			//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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_00ad: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: 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_015a: 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)
			if (s.isHead)
			{
				UpdateCamera();
				if ((Object)(object)_cam != (Object)null)
				{
					pos = ((Component)_cam).transform.position;
					rot = ((Component)_cam).transform.rotation;
				}
				else
				{
					if (!((Object)(object)_rig != (Object)null))
					{
						pos = Vector3.zero;
						rot = Quaternion.identity;
						return false;
					}
					pos = _rig.position + Vector3.up * 1.55f;
					rot = _rig.rotation;
				}
				rot *= Quaternion.Euler(_headPitch.Value, _headYaw.Value, _headRoll.Value);
				return true;
			}
			if (s.isElbow && (Object)(object)s.anchor != (Object)null)
			{
				pos = s.anchor.position;
				rot = s.anchor.rotation;
				return true;
			}
			Transform val = s.hand;
			if ((Object)(object)val == (Object)null)
			{
				val = (s.isLeft ? _leftHand : _rightHand);
			}
			if ((Object)(object)val == (Object)null)
			{
				pos = Vector3.zero;
				rot = Quaternion.identity;
				return false;
			}
			pos = val.position;
			rot = val.rotation;
			return true;
		}

		private void RetractAll()
		{
			//IL_002c: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			if (_mode != 1)
			{
				return;
			}
			if (_bloodEnabled.Value)
			{
				if ((Object)(object)_leftHand != (Object)null)
				{
					SpawnBloodBurst(_leftHand.position);
				}
				if ((Object)(object)_rightHand != (Object)null)
				{
					SpawnBloodBurst(_rightHand.position);
				}
				if (_headSaw != null && (Object)(object)_headSaw.go != (Object)null)
				{
					SpawnBloodBurst(_headSaw.go.transform.position);
				}
			}
			_mode = 2;
			_rev = false;
			StopMusic();
			StartHeightTransition(up: false);
			RestoreSpeed();
			_voiceDelay = 0f;
			_engineDelay = 0f;
			ApplyRev(revved: false);
			StopAudio();
		}

		private void DestroySaw(Saw s)
		{
			if (s == null)
			{
				return;
			}
			if ((Object)(object)s.mgr != (Object)null)
			{
				try
				{
					s.mgr.isRevved = false;
				}
				catch
				{
				}
				try
				{
					s.mgr.StopChainsaw();
				}
				catch
				{
				}
			}
			if ((Object)(object)s.go != (Object)null)
			{
				try
				{
					Object.Destroy((Object)(object)s.go);
				}
				catch
				{
				}
			}
			if (s == _leftSaw)
			{
				_leftSaw = null;
			}
			if (s == _rightSaw)
			{
				_rightSaw = null;
			}
			if (s == _headSaw)
			{
				_headSaw = null;
			}
			if (s == _leftElbowSaw)
			{
				_leftElbowSaw = null;
			}
			if (s == _rightElbowSaw)
			{
				_rightElbowSaw = null;
			}
		}

		private void EnsureMovieSounds()
		{
			if (_movieLoaded)
			{
				return;
			}
			_movieLoaded = true;
			if (_movieSounds.Value)
			{
				string soundDir = SoundDir;
				try
				{
					Directory.CreateDirectory(soundDir);
				}
				catch (Exception ex)
				{
					((MelonBase)this).LoggerInstance.Warning("sounds dir failed: " + ex.Message);
				}
				((MelonBase)this).LoggerInstance.Msg("sounds dir=" + soundDir);
				string text = Path.Combine(soundDir, "armor.wav");
				string text2 = Path.Combine(soundDir, "scream.wav");
				_armorReady = File.Exists(text) && Mci.Open("pochita_armor", text, _voiceVolume.Value);
				_voiceReady = File.Exists(text2) && Mci.Open("pochita_scream", text2, _voiceVolume.Value);
				if (!_armorReady)
				{
					((MelonBase)this).LoggerInstance.Warning("armor sound missing: " + text);
				}
				if (!_voiceReady)
				{
					((MelonBase)this).LoggerInstance.Warning("scream sound missing: " + text2);
				}
				((MelonBase)this).LoggerInstance.Msg("movie sounds armor=" + _armorReady + " scream=" + _voiceReady);
			}
		}

		private bool EnsureSoundFile(string dir, string file)
		{
			string path = Path.Combine(dir, file);
			if (File.Exists(path))
			{
				return true;
			}
			byte[] array = ReadEmbedded(file);
			if (array == null || array.Length < 44)
			{
				((MelonBase)this).LoggerInstance.Warning("wav " + file + " missing in " + dir);
				return false;
			}
			try
			{
				File.WriteAllBytes(path, array);
				((MelonBase)this).LoggerInstance.Msg("wav " + file + " unpacked");
				return true;
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("wav write " + file + " failed: " + ex.Message);
				return false;
			}
		}

		private static byte[] ReadEmbedded(string endsWith)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
			if (manifestResourceNames == null)
			{
				return null;
			}
			foreach (string text in manifestResourceNames)
			{
				if (text == null || text.Length < endsWith.Length)
				{
					continue;
				}
				bool flag = true;
				int num = text.Length - endsWith.Length;
				for (int j = 0; j < endsWith.Length; j++)
				{
					char num2 = char.ToLowerInvariant(text[num + j]);
					char c = char.ToLowerInvariant(endsWith[j]);
					if (num2 != c)
					{
						flag = false;
						break;
					}
				}
				if (!flag)
				{
					continue;
				}
				Stream stream = null;
				try
				{
					stream = executingAssembly.GetManifestResourceStream(text);
					if (stream == null)
					{
						return null;
					}
					long length = stream.Length;
					if (length <= 0 || length > int.MaxValue)
					{
						return null;
					}
					byte[] array = new byte[(int)length];
					int k;
					int num3;
					for (k = 0; k < array.Length; k += num3)
					{
						num3 = stream.Read(array, k, array.Length - k);
						if (num3 <= 0)
						{
							break;
						}
					}
					if (k != array.Length)
					{
						return null;
					}
					return array;
				}
				finally
				{
					if (stream != null)
					{
						try
						{
							stream.Dispose();
						}
						catch
						{
						}
					}
				}
			}
			return null;
		}

		private void SetupAudio(AudioClip idleClip, AudioClip revClip)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_audioGo == (Object)null)
			{
				_audioGo = new GameObject("DenjiChainsawAudio");
				Transform val = (((Object)(object)_cam != (Object)null) ? ((Component)_cam).transform : _rig);
				if ((Object)(object)val != (Object)null)
				{
					_audioGo.transform.SetParent(val, false);
				}
				_audioGo.transform.localPosition = new Vector3(0f, -0.25f, 0f);
			}
			if ((Object)(object)_idleAudio == (Object)null)
			{
				_idleAudio = _audioGo.AddComponent<AudioSource>();
			}
			if ((Object)(object)_revAudio == (Object)null)
			{
				_revAudio = _audioGo.AddComponent<AudioSource>();
			}
			if ((Object)(object)_oneShot == (Object)null)
			{
				_oneShot = _audioGo.AddComponent<AudioSource>();
			}
			ConfigureSource(_idleAudio, idleClip, loop: true);
			ConfigureSource(_revAudio, revClip, loop: true);
			ConfigureSource(_oneShot, null, loop: false);
			_idleAudio.volume = 0f;
			_revAudio.volume = 0f;
			if ((Object)(object)idleClip != (Object)null)
			{
				try
				{
					_idleAudio.Play();
				}
				catch (Exception ex)
				{
					((MelonBase)this).LoggerInstance.Warning("idle play failed: " + ex.Message);
				}
			}
			if ((Object)(object)revClip != (Object)null)
			{
				try
				{
					_revAudio.Play();
				}
				catch (Exception ex2)
				{
					((MelonBase)this).LoggerInstance.Warning("rev play failed: " + ex2.Message);
				}
			}
			((MelonBase)this).LoggerInstance.Msg("audio idle=" + ((Object)(object)idleClip != (Object)null) + " rev=" + ((Object)(object)revClip != (Object)null) + " start=" + ((Object)(object)_startClip != (Object)null) + " stop=" + ((Object)(object)_stopClip != (Object)null) + " idlePlaying=" + ((Object)(object)_idleAudio != (Object)null && _idleAudio.isPlaying) + " revPlaying=" + ((Object)(object)_revAudio != (Object)null && _revAudio.isPlaying) + " cam=" + ((Object)(object)_cam != (Object)null) + " parent=" + ((Object)(object)_audioGo != (Object)null && (Object)(object)_audioGo.transform.parent != (Object)null));
		}

		private static void ConfigureSource(AudioSource src, AudioClip clip, bool loop)
		{
			if (!((Object)(object)src == (Object)null))
			{
				src.clip = clip;
				src.loop = loop;
				src.playOnAwake = false;
				src.spatialBlend = 0.25f;
				src.minDistance = 0.3f;
				src.maxDistance = 25f;
				src.rolloffMode = (AudioRolloffMode)1;
				src.pitch = 1f;
			}
		}

		private void UpdateAudio(float dt)
		{
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			if (_voiceDelay > 0f)
			{
				_voiceDelay -= dt;
				if (_voiceDelay <= 0f && _mode == 1 && _voiceReady && !_screamPlayed)
				{
					_screamPlayed = true;
					if (Mci.Play("pochita_scream"))
					{
						((MelonBase)this).LoggerInstance.Msg("scream play");
					}
					else
					{
						((MelonBase)this).LoggerInstance.Warning("scream play failed: " + Mci.LastError);
					}
				}
			}
			if (_engineDelay > 0f)
			{
				_engineDelay = Mathf.Max(0f, _engineDelay - dt);
			}
			if ((Object)(object)_idleAudio == (Object)null || (Object)(object)_revAudio == (Object)null)
			{
				return;
			}
			float num = 0f;
			float num2 = 0f;
			if (_mode == 1 && _engineDelay <= 0f)
			{
				if (_rev)
				{
					num2 = 0.8f;
				}
				else
				{
					num = 0f;
				}
			}
			_idleAudio.volume = Mathf.MoveTowards(_idleAudio.volume, num, dt * 3f);
			_revAudio.volume = Mathf.MoveTowards(_revAudio.volume, num2, dt * 3f);
			if ((Object)(object)_audioGo != (Object)null && (Object)(object)_audioGo.transform.parent == (Object)null && (Object)(object)_rig != (Object)null)
			{
				_audioGo.transform.SetParent(_rig, false);
				_audioGo.transform.localPosition = new Vector3(0f, 1.35f, 0f);
			}
		}

		private void EnsureTint()
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_tintGo != (Object)null || (Object)(object)_cam == (Object)null)
			{
				return;
			}
			try
			{
				Shader val = Shader.Find("Sprites/Default");
				if ((Object)(object)val == (Object)null)
				{
					throw new Exception("Sprites/Default not found");
				}
				_tintGo = GameObject.CreatePrimitive((PrimitiveType)5);
				((Object)_tintGo).name = "DenjiChainsawTint";
				Collider component = _tintGo.GetComponent<Collider>();
				if ((Object)(object)component != (Object)null)
				{
					Object.Destroy((Object)(object)component);
				}
				_tintRenderer = _tintGo.GetComponent<MeshRenderer>();
				if ((Object)(object)_tintRenderer == (Object)null)
				{
					throw new Exception("quad renderer missing");
				}
				_tintMat = new Material(val);
				_tintMat.color = new Color(0.7f, 0.02f, 0.04f, 0f);
				((Renderer)_tintRenderer).material = _tintMat;
				((Renderer)_tintRenderer).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)_tintRenderer).receiveShadows = false;
				_tintGo.transform.SetParent(((Component)_cam).transform, false);
				_tintGo.transform.localPosition = new Vector3(0f, 0f, 0.35f);
				_tintGo.transform.localRotation = Quaternion.identity;
				_tintGo.transform.localScale = new Vector3(1.4f, 1.4f, 1f);
				_tintGo.SetActive(false);
				((MelonBase)this).LoggerInstance.Msg("tint created cam=" + ((Object)_cam).name + " shader=" + ((Object)val).name);
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("tint failed: " + ex);
				if ((Object)(object)_tintGo != (Object)null)
				{
					try
					{
						Object.Destroy((Object)(object)_tintGo);
					}
					catch
					{
					}
				}
				_tintGo = null;
				_tintRenderer = null;
				_tintMat = null;
			}
		}

		private void UpdateTint(float dt)
		{
			//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_00be: Unknown result type (might be due to invalid IL or missing references)
			if (_mode != 0)
			{
				EnsureTint();
			}
			if ((Object)(object)_tintGo == (Object)null || (Object)(object)_tintRenderer == (Object)null || (Object)(object)_tintMat == (Object)null)
			{
				_tintAlpha = 0f;
				return;
			}
			float num = 0f;
			if (_mode == 1 && _tintEnabled.Value)
			{
				num = Mathf.Clamp01(_tintIntensity.Value);
				if (_rev)
				{
					num = Mathf.Clamp01(num * 1.35f);
				}
			}
			_tintAlpha = Mathf.MoveTowards(_tintAlpha, num, dt * 1.2f);
			Color color = _tintMat.color;
			color.a = _tintAlpha;
			_tintMat.color = color;
			bool flag = _tintAlpha > 0.002f;
			if (_tintGo.activeSelf != flag)
			{
				_tintGo.SetActive(flag);
			}
		}

		private void StopAudio()
		{
			if ((Object)(object)_idleAudio != (Object)null)
			{
				try
				{
					_idleAudio.Stop();
				}
				catch
				{
				}
			}
			if ((Object)(object)_revAudio != (Object)null)
			{
				try
				{
					_revAudio.Stop();
				}
				catch
				{
				}
			}
			if ((Object)(object)_oneShot != (Object)null)
			{
				try
				{
					_oneShot.Stop();
				}
				catch
				{
				}
			}
			if ((Object)(object)_oneShot != (Object)null && (Object)(object)_stopClip != (Object)null)
			{
				try
				{
					_oneShot.PlayOneShot(_stopClip, Mathf.Max(0f, _volStop.Value));
				}
				catch
				{
				}
			}
		}

		private void CacheRigColliders()
		{
			_rigColliders.Clear();
			if ((Object)(object)_rig == (Object)null)
			{
				return;
			}
			Collider[] array = Il2CppArrayBase<Collider>.op_Implicit(((Component)_rig).GetComponentsInChildren<Collider>(true));
			if (array == null)
			{
				return;
			}
			for (int i = 0; i < array.Length; i++)
			{
				if ((Object)(object)array[i] != (Object)null)
				{
					_rigColliders.Add(array[i]);
				}
			}
		}

		private void IgnoreRigCollisions(Saw s)
		{
			if (s == null || s.colliders.Count == 0)
			{
				return;
			}
			for (int i = 0; i < s.colliders.Count; i++)
			{
				Collider val = s.colliders[i];
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				for (int j = 0; j < _rigColliders.Count; j++)
				{
					Collider val2 = _rigColliders[j];
					if (!((Object)(object)val2 == (Object)null))
					{
						try
						{
							Physics.IgnoreCollision(val, val2, true);
						}
						catch
						{
						}
					}
				}
			}
		}

		private void EnsureStarter()
		{
			if (!_starterEnabled.Value || (Object)(object)_starterHandle != (Object)null || _starterTried || (Object)(object)_rig == (Object)null)
			{
				return;
			}
			if ((Object)(object)_prefab == (Object)null)
			{
				FindPrefab();
			}
			if ((Object)(object)_prefab == (Object)null)
			{
				return;
			}
			Transform val = _prefab.transform.Find("PullStartHandle");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Transform val2 = _rig.Find("HexaBody/PlayerHexaPelvis");
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = _rig.Find("PhysicalUpperBody2/Body/Pelvis");
			}
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			_starterTried = true;
			try
			{
				BuildStarter(val, val2);
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("starter build failed: " + ex);
			}
		}

		private void BuildStarter(Transform handleSrc, Transform chest)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_003f: 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_00a7: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_0108: 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_01a8: Unknown result type (migh