Decompiled source of Monster Shapeshifter v1.0.0

Mods/MonsterShapeshift.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Data;
using Il2CppSLZ.Marrow.Warehouse;
using LabFusion.Entities;
using LabFusion.Network;
using LabFusion.Player;
using LabFusion.RPC;
using LabFusion.SDK.Metadata;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using MonsterShapeshift;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(ShapeshiftMod), "MonsterShapeshift", "1.3.1", "Custom", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonGame("Stress Level Zero", "com.StressLevelZero.BONELAB")]
[assembly: MelonAdditionalDependencies(new string[] { "BoneLib", "LabFusion" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MonsterShapeshift")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MonsterShapeshift")]
[assembly: AssemblyTitle("MonsterShapeshift")]
[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 MonsterShapeshift
{
	public class ShapeshiftMod : MelonMod
	{
		public enum VrBinding
		{
			Disabled,
			Right_A_TripleTap,
			Right_A_DoubleTap,
			Right_A_Hold,
			Right_B_TripleTap,
			Right_B_Hold,
			Right_Stick_TripleTap,
			Right_Stick_Hold,
			Left_X_TripleTap,
			Left_X_DoubleTap,
			Left_X_Hold,
			Left_Y_TripleTap,
			Left_Y_Hold,
			Left_Stick_TripleTap,
			Left_Stick_Hold
		}

		private enum PhysicalButton
		{
			Right_A,
			Right_B,
			Right_Stick,
			Left_X,
			Left_Y,
			Left_Stick
		}

		private class ButtonState
		{
			public int TapCount;

			public float LastTapTime;

			public float HoldStartTime;

			public bool HoldFired;

			public bool DoubleTapEvent;

			public bool TripleTapEvent;

			public bool HoldEvent;
		}

		private class ActiveSplat
		{
			public GameObject Go;

			public Material DecalMat;

			public Color BaseColor;

			public Vector3 BaseScale;

			public Vector3 Velocity;

			public bool IsFlyingGlob;

			public bool IsVerticalWallDecal;

			public float SpawnTime;

			public float StickDuration;
		}

		private static readonly ButtonState[] _vrButtonStates = new ButtonState[6]
		{
			new ButtonState(),
			new ButtonState(),
			new ButtonState(),
			new ButtonState(),
			new ButtonState(),
			new ButtonState()
		};

		private static MelonPreferences_Category _prefs;

		private static MelonPreferences_Entry<string> _monsterBarcodePref;

		private static MelonPreferences_Entry<bool> _spoofNametagPref;

		private static MelonPreferences_Entry<bool> _randomDurationPref;

		private static MelonPreferences_Entry<float> _minRandomDurationPref;

		private static MelonPreferences_Entry<float> _maxRandomDurationPref;

		private static MelonPreferences_Entry<float> _fixedDurationPref;

		private static MelonPreferences_Entry<float> _stalkDistancePref;

		private static MelonPreferences_Entry<bool> _autoStandOnBurstPref;

		private static MelonPreferences_Entry<bool> _vrControlsEnabledPref;

		private static MelonPreferences_Entry<float> _vrHoldSecondsPref;

		private static MelonPreferences_Entry<int> _vrBindShiftRandomPref;

		private static MelonPreferences_Entry<int> _vrBindTeleportBehindPref;

		private static MelonPreferences_Entry<int> _vrBindFakeCorpsePref;

		private static MelonPreferences_Entry<int> _vrBindBurstMonsterPref;

		private static MelonPreferences_Entry<bool> _bloodEnabledPref;

		private static MelonPreferences_Entry<float> _bloodStickDurationPref;

		private static MelonPreferences_Entry<int> _bloodParticleCountPref;

		private static MelonPreferences_Entry<bool> _stickySurfaceSplatsPref;

		private static MelonPreferences_Entry<bool> _soundsEnabledPref;

		private static MelonPreferences_Entry<float> _soundVolumePref;

		private static MelonPreferences_Entry<bool> _horrorHeartbeatPref;

		private static MelonPreferences_Entry<bool> _preBurstDripsPref;

		private static MelonPreferences_Entry<bool> _crimsonMistAuraPref;

		private static MelonPreferences_Entry<bool> _autoLoopPref;

		private static MelonPreferences_Entry<float> _autoLoopDelayPref;

		private static MelonPreferences_Entry<bool> _hotkeysEnabledPref;

		private static MelonPreferences_Entry<string> _networkedBurstBarcodePref;

		private static Page _mainPage;

		private static Page _playerPickerPage;

		private static Page _vrControlsPage;

		private static Page _monsterSkinPage;

		private static Page _configPage;

		private static bool _isDisguised;

		private static float _revertTime;

		private static float _nextHeartbeatTime;

		private static float _nextPreDripTime;

		private static string _disguisedAsName = string.Empty;

		private static bool _isSpoofingName;

		private static string _savedOriginalNickname = string.Empty;

		private static bool _isPlayingDead;

		private static bool _waitingForAutoLoop;

		private static float _nextAutoShiftTime;

		private static readonly Random _rng = new Random();

		private static Texture2D _dropletTex;

		private static Texture2D _bloodSplatTex;

		private static AudioClip _bloodExplosionClip;

		private static AudioClip _shapeshiftClip;

		private static AudioClip _heartbeatClip;

		private const int MaxActiveSplats = 160;

		private static readonly List<ActiveSplat> _activeSplats = new List<ActiveSplat>();

		public override void OnInitializeMelon()
		{
			_prefs = MelonPreferences.CreateCategory("MonsterShapeshift", "Monster Shapeshift");
			_monsterBarcodePref = _prefs.CreateEntry<string>("MonsterAvatarBarcode", string.Empty, "Monster Avatar Barcode", "Leave empty to auto-save whatever avatar you are wearing before transforming.", false, false, (ValueValidator)null, (string)null);
			_spoofNametagPref = _prefs.CreateEntry<bool>("IdentityTheftNametag", true, "Identity Theft (Copy Nametag)", (string)null, false, false, (ValueValidator)null, (string)null);
			_randomDurationPref = _prefs.CreateEntry<bool>("RandomDuration", true, "Random Disguise Time", (string)null, false, false, (ValueValidator)null, (string)null);
			_minRandomDurationPref = _prefs.CreateEntry<float>("MinRandomDuration", 30f, "Min Random Time (s)", (string)null, false, false, (ValueValidator)null, (string)null);
			_maxRandomDurationPref = _prefs.CreateEntry<float>("MaxRandomDuration", 60f, "Max Random Time (s)", (string)null, false, false, (ValueValidator)null, (string)null);
			_fixedDurationPref = _prefs.CreateEntry<float>("FixedDuration", 45f, "Fixed Disguise Time (s)", (string)null, false, false, (ValueValidator)null, (string)null);
			_stalkDistancePref = _prefs.CreateEntry<float>("StalkBehindDistance", 10f, "Teleport Behind Distance (m)", (string)null, false, false, (ValueValidator)null, (string)null);
			_autoStandOnBurstPref = _prefs.CreateEntry<bool>("AutoStandOnBurst", true, "Auto-Stand from Fake Corpse on Burst", (string)null, false, false, (ValueValidator)null, (string)null);
			_vrControlsEnabledPref = _prefs.CreateEntry<bool>("VrControlsEnabled", true, "VR Controller Gestures Enabled", (string)null, false, false, (ValueValidator)null, (string)null);
			_vrHoldSecondsPref = _prefs.CreateEntry<float>("VrHoldSeconds", 0.9f, "VR Hold Trigger Time (s)", (string)null, false, false, (ValueValidator)null, (string)null);
			_vrBindShiftRandomPref = _prefs.CreateEntry<int>("VrBindShiftRandom", 1, "VR Bind: Shapeshift Random", (string)null, false, false, (ValueValidator)null, (string)null);
			_vrBindTeleportBehindPref = _prefs.CreateEntry<int>("VrBindTeleportBehind", 8, "VR Bind: Teleport Behind", (string)null, false, false, (ValueValidator)null, (string)null);
			_vrBindFakeCorpsePref = _prefs.CreateEntry<int>("VrBindFakeCorpse", 10, "VR Bind: Fake Corpse", (string)null, false, false, (ValueValidator)null, (string)null);
			_vrBindBurstMonsterPref = _prefs.CreateEntry<int>("VrBindBurstMonster", 3, "VR Bind: Burst to Monster", (string)null, false, false, (ValueValidator)null, (string)null);
			_bloodEnabledPref = _prefs.CreateEntry<bool>("BloodExplosionEnabled", true, "Blood Explosion Enabled", (string)null, false, false, (ValueValidator)null, (string)null);
			_bloodStickDurationPref = _prefs.CreateEntry<float>("BloodStickDuration", 30f, "Blood Stick Duration (s)", (string)null, false, false, (ValueValidator)null, (string)null);
			_bloodParticleCountPref = _prefs.CreateEntry<int>("BloodParticleCount", 110, "Blood Particle Count", (string)null, false, false, (ValueValidator)null, (string)null);
			_stickySurfaceSplatsPref = _prefs.CreateEntry<bool>("StickySurfaceSplats", true, "Sticky Surface Splats & Globs", (string)null, false, false, (ValueValidator)null, (string)null);
			_soundsEnabledPref = _prefs.CreateEntry<bool>("HorrorSoundsEnabled", true, "Horror Sounds Enabled", (string)null, false, false, (ValueValidator)null, (string)null);
			_soundVolumePref = _prefs.CreateEntry<float>("SoundVolume", 1.15f, "Horror Sound Volume", (string)null, false, false, (ValueValidator)null, (string)null);
			_horrorHeartbeatPref = _prefs.CreateEntry<bool>("HorrorHeartbeat", true, "Pre-Burst Heartbeat", (string)null, false, false, (ValueValidator)null, (string)null);
			_preBurstDripsPref = _prefs.CreateEntry<bool>("PreBurstBloodDrips", true, "Pre-Burst Blood Drips", (string)null, false, false, (ValueValidator)null, (string)null);
			_crimsonMistAuraPref = _prefs.CreateEntry<bool>("CrimsonMistAura", true, "Crimson Monster Mist Aura", (string)null, false, false, (ValueValidator)null, (string)null);
			_autoLoopPref = _prefs.CreateEntry<bool>("AutoShapeshiftLoop", false, "Auto-Shapeshift Loop", (string)null, false, false, (ValueValidator)null, (string)null);
			_autoLoopDelayPref = _prefs.CreateEntry<float>("AutoLoopDelay", 15f, "Auto-Loop Delay (s)", (string)null, false, false, (ValueValidator)null, (string)null);
			_hotkeysEnabledPref = _prefs.CreateEntry<bool>("HotkeysEnabled", true, "Hotkeys (F7 TP / F8 Shift / F9 Burst / F10 Corpse)", (string)null, false, false, (ValueValidator)null, (string)null);
			_networkedBurstBarcodePref = _prefs.CreateEntry<string>("NetworkedBurstBarcode", string.Empty, "Networked Fusion Burst Barcode", "Optional Marrow SpawnableCrate barcode spawned via Fusion on revert so players without the mod see an effect.", false, false, (ValueValidator)null, (string)null);
			BuildBoneMenu();
			MelonLogger.Msg("MonsterShapeshift v1.3.1 (VR Controls + Identity Theft + Fake Corpse + Gore Audio) initialized.");
		}

		public override void OnSceneWasUnloaded(int buildIndex, string sceneName)
		{
			_isDisguised = false;
			_waitingForAutoLoop = false;
			_isPlayingDead = false;
			_disguisedAsName = string.Empty;
			RestoreOriginalNickname();
			ClearAllActiveSplats();
		}

		public override void OnUpdate()
		{
			if (_hotkeysEnabledPref.Value)
			{
				if (Input.GetKeyDown((KeyCode)288))
				{
					TeleportBehindRandomPlayer();
				}
				if (Input.GetKeyDown((KeyCode)289))
				{
					ShapeshiftIntoRandomPlayer();
				}
				if (Input.GetKeyDown((KeyCode)290) && _isDisguised)
				{
					RevertToMonster();
				}
				if (Input.GetKeyDown((KeyCode)291))
				{
					ToggleFakeCorpse();
				}
			}
			if (_vrControlsEnabledPref.Value)
			{
				UpdateVrControllerInputs();
			}
			if (_isDisguised)
			{
				float num = _revertTime - Time.unscaledTime;
				if (num <= 0f)
				{
					RevertToMonster();
				}
				else if (num <= 6.2f)
				{
					UpdatePreBurstHorrorEffects(num);
				}
			}
			else if (_waitingForAutoLoop && Time.unscaledTime >= _nextAutoShiftTime)
			{
				_waitingForAutoLoop = false;
				if (NetworkInfo.HasServer)
				{
					ShapeshiftIntoRandomPlayer();
				}
			}
			UpdateActiveBloodSplats();
		}

		private static void UpdateVrControllerInputs()
		{
			if (!((Object)(object)Player.RigManager == (Object)null))
			{
				BaseController rightController = Player.RightController;
				BaseController leftController = Player.LeftController;
				float unscaledTime = Time.unscaledTime;
				float holdThreshold = Mathf.Clamp(_vrHoldSecondsPref.Value, 0.4f, 3f);
				UpdateButtonState(_vrButtonStates[0], (Object)(object)rightController != (Object)null && rightController.GetAButtonDown(), (Object)(object)rightController != (Object)null && rightController.GetAButton(), unscaledTime, holdThreshold, HasTripleTapBindingFor(PhysicalButton.Right_A));
				UpdateButtonState(_vrButtonStates[1], (Object)(object)rightController != (Object)null && rightController.GetBButtonDown(), (Object)(object)rightController != (Object)null && rightController.GetBButton(), unscaledTime, holdThreshold, HasTripleTapBindingFor(PhysicalButton.Right_B));
				UpdateButtonState(_vrButtonStates[2], (Object)(object)rightController != (Object)null && rightController.GetThumbStickDown(), (Object)(object)rightController != (Object)null && rightController.GetThumbStick(), unscaledTime, holdThreshold, HasTripleTapBindingFor(PhysicalButton.Right_Stick));
				UpdateButtonState(_vrButtonStates[3], (Object)(object)leftController != (Object)null && leftController.GetAButtonDown(), (Object)(object)leftController != (Object)null && leftController.GetAButton(), unscaledTime, holdThreshold, HasTripleTapBindingFor(PhysicalButton.Left_X));
				UpdateButtonState(_vrButtonStates[4], (Object)(object)leftController != (Object)null && leftController.GetBButtonDown(), (Object)(object)leftController != (Object)null && leftController.GetBButton(), unscaledTime, holdThreshold, HasTripleTapBindingFor(PhysicalButton.Left_Y));
				UpdateButtonState(_vrButtonStates[5], (Object)(object)leftController != (Object)null && leftController.GetThumbStickDown(), (Object)(object)leftController != (Object)null && leftController.GetThumbStick(), unscaledTime, holdThreshold, HasTripleTapBindingFor(PhysicalButton.Left_Stick));
				if (WasBindingTriggered((VrBinding)_vrBindShiftRandomPref.Value))
				{
					ShapeshiftIntoRandomPlayer();
				}
				if (WasBindingTriggered((VrBinding)_vrBindTeleportBehindPref.Value))
				{
					TeleportBehindRandomPlayer();
				}
				if (WasBindingTriggered((VrBinding)_vrBindFakeCorpsePref.Value))
				{
					ToggleFakeCorpse();
				}
				if (WasBindingTriggered((VrBinding)_vrBindBurstMonsterPref.Value) && _isDisguised)
				{
					RevertToMonster();
				}
			}
		}

		private static void UpdateButtonState(ButtonState state, bool downThisFrame, bool heldThisFrame, float now, float holdThreshold, bool hasTripleBindingOnButton)
		{
			state.DoubleTapEvent = false;
			state.TripleTapEvent = false;
			state.HoldEvent = false;
			if (downThisFrame)
			{
				if (now - state.LastTapTime <= 0.42f)
				{
					state.TapCount++;
				}
				else
				{
					state.TapCount = 1;
				}
				state.LastTapTime = now;
				state.HoldStartTime = now;
				state.HoldFired = false;
				if (state.TapCount == 2)
				{
					state.DoubleTapEvent = true;
					if (!hasTripleBindingOnButton)
					{
						state.TapCount = 0;
					}
				}
				else if (state.TapCount >= 3)
				{
					state.TripleTapEvent = true;
					state.TapCount = 0;
				}
			}
			if (heldThisFrame)
			{
				if (!state.HoldFired && now - state.HoldStartTime >= holdThreshold)
				{
					state.HoldFired = true;
					state.TapCount = 0;
					state.HoldEvent = true;
				}
			}
			else
			{
				state.HoldFired = false;
			}
		}

		private static bool HasTripleTapBindingFor(PhysicalButton btn)
		{
			VrBinding[] array = new VrBinding[4]
			{
				(VrBinding)_vrBindShiftRandomPref.Value,
				(VrBinding)_vrBindTeleportBehindPref.Value,
				(VrBinding)_vrBindFakeCorpsePref.Value,
				(VrBinding)_vrBindBurstMonsterPref.Value
			};
			for (int i = 0; i < array.Length; i++)
			{
				switch (btn)
				{
				case PhysicalButton.Right_A:
					if (array[i] == VrBinding.Right_A_TripleTap)
					{
						return true;
					}
					break;
				case PhysicalButton.Right_B:
					if (array[i] == VrBinding.Right_B_TripleTap)
					{
						return true;
					}
					break;
				case PhysicalButton.Right_Stick:
					if (array[i] == VrBinding.Right_Stick_TripleTap)
					{
						return true;
					}
					break;
				case PhysicalButton.Left_X:
					if (array[i] == VrBinding.Left_X_TripleTap)
					{
						return true;
					}
					break;
				case PhysicalButton.Left_Y:
					if (array[i] == VrBinding.Left_Y_TripleTap)
					{
						return true;
					}
					break;
				case PhysicalButton.Left_Stick:
					if (array[i] == VrBinding.Left_Stick_TripleTap)
					{
						return true;
					}
					break;
				}
			}
			return false;
		}

		private static bool WasBindingTriggered(VrBinding binding)
		{
			return binding switch
			{
				VrBinding.Right_A_TripleTap => _vrButtonStates[0].TripleTapEvent, 
				VrBinding.Right_A_DoubleTap => _vrButtonStates[0].DoubleTapEvent, 
				VrBinding.Right_A_Hold => _vrButtonStates[0].HoldEvent, 
				VrBinding.Right_B_TripleTap => _vrButtonStates[1].TripleTapEvent, 
				VrBinding.Right_B_Hold => _vrButtonStates[1].HoldEvent, 
				VrBinding.Right_Stick_TripleTap => _vrButtonStates[2].TripleTapEvent, 
				VrBinding.Right_Stick_Hold => _vrButtonStates[2].HoldEvent, 
				VrBinding.Left_X_TripleTap => _vrButtonStates[3].TripleTapEvent, 
				VrBinding.Left_X_DoubleTap => _vrButtonStates[3].DoubleTapEvent, 
				VrBinding.Left_X_Hold => _vrButtonStates[3].HoldEvent, 
				VrBinding.Left_Y_TripleTap => _vrButtonStates[4].TripleTapEvent, 
				VrBinding.Left_Y_Hold => _vrButtonStates[4].HoldEvent, 
				VrBinding.Left_Stick_TripleTap => _vrButtonStates[5].TripleTapEvent, 
				VrBinding.Left_Stick_Hold => _vrButtonStates[5].HoldEvent, 
				_ => false, 
			};
		}

		private static void UpdatePreBurstHorrorEffects(float remaining)
		{
			float unscaledTime = Time.unscaledTime;
			if (_soundsEnabledPref.Value && _horrorHeartbeatPref.Value && unscaledTime >= _nextHeartbeatTime)
			{
				float num = 1f - Mathf.Clamp01(remaining / 6.2f);
				float num2 = Mathf.Lerp(1.05f, 0.36f, num);
				PlayHeartbeatSound(Mathf.Lerp(0.45f, 1f, num));
				_nextHeartbeatTime = unscaledTime + num2;
			}
			if (_bloodEnabledPref.Value && _preBurstDripsPref.Value && unscaledTime >= _nextPreDripTime)
			{
				SpawnPreBurstFloorDrip();
				_nextPreDripTime = unscaledTime + 0.55f;
			}
		}

		private static void BuildBoneMenu()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_010c: 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_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			_mainPage = Page.Root.CreatePage("Monster Shapeshift", new Color(0.95f, 0.15f, 0.15f), 0, true);
			_mainPage.CreateFunction("Shapeshift: Random Player", new Color(1f, 0.35f, 0.35f), (Action)ShapeshiftIntoRandomPlayer);
			_playerPickerPage = _mainPage.CreatePage("Pick Lobby Player", Color.cyan, 0, true);
			_mainPage.CreateFunction("Open / Refresh Player List", Color.cyan, (Action)OpenRefreshedPlayerList);
			_mainPage.CreateFunction("Teleport Behind Random Player", new Color(0.65f, 0.25f, 1f), (Action)TeleportBehindRandomPlayer);
			_mainPage.CreateFunction("Fake Corpse (Play Dead Toggle)", new Color(0.75f, 0.75f, 0.75f), (Action)ToggleFakeCorpse);
			_mainPage.CreateFunction("Revert to Monster Now", new Color(0.85f, 0.1f, 0.1f), (Action)delegate
			{
				_waitingForAutoLoop = false;
				if (_isDisguised)
				{
					RevertToMonster();
				}
				else
				{
					SendToast("Monster Shapeshift", "You are not currently disguised.");
				}
			});
			_mainPage.CreateFunction("Check Current Status", Color.white, (Action)ShowCurrentStatusToast);
			_mainPage.CreateFunction("Test Blood + Gore Sound (Local)", new Color(0.7f, 0.05f, 0.05f), (Action)delegate
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: 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)
				if ((Object)(object)Player.RigManager == (Object)null)
				{
					SendToast("Monster Shapeshift", "Player rig is not ready.");
				}
				else
				{
					Vector3 localTorsoPosition = GetLocalTorsoPosition();
					TriggerBloodExplosion(localTorsoPosition);
					if (_soundsEnabledPref.Value)
					{
						PlayBloodExplosionSound(localTorsoPosition);
					}
					SendToast("Gore Test", $"Blood sticks for {_bloodStickDurationPref.Value:0}s!");
				}
			});
			_vrControlsPage = _mainPage.CreatePage("VR Controller Controls", new Color(0.35f, 0.9f, 1f), 0, true);
			BuildVrControlsPage();
			_monsterSkinPage = _mainPage.CreatePage("Monster Skin Setup", Color.green, 0, true);
			BuildMonsterSkinPage();
			_configPage = _mainPage.CreatePage("Config Settings", Color.yellow, 0, true);
			BuildConfigPage();
		}

		private static void BuildVrControlsPage()
		{
			//IL_0014: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			_vrControlsPage.RemoveAll();
			_vrControlsPage.CreateBool("VR Gestures Enabled", Color.green, _vrControlsEnabledPref.Value, (Action<bool>)delegate(bool val)
			{
				_vrControlsEnabledPref.Value = val;
				_prefs.SaveToFile(false);
			});
			_vrControlsPage.CreateFloat("Hold Trigger Time (sec)", Color.yellow, _vrHoldSecondsPref.Value, 0.1f, 0.4f, 2.5f, (Action<float>)delegate(float val)
			{
				_vrHoldSecondsPref.Value = val;
				_prefs.SaveToFile(false);
			});
			_vrControlsPage.CreateEnum("Shapeshift Random", new Color(1f, 0.4f, 0.4f), (Enum)(VrBinding)_vrBindShiftRandomPref.Value, (Action<Enum>)delegate(Enum val)
			{
				_vrBindShiftRandomPref.Value = (int)(VrBinding)(object)val;
				_prefs.SaveToFile(false);
			});
			_vrControlsPage.CreateEnum("Burst to Monster", new Color(0.9f, 0.15f, 0.15f), (Enum)(VrBinding)_vrBindBurstMonsterPref.Value, (Action<Enum>)delegate(Enum val)
			{
				_vrBindBurstMonsterPref.Value = (int)(VrBinding)(object)val;
				_prefs.SaveToFile(false);
			});
			_vrControlsPage.CreateEnum("Teleport Behind", new Color(0.75f, 0.45f, 1f), (Enum)(VrBinding)_vrBindTeleportBehindPref.Value, (Action<Enum>)delegate(Enum val)
			{
				_vrBindTeleportBehindPref.Value = (int)(VrBinding)(object)val;
				_prefs.SaveToFile(false);
			});
			_vrControlsPage.CreateEnum("Fake Corpse", Color.white, (Enum)(VrBinding)_vrBindFakeCorpsePref.Value, (Action<Enum>)delegate(Enum val)
			{
				_vrBindFakeCorpsePref.Value = (int)(VrBinding)(object)val;
				_prefs.SaveToFile(false);
			});
			_vrControlsPage.CreateFunction("Reset VR Controls to Default", new Color(1f, 0.55f, 0.15f), (Action)delegate
			{
				_vrControlsEnabledPref.Value = true;
				_vrHoldSecondsPref.Value = 0.9f;
				_vrBindShiftRandomPref.Value = 1;
				_vrBindBurstMonsterPref.Value = 3;
				_vrBindTeleportBehindPref.Value = 8;
				_vrBindFakeCorpsePref.Value = 10;
				_prefs.SaveToFile(false);
				BuildVrControlsPage();
				SendToast("VR Controls", "Reset to Triple-Tap A/X & Hold A/X!");
			});
		}

		private static void BuildMonsterSkinPage()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			_monsterSkinPage.RemoveAll();
			_monsterSkinPage.CreateFunction("Set Current Avatar as Monster", Color.green, (Action)SaveCurrentAvatarAsMonster);
			_monsterSkinPage.CreateFunction("Clear Saved Monster (Auto-Detect)", new Color(1f, 0.6f, 0.2f), (Action)delegate
			{
				_monsterBarcodePref.Value = string.Empty;
				_prefs.SaveToFile(false);
				BuildMonsterSkinPage();
				SendToast("Monster Skin", "Cleared. Will auto-use the skin you wear before shifting.");
			});
			_monsterSkinPage.CreateString("Monster Barcode", Color.white, _monsterBarcodePref.Value ?? string.Empty, (Action<string>)delegate(string val)
			{
				_monsterBarcodePref.Value = val?.Trim() ?? string.Empty;
				_prefs.SaveToFile(false);
			});
			_monsterSkinPage.CreateFunction("Equip Saved Monster Now", Color.cyan, (Action)delegate
			{
				if (string.IsNullOrEmpty(_monsterBarcodePref.Value))
				{
					SendToast("Monster Skin", "No monster barcode saved yet.");
				}
				else
				{
					SwapAvatarSynced(_monsterBarcodePref.Value);
					SendToast("Monster Skin", "Equipped saved monster avatar.");
				}
			});
		}

		private static void BuildConfigPage()
		{
			//IL_0023: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: 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_01d3: 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_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_060f: Unknown result type (might be due to invalid IL or missing references)
			_configPage.RemoveAll();
			_configPage.CreateBool("Identity Theft (Copy Nametag)", new Color(0.4f, 1f, 0.9f), _spoofNametagPref.Value, (Action<bool>)delegate(bool val)
			{
				_spoofNametagPref.Value = val;
				if (!val)
				{
					RestoreOriginalNickname();
				}
				_prefs.SaveToFile(false);
			});
			_configPage.CreateFloat("Teleport Behind Distance (m)", new Color(0.65f, 0.25f, 1f), _stalkDistancePref.Value, 1f, 4f, 25f, (Action<float>)delegate(float val)
			{
				_stalkDistancePref.Value = val;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateBool("Auto-Stand from Corpse on Burst", Color.white, _autoStandOnBurstPref.Value, (Action<bool>)delegate(bool val)
			{
				_autoStandOnBurstPref.Value = val;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateBool("Random Disguise Time", Color.yellow, _randomDurationPref.Value, (Action<bool>)delegate(bool val)
			{
				_randomDurationPref.Value = val;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateFloat("Min Random Time (sec)", Color.yellow, _minRandomDurationPref.Value, 5f, 5f, 120f, (Action<float>)delegate(float val)
			{
				_minRandomDurationPref.Value = val;
				if (_maxRandomDurationPref.Value < val)
				{
					_maxRandomDurationPref.Value = val;
				}
				_prefs.SaveToFile(false);
			});
			_configPage.CreateFloat("Max Random Time (sec)", Color.yellow, _maxRandomDurationPref.Value, 5f, 10f, 180f, (Action<float>)delegate(float val)
			{
				_maxRandomDurationPref.Value = val;
				if (_minRandomDurationPref.Value > val)
				{
					_minRandomDurationPref.Value = val;
				}
				_prefs.SaveToFile(false);
			});
			_configPage.CreateFloat("Fixed Disguise Time (sec)", Color.yellow, _fixedDurationPref.Value, 5f, 5f, 180f, (Action<float>)delegate(float val)
			{
				_fixedDurationPref.Value = val;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateBool("Horror Sounds Enabled", new Color(1f, 0.45f, 0.2f), _soundsEnabledPref.Value, (Action<bool>)delegate(bool val)
			{
				_soundsEnabledPref.Value = val;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateFloat("Horror Sound Volume", new Color(1f, 0.45f, 0.2f), _soundVolumePref.Value, 0.1f, 0.1f, 2f, (Action<float>)delegate(float val)
			{
				_soundVolumePref.Value = val;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateBool("Pre-Burst Heartbeat (Last 6s)", new Color(1f, 0.25f, 0.4f), _horrorHeartbeatPref.Value, (Action<bool>)delegate(bool val)
			{
				_horrorHeartbeatPref.Value = val;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateBool("Pre-Burst Blood Drips", new Color(1f, 0.25f, 0.4f), _preBurstDripsPref.Value, (Action<bool>)delegate(bool val)
			{
				_preBurstDripsPref.Value = val;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateBool("Crimson Monster Mist Aura", Color.red, _crimsonMistAuraPref.Value, (Action<bool>)delegate(bool val)
			{
				_crimsonMistAuraPref.Value = val;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateBool("Blood Explosion Enabled", Color.red, _bloodEnabledPref.Value, (Action<bool>)delegate(bool val)
			{
				_bloodEnabledPref.Value = val;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateFloat("Blood Stick Time (sec)", Color.red, _bloodStickDurationPref.Value, 5f, 5f, 90f, (Action<float>)delegate(float val)
			{
				_bloodStickDurationPref.Value = val;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateInt("Blood Particle Amount", Color.red, _bloodParticleCountPref.Value, 15, 20, 250, (Action<int>)delegate(int val)
			{
				_bloodParticleCountPref.Value = val;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateBool("Sticky Surface Splats & Globs", Color.red, _stickySurfaceSplatsPref.Value, (Action<bool>)delegate(bool val)
			{
				_stickySurfaceSplatsPref.Value = val;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateBool("Auto-Shapeshift Loop", Color.magenta, _autoLoopPref.Value, (Action<bool>)delegate(bool val)
			{
				_autoLoopPref.Value = val;
				if (!val)
				{
					_waitingForAutoLoop = false;
				}
				_prefs.SaveToFile(false);
			});
			_configPage.CreateFloat("Auto-Loop Delay (sec)", Color.magenta, _autoLoopDelayPref.Value, 5f, 5f, 120f, (Action<float>)delegate(float val)
			{
				_autoLoopDelayPref.Value = val;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateBool("PC Hotkeys (F7 TP/F8 Shift/F9 Burst/F10 Corpse)", Color.cyan, _hotkeysEnabledPref.Value, (Action<bool>)delegate(bool val)
			{
				_hotkeysEnabledPref.Value = val;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateString("Networked Burst Barcode", Color.white, _networkedBurstBarcodePref.Value ?? string.Empty, (Action<string>)delegate(string val)
			{
				_networkedBurstBarcodePref.Value = val?.Trim() ?? string.Empty;
				_prefs.SaveToFile(false);
			});
			_configPage.CreateFunction("Clear Active Blood Now", new Color(1f, 0.5f, 0.5f), (Action)ClearAllActiveSplats);
			_configPage.CreateFunction("Reset Config to Defaults", new Color(1f, 0.4f, 0.1f), (Action)ResetConfigToDefaults);
		}

		private static void ResetConfigToDefaults()
		{
			_spoofNametagPref.Value = true;
			_stalkDistancePref.Value = 10f;
			_autoStandOnBurstPref.Value = true;
			_randomDurationPref.Value = true;
			_minRandomDurationPref.Value = 30f;
			_maxRandomDurationPref.Value = 60f;
			_fixedDurationPref.Value = 45f;
			_bloodEnabledPref.Value = true;
			_bloodStickDurationPref.Value = 30f;
			_bloodParticleCountPref.Value = 110;
			_stickySurfaceSplatsPref.Value = true;
			_soundsEnabledPref.Value = true;
			_soundVolumePref.Value = 1.15f;
			_horrorHeartbeatPref.Value = true;
			_preBurstDripsPref.Value = true;
			_crimsonMistAuraPref.Value = true;
			_autoLoopPref.Value = false;
			_autoLoopDelayPref.Value = 15f;
			_hotkeysEnabledPref.Value = true;
			_networkedBurstBarcodePref.Value = string.Empty;
			_waitingForAutoLoop = false;
			_prefs.SaveToFile(false);
			BuildConfigPage();
			SendToast("Config Reset", "All settings restored to defaults.");
		}

		private static void ShowCurrentStatusToast()
		{
			if (_isDisguised)
			{
				float value = Mathf.Max(0f, _revertTime - Time.unscaledTime);
				SendToast("Disguised", $"Copied: {_disguisedAsName}\nReverting in {value:0.0}s");
			}
			else if (_waitingForAutoLoop)
			{
				float value2 = Mathf.Max(0f, _nextAutoShiftTime - Time.unscaledTime);
				SendToast("Monster Form", $"Next auto-shapeshift in {value2:0.0}s");
			}
			else
			{
				string text = (string.IsNullOrEmpty(_monsterBarcodePref.Value) ? "Auto-detect" : _monsterBarcodePref.Value);
				SendToast("Monster Form", "Ready! Monster skin:\n" + text);
			}
		}

		private static void ToggleFakeCorpse()
		{
			if ((Object)(object)Player.RigManager == (Object)null || (Object)(object)Player.RigManager.physicsRig == (Object)null)
			{
				SendToast("Fake Corpse", "Player rig is not ready.");
			}
			else if (_isPlayingDead)
			{
				ExitFakeCorpse();
				SendToast("Fake Corpse", "Stood back up!");
			}
			else
			{
				EnterFakeCorpse();
				SendToast("Fake Corpse", "Playing dead! Wait for someone to check your body...");
			}
		}

		private static void EnterFakeCorpse()
		{
			if ((Object)(object)Player.RigManager == (Object)null || (Object)(object)Player.RigManager.physicsRig == (Object)null)
			{
				return;
			}
			try
			{
				PhysicsRig physicsRig = Player.RigManager.physicsRig;
				physicsRig.ShutdownRig();
				physicsRig.RagdollRig();
				_isPlayingDead = true;
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("EnterFakeCorpse error: " + ex.Message);
			}
		}

		private static void ExitFakeCorpse()
		{
			if ((Object)(object)Player.RigManager == (Object)null || (Object)(object)Player.RigManager.physicsRig == (Object)null)
			{
				_isPlayingDead = false;
				return;
			}
			try
			{
				PhysicsRig physicsRig = Player.RigManager.physicsRig;
				physicsRig.UnRagdollRig();
				physicsRig.EnableBallLoco();
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("ExitFakeCorpse error: " + ex.Message);
			}
			_isPlayingDead = false;
		}

		private static void TeleportBehindRandomPlayer()
		{
			if (EnsureInFusionLobby())
			{
				List<NetworkPlayer> otherLobbyPlayers = GetOtherLobbyPlayers();
				if (otherLobbyPlayers.Count == 0)
				{
					SendToast("Stalk Teleport", "No other players in the lobby.");
				}
				else
				{
					TeleportBehindPlayer(otherLobbyPlayers[_rng.Next(otherLobbyPlayers.Count)]);
				}
			}
		}

		private static void TeleportBehindPlayer(NetworkPlayer target)
		{
			//IL_004a: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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_00ee: 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_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_0111: 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_00cc: 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)
			if (!EnsureInFusionLobby())
			{
				return;
			}
			if (target == null || !target.HasRig || target.RigRefs == null || (Object)(object)target.RigRefs.RigManager == (Object)null)
			{
				SendToast("Stalk Teleport", "Target player's rig is not loaded.");
				return;
			}
			RigManager rigManager = target.RigRefs.RigManager;
			Vector3 rigGroundAnchorPosition = GetRigGroundAnchorPosition(rigManager);
			Vector3 rigFlatForward = GetRigFlatForward(rigManager);
			Vector3 behindDir = -rigFlatForward;
			float desiredDist = Mathf.Clamp(_stalkDistancePref.Value, 4f, 25f);
			int worldBloodMask = GetWorldBloodMask();
			if (!TryFindSafeStalkSpot(rigGroundAnchorPosition, behindDir, desiredDist, worldBloodMask, out var safePos))
			{
				SendToast("Stalk Teleport", "No open floor behind that player (cancelled so you don't get stuck in a wall!).");
				return;
			}
			if (_isPlayingDead)
			{
				ExitFakeCorpse();
			}
			Vector3 val = rigGroundAnchorPosition - safePos;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.001f)
			{
				val = rigFlatForward;
			}
			((Vector3)(ref val)).Normalize();
			Player.RigManager.Teleport(safePos, val, true);
			string playerDisplayName = GetPlayerDisplayName(target);
			float value = Vector3.Distance(new Vector3(safePos.x, 0f, safePos.z), new Vector3(rigGroundAnchorPosition.x, 0f, rigGroundAnchorPosition.z));
			SendToast("Stalking...", $"Teleported {value:0.0}m behind {playerDisplayName}!");
		}

		private static bool TryFindSafeStalkSpot(Vector3 targetPos, Vector3 behindDir, float desiredDist, int worldMask, out Vector3 safePos)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: 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_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			safePos = Vector3.zero;
			float[] array = new float[9] { 0f, 15f, -15f, 32f, -32f, 52f, -52f, 75f, -75f };
			Vector3 val = targetPos + Vector3.up * 1.15f;
			RaycastHit val3 = default(RaycastHit);
			for (int i = 0; i < array.Length; i++)
			{
				Vector3 val2 = Quaternion.Euler(0f, array[i], 0f) * behindDir;
				val2.y = 0f;
				((Vector3)(ref val2)).Normalize();
				float num = desiredDist;
				if (Physics.SphereCast(val, 0.38f, val2, ref val3, desiredDist, worldMask, (QueryTriggerInteraction)1))
				{
					num = ((RaycastHit)(ref val3)).distance - 0.85f;
				}
				float[] array2 = new float[3] { 1f, 0.78f, 0.58f };
				for (int j = 0; j < array2.Length; j++)
				{
					float num2 = num * array2[j];
					if (num2 < 3.5f)
					{
						continue;
					}
					Vector3 val4 = targetPos + val2 * num2;
					if (TryFindRealSurfaceHit(new Vector3(val4.x, targetPos.y + 3f, val4.z), Vector3.down, 11f, 0.1f, worldMask, out var bestHit) && !(((RaycastHit)(ref bestHit)).normal.y < 0.65f))
					{
						Vector3 val5 = ((RaycastHit)(ref bestHit)).point + Vector3.up * 0.08f;
						Vector3 val6 = val5 + Vector3.up * 0.45f;
						Vector3 val7 = val5 + Vector3.up * 1.65f;
						if (!Physics.CheckCapsule(val6, val7, 0.36f, worldMask, (QueryTriggerInteraction)1))
						{
							safePos = val5;
							return true;
						}
					}
				}
			}
			return false;
		}

		private static Vector3 GetRigGroundAnchorPosition(RigManager rm)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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)
			if ((Object)(object)rm.physicsRig != (Object)null && (Object)(object)rm.physicsRig.feet != (Object)null)
			{
				return rm.physicsRig.feet.transform.position;
			}
			if ((Object)(object)rm.physicsRig != (Object)null && (Object)(object)rm.physicsRig.torso != (Object)null)
			{
				return ((Component)rm.physicsRig.torso).transform.position - Vector3.up * 1f;
			}
			return ((Component)rm).transform.position;
		}

		private static Vector3 GetRigFlatForward(RigManager rm)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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)
			Vector3 val = Vector3.forward;
			val = (((Object)(object)rm.physicsRig != (Object)null && (Object)(object)((Rig)rm.physicsRig).m_head != (Object)null) ? ((Rig)rm.physicsRig).m_head.forward : ((!((Object)(object)rm.physicsRig != (Object)null) || !((Object)(object)rm.physicsRig.torso != (Object)null)) ? ((Component)rm).transform.forward : ((Component)rm.physicsRig.torso).transform.forward));
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.001f)
			{
				return Vector3.forward;
			}
			return ((Vector3)(ref val)).normalized;
		}

		private static void SaveCurrentAvatarAsMonster()
		{
			string localAvatarBarcode = GetLocalAvatarBarcode();
			if (string.IsNullOrEmpty(localAvatarBarcode))
			{
				SendToast("Monster Shapeshift", "Player rig is not ready yet.");
				return;
			}
			_monsterBarcodePref.Value = localAvatarBarcode;
			_prefs.SaveToFile(false);
			BuildMonsterSkinPage();
			SendToast("Monster Saved", "Monster skin set to:\n" + localAvatarBarcode);
		}

		private static void OpenRefreshedPlayerList()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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)
			_playerPickerPage.RemoveAll();
			if (!NetworkInfo.HasServer)
			{
				_playerPickerPage.CreateFunction("Not in a Fusion lobby!", Color.red, (Action)delegate
				{
				});
				Menu.OpenPage(_playerPickerPage);
				return;
			}
			List<NetworkPlayer> otherLobbyPlayers = GetOtherLobbyPlayers();
			if (otherLobbyPlayers.Count == 0)
			{
				_playerPickerPage.CreateFunction("No other players found.", Color.gray, (Action)delegate
				{
				});
				Menu.OpenPage(_playerPickerPage);
				return;
			}
			foreach (NetworkPlayer item in otherLobbyPlayers)
			{
				NetworkPlayer captured = item;
				string playerDisplayName = GetPlayerDisplayName(captured);
				_playerPickerPage.CreateFunction("Copy: " + playerDisplayName, Color.white, (Action)delegate
				{
					ShapeshiftIntoPlayer(captured);
				});
				_playerPickerPage.CreateFunction("TP Behind: " + playerDisplayName, new Color(0.75f, 0.45f, 1f), (Action)delegate
				{
					TeleportBehindPlayer(captured);
				});
			}
			Menu.OpenPage(_playerPickerPage);
		}

		private static void ShapeshiftIntoRandomPlayer()
		{
			if (EnsureInFusionLobby())
			{
				List<NetworkPlayer> otherLobbyPlayers = GetOtherLobbyPlayers();
				if (otherLobbyPlayers.Count == 0)
				{
					SendToast("Monster Shapeshift", "No other players with valid avatars in this lobby.");
				}
				else
				{
					ShapeshiftIntoPlayer(otherLobbyPlayers[_rng.Next(otherLobbyPlayers.Count)]);
				}
			}
		}

		private static void ShapeshiftIntoPlayer(NetworkPlayer target)
		{
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			if (!EnsureInFusionLobby())
			{
				return;
			}
			if (target == null || !target.HasRig || target.RigRefs == null || (Object)(object)target.RigRefs.RigManager == (Object)null)
			{
				SendToast("Monster Shapeshift", "Target player's rig is not loaded yet.");
				return;
			}
			AvatarCrateReference avatarCrate = target.RigRefs.RigManager.AvatarCrate;
			object obj;
			if (avatarCrate == null)
			{
				obj = null;
			}
			else
			{
				Barcode barcode = ((ScannableReference)avatarCrate).Barcode;
				obj = ((barcode != null) ? barcode.ID : null);
			}
			string text = (string)obj;
			if (string.IsNullOrEmpty(text))
			{
				SendToast("Monster Shapeshift", "Target player has no valid avatar barcode.");
				return;
			}
			if (string.IsNullOrEmpty(_monsterBarcodePref.Value))
			{
				string localAvatarBarcode = GetLocalAvatarBarcode();
				if (!string.IsNullOrEmpty(localAvatarBarcode))
				{
					_monsterBarcodePref.Value = localAvatarBarcode;
					_prefs.SaveToFile(false);
				}
			}
			float num3;
			if (_randomDurationPref.Value)
			{
				float num = Mathf.Min(_minRandomDurationPref.Value, _maxRandomDurationPref.Value);
				float num2 = Mathf.Max(_minRandomDurationPref.Value, _maxRandomDurationPref.Value);
				num3 = Mathf.Round(Random.Range(num, num2));
			}
			else
			{
				num3 = Mathf.Clamp(_fixedDurationPref.Value, 5f, 300f);
			}
			string playerVisibleTagName = GetPlayerVisibleTagName(target);
			SwapAvatarSynced(text);
			if (_spoofNametagPref.Value)
			{
				SpoofLocalNickname(playerVisibleTagName);
			}
			if (_soundsEnabledPref.Value)
			{
				PlayShapeshiftSound(GetLocalTorsoPosition());
			}
			_waitingForAutoLoop = false;
			_isDisguised = true;
			_revertTime = Time.unscaledTime + num3;
			_nextHeartbeatTime = 0f;
			_nextPreDripTime = 0f;
			_disguisedAsName = playerVisibleTagName;
			SendToast("Identity Stolen!", $"Became {playerVisibleTagName} for {num3:0}s.");
		}

		private static void RevertToMonster()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			_isDisguised = false;
			if (_isPlayingDead && _autoStandOnBurstPref.Value)
			{
				ExitFakeCorpse();
			}
			Vector3 localTorsoPosition = GetLocalTorsoPosition();
			if (_bloodEnabledPref.Value)
			{
				TriggerBloodExplosion(localTorsoPosition);
			}
			if (_soundsEnabledPref.Value)
			{
				PlayBloodExplosionSound(localTorsoPosition);
			}
			TrySpawnNetworkedBurst(localTorsoPosition);
			RestoreOriginalNickname();
			string value = _monsterBarcodePref.Value;
			if (!string.IsNullOrEmpty(value))
			{
				SwapAvatarSynced(value);
			}
			SendToast("Monster Revealed!", "Exploded out of " + _disguisedAsName + "!");
			_disguisedAsName = string.Empty;
			if (_autoLoopPref.Value && NetworkInfo.HasServer)
			{
				_waitingForAutoLoop = true;
				_nextAutoShiftTime = Time.unscaledTime + Mathf.Clamp(_autoLoopDelayPref.Value, 5f, 300f);
			}
		}

		private static void SpoofLocalNickname(string targetName)
		{
			if (string.IsNullOrWhiteSpace(targetName))
			{
				return;
			}
			try
			{
				PlayerMetadata metadata = LocalPlayer.Metadata;
				if (metadata != null && metadata.Nickname != null)
				{
					if (!_isSpoofingName)
					{
						_savedOriginalNickname = metadata.Nickname.GetValueOrEmpty() ?? string.Empty;
						_isSpoofingName = true;
					}
					metadata.Nickname.SetValue(targetName);
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("Could not spoof Fusion nickname: " + ex.Message);
			}
		}

		private static void RestoreOriginalNickname()
		{
			if (!_isSpoofingName)
			{
				return;
			}
			try
			{
				PlayerMetadata metadata = LocalPlayer.Metadata;
				if (metadata != null && metadata.Nickname != null)
				{
					metadata.Nickname.SetValue(_savedOriginalNickname ?? string.Empty);
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("Could not restore Fusion nickname: " + ex.Message);
			}
			finally
			{
				_isSpoofingName = false;
				_savedOriginalNickname = string.Empty;
			}
		}

		private static void SwapAvatarSynced(string barcodeId)
		{
			if (string.IsNullOrEmpty(barcodeId))
			{
				return;
			}
			try
			{
				LocalAvatar.SwapAvatarCrate(barcodeId);
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("LocalAvatar.SwapAvatarCrate failed: " + ex.Message);
			}
		}

		private static bool EnsureInFusionLobby()
		{
			if (!NetworkInfo.HasServer)
			{
				SendToast("Fusion Required", "Join or host a LabFusion lobby first!");
				return false;
			}
			if ((Object)(object)Player.RigManager == (Object)null)
			{
				SendToast("Monster Shapeshift", "Local player rig is not ready.");
				return false;
			}
			return true;
		}

		private static List<NetworkPlayer> GetOtherLobbyPlayers()
		{
			List<NetworkPlayer> list = new List<NetworkPlayer>();
			foreach (NetworkPlayer player in NetworkPlayer.Players)
			{
				if (player != null && player.HasRig && player.PlayerID != null && player.PlayerID != PlayerIDManager.LocalID && (player.NetworkEntity == null || !player.NetworkEntity.IsOwner) && player.RigRefs != null && !((Object)(object)player.RigRefs.RigManager == (Object)null))
				{
					AvatarCrateReference avatarCrate = player.RigRefs.RigManager.AvatarCrate;
					object value;
					if (avatarCrate == null)
					{
						value = null;
					}
					else
					{
						Barcode barcode = ((ScannableReference)avatarCrate).Barcode;
						value = ((barcode != null) ? barcode.ID : null);
					}
					if (!string.IsNullOrEmpty((string?)value))
					{
						list.Add(player);
					}
				}
			}
			return list;
		}

		private static string GetPlayerVisibleTagName(NetworkPlayer player)
		{
			if (player == null || player.PlayerID == null)
			{
				return "Unknown";
			}
			try
			{
				PlayerMetadata metadata = player.PlayerID.Metadata;
				object obj;
				if (metadata == null)
				{
					obj = null;
				}
				else
				{
					MetadataVariable nickname = metadata.Nickname;
					obj = ((nickname != null) ? nickname.GetValueOrEmpty() : null);
				}
				string text = (string)obj;
				if (!string.IsNullOrWhiteSpace(text))
				{
					return text;
				}
			}
			catch
			{
			}
			return GetPlayerDisplayName(player);
		}

		private static string GetPlayerDisplayName(NetworkPlayer player)
		{
			if (player == null || player.PlayerID == null)
			{
				return "Unknown Player";
			}
			try
			{
				PlayerMetadata metadata = player.PlayerID.Metadata;
				object obj;
				if (metadata == null)
				{
					obj = null;
				}
				else
				{
					MetadataVariable username = metadata.Username;
					obj = ((username != null) ? username.GetValue() : null);
				}
				string text = (string)obj;
				if (!string.IsNullOrWhiteSpace(text))
				{
					return text;
				}
			}
			catch
			{
			}
			return $"Player {player.PlayerID.SmallID}";
		}

		private static string GetLocalAvatarBarcode()
		{
			if ((Object)(object)Player.RigManager == (Object)null || Player.RigManager.AvatarCrate == null)
			{
				return null;
			}
			Barcode barcode = ((ScannableReference)Player.RigManager.AvatarCrate).Barcode;
			if (barcode == null)
			{
				return null;
			}
			return barcode.ID;
		}

		private static Vector3 GetLocalTorsoPosition()
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Player.RigManager != (Object)null)
			{
				if ((Object)(object)Player.RigManager.physicsRig != (Object)null && (Object)(object)Player.RigManager.physicsRig.torso != (Object)null)
				{
					if ((Object)(object)Player.RigManager.physicsRig.torso.rbChest != (Object)null)
					{
						return Player.RigManager.physicsRig.torso.rbChest.position;
					}
					return ((Component)Player.RigManager.physicsRig.torso).transform.position;
				}
				return ((Component)Player.RigManager).transform.position + Vector3.up * 1f;
			}
			return Vector3.zero;
		}

		private static void TrySpawnNetworkedBurst(Vector3 pos)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_007b: Expected O, but got Unknown
			//IL_0080: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			string text = _networkedBurstBarcodePref.Value?.Trim();
			if (string.IsNullOrEmpty(text) || !NetworkInfo.HasServer)
			{
				return;
			}
			try
			{
				SpawnableCrate val = null;
				Barcode val2 = new Barcode(text);
				if (!AssetWarehouse.Instance.TryGetCrate<SpawnableCrate>(val2, ref val) || (Object)(object)val == (Object)null)
				{
					MelonLogger.Warning("Networked burst crate '" + text + "' not found in AssetWarehouse.");
					return;
				}
				NetworkAssetSpawner.Spawn(new SpawnRequestInfo
				{
					Spawnable = new Spawnable
					{
						crateRef = new SpawnableCrateReference(text)
					},
					Position = pos,
					Rotation = Quaternion.identity,
					SpawnEffect = true,
					SpawnCallback = null
				});
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("Failed to spawn networked burst: " + ex.Message);
			}
		}

		private static void PlayBloodExplosionSound(Vector3 position)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PlayClip(GetOrCreateBloodExplosionClip(), position, Mathf.Clamp(_soundVolumePref.Value, 0.05f, 2f), 0.25f, 2.5f);
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("Blood explosion audio error: " + ex.Message);
			}
		}

		private static void PlayShapeshiftSound(Vector3 position)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PlayClip(GetOrCreateShapeshiftClip(), position, Mathf.Clamp(_soundVolumePref.Value * 0.9f, 0.05f, 2f), 0.15f, 1.2f);
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("Shapeshift audio error: " + ex.Message);
			}
		}

		private static void PlayHeartbeatSound(float multiplier)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				AudioClip orCreateHeartbeatClip = GetOrCreateHeartbeatClip();
				Vector3 localTorsoPosition = GetLocalTorsoPosition();
				float volume = Mathf.Clamp(_soundVolumePref.Value * multiplier, 0.05f, 2f);
				PlayClip(orCreateHeartbeatClip, localTorsoPosition, volume, 0f, 1f);
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("Heartbeat audio error: " + ex.Message);
			}
		}

		private static void PlayClip(AudioClip clip, Vector3 position, float volume, float spatialBlend, float lifetime)
		{
			//IL_000f: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			if (!((Object)(object)clip == (Object)null))
			{
				GameObject val = new GameObject("ShapeshiftHorrorSFX");
				val.transform.position = position;
				AudioSource obj = val.AddComponent<AudioSource>();
				obj.clip = clip;
				obj.volume = volume;
				obj.spatialBlend = spatialBlend;
				obj.minDistance = 4f;
				obj.maxDistance = 35f;
				obj.playOnAwake = false;
				obj.Play();
				Object.Destroy((Object)val, lifetime);
			}
		}

		private static AudioClip GetOrCreateBloodExplosionClip()
		{
			if ((Object)(object)_bloodExplosionClip != (Object)null)
			{
				return _bloodExplosionClip;
			}
			int num = 81585;
			float[] array = new float[num];
			Random random = new Random(9901);
			List<(float, float, float)> list = new List<(float, float, float)>();
			float num2 = 0f;
			while (num2 < 0.36f)
			{
				num2 += 0.004f + (float)random.NextDouble() * 0.015f;
				float item = 0.4f + (float)random.NextDouble() * 0.9f;
				float item2 = 260f + (float)random.NextDouble() * 980f;
				list.Add((num2, item, item2));
			}
			List<(float, float, float, float)> list2 = new List<(float, float, float, float)>();
			for (int i = 0; i < 22; i++)
			{
				float item3 = 0.24f + (float)random.NextDouble() * 1.42f;
				float item4 = 65f + (float)random.NextDouble() * 150f;
				float item5 = 0.015f + (float)random.NextDouble() * 0.045f;
				float item6 = 0.22f + (float)random.NextDouble() * 0.45f;
				list2.Add((item3, item4, item5, item6));
			}
			float num3 = 0f;
			float num4 = 0f;
			float num5 = 0f;
			float num6 = 0f;
			float num7 = 0f;
			float num8 = 0f;
			float num9 = 0f;
			float num10 = 0f;
			float num11 = 0f;
			float num12 = 0f;
			for (int j = 0; j < num; j++)
			{
				float num13 = (float)j / 44100f;
				float num14 = (float)(random.NextDouble() * 2.0 - 1.0);
				num9 = 0.997f * num9 + num14 * 0.029f;
				num10 = 0.985f * num10 + num14 * 0.032f;
				num11 = 0.95f * num11 + num14 * 0.048f;
				float num15 = (num9 + num10 + num11 + num14 * 0.14f) * 1.8f;
				float num16 = 0f;
				for (int k = 0; k < list.Count; k++)
				{
					float num17 = num13 - list[k].Item1;
					if (num17 >= 0f && num17 < 0.014f)
					{
						float num18 = Mathf.Exp((0f - num17) * 240f);
						num16 += (num14 * 0.8f + Mathf.Sin((float)Math.PI * 2f * list[k].Item3 * num17) * 0.5f) * num18 * list[k].Item2;
					}
				}
				float num19 = 260f + 190f * Mathf.Sin((float)Math.PI * 23f * num13 + Mathf.Sin((float)Math.PI * 54f * num13));
				float num20 = 2f * Mathf.Sin((float)Math.PI * Mathf.Clamp(num19, 80f, 1200f) / 44100f);
				float num21 = 0.28f;
				float num22 = num15 * 0.85f + num16 * 0.9f;
				num3 += num20 * num4;
				float num23 = num22 - num3 - num21 * num4;
				num4 += num20 * num23;
				float num24 = 920f + 420f * Mathf.Sin((float)Math.PI * 38f * num13);
				float num25 = 2f * Mathf.Sin((float)Math.PI * num24 / 44100f);
				float num26 = 0.35f;
				float num27 = num16 * 1.4f + num14 * 0.25f;
				num5 += num25 * num6;
				float num28 = num27 - num5 - num26 * num6;
				num6 += num25 * num28;
				float num29 = 0f;
				if (num13 >= 0.11f && num13 < 0.17f)
				{
					float num30 = num13 - 0.11f;
					num29 += (num14 * 1.1f + Mathf.Sin((float)Math.PI * 2360f * num30) * 0.6f) * Mathf.Exp((0f - num30) * 140f) * 1.35f;
				}
				if (num13 >= 0.18f && num13 < 0.25f)
				{
					float num31 = num13 - 0.18f;
					num29 += (num14 * 1f + Mathf.Sin((float)Math.PI * 1720f * num31) * 0.55f) * Mathf.Exp((0f - num31) * 110f) * 1.15f;
				}
				float num32 = 0f;
				if (num13 >= 0.12f && num13 < 0.35f)
				{
					float num33 = num13 - 0.12f;
					float num34 = 28f + 95f * Mathf.Exp((0f - num33) * 42f);
					num12 += (float)Math.PI * 2f * num34 / 44100f;
					num32 = Mathf.Sin(num12) * Mathf.Exp((0f - num33) * 18f) * 1.4f;
				}
				float num35 = 0f;
				for (int l = 0; l < list2.Count; l++)
				{
					float num36 = num13 - list2[l].Item1;
					if (num36 >= 0f && num36 < 0.085f)
					{
						float num37 = Mathf.Exp((0f - num36) / list2[l].Item3);
						float num38 = Mathf.Sin((float)Math.PI * 2f * list2[l].Item2 * Mathf.Exp((0f - num36) * 14f) * num36) * 0.8f;
						num35 += (num38 + num15 * 0.65f) * num37 * list2[l].Item4;
					}
				}
				float num39 = 2f * Mathf.Sin(0.037043724f);
				num7 += num39 * num8;
				float num40 = num35 - num7 - 0.45f * num8;
				num8 += num39 * num40;
				float num41 = Mathf.Exp((0f - num13) * 5.2f);
				float num42 = Mathf.Clamp01((num13 - 0.06f) / 0.06f) * Mathf.Exp((0f - Mathf.Max(0f, num13 - 0.14f)) * 3.1f);
				float num43 = num6 * num41 * 1.35f + num4 * (num41 * 0.7f + num42 * 1.85f) + num15 * num42 * 0.65f + num29 + num32 + (num8 * 1.2f + num35 * 0.55f);
				float num44 = num43 / (1f + Mathf.Abs(num43) * 0.65f);
				float num45 = Mathf.Clamp01(num13 / 0.004f);
				float num46 = Mathf.Clamp01((1.85f - num13) / 0.16f);
				array[j] = Mathf.Clamp(num44 * num45 * num46 * 1.25f, -0.98f, 0.98f);
			}
			_bloodExplosionClip = AudioClip.Create("Shapeshift_GoreExplosion", num, 1, 44100, false);
			((Object)_bloodExplosionClip).hideFlags = (HideFlags)32;
			_bloodExplosionClip.SetData(Il2CppStructArray<float>.op_Implicit(array), 0);
			return _bloodExplosionClip;
		}

		private static AudioClip GetOrCreateShapeshiftClip()
		{
			if ((Object)(object)_shapeshiftClip != (Object)null)
			{
				return _shapeshiftClip;
			}
			int num = 29988;
			float[] array = new float[num];
			Random random = new Random(777);
			float num2 = 0f;
			float num3 = 0f;
			float num4 = 0f;
			for (int i = 0; i < num; i++)
			{
				float num5 = (float)i / 44100f;
				float num6 = (float)(random.NextDouble() * 2.0 - 1.0);
				num4 += 0.14f * (num6 - num4);
				float num7 = 190f + 360f * Mathf.Clamp01(num5 / 0.45f);
				float num8 = 2f * Mathf.Sin((float)Math.PI * num7 / 44100f);
				num2 += num8 * num3;
				float num9 = num4 - num2 - 0.3f * num3;
				num3 += num8 * num9;
				float num10 = ((num5 >= 0.14f && num5 < 0.2f) ? ((num6 * 0.9f + Mathf.Sin((float)Math.PI * 1880f * (num5 - 0.14f)) * 0.5f) * Mathf.Exp((0f - (num5 - 0.14f)) * 120f)) : 0f);
				float num11 = ((num5 >= 0.34f && num5 < 0.41f) ? ((num6 * 1f + Mathf.Sin((float)Math.PI * 1440f * (num5 - 0.34f)) * 0.5f) * Mathf.Exp((0f - (num5 - 0.34f)) * 105f)) : 0f);
				float num12 = Mathf.Sin((float)Math.PI * Mathf.Clamp01(num5 / 0.6f));
				float num13 = num3 * num12 * 1.4f + num10 * 0.85f + num11 * 0.95f;
				float num14 = Mathf.Clamp01((0.68f - num5) / 0.08f);
				array[i] = Mathf.Clamp(num13 / (1f + Mathf.Abs(num13) * 0.5f) * num14, -0.95f, 0.95f);
			}
			_shapeshiftClip = AudioClip.Create("Shapeshift_FleshShift", num, 1, 44100, false);
			((Object)_shapeshiftClip).hideFlags = (HideFlags)32;
			_shapeshiftClip.SetData(Il2CppStructArray<float>.op_Implicit(array), 0);
			return _shapeshiftClip;
		}

		private static AudioClip GetOrCreateHeartbeatClip()
		{
			if ((Object)(object)_heartbeatClip != (Object)null)
			{
				return _heartbeatClip;
			}
			int num = 24255;
			float[] array = new float[num];
			float num2 = 0f;
			float num3 = 0f;
			for (int i = 0; i < num; i++)
			{
				float num4 = (float)i / 44100f;
				float num5 = 0f;
				if (num4 < 0.18f)
				{
					float num6 = 36f + 26f * Mathf.Exp((0f - num4) * 25f);
					num2 += (float)Math.PI * 2f * num6 / 44100f;
					num5 = Mathf.Sin(num2) * Mathf.Exp((0f - num4) * 22f) * Mathf.Clamp01(num4 / 0.008f) * 0.9f;
				}
				float num7 = 0f;
				if (num4 >= 0.19f)
				{
					float num8 = num4 - 0.19f;
					float num9 = 42f + 34f * Mathf.Exp((0f - num8) * 28f);
					num3 += (float)Math.PI * 2f * num9 / 44100f;
					num7 = Mathf.Sin(num3) * Mathf.Exp((0f - num8) * 24f) * Mathf.Clamp01(num8 / 0.006f) * 1f;
				}
				array[i] = Mathf.Clamp(num5 + num7, -1f, 1f);
			}
			_heartbeatClip = AudioClip.Create("Shapeshift_Heartbeat", num, 1, 44100, false);
			((Object)_heartbeatClip).hideFlags = (HideFlags)32;
			_heartbeatClip.SetData(Il2CppStructArray<float>.op_Implicit(array), 0);
			return _heartbeatClip;
		}

		private static void TriggerBloodExplosion(Vector3 position)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			float stickSeconds = Mathf.Clamp(_bloodStickDurationPref.Value, 5f, 90f);
			int worldBloodMask = GetWorldBloodMask();
			SpawnStickyBloodParticles(position, stickSeconds, worldBloodMask);
			if (_crimsonMistAuraPref.Value)
			{
				SpawnCrimsonMonsterMistAura(position);
			}
			if (_stickySurfaceSplatsPref.Value)
			{
				SpawnSurfaceBloodDecals(position, stickSeconds, worldBloodMask);
				SpawnFlying3DBloodGlobs(position, stickSeconds, worldBloodMask);
			}
		}

		private static void SpawnPreBurstFloorDrip()
		{
			//IL_0000: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: 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_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Vector3 localTorsoPosition = GetLocalTorsoPosition();
				int worldBloodMask = GetWorldBloodMask();
				Vector3 val = Vector3.down + new Vector3(Random.Range(-0.22f, 0.22f), 0f, Random.Range(-0.22f, 0.22f));
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				if (!TryFindRealSurfaceHit(localTorsoPosition, normalized, 3.5f, 0.35f, worldBloodMask, out var bestHit))
				{
					return;
				}
				Material val2 = CreateTransparentBloodMaterial(GetBloodSplatTexture());
				if (!((Object)(object)val2 == (Object)null))
				{
					Color val3 = default(Color);
					((Color)(ref val3))..ctor(0.52f, 0.015f, 0.015f, 0.92f);
					val2.color = val3;
					GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)5);
					((Object)val4).name = "ShapeshiftPreBurstDrip";
					Collider component = val4.GetComponent<Collider>();
					if ((Object)(object)component != (Object)null)
					{
						Object.Destroy((Object)(object)component);
					}
					val4.transform.position = ((RaycastHit)(ref bestHit)).point + ((RaycastHit)(ref bestHit)).normal * 0.005f;
					val4.transform.rotation = Quaternion.LookRotation(-((RaycastHit)(ref bestHit)).normal);
					val4.transform.Rotate(0f, 0f, Random.Range(0f, 360f), (Space)1);
					float num = Random.Range(0.18f, 0.36f);
					Vector3 val5 = default(Vector3);
					((Vector3)(ref val5))..ctor(num, num, 1f);
					val4.transform.localScale = val5;
					MeshRenderer component2 = val4.GetComponent<MeshRenderer>();
					if ((Object)(object)component2 != (Object)null)
					{
						((Renderer)component2).sharedMaterial = val2;
					}
					RegisterSplat(new ActiveSplat
					{
						Go = val4,
						DecalMat = val2,
						BaseColor = val3,
						BaseScale = val5,
						IsFlyingGlob = false,
						IsVerticalWallDecal = false,
						SpawnTime = Time.unscaledTime,
						StickDuration = Mathf.Clamp(_bloodStickDurationPref.Value, 5f, 90f)
					});
				}
			}
			catch
			{
			}
		}

		private static void SpawnStickyBloodParticles(Vector3 position, float stickSeconds, int worldMask)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Expected O, but got Unknown
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: 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_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Expected O, but got Unknown
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Expected O, but got Unknown
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Expected O, but got Unknown
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Expected O, but got Unknown
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Expected O, but got Unknown
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Expected O, but got Unknown
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Expected O, but got Unknown
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Expected O, but got Unknown
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: 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_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Expected O, but got Unknown
			try
			{
				int num = Mathf.Clamp(_bloodParticleCountPref.Value, 20, 250);
				Material val = CreateTransparentBloodMaterial(GetDropletTexture());
				GameObject val2 = new GameObject("ShapeshiftStickyBloodDroplets");
				val2.transform.position = position;
				ParticleSystem val3 = val2.AddComponent<ParticleSystem>();
				MainModule main = val3.main;
				main.loop = false;
				main.duration = stickSeconds + 2f;
				main.startLifetime = new MinMaxCurve(stickSeconds * 0.85f, stickSeconds);
				main.startSpeed = new MinMaxCurve(3f, 9.5f);
				main.startSize = new MinMaxCurve(0.05f, 0.16f);
				main.gravityModifier = new MinMaxCurve(2f);
				main.simulationSpace = (ParticleSystemSimulationSpace)1;
				main.maxParticles = num + 20;
				main.startColor = new MinMaxGradient(new Color(0.35f, 0.005f, 0.005f, 0.98f), new Color(0.75f, 0.02f, 0.02f, 0.95f));
				val3.emission.enabled = false;
				ShapeModule shape = val3.shape;
				shape.shapeType = (ParticleSystemShapeType)0;
				shape.radius = 0.28f;
				CollisionModule collision = val3.collision;
				collision.enabled = true;
				collision.type = (ParticleSystemCollisionType)1;
				collision.dampen = MinMaxCurve.op_Implicit(1f);
				collision.bounce = MinMaxCurve.op_Implicit(0f);
				collision.radiusScale = 0.25f;
				collision.collidesWith = LayerMask.op_Implicit(worldMask);
				ColorOverLifetimeModule colorOverLifetime = val3.colorOverLifetime;
				colorOverLifetime.enabled = true;
				Gradient val4 = new Gradient();
				val4.SetKeys(Il2CppStructArray<GradientColorKey>.op_Implicit((GradientColorKey[])(object)new GradientColorKey[3]
				{
					new GradientColorKey(new Color(0.85f, 0.03f, 0.03f), 0f),
					new GradientColorKey(new Color(0.32f, 0.01f, 0.01f), 0.5f),
					new GradientColorKey(new Color(0.18f, 0.005f, 0.005f), 1f)
				}), Il2CppStructArray<GradientAlphaKey>.op_Implicit((GradientAlphaKey[])(object)new GradientAlphaKey[3]
				{
					new GradientAlphaKey(1f, 0f),
					new GradientAlphaKey(0.92f, 0.85f),
					new GradientAlphaKey(0f, 1f)
				}));
				colorOverLifetime.color = new MinMaxGradient(val4);
				ParticleSystemRenderer component = val2.GetComponent<ParticleSystemRenderer>();
				if ((Object)(object)component != (Object)null && (Object)(object)val != (Object)null)
				{
					((Renderer)component).sharedMaterial = val;
				}
				val3.Emit(num);
				Object.Destroy((Object)(object)val2, stickSeconds + 2.5f);
				GameObject val5 = new GameObject("ShapeshiftBloodMist");
				val5.transform.position = position;
				ParticleSystem val6 = val5.AddComponent<ParticleSystem>();
				MainModule main2 = val6.main;
				main2.loop = false;
				main2.duration = 2f;
				main2.startLifetime = new MinMaxCurve(0.6f, 1.4f);
				main2.startSpeed = new MinMaxCurve(1f, 3.6f);
				main2.startSize = new MinMaxCurve(0.45f, 1.1f);
				main2.gravityModifier = new MinMaxCurve(0.15f);
				main2.simulationSpace = (ParticleSystemSimulationSpace)1;
				main2.startColor = new MinMaxGradient(new Color(0.45f, 0.01f, 0.01f, 0.55f), new Color(0.65f, 0.02f, 0.02f, 0.35f));
				val6.emission.enabled = false;
				ShapeModule shape2 = val6.shape;
				shape2.shapeType = (ParticleSystemShapeType)0;
				shape2.radius = 0.35f;
				ColorOverLifetimeModule colorOverLifetime2 = val6.colorOverLifetime;
				colorOverLifetime2.enabled = true;
				Gradient val7 = new Gradient();
				val7.SetKeys(Il2CppStructArray<GradientColorKey>.op_Implicit((GradientColorKey[])(object)new GradientColorKey[2]
				{
					new GradientColorKey(new Color(0.55f, 0.01f, 0.01f), 0f),
					new GradientColorKey(new Color(0.25f, 0.005f, 0.005f), 1f)
				}), Il2CppStructArray<GradientAlphaKey>.op_Implicit((GradientAlphaKey[])(object)new GradientAlphaKey[2]
				{
					new GradientAlphaKey(0.65f, 0f),
					new GradientAlphaKey(0f, 1f)
				}));
				colorOverLifetime2.color = new MinMaxGradient(val7);
				ParticleSystemRenderer component2 = val5.GetComponent<ParticleSystemRenderer>();
				if ((Object)(object)component2 != (Object)null && (Object)(object)val != (Object)null)
				{
					((Renderer)component2).sharedMaterial = val;
				}
				val6.Emit(28);
				Object.Destroy((Object)(object)val5, 2.5f);
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("Particle blood spawn error: " + ex.Message);
			}
		}

		private static void SpawnCrimsonMonsterMistAura(Vector3 position)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_001c: 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_0055: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00d2: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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_014e: 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_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_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_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Expected O, but got Unknown
			try
			{
				Material val = CreateTransparentBloodMaterial(GetDropletTexture());
				GameObject val2 = new GameObject("ShapeshiftMonsterMistAura");
				val2.transform.position = position;
				ParticleSystem obj = val2.AddComponent<ParticleSystem>();
				MainModule main = obj.main;
				main.loop = false;
				main.duration = 4f;
				main.startLifetime = new MinMaxCurve(1.4f, 2.4f);
				main.startSpeed = new MinMaxCurve(0.2f, 0.85f);
				main.startSize = new MinMaxCurve(0.75f, 1.55f);
				main.gravityModifier = new MinMaxCurve(-0.08f);
				main.simulationSpace = (ParticleSystemSimulationSpace)1;
				main.startColor = new MinMaxGradient(new Color(0.32f, 0.005f, 0.005f, 0.28f), new Color(0.55f, 0.01f, 0.01f, 0.18f));
				obj.emission.rateOverTime = new MinMaxCurve(14f);
				ShapeModule shape = obj.shape;
				shape.shapeType = (ParticleSystemShapeType)0;
				shape.radius = 0.75f;
				ColorOverLifetimeModule colorOverLifetime = obj.colorOverLifetime;
				colorOverLifetime.enabled = true;
				Gradient val3 = new Gradient();
				val3.SetKeys(Il2CppStructArray<GradientColorKey>.op_Implicit((GradientColorKey[])(object)new GradientColorKey[2]
				{
					new GradientColorKey(new Color(0.45f, 0.01f, 0.01f), 0f),
					new GradientColorKey(new Color(0.18f, 0.003f, 0.003f), 1f)
				}), Il2CppStructArray<GradientAlphaKey>.op_Implicit((GradientAlphaKey[])(object)new GradientAlphaKey[3]
				{
					new GradientAlphaKey(0f, 0f),
					new GradientAlphaKey(0.45f, 0.25f),
					new GradientAlphaKey(0f, 1f)
				}));
				colorOverLifetime.color = new MinMaxGradient(val3);
				ParticleSystemRenderer component = val2.GetComponent<ParticleSystemRenderer>();
				if ((Object)(object)component != (Object)null && (Object)(object)val != (Object)null)
				{
					((Renderer)component).sharedMaterial = val;
				}
				Object.Destroy((Object)(object)val2, 6.8f);
			}
			catch
			{
			}
		}

		private static void SpawnSurfaceBloodDecals(Vector3 origin, float stickSeconds, int worldMask)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_0198: 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_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Material val = CreateTransparentBloodMaterial(GetBloodSplatTexture());
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				Color val2 = default(Color);
				((Color)(ref val2))..ctor(0.48f, 0.015f, 0.015f, 0.94f);
				val.color = val2;
				Vector3 val4 = default(Vector3);
				for (int i = 0; i < 28; i++)
				{
					Vector3 onUnitSphere = Random.onUnitSphere;
					if (i < 12)
					{
						onUnitSphere.y = 0f - Mathf.Abs(onUnitSphere.y) - 0.35f;
						((Vector3)(ref onUnitSphere)).Normalize();
					}
					if (TryFindRealSurfaceHit(origin, onUnitSphere, 6f, 0.35f, worldMask, out var bestHit))
					{
						GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)5);
						((Object)val3).name = "ShapeshiftBloodDecal";
						Collider component = val3.GetComponent<Collider>();
						if ((Object)(object)component != (Object)null)
						{
							Object.Destroy((Object)(object)component);
						}
						val3.transform.position = ((RaycastHit)(ref bestHit)).point + ((RaycastHit)(ref bestHit)).normal * (0.005f + (float)i * 0.00025f);
						val3.transform.rotation = Quaternion.LookRotation(-((RaycastHit)(ref bestHit)).normal);
						val3.transform.Rotate(0f, 0f, Random.Range(0f, 360f), (Space)1);
						float num = Random.Range(0.42f, 1.15f);
						((Vector3)(ref val4))..ctor(num * Random.Range(0.8f, 1.25f), num, 1f);
						val3.transform.localScale = val4;
						MeshRenderer component2 = val3.GetComponent<MeshRenderer>();
						if ((Object)(object)component2 != (Object)null)
						{
							((Renderer)component2).sharedMaterial = val;
						}
						RegisterSplat(new ActiveSplat
						{
							Go = val3,
							DecalMat = val,
							BaseColor = val2,
							BaseScale = val4,
							IsFlyingGlob = false,
							IsVerticalWallDecal = (Mathf.Abs(((RaycastHit)(ref bestHit)).normal.y) < 0.45f),
							SpawnTime = Time.unscaledTime,
							StickDuration = stickSeconds
						});
					}
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("Surface blood decal error: " + ex.Message);
			}
		}

		private static void SpawnFlying3DBloodGlobs(Vector3 origin, float stickSeconds, int worldMask)
		{
			//IL_003b: 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_0079: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_00ff: 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)
			try
			{
				Material val = CreateGlossyGlobMaterial();
				Vector3 val3 = default(Vector3);
				for (int i = 0; i < 18; i++)
				{
					GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0);
					((Object)val2).name = "ShapeshiftBloodGlob";
					Collider component = val2.GetComponent<Collider>();
					if ((Object)(object)component != (Object)null)
					{
						Object.Destroy((Object)(object)component);
					}
					val2.transform.position = origin + Random.insideUnitSphere * 0.18f;
					float num = Random.Range(0.035f, 0.095f);
					((Vector3)(ref val3))..ctor(num, num, num);
					val2.transform.localScale = val3;
					MeshRenderer component2 = val2.GetComponent<MeshRenderer>();
					if ((Object)(object)component2 != (Object)null && (Object)(object)val != (Object)null)
					{
						((Renderer)component2).sharedMaterial = val;
					}
					Vector3 velocity = Random.onUnitSphere * Random.Range(3.2f, 8.8f);
					velocity.y += Random.Range(0.8f, 3.6f);
					RegisterSplat(new ActiveSplat
					{
						Go = val2,
						DecalMat = null,
						BaseColor = Color.white,
						BaseScale = val3,
						Velocity = velocity,
						IsFlyingGlob = true,
						SpawnTime = Time.unscaledTime,
						StickDuration = stickSeconds
					});
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("3D blood glob error: " + ex.Message);
			}
		}

		private static void UpdateActiveBloodSplats()
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00d5: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: 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_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			if (_activeSplats.Count == 0)
			{
				return;
			}
			float unscaledTime = Time.unscaledTime;
			float num = Mathf.Min(Time.deltaTime, 0.05f);
			int worldBloodMask = GetWorldBloodMask();
			for (int num2 = _activeSplats.Count - 1; num2 >= 0; num2--)
			{
				ActiveSplat activeSplat = _activeSplats[num2];
				if ((Object)(object)activeSplat.Go == (Object)null)
				{
					_activeSplats.RemoveAt(num2);
				}
				else
				{
					float num3 = unscaledTime - activeSplat.SpawnTime;
					if (num3 >= activeSplat.StickDuration)
					{
						Object.Destroy((Object)(object)activeSplat.Go);
						_activeSplats.RemoveAt(num2);
					}
					else
					{
						if (activeSplat.IsFlyingGlob)
						{
							Vector3 position = activeSplat.Go.transform.position;
							activeSplat.Velocity += Vector3.down * 14.5f * num;
							Vector3 val = activeSplat.Velocity * num;
							float magnitude = ((Vector3)(ref val)).magnitude;
							if (magnitude > 0.0001f && TryFindRealSurfaceHit(position, val / magnitude, magnitude + 0.05f, 0f, worldBloodMask, out var bestHit))
							{
								activeSplat.IsFlyingGlob = false;
								activeSplat.Go.transform.position = ((RaycastHit)(ref bestHit)).point + ((RaycastHit)(ref bestHit)).normal * 0.008f;
								activeSplat.Go.transform.rotation = Quaternion.LookRotation(((RaycastHit)(ref bestHit)).normal);
								float num4 = activeSplat.BaseScale.x * Random.Range(2.1f, 3.4f);
								activeSplat.BaseScale = new Vector3(num4, num4 * Random.Range(0.75f, 1.25f), activeSplat.BaseScale.x * 0.25f);
								activeSplat.Go.transform.localScale = activeSplat.BaseScale;
							}
							else
							{
								activeSplat.Go.transform.position = position + val;
								if (((Vector3)(ref activeSplat.Velocity)).sqrMagnitude > 0.05f)
								{
									activeSplat.Go.transform.rotation = Quaternion.LookRotation(activeSplat.Velocity);
									activeSplat.Go.transform.localScale = new Vector3(activeSplat.BaseScale.x * 0.7f, activeSplat.BaseScale.y * 0.7f, activeSplat.BaseScale.z * 2.2f);
								}
							}
						}
						else if (activeSplat.IsVerticalWallDecal && num3 < 2f)
						{
							Transform transform = activeSplat.Go.transform;
							transform.position += Vector3.down * (0.045f * num);
							activeSplat.Go.transform.localScale = new Vector3(activeSplat.BaseScale.x, activeSplat.BaseScale.y * (1f + num3 * 0.14f), activeSplat.BaseScale.z);
						}
						float num5 = activeSplat.StickDuration - num3;
						if (num5 < 3f)
						{
							float num6 = Mathf.Clamp01(num5 / 3f);
							if ((Object)(object)activeSplat.DecalMat != (Object)null)
							{
								activeSplat.DecalMat.color = new Color(activeSplat.BaseColor.r, activeSplat.BaseColor.g, activeSplat.BaseColor.b, activeSplat.BaseColor.a * num6);
							}
							else
							{
								activeSplat.Go.transform.localScale = activeSplat.BaseScale * num6;
							}
						}
					}
				}
			}
		}

		private static bool TryFindRealSurfaceHit(Vector3 origin, Vector3 dir, float maxDist, float minDist, int worldMask, out RaycastHit bestHit)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			bestHit = default(RaycastHit);
			Il2CppStructArray<RaycastHit> val = Physics.RaycastAll(origin, dir, maxDist, worldMask, (QueryTriggerInteraction)1);
			if (val == null || ((Il2CppArrayBase<RaycastHit>)(object