Decompiled source of WILDCARDStuff v0.16.7

BepInEx/plugins/WildCardMod/LCWildCardMod.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LCWildCardMod.Config;
using LCWildCardMod.Items;
using LCWildCardMod.Items.Fyrus;
using LCWildCardMod.NetcodePatcher;
using LCWildCardMod.Utils;
using LethalCompanyInputUtils.Api;
using LethalLib.Modules;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Steamworks;
using TMPro;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace LCWildCardMod
{
	[BepInPlugin("deB.WildCard", "WILDCARD Stuff", "0.16.7")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class WildCardMod : BaseUnityPlugin
	{
		internal const string modGUID = "deB.WildCard";

		internal const string modName = "WILDCARD Stuff";

		internal const string modVersion = "0.16.7";

		internal static ManualLogSource Log = null;

		internal static KeyBinds wildcardKeyBinds;

		internal static SkinsClass skinsClass;

		internal static MapObjectHelper mapClass;

		private static WildCardMod Instance;

		private readonly Harmony harmony = new Harmony("deB.WildCard");

		private readonly string[] declaredAssetPaths = new string[3] { "assets/my creations/scrap items", "assets/my creations/skins", "assets/my creations/map objects" };

		public static List<Item> scrapList = new List<Item>();

		public static List<Skin> skinList = new List<Skin>();

		public static List<MapObject> mapObjectsList = new List<MapObject>();

		public static List<MapObject> autoMapObjectsList = new List<MapObject>();

		internal static WildCardConfig ModConfig { get; private set; } = null;


		private void Awake()
		{
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			wildcardKeyBinds = new KeyBinds();
			Log = ((BaseUnityPlugin)this).Logger;
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"))
			{
				Log.LogDebug((object)"Registering with LobbyCompatibility");
				SoftDepHelper.LobCompatRegister();
			}
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				for (int j = 0; j < methods.Length; j++)
				{
					object[] customAttributes = methods[j].GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methods[j].Invoke(null, null);
					}
				}
			}
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "wildcardmod"));
			string[] allAssetNames = val.GetAllAssetNames();
			for (int k = 0; k < allAssetNames.Length; k++)
			{
				if (declaredAssetPaths.Contains(allAssetNames[k].Substring(0, allAssetNames[k].LastIndexOf("/"))))
				{
					switch (allAssetNames[k].Substring(0, allAssetNames[k].LastIndexOf("/")))
					{
					case "assets/my creations/scrap items":
						scrapList.Add(val.LoadAsset<Item>(allAssetNames[k]));
						break;
					case "assets/my creations/skins":
						skinList.Add(val.LoadAsset<Skin>(allAssetNames[k]));
						break;
					case "assets/my creations/map objects":
					{
						MapObject mapObject = val.LoadAsset<MapObject>(allAssetNames[k]);
						if (mapObject.autoHandle)
						{
							autoMapObjectsList.Add(mapObject);
						}
						else
						{
							mapObjectsList.Add(mapObject);
						}
						break;
					}
					}
				}
				else
				{
					Log.LogWarning((object)("\"" + allAssetNames[k] + "\" is not a known asset path, skipping."));
				}
			}
			ModConfig = new WildCardConfig(((BaseUnityPlugin)this).Config, scrapList, skinList, mapObjectsList);
			skinsClass = new SkinsClass();
			mapClass = new MapObjectHelper();
			for (int l = 0; l < scrapList.Count; l++)
			{
				if (scrapList[l].spawnPrefab.GetComponent<AdditionalInfo>().isBonus && !ModConfig.assortedScrap.Value)
				{
					Log.LogInfo((object)("\"" + scrapList[l].itemName + "\" scrap was disabled!"));
				}
				else if (ModConfig.isScrapEnabled[l].Value)
				{
					Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
					Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
					string[] array = ModConfig.scrapSpawnWeights[l].Value.Split(",");
					bool flag = false;
					for (int m = 0; m < array.Length; m++)
					{
						if (array[m].Contains(":") && int.TryParse(array[m].Split(":")[1], out var _))
						{
							flag = true;
							continue;
						}
						flag = false;
						break;
					}
					if (flag)
					{
						for (int n = 0; n < array.Length; n++)
						{
							if (Enum.TryParse<LevelTypes>(array[n].Split(":")[0], out LevelTypes result2))
							{
								dictionary.Add(result2, int.Parse(array[n].Split(":")[1]));
							}
							else
							{
								dictionary2.Add(array[n], int.Parse(array[n].Split(":")[1]));
							}
						}
						NetworkPrefabs.RegisterNetworkPrefab(scrapList[l].spawnPrefab);
						Utilities.FixMixerGroups(scrapList[l].spawnPrefab);
						Items.RegisterScrap(scrapList[l], (Dictionary<LevelTypes, int>)null, dictionary2);
						Items.RegisterScrap(scrapList[l], dictionary, (Dictionary<string, int>)null);
						Log.LogDebug((object)("\"" + scrapList[l].itemName + "\" scrap was loaded!"));
						for (int num = 0; num < Items.scrapItems.LastOrDefault().levelRarities.Count; num++)
						{
							Log.LogDebug((object)$"LethalLib Scrap Weights \"{Items.scrapItems.LastOrDefault().levelRarities.ToArray()[num]}\"");
						}
					}
					else
					{
						Log.LogWarning((object)("\"" + scrapList[l].itemName + "\" scrap was not loaded as its config was not set up correctly!"));
					}
				}
				else
				{
					Log.LogInfo((object)("\"" + scrapList[l].itemName + "\" scrap was disabled!"));
					scrapList.Remove(scrapList[l]);
					l--;
				}
			}
			for (int num2 = 0; num2 < skinList.Count; num2++)
			{
				if (ModConfig.isSkinEnabled[num2].Value)
				{
					Log.LogDebug((object)("\"" + skinList[num2].skinName + "\" skin was loaded!"));
					continue;
				}
				Log.LogInfo((object)("\"" + skinList[num2].skinName + "\" skin was disabled!"));
				skinList.Remove(skinList[num2]);
				num2--;
			}
			mapClass.Init(mapObjectsList, autoMapObjectsList, ModConfig);
			GrabbableObject val2 = default(GrabbableObject);
			for (int num3 = 0; num3 < mapObjectsList.Count; num3++)
			{
				if (ModConfig.isMapObjectEnabled[num3].Value)
				{
					if (!ModConfig.useDefaultMapObjectCurve[num3].Value)
					{
						mapObjectsList[num3].curveFunc = mapClass.MapObjectFunc;
						Log.LogInfo((object)("Using config settings for \"" + mapObjectsList[num3].mapObjectName + "\"'s amount curve!"));
					}
					else
					{
						mapObjectsList[num3].curveFunc = mapClass.MapObjectFunc;
					}
					NetworkPrefabs.RegisterNetworkPrefab(mapObjectsList[num3].spawnableMapObject.prefabToSpawn);
					Utilities.FixMixerGroups(mapObjectsList[num3].spawnableMapObject.prefabToSpawn);
					if (mapObjectsList[num3].spawnableMapObject.prefabToSpawn.TryGetComponent<GrabbableObject>(ref val2))
					{
						Items.RegisterItem(val2.itemProperties);
					}
					MapObjects.RegisterMapObject(mapObjectsList[num3].spawnableMapObject, (LevelTypes)(-1), mapObjectsList[num3].curveFunc);
					Log.LogDebug((object)("\"" + mapObjectsList[num3].mapObjectName + "\" map object was loaded!"));
				}
				else
				{
					mapObjectsList.Remove(mapObjectsList[num3]);
					Log.LogInfo((object)("\"" + mapObjectsList[num3].mapObjectName + "\" map object was disabled!"));
					num3--;
				}
			}
			GrabbableObject val3 = default(GrabbableObject);
			for (int num4 = 0; num4 < autoMapObjectsList.Count; num4++)
			{
				NetworkPrefabs.RegisterNetworkPrefab(autoMapObjectsList[num4].spawnableMapObject.prefabToSpawn);
				Utilities.FixMixerGroups(autoMapObjectsList[num4].spawnableMapObject.prefabToSpawn);
				if (autoMapObjectsList[num4].spawnableMapObject.prefabToSpawn.TryGetComponent<GrabbableObject>(ref val3))
				{
					Items.RegisterItem(val3.itemProperties);
				}
				autoMapObjectsList[num4].curveFunc = mapClass.AutoMapObjectFunc;
				MapObjects.RegisterMapObject(autoMapObjectsList[num4].spawnableMapObject, (LevelTypes)(-1), autoMapObjectsList[num4].curveFunc);
				Log.LogDebug((object)("\"" + autoMapObjectsList[num4].mapObjectName + "\" is being handled automatically!"));
			}
			harmony.PatchAll();
			Log.LogInfo((object)"WILDCARD Stuff Successfully Loaded");
		}
	}
}
namespace LCWildCardMod.Utils
{
	public class KeyBinds : LcInputActions
	{
		[InputAction("<Keyboard>/r", Name = "WildCardUse")]
		public InputAction WildCardButton { get; set; }
	}
	public class SoftDepHelper
	{
		public static void LobCompatRegister()
		{
			PluginHelper.RegisterPlugin("deB.WildCard", new Version("0.16.7"), (CompatibilityLevel)2, (VersionStrictness)3);
		}
	}
	public class AdditionalInfo : MonoBehaviour
	{
		public bool defaultEnabled;

		public string defaultRarities;

		public bool isBonus;
	}
	public class SkinsClass : MonoBehaviour
	{
		private readonly ManualLogSource log = WildCardMod.Log;

		private readonly List<ConfigEntry<int>> configChances = WildCardMod.ModConfig.skinApplyChance;

		private readonly List<Skin> allSkins = WildCardMod.skinList;

		public void SetSkin(List<Skin> potentialSkins, EnemyAI enemy = null, GrabbableObject item = null)
		{
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			Random random = new Random(StartOfRound.Instance.randomMapSeed + 69);
			Skin skin = null;
			int num = 0;
			int num2 = 0;
			for (int i = 0; i < potentialSkins.Count; i++)
			{
				int index = allSkins.IndexOf(potentialSkins[i]);
				if (configChances[index].Value <= 0)
				{
					log.LogDebug((object)("Skin \"" + potentialSkins[i].skinName + "\" was disabled!"));
					potentialSkins.Remove(potentialSkins[i]);
					i--;
				}
				else
				{
					log.LogDebug((object)("Adding skin \"" + potentialSkins[i].skinName + "\"'s chance weight!"));
					num2 += configChances[index].Value;
					num += 100 - configChances[index].Value;
				}
			}
			float num3 = (float)random.NextDouble();
			log.LogDebug((object)"Rolling to see if a skin will be applied!");
			if ((float)num / (float)(num + num2) < num3)
			{
				potentialSkins.Sort((Skin x, Skin y) => configChances[allSkins.IndexOf(potentialSkins[potentialSkins.IndexOf(x)])].Value.CompareTo(configChances[allSkins.IndexOf(potentialSkins[potentialSkins.IndexOf(y)])].Value));
				for (int j = 0; j < potentialSkins.Count; j++)
				{
					log.LogDebug((object)("Rolling to see if \"" + potentialSkins[j].skinName + "\" is selected!"));
					if ((float)(configChances[allSkins.IndexOf(potentialSkins[j])].Value / num2) >= num3)
					{
						log.LogDebug((object)("Skin \"" + potentialSkins[j].skinName + "\" was selected!"));
						skin = potentialSkins[j];
						break;
					}
				}
				if ((Object)(object)skin.targetEnemy != (Object)null)
				{
					string enemyName = skin.targetEnemy.enemyName;
					string text = enemyName;
					if (text == "Earth Leviathan")
					{
						log.LogDebug((object)("Skin \"" + skin.skinName + "\" is being applied!"));
						((Component)((Component)enemy).transform.Find("MeshContainer").Find("Renderer")).GetComponent<SkinnedMeshRenderer>().sharedMesh = skin.newMesh;
						((Renderer)((Component)((Component)enemy).transform.Find("MeshContainer").Find("Renderer")).GetComponent<SkinnedMeshRenderer>()).sharedMaterial = skin.newMaterial;
						((Component)((Component)enemy).transform.Find("MeshContainer").Find("Armature").Find("Bone")
							.Find("Bone.001")
							.Find("Bone.003")
							.Find("Bone.002")
							.Find("ScanNode")).GetComponent<ScanNodeProperties>().headerText = skin.skinName;
						((Component)((Component)enemy).transform).GetComponent<SandWormAI>().ambientRumbleSFX[0] = skin.newAudioClips[0];
						((Component)((Component)enemy).transform).GetComponent<SandWormAI>().ambientRumbleSFX[1] = skin.newAudioClips[0];
						((Component)((Component)enemy).transform).GetComponent<SandWormAI>().ambientRumbleSFX[2] = skin.newAudioClips[0];
						AudioSource creatureSFX = ((EnemyAI)((Component)((Component)enemy).transform).GetComponent<SandWormAI>()).creatureSFX;
						creatureSFX.volume *= 1.5f;
						((Component)((Component)enemy).transform).GetComponent<SandWormAI>().roarSFX[0] = skin.newAudioClips[1];
						((Component)((Component)enemy).transform).GetComponent<SandWormAI>().roarSFX[1] = skin.newAudioClips[2];
					}
					else
					{
						log.LogError((object)("\"" + potentialSkins[0].skinName + "\" did not match any known enemy type!"));
					}
				}
				else if ((Object)(object)skin.targetItem != (Object)null)
				{
					string itemName = skin.targetItem.itemName;
					string text2 = itemName;
					if (text2 == "Clown horn")
					{
						log.LogDebug((object)("Skin \"" + skin.skinName + "\" is being applied!"));
						Item val = Object.Instantiate<Item>(item.itemProperties);
						val.itemName = skin.skinName;
						val.isConductiveMetal = false;
						val.grabSFX = skin.newAudioClips[0];
						val.dropSFX = skin.newAudioClips[1];
						val.toolTips[0] = "Squeeze : [LMB]";
						val.positionOffset = new Vector3(0.05f, 0.15f, -0.05f);
						item.useCooldown = 0.5f;
						val.spawnPrefab.GetComponent<MeshFilter>().mesh = skin.newMesh;
						((Component)((Component)item).transform).GetComponent<MeshFilter>().mesh = skin.newMesh;
						((Renderer)((Component)((Component)item).transform).GetComponent<MeshRenderer>()).material = skin.newMaterial;
						val.spawnPrefab.GetComponent<MeshFilter>().sharedMesh = skin.newMesh;
						((Component)((Component)item).transform).GetComponent<MeshFilter>().sharedMesh = skin.newMesh;
						((Renderer)((Component)((Component)item).transform).GetComponent<MeshRenderer>()).sharedMaterial = skin.newMaterial;
						((Component)((Component)item).transform.Find("ScanNode")).GetComponent<ScanNodeProperties>().headerText = skin.skinName;
						Animator val2 = ((Component)item).gameObject.AddComponent<Animator>();
						val2.runtimeAnimatorController = skin.newAnimationController;
						((Component)((Component)item).transform).GetComponent<NoisemakerProp>().triggerAnimator = val2;
						item.itemProperties = val;
					}
					else
					{
						log.LogError((object)("\"" + potentialSkins[0].skinName + "\" did not match any known item!"));
					}
				}
			}
			else
			{
				log.LogDebug((object)("No skin for \"" + potentialSkins[0].targetEnemy.enemyName + "\" was chosen to apply!"));
			}
		}
	}
	[CreateAssetMenu(menuName = "WCScriptableObjects/Skin", order = 1)]
	public class Skin : ScriptableObject
	{
		public string skinName;

		public bool skinEnabled;

		public int skinChance;

		public EnemyType targetEnemy;

		public Item targetItem;

		public Mesh newMesh;

		public Material newMaterial;

		public AudioClip[] newAudioClips;

		public RuntimeAnimatorController newAnimationController;
	}
	[CreateAssetMenu(menuName = "WCScriptableObjects/MapObject", order = 1)]
	public class MapObject : ScriptableObject
	{
		public string mapObjectName;

		public SpawnableMapObject spawnableMapObject;

		public Func<SelectableLevel, AnimationCurve> curveFunc;

		public List<LevelCurve> levelCurves;

		public bool autoHandle;
	}
	[Serializable]
	public class LevelCurve
	{
		public string level;

		public AnimationCurve curve;
	}
	public class MapObjectHelper
	{
		private readonly ManualLogSource log = WildCardMod.Log;

		public static WildCardConfig ModConfig;

		public static List<MapObject> mapObjects;

		public static List<MapObject> autoMapObjects;

		public int levelIndex = 0;

		public int mapIndex = 0;

		public void Init(List<MapObject> maps, List<MapObject> autoMaps, WildCardConfig config)
		{
			ModConfig = config;
			mapObjects = maps;
			autoMapObjects = autoMaps;
		}

		public AnimationCurve MapObjectFunc(SelectableLevel level)
		{
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			AnimationCurve curve;
			if (ModConfig.useDefaultMapObjectCurve[mapIndex].Value)
			{
				List<string> list = new List<string>();
				for (int i = 0; i < mapObjects[mapIndex].levelCurves.Count; i++)
				{
					list.Add(mapObjects[mapIndex].levelCurves[i].level);
				}
				for (int j = 0; j < mapObjects[mapIndex].levelCurves.Count; j++)
				{
					LevelCurve levelCurve = mapObjects[mapIndex].levelCurves[j];
					if (list.Contains(levelCurve.level) && levelCurve.level == ((Object)level).name)
					{
						curve = levelCurve.curve;
						IterateIndices();
						return curve;
					}
				}
				curve = mapObjects[mapIndex].spawnableMapObject.numberToSpawn;
				IterateIndices();
				return curve;
			}
			curve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
			{
				new Keyframe(0f, (float)ModConfig.mapObjectMinNo[mapIndex].Value),
				new Keyframe(1f, (float)ModConfig.mapObjectMaxNo[mapIndex].Value)
			});
			IterateIndices();
			return curve;
		}

		public void IterateIndices()
		{
			if (levelIndex == StartOfRound.Instance.levels.Length)
			{
				levelIndex = 0;
				mapIndex++;
				if (mapIndex == mapObjects.Count)
				{
					mapIndex = 0;
				}
			}
			levelIndex++;
		}

		public AnimationCurve AutoMapObjectFunc(SelectableLevel level)
		{
			List<string> list = new List<string>();
			for (int i = 0; i < autoMapObjects[mapIndex].levelCurves.Count; i++)
			{
				list.Add(autoMapObjects[mapIndex].levelCurves[i].level);
			}
			AnimationCurve curve;
			for (int j = 0; j < autoMapObjects[mapIndex].levelCurves.Count; j++)
			{
				LevelCurve levelCurve = autoMapObjects[mapIndex].levelCurves[j];
				if (list.Contains(levelCurve.level) && levelCurve.level == ((Object)level).name)
				{
					curve = levelCurve.curve;
					IterateIndices();
					return curve;
				}
			}
			curve = autoMapObjects[mapIndex].spawnableMapObject.numberToSpawn;
			IterateIndices();
			return curve;
		}
	}
}
namespace LCWildCardMod.Patches
{
	[HarmonyPatch(typeof(EnemyAI))]
	public static class EnemyAIPatch
	{
		private static readonly ManualLogSource log = WildCardMod.Log;

		[HarmonyPatch("Start")]
		[HarmonyAfter(new string[] { "AudioKnight.StarlancerAIFix", "antlershed.lethalcompany.enemyskinregistry" })]
		[HarmonyPostfix]
		private static void ChangeAssets(EnemyAI __instance)
		{
			List<Skin> list = new List<Skin>();
			List<Skin> skinList = WildCardMod.skinList;
			for (int i = 0; i < skinList.Count; i++)
			{
				if ((Object)(object)skinList[i].targetEnemy != (Object)null && __instance.enemyType.enemyName == skinList[i].targetEnemy.enemyName)
				{
					list.Add(skinList[i]);
				}
			}
			if (list.Count > 0)
			{
				log.LogDebug((object)("A \"" + __instance.enemyType.enemyName + "\" has spawned with potential skins!"));
				WildCardMod.skinsClass.SetSkin(list, __instance);
			}
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	public static class GrabbableObjectPatch
	{
		private static readonly ManualLogSource log = WildCardMod.Log;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void ChangeAssets(GrabbableObject __instance)
		{
			List<Skin> list = new List<Skin>();
			List<Skin> skinList = WildCardMod.skinList;
			for (int i = 0; i < skinList.Count; i++)
			{
				if ((Object)(object)skinList[i].targetItem != (Object)null && __instance.itemProperties.itemName == skinList[i].targetItem.itemName)
				{
					list.Add(skinList[i]);
				}
			}
			if (list.Count > 0)
			{
				log.LogDebug((object)("A \"" + __instance.itemProperties.itemName + "\" has spawned with potential skins!"));
				WildCardMod.skinsClass.SetSkin(list, null, __instance);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public static class PlayerControllerBPatch
	{
		private static readonly ManualLogSource log = WildCardMod.Log;

		[HarmonyPatch("DamagePlayer")]
		[HarmonyPrefix]
		public static bool SavePlayerDamage(PlayerControllerB __instance, ref CauseOfDeath causeOfDeath, ref int damageNumber)
		{
			if ((int)causeOfDeath != 7)
			{
				FyrusStar[] array = Object.FindObjectsByType<FyrusStar>((FindObjectsSortMode)0);
				foreach (FyrusStar fyrusStar in array)
				{
					if (fyrusStar.starEffect && (Object)(object)fyrusStar.consumedPlayer == (Object)(object)__instance)
					{
						log.LogDebug((object)$"FyrusStar Saving Player from {causeOfDeath}");
						damageNumber = 0;
					}
				}
				SmithHalo smithHalo = default(SmithHalo);
				if (__instance.isHoldingObject && ((Component)__instance.currentlyHeldObjectServer).TryGetComponent<SmithHalo>(ref smithHalo) && smithHalo.isExhausted == 0 && damageNumber >= __instance.health)
				{
					log.LogDebug((object)$"Halo Saving Player from {causeOfDeath}");
					__instance.health = damageNumber + 1;
					if (smithHalo.exhaustCoroutine == null)
					{
						smithHalo.ExhaustHaloServerRpc();
					}
				}
			}
			return true;
		}

		[HarmonyPatch("KillPlayer")]
		[HarmonyPrefix]
		public static bool SavePlayerKill(PlayerControllerB __instance, ref CauseOfDeath causeOfDeath)
		{
			if ((int)causeOfDeath == 7)
			{
				FyrusStar[] array = Object.FindObjectsByType<FyrusStar>((FindObjectsSortMode)0);
				foreach (FyrusStar fyrusStar in array)
				{
					if (fyrusStar.starEffect && (Object)(object)fyrusStar.consumedPlayer == (Object)(object)__instance)
					{
						log.LogDebug((object)$"FyrusStar Saving Player from {causeOfDeath}");
						return false;
					}
				}
				SmithHalo smithHalo = default(SmithHalo);
				if (__instance.isHoldingObject && ((Component)__instance.currentlyHeldObjectServer).TryGetComponent<SmithHalo>(ref smithHalo) && smithHalo.isExhausted == 0)
				{
					log.LogDebug((object)$"Halo Saving Player from {causeOfDeath}");
					__instance.health = 1;
					if (smithHalo.exhaustCoroutine == null)
					{
						smithHalo.ExhaustHaloServerRpc();
					}
					return false;
				}
			}
			return true;
		}

		[HarmonyPatch("PlayerHitGroundEffects")]
		[HarmonyPrefix]
		public static bool PreventFallDamage(PlayerControllerB __instance)
		{
			Cojiro cojiro = null;
			if (__instance.isHoldingObject && ((Component)__instance.currentlyHeldObjectServer).TryGetComponent<Cojiro>(ref cojiro) && cojiro.isFloating && __instance.fallValue >= -38f)
			{
				log.LogDebug((object)"Cojiro Preventing Fall Damage");
				__instance.fallValue = -10f;
				__instance.fallValueUncapped = -10f;
				cojiro.itemAnimator.Animator.SetBool("Floating", false);
			}
			else if ((Object)(object)cojiro == (Object)null && __instance.fallValue >= -38f)
			{
				Cojiro[] array = Object.FindObjectsOfType<Cojiro>();
				for (int i = 0; i < array.Length; i++)
				{
					if ((Object)(object)array[i].previousPlayer == (Object)(object)__instance && ((GrabbableObject)array[i]).currentUseCooldown > 0f)
					{
						log.LogDebug((object)"Cojiro Preventing Fall Damage");
						__instance.fallValue = -10f;
						__instance.fallValueUncapped = -10f;
						array[i].itemAnimator.Animator.SetBool("Floating", false);
					}
				}
			}
			return true;
		}
	}
}
namespace LCWildCardMod.MapObjects
{
	public enum WormState
	{
		Peeping,
		Hungry,
		Consuming,
		Sleeping
	}
	public class WormPit : NetworkBehaviour
	{
		private readonly ManualLogSource log = WildCardMod.Log;

		public MapObject mapObject;

		public AudioSource pitSource;

		public AudioSource miscSource;

		public AudioClip[] squishClips;

		public AudioClip biteClip;

		public AudioClip growlClip;

		public WormState State = WormState.Peeping;

		public Transform irisTransform;

		public NetworkAnimator netAnim;

		public float peepCooldown;

		public float peepWaitBetween = 10f;

		public float peepWaitHold;

		public PlayerControllerB playerLookingAt;

		public List<PlayerControllerB> playersOverlapping = new List<PlayerControllerB>();

		public bool peeping;

		public float lookLerp;

		public Quaternion initialRot;

		public Quaternion targetRot;

		public float hunger;

		public float patience = 5f;

		public float sleepiness = 0f;

		public bool consuming;

		private Random random;

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			log.LogDebug((object)"Worm Pit Spawned");
			random = new Random(StartOfRound.Instance.randomMapSeed + 69);
		}

		public void Update()
		{
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			for (int i = 0; i < playersOverlapping.Count; i++)
			{
				playerLookingAt = SelectNewPlayer(playersOverlapping[i]);
			}
			if (playersOverlapping.Count == 0)
			{
				playerLookingAt = SelectNewPlayer(null);
			}
			switch (State)
			{
			case WormState.Peeping:
				if (peeping)
				{
					if ((Object)(object)playerLookingAt != (Object)null)
					{
						PlayerFearIncreaseClientRpc(overTime: true, 1f, 0.5f, playerLookingAt.actualClientId);
						IrisLookClientRpc(nullify: false, playerLookingAt.playerClientId);
					}
					if (peepCooldown >= peepWaitHold)
					{
						int id = random.Next(0, squishClips.Length);
						float pitch = (float)random.Next(9, 11) / 10f;
						PlaySquishClientRpc(id, pitch);
						netAnim.Animator.SetBool("HoldPeep", false);
						peeping = false;
						peepCooldown = 0f;
					}
				}
				else
				{
					if (irisTransform.localRotation != Quaternion.identity)
					{
						lookLerp = 0f;
						IrisLookClientRpc(nullify: true, 0uL);
					}
					if (peepCooldown >= peepWaitBetween)
					{
						int id2 = random.Next(0, squishClips.Length);
						float pitch2 = (float)random.Next(9, 11) / 10f;
						PlaySquishClientRpc(id2, pitch2);
						netAnim.SetTrigger("Peep");
						netAnim.Animator.SetBool("HoldPeep", true);
						peepWaitBetween = (float)random.Next(50, 101) / 10f;
						peepWaitHold = (float)random.Next(30, 81) / 10f;
						peeping = true;
						peepCooldown = 0f;
					}
				}
				if (hunger >= 25f)
				{
					peeping = false;
					peepCooldown = 0f;
					netAnim.Animator.SetBool("HoldPeep", false);
					hunger = 0f;
					float pitch3 = (float)random.Next(9, 11) / 10f;
					PlayGrowlClientRpc(pitch3);
					State = WormState.Hungry;
					break;
				}
				if ((Object)(object)playerLookingAt != (Object)null && peeping)
				{
					hunger += Time.deltaTime * 1.5f;
					if (Vector3.Distance(((Component)this).transform.position, ((Component)playerLookingAt).transform.position) <= 7.5f)
					{
						hunger += Time.deltaTime * 2f;
					}
				}
				peepCooldown += Time.deltaTime;
				break;
			case WormState.Hungry:
				if (((Object)(object)playerLookingAt != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)playerLookingAt).transform.position) <= 5f) || patience <= 0f)
				{
					patience = 10f;
					State = WormState.Consuming;
				}
				else if ((Object)(object)playerLookingAt != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)playerLookingAt).transform.position) <= 15f)
				{
					patience -= Time.deltaTime;
				}
				break;
			case WormState.Consuming:
				if (consuming)
				{
					for (int j = 0; j < playersOverlapping.Count; j++)
					{
						PlayerFearIncreaseClientRpc(overTime: true, 2f, 1f, playersOverlapping[j].actualClientId);
						PlayerExternalForcesClientRpc(playersOverlapping[j].actualClientId);
					}
					if (sleepiness >= 12.5f)
					{
						consuming = false;
						netAnim.SetTrigger("Emerge");
						sleepiness = (float)random.Next(75, 151) / 10f;
						float pitch4 = (float)random.Next(9, 11) / 10f;
						PlayGrowlClientRpc(pitch4);
						PitMusicClientRpc(play: false);
						State = WormState.Sleeping;
						break;
					}
					if (playersOverlapping.Count == 0 && sleepiness >= 7.5f)
					{
						consuming = false;
						netAnim.SetTrigger("Emerge");
						sleepiness = 0f;
						PitMusicClientRpc(play: false);
						State = WormState.Peeping;
						break;
					}
				}
				else
				{
					consuming = true;
					sleepiness = 0f;
					netAnim.SetTrigger("Emerge");
					PitMusicClientRpc(play: true);
					for (int k = 0; k < playersOverlapping.Count; k++)
					{
						PlayerFearIncreaseClientRpc(overTime: false, 0.25f, 0f, playersOverlapping[k].actualClientId);
					}
				}
				sleepiness += Time.deltaTime;
				break;
			case WormState.Sleeping:
				if (sleepiness > 0f)
				{
					sleepiness -= Time.deltaTime;
				}
				else
				{
					State = WormState.Peeping;
				}
				break;
			}
		}

		public void PitChomp()
		{
			//IL_0020: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsServer || !consuming)
			{
				return;
			}
			RaycastHit[] array = Physics.SphereCastAll(((Component)this).transform.position, 2f, ((Component)this).transform.up, 0f, 1074266120, (QueryTriggerInteraction)2);
			PlayerControllerB val = default(PlayerControllerB);
			IHittable val2 = default(IHittable);
			for (int i = 0; i < array.Length; i++)
			{
				if (((Component)((RaycastHit)(ref array[i])).transform).TryGetComponent<PlayerControllerB>(ref val))
				{
					val.DamagePlayer(15, true, true, (CauseOfDeath)6, 0, false, ((Component)this).transform.up * -10f);
				}
				else if (Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref array[i])).transform).GetComponent<EnemyAICollisionDetect>()) && ((Component)((RaycastHit)(ref array[i])).transform).TryGetComponent<IHittable>(ref val2))
				{
					val2.Hit(2, ((Component)this).transform.up * -1f, (PlayerControllerB)null, true, -1);
				}
			}
		}

		public void PitAudioAnim()
		{
			if (State == WormState.Consuming)
			{
				miscSource.pitch = (float)random.Next(9, 11) / 10f;
				miscSource.PlayOneShot(biteClip);
			}
		}

		public PlayerControllerB SelectNewPlayer(PlayerControllerB player)
		{
			//IL_0018: 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_003b: 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_00b1: 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_00d1: 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)
			if ((Object)(object)player == (Object)null || player.isPlayerDead || (Physics.Linecast(((Component)this).transform.position, player.playerGlobalHead.position, 1107298560, (QueryTriggerInteraction)1) && Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position) >= 7.5f))
			{
				if ((Object)(object)playerLookingAt != (Object)null)
				{
					log.LogDebug((object)"WormPit Selected Player changed to null!");
				}
				return null;
			}
			if ((Object)(object)player != (Object)(object)playerLookingAt && ((Object)(object)playerLookingAt == (Object)null || Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position) < Vector3.Distance(((Component)playerLookingAt).transform.position, ((Component)this).transform.position)))
			{
				if ((Object)(object)playerLookingAt != (Object)(object)player)
				{
					log.LogDebug((object)("WormPit Selected Player changed to " + player.playerUsername + "!"));
				}
				return player;
			}
			return playerLookingAt;
		}

		public void OnTriggerEnter(Collider other)
		{
			PlayerControllerB val = default(PlayerControllerB);
			if (!((Component)other).gameObject.TryGetComponent<PlayerControllerB>(ref val))
			{
				return;
			}
			if (!val.isPlayerDead)
			{
				playersOverlapping.Add(val);
				return;
			}
			playersOverlapping.Remove(val);
			if (playersOverlapping.Count == 0)
			{
				playerLookingAt = SelectNewPlayer(null);
			}
		}

		public void OnTriggerExit(Collider other)
		{
			PlayerControllerB item = default(PlayerControllerB);
			if (((Component)other).gameObject.TryGetComponent<PlayerControllerB>(ref item))
			{
				playersOverlapping.Remove(item);
			}
			if (playersOverlapping.Count == 0)
			{
				playerLookingAt = SelectNewPlayer(null);
			}
		}

		[ClientRpc]
		public void IrisLookClientRpc(bool nullify, ulong id = 0uL)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0154: 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_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: 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_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: 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_01ef: 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_026c: 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_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: 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_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1708300264u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref nullify, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, id);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1708300264u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			if (lookLerp == 0f)
			{
				initialRot = irisTransform.rotation;
			}
			if (lookLerp < 360f)
			{
				lookLerp += Time.deltaTime * 270f;
			}
			else if (lookLerp > 360f)
			{
				lookLerp = 360f;
			}
			if (Quaternion.Dot(initialRot, irisTransform.rotation) >= 0.95f)
			{
				Quaternion val3 = (nullify ? Quaternion.LookRotation(((Component)this).transform.up) : ((!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)StartOfRound.Instance.allPlayerScripts[id])) ? Quaternion.LookRotation(((Component)StartOfRound.Instance.allPlayerScripts[id].playerGlobalHead).transform.position - ((Component)this).transform.position) : Quaternion.LookRotation(((Component)StartOfRound.Instance.allPlayerScripts[id].gameplayCamera).transform.position - ((Component)this).transform.position)));
				if (((Quaternion)(ref val3)).eulerAngles.x < 225f)
				{
					val3 = Quaternion.Euler(225f, ((Quaternion)(ref val3)).eulerAngles.y, ((Quaternion)(ref val3)).eulerAngles.z);
				}
				else if (((Quaternion)(ref val3)).eulerAngles.x > 315f)
				{
					val3 = Quaternion.Euler(315f, ((Quaternion)(ref val3)).eulerAngles.y, ((Quaternion)(ref val3)).eulerAngles.z);
				}
				targetRot = val3;
				irisTransform.rotation = Quaternion.RotateTowards(initialRot, targetRot, lookLerp);
			}
			else
			{
				lookLerp = 0f;
			}
		}

		[ClientRpc]
		public void PlayerExternalForcesClientRpc(ulong id)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2539007924u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, id);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2539007924u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				if (localPlayerController.actualClientId == id)
				{
					Vector3 externalForces = localPlayerController.externalForces;
					Vector3 val3 = ((Component)this).transform.position - ((Component)localPlayerController).transform.position;
					localPlayerController.externalForces = externalForces + ((Vector3)(ref val3)).normalized * 3.5f;
				}
			}
		}

		[ClientRpc]
		public void PlayerFearIncreaseClientRpc(bool overTime, float amount, float cap, ulong id)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(277365602u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref overTime, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref amount, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref cap, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, id);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 277365602u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && GameNetworkManager.Instance.localPlayerController.actualClientId == id)
			{
				if (overTime)
				{
					GameNetworkManager.Instance.localPlayerController.IncreaseFearLevelOverTime(amount, cap);
				}
				else
				{
					GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(amount, true);
				}
			}
		}

		[ClientRpc]
		public void PlaySquishClientRpc(int id, float pitch)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: 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_0071: 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_0090: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1654287888u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, id);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref pitch, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1654287888u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					miscSource.pitch = pitch;
					miscSource.PlayOneShot(squishClips[id], 1.5f);
				}
			}
		}

		[ClientRpc]
		public void PlayGrowlClientRpc(float pitch)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2916852503u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref pitch, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2916852503u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					miscSource.pitch = pitch;
					miscSource.PlayOneShot(growlClip, 1.5f);
				}
			}
		}

		[ClientRpc]
		public void PitMusicClientRpc(bool play)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(972706182u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref play, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 972706182u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (play)
				{
					pitSource.Play();
				}
				else
				{
					pitSource.Stop();
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_WormPit()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1708300264u, new RpcReceiveHandler(__rpc_handler_1708300264));
			NetworkManager.__rpc_func_table.Add(2539007924u, new RpcReceiveHandler(__rpc_handler_2539007924));
			NetworkManager.__rpc_func_table.Add(277365602u, new RpcReceiveHandler(__rpc_handler_277365602));
			NetworkManager.__rpc_func_table.Add(1654287888u, new RpcReceiveHandler(__rpc_handler_1654287888));
			NetworkManager.__rpc_func_table.Add(2916852503u, new RpcReceiveHandler(__rpc_handler_2916852503));
			NetworkManager.__rpc_func_table.Add(972706182u, new RpcReceiveHandler(__rpc_handler_972706182));
		}

		private static void __rpc_handler_1708300264(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool nullify = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref nullify, default(ForPrimitives));
				ulong id = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref id);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((WormPit)(object)target).IrisLookClientRpc(nullify, id);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2539007924(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong id = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref id);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((WormPit)(object)target).PlayerExternalForcesClientRpc(id);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_277365602(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0065: 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_0074: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool overTime = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref overTime, default(ForPrimitives));
				float amount = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref amount, default(ForPrimitives));
				float cap = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref cap, default(ForPrimitives));
				ulong id = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref id);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((WormPit)(object)target).PlayerFearIncreaseClientRpc(overTime, amount, cap, id);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1654287888(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int id = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref id);
				float pitch = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref pitch, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((WormPit)(object)target).PlaySquishClientRpc(id, pitch);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2916852503(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float pitch = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref pitch, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((WormPit)(object)target).PlayGrowlClientRpc(pitch);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_972706182(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool play = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref play, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((WormPit)(object)target).PitMusicClientRpc(play);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "WormPit";
		}
	}
}
namespace LCWildCardMod.Items
{
	public class BleedingHeart : PhysicsProp
	{
		private readonly ManualLogSource log = WildCardMod.Log;

		public ScanNodeProperties scanNode;

		public NetworkAnimator itemAnimator;

		public AudioSource beatAudio;

		public AnimationCurve weightCurve;

		public ParticleSystem dripParticles;

		public AudioClip smashClip;

		public int startingValue = 0;

		public float intensityValue;

		public float targetLiquidLevel;

		public float startWeight = -1f;

		public float weightOverTime = 0f;

		public float playerMovementMag;

		public int playerSensitivity;

		public int levelLayerIndex;

		public int sloshLayerIndex;

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			levelLayerIndex = itemAnimator.Animator.GetLayerIndex("LiquidLevelLayer");
			sloshLayerIndex = itemAnimator.Animator.GetLayerIndex("SloshingLayer");
			((MonoBehaviour)this).StartCoroutine(StartingValueCoroutine());
		}

		public IEnumerator StartingValueCoroutine()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => ((GrabbableObject)this).scrapValue > 0));
			if (startingValue == 0)
			{
				startingValue = ((GrabbableObject)this).scrapValue;
			}
		}

		public override void Update()
		{
			//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_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: 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_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Update();
			if (((NetworkBehaviour)this).IsServer && ((GrabbableObject)this).currentUseCooldown <= 0f && startingValue > 0)
			{
				playerMovementMag = 0f;
				if (((GrabbableObject)this).scrapValue > 0)
				{
					ScrapValueClientRpc(((GrabbableObject)this).scrapValue - 1);
					intensityValue = ((float)startingValue - (float)((GrabbableObject)this).scrapValue) / (float)startingValue;
					SetIntensityClientRpc(intensityValue);
				}
				((GrabbableObject)this).currentUseCooldown = 3f;
			}
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				if ((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					SetMagnitudeServerRpc(Mathf.Clamp01(((Vector2)(ref GameNetworkManager.Instance.localPlayerController.moveInputVector)).magnitude));
					SetSensitivityServerRpc(IngamePlayerSettings.Instance.settings.lookSensitivity);
				}
				ManualLogSource obj = log;
				float num = playerMovementMag + 0.5f;
				MovementActions movement = ((GrabbableObject)this).playerHeldBy.playerActions.Movement;
				Vector2 val = ((MovementActions)(ref movement)).Look.ReadValue<Vector2>();
				obj.LogDebug((object)$"Slosh Intensity: {num * Mathf.Max(0.1f, ((Vector2)(ref val)).magnitude / 360f) * Mathf.Max(1f, (float)playerSensitivity)}");
				Animator animator = itemAnimator.Animator;
				int num2 = sloshLayerIndex;
				float num3 = playerMovementMag + 0.5f;
				movement = ((GrabbableObject)this).playerHeldBy.playerActions.Movement;
				val = ((MovementActions)(ref movement)).Look.ReadValue<Vector2>();
				animator.SetLayerWeight(num2, Mathf.Max(0.1f, Mathf.Min(1f, num3 * Mathf.Max(0.1f, ((Vector2)(ref val)).magnitude / 360f) * Mathf.Max(1f, (float)playerSensitivity))));
			}
			float layerWeight = itemAnimator.Animator.GetLayerWeight(levelLayerIndex);
			if (layerWeight < targetLiquidLevel - 0.01f || layerWeight > targetLiquidLevel + 0.01f)
			{
				if (startWeight == -1f)
				{
					startWeight = layerWeight;
				}
				weightOverTime += Time.deltaTime;
				float num4 = Mathf.Lerp(startWeight, targetLiquidLevel, weightCurve.Evaluate(weightOverTime));
				itemAnimator.Animator.SetLayerWeight(levelLayerIndex, num4);
				layerWeight = itemAnimator.Animator.GetLayerWeight(levelLayerIndex);
				if (layerWeight > targetLiquidLevel - 0.01f && layerWeight < targetLiquidLevel + 0.01f)
				{
					startWeight = -1f;
					weightOverTime = 0f;
				}
			}
			if (((GrabbableObject)this).scrapValue <= 0 && ((GrabbableObject)this).hasBeenHeld)
			{
				((MonoBehaviour)this).StartCoroutine(ExplodeCoroutine());
			}
		}

		public override void EquipItem()
		{
			((PhysicsProp)this).EquipItem();
			dripParticles.Play();
			dripParticles.Emit(2);
			if (((NetworkBehaviour)this).IsServer)
			{
				itemAnimator.Animator.SetBool("isHeld", true);
			}
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			dripParticles.Stop();
			dripParticles.Clear();
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			dripParticles.Play();
			dripParticles.Emit(2);
			itemAnimator.Animator.SetLayerWeight(sloshLayerIndex, 0.1f);
			if (((NetworkBehaviour)this).IsServer)
			{
				itemAnimator.Animator.SetBool("isHeld", false);
			}
		}

		public void HeartBeat()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (((GrabbableObject)this).scrapValue > 0)
			{
				beatAudio.Stop();
				beatAudio.Play();
				WalkieTalkie.TransmitOneShotAudio(beatAudio, beatAudio.clip, 1f);
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 25f, 0.25f, 0, ((GrabbableObject)this).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			}
			if (((NetworkBehaviour)this).IsServer && itemAnimator.Animator.GetBool("isHeld"))
			{
				itemAnimator.Animator.SetBool("isHeld", false);
			}
		}

		public IEnumerator ExplodeCoroutine()
		{
			if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				int playerOriginalSlot = ((GrabbableObject)this).playerHeldBy.currentItemSlot;
				PlayerControllerB player = ((GrabbableObject)this).playerHeldBy;
				if ((Object)(object)player.currentlyHeldObjectServer != (Object)(object)this)
				{
					player.SwitchToItemSlot(Array.FindIndex(player.ItemSlots, (GrabbableObject x) => (Object)(object)x == (Object)(object)this), (GrabbableObject)null);
				}
				player.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
				if (playerOriginalSlot != player.currentItemSlot)
				{
					player.SwitchToItemSlot(playerOriginalSlot, (GrabbableObject)null);
				}
			}
			yield return (object)new WaitForSeconds(0.1f);
			((GrabbableObject)this).EnableItemMeshes(false);
			beatAudio.PlayOneShot(smashClip);
			yield return (object)new WaitForSeconds(0.1f);
			Landmine.SpawnExplosion(((Component)this).transform.position + Vector3.up, true, 5f, 10f, 25, 10f, (GameObject)null, false);
			yield return (object)new WaitForSeconds(0.5f);
			if (((NetworkBehaviour)this).IsServer)
			{
				((NetworkBehaviour)this).NetworkObject.Despawn(true);
			}
		}

		public override int GetItemDataToSave()
		{
			return startingValue;
		}

		public override void LoadItemSaveData(int saveData)
		{
			startingValue = saveData;
		}

		[ClientRpc]
		public void ScrapValueClientRpc(int newValue)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1818198431u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, newValue);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1818198431u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				((GrabbableObject)this).SetScrapValue(newValue);
				if (((GrabbableObject)this).hasBeenHeld)
				{
					log.LogDebug((object)$"Bleeding Heart Value: {((GrabbableObject)this).scrapValue}, Starting Value: {startingValue}");
				}
			}
		}

		[ClientRpc]
		public void SetIntensityClientRpc(float intensity)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1107753082u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref intensity, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1107753082u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					intensityValue = intensity;
					targetLiquidLevel = intensityValue;
					EmissionModule emission = dripParticles.emission;
					Burst burst = ((EmissionModule)(ref emission)).GetBurst(0);
					((Burst)(ref burst)).probability = Mathf.Max(0.2f, Mathf.Min(0.8f, targetLiquidLevel));
					emission = dripParticles.emission;
					((EmissionModule)(ref emission)).SetBurst(0, burst);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetMagnitudeServerRpc(float magnitude)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2909367662u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref magnitude, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2909367662u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SetMagnitudeClientRpc(magnitude);
				}
			}
		}

		[ClientRpc]
		public void SetMagnitudeClientRpc(float magnitude)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: 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_007d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(838093720u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref magnitude, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 838093720u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					playerMovementMag = magnitude;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetSensitivityServerRpc(int sensitivity)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1719301820u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, sensitivity);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1719301820u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SetSensitivityClientRpc(sensitivity);
				}
			}
		}

		[ClientRpc]
		public void SetSensitivityClientRpc(int sensitivity)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3358053698u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, sensitivity);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3358053698u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					playerSensitivity = sensitivity;
				}
			}
		}

		protected override void __initializeVariables()
		{
			((PhysicsProp)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_BleedingHeart()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1818198431u, new RpcReceiveHandler(__rpc_handler_1818198431));
			NetworkManager.__rpc_func_table.Add(1107753082u, new RpcReceiveHandler(__rpc_handler_1107753082));
			NetworkManager.__rpc_func_table.Add(2909367662u, new RpcReceiveHandler(__rpc_handler_2909367662));
			NetworkManager.__rpc_func_table.Add(838093720u, new RpcReceiveHandler(__rpc_handler_838093720));
			NetworkManager.__rpc_func_table.Add(1719301820u, new RpcReceiveHandler(__rpc_handler_1719301820));
			NetworkManager.__rpc_func_table.Add(3358053698u, new RpcReceiveHandler(__rpc_handler_3358053698));
		}

		private static void __rpc_handler_1818198431(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int newValue = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref newValue);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BleedingHeart)(object)target).ScrapValueClientRpc(newValue);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1107753082(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float intensityClientRpc = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref intensityClientRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BleedingHeart)(object)target).SetIntensityClientRpc(intensityClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2909367662(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float magnitudeServerRpc = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref magnitudeServerRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BleedingHeart)(object)target).SetMagnitudeServerRpc(magnitudeServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_838093720(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float magnitudeClientRpc = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref magnitudeClientRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BleedingHeart)(object)target).SetMagnitudeClientRpc(magnitudeClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1719301820(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int sensitivityServerRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref sensitivityServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BleedingHeart)(object)target).SetSensitivityServerRpc(sensitivityServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3358053698(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int sensitivityClientRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref sensitivityClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BleedingHeart)(object)target).SetSensitivityClientRpc(sensitivityClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "BleedingHeart";
		}
	}
	public class ClauvioMask : PhysicsProp
	{
		private readonly ManualLogSource log = WildCardMod.Log;

		public bool isLifted = false;

		public Transform meshTransform;

		public Animator maskAnimator;

		public Coroutine peekCoroutine;

		public PlayerControllerB previousPlayer;

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			WildCardMod.wildcardKeyBinds.WildCardButton.started += MaskPeek;
		}

		public override void EquipItem()
		{
			((PhysicsProp)this).EquipItem();
			if (((NetworkBehaviour)this).IsOwner)
			{
				meshTransform.parent = ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform;
				maskAnimator.SetBool("isOwner", true);
			}
			else
			{
				meshTransform.parent = ((GrabbableObject)this).playerHeldBy.bodyParts[0];
				maskAnimator.SetBool("isOwner", false);
			}
			previousPlayer = ((GrabbableObject)this).playerHeldBy;
			maskAnimator.SetBool("isHeld", true);
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			meshTransform.parent = ((Component)this).transform;
			maskAnimator.SetBool("isHeld", false);
			if (peekCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(peekCoroutine);
				peekCoroutine = null;
			}
		}

		public override void DiscardItem()
		{
			meshTransform.parent = ((Component)this).transform;
			maskAnimator.SetBool("isHeld", false);
			if (peekCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(peekCoroutine);
				peekCoroutine = null;
			}
			((GrabbableObject)this).DiscardItem();
		}

		public void MaskPeek(CallbackContext throwContext)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsOwner && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				log.LogDebug((object)("\"" + ((GrabbableObject)this).itemProperties.itemName + "\" Beginning Peek"));
				peekCoroutine = ((MonoBehaviour)this).StartCoroutine(PeekCoroutine(throwContext));
			}
		}

		public IEnumerator PeekCoroutine(CallbackContext throwContext)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			while (((CallbackContext)(ref throwContext)).action.IsPressed())
			{
				if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && ((GrabbableObject)this).playerHeldBy.moveInputVector == Vector2.zero && !isLifted)
				{
					isLifted = true;
					SetTriggerServerRpc("Lift");
					log.LogDebug((object)("\"" + ((GrabbableObject)this).itemProperties.itemName + "\" Waiting for Button Release"));
				}
				yield return (object)new WaitUntil((Func<bool>)(() => !((CallbackContext)(ref throwContext)).action.IsPressed() || (Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null || ((GrabbableObject)this).playerHeldBy.moveInputVector != Vector2.zero));
				if (isLifted)
				{
					log.LogDebug((object)("\"" + ((GrabbableObject)this).itemProperties.itemName + "\" Button Released"));
					SetTriggerServerRpc("Lower");
					isLifted = false;
				}
			}
			peekCoroutine = null;
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetTriggerServerRpc(string name)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: 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_0088: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2661853379u, val, (RpcDelivery)0);
				bool flag = name != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(name, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2661853379u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SetTriggerClientRpc(name);
			}
		}

		[ClientRpc]
		public void SetTriggerClientRpc(string name)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: 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_0088: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2861916945u, val, (RpcDelivery)0);
				bool flag = name != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(name, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2861916945u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				maskAnimator.SetTrigger(name);
			}
		}

		protected override void __initializeVariables()
		{
			((PhysicsProp)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ClauvioMask()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2661853379u, new RpcReceiveHandler(__rpc_handler_2661853379));
			NetworkManager.__rpc_func_table.Add(2861916945u, new RpcReceiveHandler(__rpc_handler_2861916945));
		}

		private static void __rpc_handler_2661853379(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string triggerServerRpc = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref triggerServerRpc, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ClauvioMask)(object)target).SetTriggerServerRpc(triggerServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2861916945(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string triggerClientRpc = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref triggerClientRpc, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ClauvioMask)(object)target).SetTriggerClientRpc(triggerClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ClauvioMask";
		}
	}
	public class ClauvioMouse : PhysicsProp
	{
		private readonly ManualLogSource log = WildCardMod.Log;

		public NetworkAnimator itemAnimator;

		public MeshRenderer meshRenderer;

		public ParticleSystem particleSystem;

		public AnimationCurve sleebCurve;

		public Texture[] particleTextures;

		public Texture[] faceTextures;

		public AudioSource passiveSource;

		public AudioClip[] passiveClips;

		public AudioClip[] squeakClips;

		public Coroutine agitateCounter;

		public Coroutine cryingCoroutine;

		public int stateId;

		public int agitate;

		public bool agitating;

		public bool crying;

		private Random random;

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			random = new Random(StartOfRound.Instance.randomMapSeed + 69);
			if (((NetworkBehaviour)this).IsServer)
			{
				ChangeStateClientRpc(0);
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (((NetworkBehaviour)this).IsServer)
			{
				agitate--;
				if (agitate == 0 && stateId == 1)
				{
					ChangeStateClientRpc(0);
				}
				else if (agitate < 0)
				{
					agitate = 0;
				}
				if (stateId == 1)
				{
					float num = Mathf.Max(1f, (float)agitate / 2f);
					((GrabbableObject)this).useCooldown = 0.5f / num;
					itemAnimator.Animator.SetFloat("Intensity", num);
				}
				else
				{
					((GrabbableObject)this).useCooldown = 0.5f;
					itemAnimator.Animator.SetFloat("Intensity", 1f);
				}
				itemAnimator.SetTrigger("Pet");
			}
			AudioSource component = ((Component)this).GetComponent<AudioSource>();
			int num2 = random.Next(0, squeakClips.Length);
			component.PlayOneShot(squeakClips[num2], 1f);
			WalkieTalkie.TransmitOneShotAudio(component, squeakClips[num2], 1f);
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			if (((NetworkBehaviour)this).IsServer && agitateCounter == null)
			{
				agitateCounter = ((MonoBehaviour)this).StartCoroutine(AgitateCounter());
			}
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			particleSystem.Stop();
			particleSystem.Clear();
		}

		public override void EquipItem()
		{
			((PhysicsProp)this).EquipItem();
			if (!particleSystem.isPlaying)
			{
				particleSystem.Play();
			}
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			if (!particleSystem.isPlaying)
			{
				particleSystem.Play();
			}
		}

		public IEnumerator AgitateCounter()
		{
			for (agitating = true; agitate < 10; agitate++)
			{
				yield return (object)new WaitForSeconds((float)random.Next(5, 50) / 10f);
				WalkieNoiseClientRpc();
			}
			yield return (object)new WaitUntil((Func<bool>)(() => !StartOfRound.Instance.inShipPhase));
			log.LogDebug((object)"Clauvio Mouse Crying");
			ChangeStateClientRpc(1);
			cryingCoroutine = ((MonoBehaviour)this).StartCoroutine(CryingCoroutine());
			agitating = false;
		}

		public IEnumerator CryingCoroutine()
		{
			crying = true;
			int cryingTime = 0;
			while (stateId == 1)
			{
				DogNoiseClientRpc();
				WalkieNoiseClientRpc();
				cryingTime++;
				yield return (object)new WaitForSeconds(1f);
			}
			log.LogDebug((object)"Clauvio Mouse Sleebing");
			agitateCounter = ((MonoBehaviour)this).StartCoroutine(AgitateCounter());
			crying = false;
		}

		public void ChangeState(int id)
		{
			stateId = id;
			((Renderer)((Component)particleSystem).gameObject.GetComponent<ParticleSystemRenderer>()).material.mainTexture = particleTextures[stateId];
			((Renderer)meshRenderer).materials[1].mainTexture = faceTextures[stateId];
			passiveSource.Stop();
			passiveSource.clip = passiveClips[stateId];
			if (stateId == 0)
			{
				passiveSource.rolloffMode = (AudioRolloffMode)2;
				passiveSource.SetCustomCurve((AudioSourceCurveType)0, sleebCurve);
				passiveSource.volume = 0.1f;
			}
			else if (stateId == 1)
			{
				passiveSource.rolloffMode = (AudioRolloffMode)1;
				passiveSource.volume = 1f;
			}
			passiveSource.Play();
			WalkieTalkie.TransmitOneShotAudio(passiveSource, passiveSource.clip, 1f);
		}

		public override void LoadItemSaveData(int saveData)
		{
			agitateCounter = ((MonoBehaviour)this).StartCoroutine(AgitateCounter());
		}

		[ClientRpc]
		public void ChangeStateClientRpc(int id)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2097798272u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, id);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2097798272u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					ChangeState(id);
				}
			}
		}

		[ClientRpc]
		public void DogNoiseClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_007c: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(364255872u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 364255872u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 25f, 1f, 0, ((GrabbableObject)this).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
				if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
				{
					((GrabbableObject)this).playerHeldBy.timeSinceMakingLoudNoise = 0f;
				}
			}
		}

		[ClientRpc]
		public void WalkieNoiseClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3539331939u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3539331939u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.