Decompiled source of ZombiesPlush v1.2.2

com.github.zehsteam.ZombiesPlush.dll

Decompiled a week 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 LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using com.github.zehsteam.TakeyPlush.MonoBehaviours;
using com.github.zehsteam.ZombiesPlush.Data;
using com.github.zehsteam.ZombiesPlush.Dependencies;
using com.github.zehsteam.ZombiesPlush.Enums;
using com.github.zehsteam.ZombiesPlush.MonoBehaviours;
using com.github.zehsteam.ZombiesPlush.NetcodePatcher;
using com.github.zehsteam.ZombiesPlush.Patches;

[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: AssemblyCompany("com.github.zehsteam.ZombiesPlush")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds a customizable Zombies plushie scrap item with complex interactions/behaviors and other secrets. \ud83d\ude08")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyInformationalVersion("1.2.2+3990e464341a6ab5c8fb774a4b069cd602849183")]
[assembly: AssemblyProduct("ZombiesPlush")]
[assembly: AssemblyTitle("com.github.zehsteam.ZombiesPlush")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace com.github.zehsteam.ZombiesPlush
{
	public static class Api
	{
		public static bool ForceMaskedZombiesSpawns
		{
			get
			{
				return MaskedPlayerEnemyPatch.ForceMaskedZombiesSpawns;
			}
			set
			{
				MaskedPlayerEnemyPatch.ForceMaskedZombiesSpawns = value;
			}
		}

		[Obsolete("forceMaskedZombiesSpawns is deprecated, please use ForceMaskedZombiesSpawns instead.", true)]
		public static bool forceMaskedZombiesSpawns
		{
			get
			{
				return MaskedPlayerEnemyPatch.ForceMaskedZombiesSpawns;
			}
			set
			{
				MaskedPlayerEnemyPatch.ForceMaskedZombiesSpawns = value;
			}
		}

		public static bool SetMaskedZombiesOnServer(MaskedPlayerEnemy maskedPlayerEnemy)
		{
			return MaskedPlayerEnemyPatch.SetMaskedZombiesOnServer(maskedPlayerEnemy);
		}
	}
	internal static class ConfigHelper
	{
		public static void SkipAutoGen()
		{
			if (LethalConfigProxy.Enabled)
			{
				LethalConfigProxy.SkipAutoGen();
			}
		}

		public static void AddButton(string section, string name, string description, string buttonText, Action callback)
		{
			if (LethalConfigProxy.Enabled)
			{
				LethalConfigProxy.AddButton(section, name, description, buttonText, callback);
			}
		}

		public static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, bool requiresRestart, string description, AcceptableValueBase acceptableValues = null, Action<T> settingChanged = null, ConfigFile configFile = null)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			if (configFile == null)
			{
				configFile = ((BaseUnityPlugin)Plugin.Instance).Config;
			}
			ConfigEntry<T> configEntry = ((acceptableValues == null) ? configFile.Bind<T>(section, key, defaultValue, description) : configFile.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty<object>())));
			if (settingChanged != null)
			{
				configEntry.SettingChanged += delegate
				{
					settingChanged?.Invoke(configEntry.Value);
				};
			}
			if (LethalConfigProxy.Enabled)
			{
				LethalConfigProxy.AddConfig<T>(configEntry, requiresRestart);
			}
			return configEntry;
		}

		public static Dictionary<ConfigDefinition, string> GetOrphanedConfigEntries(ConfigFile configFile = null)
		{
			if (configFile == null)
			{
				configFile = ((BaseUnityPlugin)Plugin.Instance).Config;
			}
			PropertyInfo property = ((object)configFile).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			return (Dictionary<ConfigDefinition, string>)property.GetValue(configFile, null);
		}

		public static void SetConfigEntryValue<T>(ConfigEntry<T> configEntry, string value)
		{
			if (typeof(T) == typeof(int) && int.TryParse(value, out var result))
			{
				configEntry.Value = (T)(object)result;
				return;
			}
			if (typeof(T) == typeof(float) && float.TryParse(value, out var result2))
			{
				configEntry.Value = (T)(object)result2;
				return;
			}
			if (typeof(T) == typeof(double) && double.TryParse(value, out var result3))
			{
				configEntry.Value = (T)(object)result3;
				return;
			}
			if (typeof(T) == typeof(bool) && bool.TryParse(value, out var result4))
			{
				configEntry.Value = (T)(object)result4;
				return;
			}
			if (typeof(T) == typeof(string))
			{
				configEntry.Value = (T)(object)value;
				return;
			}
			throw new InvalidOperationException($"Unsupported type: {typeof(T)}");
		}

		public static void ClearUnusedEntries(ConfigFile configFile = null)
		{
			if (configFile == null)
			{
				configFile = ((BaseUnityPlugin)Plugin.Instance).Config;
			}
			Dictionary<ConfigDefinition, string> orphanedConfigEntries = GetOrphanedConfigEntries(configFile);
			if (orphanedConfigEntries != null)
			{
				orphanedConfigEntries.Clear();
				configFile.Save();
			}
		}
	}
	internal class ConfigManager
	{
		public ConfigEntry<bool> ExtendedLogging { get; private set; }

		public ItemConfigData SmolZombies { get; private set; }

		public ConfigEntry<float> SmolZombies_VoiceLineVolume { get; private set; }

		public ConfigEntry<float> SmolZombies_SingingVolume { get; private set; }

		public ItemConfigData RobynsRainbowSmolZombies { get; private set; }

		public ConfigEntry<int> MaskedZombies_SpawnChance { get; private set; }

		public ConfigManager()
		{
			BindConfigs();
			ConfigHelper.ClearUnusedEntries();
		}

		private void BindConfigs()
		{
			ConfigHelper.SkipAutoGen();
			ExtendedLogging = ConfigHelper.Bind("General", "ExtendedLogging", defaultValue: false, requiresRestart: false, "Enable extended logging.");
			SmolZombies = new ItemConfigData(Content.SmolZombies, "Smol Zombies", 10, twoHanded: false, 6, 80, 250);
			SmolZombies_VoiceLineVolume = ConfigHelper.Bind("Smol Zombies", "VoiceLineVolume", 80f, requiresRestart: false, "The volume of Smol Zombies voice lines.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f));
			SmolZombies_SingingVolume = ConfigHelper.Bind("Smol Zombies", "SingingVolume", 80f, requiresRestart: false, "The volume of Smol Zombies singing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f));
			SmolZombies_VoiceLineVolume.SettingChanged += delegate
			{
				ZombiesBehaviour.OnConfigSettingsChanged();
			};
			SmolZombies_SingingVolume.SettingChanged += delegate
			{
				ZombiesBehaviour.OnConfigSettingsChanged();
			};
			MaskedZombies_SpawnChance = ConfigHelper.Bind("Masked Zombies", "SpawnChance", 25, requiresRestart: false, "The percent chance a Masked enemy will turn into a Masked Zombies enemy.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
		}
	}
	internal static class Content
	{
		public static GameObject NetworkHandlerPrefab { get; private set; }

		public static GameObject MaskedZombiesControllerPrefab { get; private set; }

		public static Item SmolZombies { get; private set; }

		public static Item Poop { get; private set; }

		public static Item GoldenPoop { get; private set; }

		public static Item RobynsRainbowSmolZombies { get; private set; }

		public static void Load()
		{
			LoadAssetsFromAssetBundle();
		}

		private static void LoadAssetsFromAssetBundle()
		{
			AssetBundle val = LoadAssetBundle("zombiesplush_assets");
			if (!((Object)(object)val == (Object)null))
			{
				NetworkHandlerPrefab = LoadAssetFromAssetBundle<GameObject>("NetworkHandler", val);
				NetworkHandlerPrefab.AddComponent<PluginNetworkBehaviour>();
				MaskedZombiesControllerPrefab = LoadAssetFromAssetBundle<GameObject>("MaskedZombiesController", val);
				SmolZombies = LoadAssetFromAssetBundle<Item>("SmolZombies", val);
				Poop = LoadAssetFromAssetBundle<Item>("Poop", val);
				GoldenPoop = LoadAssetFromAssetBundle<Item>("GoldenPoop", val);
				Plugin.Logger.LogInfo((object)"Successfully loaded assets from AssetBundle!");
			}
		}

		private static AssetBundle LoadAssetBundle(string fileName)
		{
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location);
				string text = Path.Combine(directoryName, fileName);
				return AssetBundle.LoadFromFile(text);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Failed to load AssetBundle \"{fileName}\". {arg}");
			}
			return null;
		}

		private static T LoadAssetFromAssetBundle<T>(string name, AssetBundle assetBundle) where T : Object
		{
			if (string.IsNullOrWhiteSpace(name))
			{
				Plugin.Logger.LogError((object)("Failed to load asset of type \"" + typeof(T).Name + "\" from AssetBundle. Name is null or whitespace."));
				return default(T);
			}
			if ((Object)(object)assetBundle == (Object)null)
			{
				Plugin.Logger.LogError((object)("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. AssetBundle is null."));
				return default(T);
			}
			T val = assetBundle.LoadAsset<T>(name);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Logger.LogError((object)("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. No asset found with that type and name."));
				return default(T);
			}
			return val;
		}
	}
	internal static class ItemHelper
	{
		public static void RegisterScrap(Item item, int rarity, bool twoHanded, int carryWeight, int minValue, int maxValue)
		{
			if ((Object)(object)item == (Object)null)
			{
				Plugin.Logger.LogError((object)"Failed to register scrap item. Item is null.");
				return;
			}
			item.twoHanded = twoHanded;
			item.weight = (float)carryWeight / 105f + 1f;
			item.minValue = minValue;
			item.maxValue = maxValue;
			Utilities.FixMixerGroups(item.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab);
			Items.RegisterScrap(item, rarity, (LevelTypes)(-1));
			Plugin.Logger.LogInfo((object)$"Registered \"{item.itemName}\" scrap item. (Rarity: {rarity}, TwoHanded: {twoHanded}, CarryWeight: {carryWeight}, MinValue: {minValue}, MaxValue: {maxValue})");
		}

		public static void RegisterScrap(ItemConfigData itemConfigData)
		{
			RegisterScrap(itemConfigData.Item, itemConfigData.SpawnWeight.Value, itemConfigData.TwoHanded.Value, itemConfigData.CarryWeight.Value, itemConfigData.MinValue.Value, itemConfigData.MaxValue.Value);
		}

		public static void UpdateScrapRarity(Item item, int rarity)
		{
			if ((Object)(object)item == (Object)null)
			{
				Plugin.Logger.LogError((object)"Failed to update scrap item rarity. Item is null.");
				return;
			}
			if ((Object)(object)StartOfRound.Instance == (Object)null)
			{
				Plugin.Logger.LogError((object)"Failed to update scrap item rarity. StartOfRound instance is null.");
				return;
			}
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				foreach (SpawnableItemWithRarity item2 in val.spawnableScrap)
				{
					if (!((Object)(object)item2.spawnableItem != (Object)(object)item))
					{
						item2.rarity = rarity;
						Plugin.Logger.LogInfo((object)$"Updated \"{item.itemName}\" scrap item rarity to {rarity} on \"{val.PlanetName}\".");
					}
				}
			}
		}

		public static void UpdateScrapRarity(ItemConfigData itemConfigData)
		{
			UpdateScrapRarity(itemConfigData.Item, itemConfigData.SpawnWeight.Value);
		}

		public static void UpdateItemProperties(Item item, bool twoHanded, int carryWeight, int minValue, int maxValue)
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)item == (Object)null)
			{
				Plugin.Logger.LogError((object)"Failed to update item properties. Item is null.");
				return;
			}
			item.twoHanded = twoHanded;
			item.weight = (float)carryWeight / 105f + 1f;
			item.minValue = minValue;
			item.maxValue = maxValue;
			Plugin.Logger.LogInfo((object)$"Updated \"{item.itemName}\" item properties. (TwoHanded: {twoHanded}, CarryWeight: {carryWeight}, MinValue: {minValue}, MaxValue: {maxValue})");
			if (NetworkUtils.IsServer)
			{
				PluginNetworkBehaviour.Instance.UpdateItemPropertiesClientRpc(item.itemName, twoHanded, carryWeight, minValue, maxValue);
			}
		}

		public static void UpdateScrapProperties(ItemConfigData itemConfigData)
		{
			UpdateItemProperties(itemConfigData.Item, itemConfigData.TwoHanded.Value, itemConfigData.CarryWeight.Value, itemConfigData.MinValue.Value, itemConfigData.MaxValue.Value);
		}

		public static Item GetItemByName(string itemName, bool matchCase = true)
		{
			if ((Object)(object)StartOfRound.Instance == (Object)null)
			{
				Plugin.Logger.LogError((object)"Failed to get item by name. StartOfRound instance is null.");
				return null;
			}
			StringComparison comparisonType = ((!matchCase) ? StringComparison.OrdinalIgnoreCase : StringComparison.CurrentCulture);
			foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
			{
				if (items.itemName.Equals(itemName, comparisonType))
				{
					return items;
				}
			}
			return null;
		}

		public static bool TryGetItemByName(string itemName, out Item item, bool matchCase = true)
		{
			item = GetItemByName(itemName, matchCase);
			return (Object)(object)item != (Object)null;
		}

		public static Item[] GetItemsByNames(string[] itemNames, bool matchCase = true)
		{
			List<Item> list = new List<Item>();
			foreach (string itemName in itemNames)
			{
				if (TryGetItemByName(itemName, out var item, matchCase))
				{
					list.Add(item);
				}
			}
			return list.ToArray();
		}
	}
	internal static class NetworkUtils
	{
		public static bool IsServer
		{
			get
			{
				if ((Object)(object)NetworkManager.Singleton == (Object)null)
				{
					return false;
				}
				return NetworkManager.Singleton.IsServer;
			}
		}

		public static bool IsHost
		{
			get
			{
				if ((Object)(object)NetworkManager.Singleton == (Object)null)
				{
					return false;
				}
				return NetworkManager.Singleton.IsHost;
			}
		}

		public static ulong GetLocalClientId()
		{
			return NetworkManager.Singleton.LocalClientId;
		}

		public static bool IsLocalClientId(ulong clientId)
		{
			return clientId == GetLocalClientId();
		}
	}
	internal static class PlayerUtils
	{
		public static PlayerControllerB GetLocalPlayerScript()
		{
			if ((Object)(object)GameNetworkManager.Instance == (Object)null)
			{
				return null;
			}
			return GameNetworkManager.Instance.localPlayerController;
		}

		public static bool IsLocalPlayer(PlayerControllerB playerScript)
		{
			return (Object)(object)playerScript == (Object)(object)GetLocalPlayerScript();
		}

		public static PlayerControllerB GetPlayerScriptByClientId(ulong clientId)
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (val.actualClientId == clientId)
				{
					return val;
				}
			}
			return null;
		}

		public static List<ZombiesBehaviour> GetZombiesPlushiesFromLocalPlayer()
		{
			PlayerControllerB localPlayerScript = GetLocalPlayerScript();
			if ((Object)(object)localPlayerScript == (Object)null)
			{
				return new List<ZombiesBehaviour>();
			}
			List<ZombiesBehaviour> list = new List<ZombiesBehaviour>();
			GrabbableObject[] itemSlots = localPlayerScript.ItemSlots;
			foreach (GrabbableObject val in itemSlots)
			{
				if (!((Object)(object)val == (Object)null))
				{
					ZombiesBehaviour zombiesBehaviour = val as ZombiesBehaviour;
					if ((Object)(object)zombiesBehaviour != (Object)null)
					{
						list.Add(zombiesBehaviour);
					}
				}
			}
			return list;
		}
	}
	[BepInPlugin("com.github.zehsteam.ZombiesPlush", "ZombiesPlush", "1.2.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("com.github.zehsteam.ZombiesPlush");

		internal static Plugin Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static ConfigManager ConfigManager { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Logger = Logger.CreateLogSource("com.github.zehsteam.ZombiesPlush");
			Logger.LogInfo((object)"ZombiesPlush has awoken!");
			_harmony.PatchAll(typeof(GameNetworkManagerPatch));
			_harmony.PatchAll(typeof(StartOfRoundPatch));
			_harmony.PatchAll(typeof(PlayerControllerBPatch));
			_harmony.PatchAll(typeof(MaskedPlayerEnemyPatch));
			_harmony.PatchAll(typeof(NoisemakerPropPatch));
			Content.Load();
			ConfigManager = new ConfigManager();
			RegisterScrapItems();
			NetcodePatcherAwake();
		}

		private void NetcodePatcherAwake()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		private void RegisterScrapItems()
		{
			ItemHelper.RegisterScrap(ConfigManager.SmolZombies);
			ItemHelper.RegisterScrap(Content.Poop, 0, twoHanded: false, 0, 0, 0);
			ItemHelper.RegisterScrap(Content.GoldenPoop, 0, twoHanded: false, 24, 0, 0);
		}

		public void OnShipHasLeft()
		{
			MaskedPlayerEnemyPatch.Reset();
		}

		public void LogInfoExtended(object data)
		{
			LogExtended((LogLevel)16, data);
		}

		public void LogExtended(LogLevel level, object data)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (ConfigManager == null || ConfigManager.ExtendedLogging == null)
			{
				Logger.Log(level, data);
			}
			else if (ConfigManager.ExtendedLogging.Value)
			{
				Logger.Log(level, data);
			}
		}
	}
	internal static class SaveSystem
	{
		public static void SaveData<T>(string key, T data)
		{
			ES3.Save<T>(GetBaseKey() + "." + key, data, GetCurrentSaveFilePath());
		}

		public static T LoadData<T>(string key, T defaultValue = default(T))
		{
			return ES3.Load<T>(GetBaseKey() + "." + key, GetCurrentSaveFilePath(), defaultValue);
		}

		private static string GetBaseKey()
		{
			return MethodBase.GetCurrentMethod().DeclaringType.Namespace;
		}

		private static string GetCurrentSaveFilePath()
		{
			return GameNetworkManager.Instance.currentSaveFileName;
		}
	}
	internal static class Utils
	{
		public static bool RandomPercent(float percent)
		{
			if (percent <= 0f)
			{
				return false;
			}
			if (percent >= 100f)
			{
				return true;
			}
			return Random.value * 100f <= percent;
		}

		public static string GetEnumName(object e)
		{
			try
			{
				return Enum.GetName(e.GetType(), e);
			}
			catch
			{
				return string.Empty;
			}
		}

		public static void CreateExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, int damage = 20, float minDamageRange = 0f, float maxDamageRange = 6.4f, int enemyHitForce = 6, CauseOfDeath causeOfDeath = 3, PlayerControllerB attacker = null)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Logger.LogInfo((object)$"Spawning explosion at position: (x: {explosionPosition.x}, y: {explosionPosition.y}, z: {explosionPosition.z})");
			Transform val = null;
			if ((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer.transform != (Object)null)
			{
				val = RoundManager.Instance.mapPropsContainer.transform;
			}
			if (spawnExplosionEffect)
			{
				Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, explosionPosition, Quaternion.Euler(-90f, 0f, 0f), val).SetActive(true);
			}
			float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, explosionPosition);
			if (num < 14f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			}
			else if (num < 25f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
			Collider[] array = Physics.OverlapSphere(explosionPosition, maxDamageRange, 2621448, (QueryTriggerInteraction)2);
			PlayerControllerB val2 = null;
			for (int i = 0; i < array.Length; i++)
			{
				float num2 = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position);
				if (num2 > 4f && Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1))
				{
					continue;
				}
				if (((Component)array[i]).gameObject.layer == 3)
				{
					val2 = ((Component)array[i]).gameObject.GetComponent<PlayerControllerB>();
					if ((Object)(object)val2 != (Object)null && ((NetworkBehaviour)val2).IsOwner)
					{
						float num3 = 1f - Mathf.Clamp01((num2 - minDamageRange) / (maxDamageRange - minDamageRange));
						val2.DamagePlayer((int)((float)damage * num3), true, true, causeOfDeath, 0, false, default(Vector3));
					}
				}
				else if (((Component)array[i]).gameObject.layer == 21)
				{
					Landmine componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<Landmine>();
					if ((Object)(object)componentInChildren != (Object)null && !componentInChildren.hasExploded && num2 < 6f)
					{
						Plugin.Logger.LogInfo((object)"Setting off other mine");
						((MonoBehaviour)StartOfRound.Instance).StartCoroutine(TriggerOtherMineDelayed(componentInChildren));
					}
				}
				else if (((Component)array[i]).gameObject.layer == 19)
				{
					EnemyAICollisionDetect componentInChildren2 = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
					if ((Object)(object)componentInChildren2 != (Object)null && ((NetworkBehaviour)componentInChildren2.mainScript).IsOwner && num2 < 4.5f)
					{
						componentInChildren2.mainScript.HitEnemyOnLocalClient(enemyHitForce, default(Vector3), attacker, false, -1);
					}
				}
			}
			int num4 = ~LayerMask.GetMask(new string[1] { "Room" });
			num4 = ~LayerMask.GetMask(new string[1] { "Colliders" });
			array = Physics.OverlapSphere(explosionPosition, 10f, num4);
			for (int j = 0; j < array.Length; j++)
			{
				Rigidbody component = ((Component)array[j]).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.AddExplosionForce(70f, explosionPosition, 10f);
				}
			}
		}

		private static IEnumerator TriggerOtherMineDelayed(Landmine mine)
		{
			if (!mine.hasExploded)
			{
				mine.mineAudio.pitch = Random.Range(0.75f, 1.07f);
				mine.hasExploded = true;
				yield return (object)new WaitForSeconds(0.2f);
				mine.SetOffMineAnimation();
			}
		}

		public static bool IsNearbyEnemy(Vector3 position, float radius = 15f, bool dangerousEnemiesOnly = true)
		{
			//IL_006d: 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)
			if ((Object)(object)RoundManager.Instance == (Object)null || RoundManager.Instance.SpawnedEnemies == null)
			{
				return false;
			}
			foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
			{
				if (spawnedEnemy.isEnemyDead || (dangerousEnemiesOnly && !IsDangerousEnemy(spawnedEnemy)) || !(Vector3.Distance(position, ((Component)spawnedEnemy).transform.position) <= radius))
				{
					continue;
				}
				return true;
			}
			return false;
		}

		public static bool IsDangerousEnemy(EnemyAI enemyAI)
		{
			string enemyName = enemyAI.enemyType.enemyName;
			if (enemyName == "Docile Locust Bees")
			{
				return false;
			}
			if (enemyName == "Manticoil")
			{
				return false;
			}
			return true;
		}

		public static int GetRandomIndexFromWeightList(List<int> weightList)
		{
			List<(int, int)> list = new List<(int, int)>();
			for (int i = 0; i < weightList.Count; i++)
			{
				int num = weightList[i];
				if (num > 0)
				{
					list.Add((i, num));
				}
			}
			int num2 = 0;
			foreach (var item4 in list)
			{
				int item = item4.Item2;
				num2 += item;
			}
			if (num2 == 0)
			{
				return -1;
			}
			int num3 = Random.Range(0, num2);
			int num4 = 0;
			foreach (var item5 in list)
			{
				int item2 = item5.Item1;
				int item3 = item5.Item2;
				num4 += item3;
				if (num3 < num4)
				{
					return item2;
				}
			}
			throw new InvalidOperationException("Weights are not properly specified.");
		}

		public static bool HasActiveDiscoBall()
		{
			int unlockableId = GetUnlockableId("Disco Ball");
			if (unlockableId == -1)
			{
				Plugin.Logger.LogError((object)"Failed to get unlockable id for \"Disco Ball\".");
				return false;
			}
			PlaceableShipObject[] array = Object.FindObjectsByType<PlaceableShipObject>((FindObjectsSortMode)0);
			foreach (PlaceableShipObject val in array)
			{
				if (val.unlockableID == unlockableId)
				{
					return !StartOfRound.Instance.shipRoomLights.areLightsOn;
				}
			}
			return false;
		}

		public static int GetUnlockableId(string unlockableName)
		{
			if ((Object)(object)StartOfRound.Instance == (Object)null)
			{
				return -1;
			}
			List<UnlockableItem> unlockables = StartOfRound.Instance.unlockablesList.unlockables;
			for (int i = 0; i < unlockables.Count; i++)
			{
				if (unlockables[i].unlockableName == unlockableName)
				{
					return i;
				}
			}
			return -1;
		}

		public static void LogStackTrace()
		{
			StackTrace stackTrace = new StackTrace();
			for (int i = 1; i < stackTrace.FrameCount; i++)
			{
				StackFrame frame = stackTrace.GetFrame(i);
				MethodBase method = frame.GetMethod();
				Type declaringType = method.DeclaringType;
				string name = method.Name;
				Plugin.Instance.LogInfoExtended($"Call stack depth {i}: {declaringType}.{name}");
			}
		}

		public static Coroutine StartCoroutine(IEnumerator routine)
		{
			if ((Object)(object)Plugin.Instance != (Object)null)
			{
				return ((MonoBehaviour)Plugin.Instance).StartCoroutine(routine);
			}
			if ((Object)(object)GameNetworkManager.Instance != (Object)null)
			{
				return ((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(routine);
			}
			Plugin.Logger.LogError((object)("Failed to start coroutine. " + routine));
			return null;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.zehsteam.ZombiesPlush";

		public const string PLUGIN_NAME = "ZombiesPlush";

		public const string PLUGIN_VERSION = "1.2.2";
	}
}
namespace com.github.zehsteam.ZombiesPlush.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal static class GameNetworkManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch()
		{
			AddNetworkPrefabs();
		}

		private static void AddNetworkPrefabs()
		{
			AddNetworkPrefab(Content.NetworkHandlerPrefab);
			AddNetworkPrefab(Content.MaskedZombiesControllerPrefab);
		}

		private static void AddNetworkPrefab(GameObject prefab)
		{
			if ((Object)(object)prefab == (Object)null)
			{
				Plugin.Logger.LogError((object)"Failed to register network prefab. GameObject is null.");
				return;
			}
			NetworkManager.Singleton.AddNetworkPrefab(prefab);
			Plugin.Logger.LogInfo((object)("Registered \"" + ((Object)prefab).name + "\" network prefab."));
		}
	}
	[HarmonyPatch(typeof(MaskedPlayerEnemy))]
	internal static class MaskedPlayerEnemyPatch
	{
		public static bool ForceMaskedZombiesSpawns = false;

		public static Dictionary<MaskedPlayerEnemy, MaskedZombiesBehaviour> MaskedZombiesPairs { get; private set; } = new Dictionary<MaskedPlayerEnemy, MaskedZombiesBehaviour>();


		public static void Reset()
		{
			if (!NetworkUtils.IsServer)
			{
				return;
			}
			int num = 0;
			NetworkObject val = default(NetworkObject);
			foreach (MaskedZombiesBehaviour value in MaskedZombiesPairs.Values)
			{
				if (!((Object)(object)value == (Object)null) && ((NetworkBehaviour)value).IsSpawned && ((Component)value).TryGetComponent<NetworkObject>(ref val))
				{
					val.Despawn(true);
					num++;
					Plugin.Instance.LogInfoExtended("Despawned MaskedZombiesController.");
				}
			}
			Plugin.Instance.LogInfoExtended($"Finished despawning {num}/{MaskedZombiesPairs.Count} MaskedZombiesController(s).");
			MaskedZombiesPairs.Clear();
			ForceMaskedZombiesSpawns = false;
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(ref MaskedPlayerEnemy __instance)
		{
			if (NetworkUtils.IsServer && (Utils.RandomPercent(Plugin.ConfigManager.MaskedZombies_SpawnChance.Value) || ForceMaskedZombiesSpawns))
			{
				SetMaskedZombiesOnServer(__instance);
			}
		}

		public static bool SetMaskedZombiesOnServer(MaskedPlayerEnemy maskedPlayerEnemy)
		{
			if (!NetworkUtils.IsServer)
			{
				return false;
			}
			if (MaskedZombiesPairs.ContainsKey(maskedPlayerEnemy))
			{
				Plugin.Logger.LogError((object)"Failed to set masked zombies on server. MaskedPlayerEnemy is already a masked zombies.");
				return false;
			}
			try
			{
				GameObject val = Object.Instantiate<GameObject>(Content.MaskedZombiesControllerPrefab, ((Component)maskedPlayerEnemy).transform);
				val.GetComponent<NetworkObject>().Spawn(false);
				val.transform.SetParent(((Component)maskedPlayerEnemy).transform);
				MaskedZombiesPairs.Add(maskedPlayerEnemy, val.GetComponent<MaskedZombiesBehaviour>());
				Plugin.Instance.LogInfoExtended("Spawned masked zombies.");
				return true;
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Failed to set masked zombies on server.\n\n{arg}");
			}
			return false;
		}

		[HarmonyPatch("killAnimation")]
		[HarmonyPrefix]
		private static void KillAnimationPatch(ref MaskedPlayerEnemy __instance)
		{
			SetZombiesHeadOnServer(__instance, ZombiesVariantType.Heart);
		}

		[HarmonyPatch("FinishKillAnimation")]
		[HarmonyPrefix]
		private static void FinishKillAnimationPatch(ref MaskedPlayerEnemy __instance)
		{
			SetZombiesHeadOnServer(__instance, ZombiesVariantType.Angry);
		}

		private static void SetZombiesHeadOnServer(MaskedPlayerEnemy maskedPlayerEnemy, ZombiesVariantType state)
		{
			if (NetworkUtils.IsServer && MaskedZombiesPairs.TryGetValue(maskedPlayerEnemy, out var value))
			{
				value.SetZombiesHeadServerRpc(state);
			}
		}
	}
	[HarmonyPatch(typeof(NoisemakerProp))]
	internal static class NoisemakerPropPatch
	{
		[HarmonyPatch("ItemActivate")]
		[HarmonyPostfix]
		private static void ItemActivatePatch(ref NoisemakerProp __instance)
		{
			if (PlayerUtils.IsLocalPlayer(((GrabbableObject)__instance).playerHeldBy) && !((Object)(object)((GrabbableObject)__instance).itemProperties == (Object)null))
			{
				string itemName = ((GrabbableObject)__instance).itemProperties.itemName;
				if (itemName.Equals("Clown horn", StringComparison.OrdinalIgnoreCase))
				{
					ItemActivate_ClownHorn(__instance);
				}
				else if (itemName.Equals("Hairdryer", StringComparison.OrdinalIgnoreCase))
				{
					ItemActivate_Hairdryer(__instance);
				}
			}
		}

		private static void ItemActivate_ClownHorn(NoisemakerProp noisemakerProp)
		{
			foreach (ZombiesBehaviour item in PlayerUtils.GetZombiesPlushiesFromLocalPlayer())
			{
				item.SetSpecialVariantServerRpc(ZombiesVariantType.Clown);
			}
		}

		private static void ItemActivate_Hairdryer(NoisemakerProp noisemakerProp)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerScript = PlayerUtils.GetLocalPlayerScript();
			if ((Object)(object)localPlayerScript == (Object)null)
			{
				return;
			}
			Transform transform = ((Component)localPlayerScript.gameplayCamera).transform;
			RaycastHit[] array = Physics.RaycastAll(transform.position, transform.forward, 2.5f, LayerMask.GetMask(new string[1] { "Props" }));
			RaycastHit[] array2 = array;
			ZombiesBehaviour zombiesBehaviour = default(ZombiesBehaviour);
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val = array2[i];
				if (((Component)((RaycastHit)(ref val)).collider).TryGetComponent<ZombiesBehaviour>(ref zombiesBehaviour))
				{
					zombiesBehaviour.SetSpecialVariantServerRpc(ZombiesVariantType.Sunburnt);
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal static class PlayerControllerBPatch
	{
		private static float _drunkCheckCooldown = 1f;

		private static float _drunkCheckTimer;

		[HarmonyPatch("DamagePlayer")]
		[HarmonyPrefix]
		private static void DamagePlayerPatch(ref PlayerControllerB __instance, int damageNumber)
		{
			if (PlayerUtils.IsLocalPlayer(__instance) && !__instance.isPlayerDead && damageNumber > 0)
			{
				Utils.StartCoroutine(DamagePlayerNextFrameCoroutine(__instance));
			}
		}

		private static IEnumerator DamagePlayerNextFrameCoroutine(PlayerControllerB playerScript)
		{
			yield return null;
			if (playerScript.isPlayerDead)
			{
				yield break;
			}
			foreach (ZombiesBehaviour zombiesBehaviour in PlayerUtils.GetZombiesPlushiesFromLocalPlayer())
			{
				zombiesBehaviour.OnLocalPlayerHoldingPlushieTookDamage();
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void UpdatePatch(ref PlayerControllerB __instance)
		{
			if (!PlayerUtils.IsLocalPlayer(__instance) || __instance.isPlayerDead)
			{
				return;
			}
			if (__instance.drunkness > 0f)
			{
				if (_drunkCheckTimer >= _drunkCheckCooldown)
				{
					_drunkCheckTimer = 0f;
					{
						foreach (ZombiesBehaviour item in PlayerUtils.GetZombiesPlushiesFromLocalPlayer())
						{
							if (NetworkUtils.IsServer)
							{
								item.SetDrunkOnServer();
							}
							else
							{
								item.SetDrunkServerRpc();
							}
						}
						return;
					}
				}
				_drunkCheckTimer += Time.deltaTime;
			}
			else
			{
				_drunkCheckTimer = 0f;
			}
		}

		[HarmonyPatch("PerformEmote")]
		[HarmonyPostfix]
		private static void PerformEmotePatch(ref PlayerControllerB __instance, int emoteID)
		{
			if (!PlayerUtils.IsLocalPlayer(__instance) || __instance.isPlayerDead || !__instance.performingEmote || emoteID != 1 || !Utils.HasActiveDiscoBall())
			{
				return;
			}
			foreach (ZombiesBehaviour item in PlayerUtils.GetZombiesPlushiesFromLocalPlayer())
			{
				item.SetSpecialVariantServerRpc(ZombiesVariantType.Party);
			}
		}

		[HarmonyPatch("KillPlayer")]
		[HarmonyPrefix]
		private static void KillPlayerPatch(ref PlayerControllerB __instance)
		{
			if (!PlayerUtils.IsLocalPlayer(__instance) || __instance.isPlayerDead || !__instance.AllowPlayerDeath())
			{
				return;
			}
			ZombiesVariantType specialVariantServerRpc = (PlayerDiedToShotgunFromPlayer() ? ZombiesVariantType.Panda : ZombiesVariantType.Dead);
			foreach (ZombiesBehaviour item in PlayerUtils.GetZombiesPlushiesFromLocalPlayer())
			{
				item.SetSpecialVariantServerRpc(specialVariantServerRpc);
			}
		}

		private static bool PlayerDiedToShotgunFromPlayer()
		{
			StackTrace stackTrace = new StackTrace();
			StackFrame[] frames = stackTrace.GetFrames();
			foreach (StackFrame stackFrame in frames)
			{
				MethodBase method = stackFrame.GetMethod();
				if (!(method.DeclaringType == null) && method.DeclaringType.Name == "ShotgunItem" && method.Name == "ShootGunClientRpc")
				{
					return true;
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal static class StartOfRoundPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch()
		{
			SpawnNetworkHandler();
		}

		private static void SpawnNetworkHandler()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkUtils.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(Content.NetworkHandlerPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch()
		{
			foreach (ItemConfigData instance in ItemConfigData.Instances)
			{
				instance.RefreshConfigData();
			}
		}

		[HarmonyPatch("ShipHasLeft")]
		[HarmonyPostfix]
		private static void ShipHasLeftPatch()
		{
			Plugin.Instance.OnShipHasLeft();
		}

		[HarmonyPatch("OnClientConnect")]
		[HarmonyPrefix]
		private static void OnClientConnectPatch(ref ulong clientId)
		{
			SendConfigsToNewConnectedPlayer(clientId);
		}

		private static void SendConfigsToNewConnectedPlayer(ulong clientId)
		{
			if (!NetworkUtils.IsServer)
			{
				return;
			}
			Plugin.Logger.LogInfo((object)$"Sending item config data to client: {clientId}");
			foreach (ItemConfigData instance in ItemConfigData.Instances)
			{
				instance.SendConfigDataToClient(clientId);
			}
		}
	}
}
namespace com.github.zehsteam.ZombiesPlush.MonoBehaviours
{
	public abstract class AdvancedGrabbableObject : GrabbableObject
	{
		public int UniqueId { get; private set; }

		public string SaveKey => string.Format("{0}_{1}", "AdvancedGrabbableObject", UniqueId);

		public virtual void Awake()
		{
			if (NetworkUtils.IsServer)
			{
				UniqueId = Random.Range(0, 1000000);
			}
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (NetworkUtils.IsServer)
			{
				NetworkManager.Singleton.OnClientConnectedCallback += OnClientConnected;
			}
		}

		public override void OnNetworkDespawn()
		{
			((NetworkBehaviour)this).OnNetworkDespawn();
			if (NetworkUtils.IsServer)
			{
				NetworkManager.Singleton.OnClientConnectedCallback -= OnClientConnected;
			}
		}

		protected virtual void OnClientConnected(ulong clientId)
		{
		}

		public override int GetItemDataToSave()
		{
			return UniqueId;
		}

		public override void LoadItemSaveData(int saveData)
		{
			((GrabbableObject)this).LoadItemSaveData(saveData);
			UniqueId = saveData;
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "AdvancedGrabbableObject";
		}
	}
	public class AdvancedNoisemakerProp : AdvancedGrabbableObject
	{
		[Space(20f)]
		[Header("Advanced Noisemaker Prop")]
		[Space(5f)]
		public AudioSourceGroup NoiseAudio;

		public AudioClipGroupWithWeight[] NoiseSFX = Array.Empty<AudioClipGroupWithWeight>();

		[Space(10f)]
		public float NoiseRange = 65f;

		public float MaxLoudness = 1f;

		public float MinLoudness = 0.95f;

		public float MinPitch = 1f;

		public float MaxPitch = 1f;

		[Space(10f)]
		public bool UseDynamicCooldown;

		public bool CancelActiveSFXOnItemActivate;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (NoiseSFX.Length != 0)
			{
				int randomIndexFromWeightList = Utils.GetRandomIndexFromWeightList(NoiseSFX.Select((AudioClipGroupWithWeight x) => x.Weight).ToList());
				PlaySound(randomIndexFromWeightList);
			}
		}

		public void PlaySound(int index)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (NoiseSFX.Length != 0)
			{
				PlaySoundServerRpc(index);
				PlaySoundOnLocalClient(index);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		protected void PlaySoundServerRpc(int index, ServerRpcParams serverRpcParams = default(ServerRpcParams))
		{
			//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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1446525904u, serverRpcParams, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, index);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 1446525904u, serverRpcParams, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ulong senderClientId = serverRpcParams.Receive.SenderClientId;
				if (((NetworkBehaviour)this).NetworkManager.ConnectedClients.ContainsKey(senderClientId))
				{
					PlaySoundClientRpc(index, senderClientId);
				}
			}
		}

		[ClientRpc]
		protected void PlaySoundClientRpc(int index, ulong senderClientId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			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(4191135864u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					BytePacker.WriteValueBitPacked(val2, senderClientId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4191135864u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !NetworkUtils.IsLocalClientId(senderClientId))
				{
					PlaySoundOnLocalClient(index);
				}
			}
		}

		public void PlaySoundOnLocalClient(int index)
		{
			AudioClipGroup audioClipGroup = ((index >= 0 && index < NoiseSFX.Length) ? NoiseSFX[index] : null);
			PlaySoundOnLocalClient(audioClipGroup);
			OnPlaySoundFromIndex(index);
		}

		protected virtual void OnPlaySoundFromIndex(int index)
		{
		}

		public float PlaySoundOnLocalClient(AudioClip audioClip, AudioClip audioClipFar, bool stopPreviousSFX = false)
		{
			return PlaySoundOnLocalClient(new AudioClipGroup(audioClip, audioClipFar), stopPreviousSFX);
		}

		public float PlaySoundOnLocalClient(AudioClipGroup audioClipGroup, bool stopPreviousSFX = false)
		{
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			if (audioClipGroup == null || (Object)(object)audioClipGroup.AudioClip == (Object)null)
			{
				return 0f;
			}
			float num = (float)Random.Range((int)(MinLoudness * 100f), (int)(MaxLoudness * 100f)) / 100f;
			float pitch = (float)Random.Range((int)(MinPitch * 100f), (int)(MaxPitch * 100f)) / 100f;
			if (CancelActiveSFXOnItemActivate || stopPreviousSFX)
			{
				NoiseAudio.Stop();
			}
			if (UseDynamicCooldown && !CancelActiveSFXOnItemActivate)
			{
				((GrabbableObject)this).currentUseCooldown = audioClipGroup.Length;
			}
			NoiseAudio.Pitch = pitch;
			NoiseAudio.PlayOneShot(audioClipGroup, num);
			WalkieTalkie.TransmitOneShotAudio(NoiseAudio.AudioSource, audioClipGroup.AudioClip, num);
			RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, NoiseRange, num, 0, ((GrabbableObject)this).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			if (MinLoudness >= 0.6f && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.timeSinceMakingLoudNoise = 0f;
			}
			return audioClipGroup.Length;
		}

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_AdvancedNoisemakerProp()
		{
			//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(1446525904u, new RpcReceiveHandler(__rpc_handler_1446525904));
			NetworkManager.__rpc_func_table.Add(4191135864u, new RpcReceiveHandler(__rpc_handler_4191135864));
		}

		private static void __rpc_handler_1446525904(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int index = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref index);
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AdvancedNoisemakerProp)(object)target).PlaySoundServerRpc(index, server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "AdvancedNoisemakerProp";
		}
	}
	public class EnemyRandomPeriodicAudioPlayer : NetworkBehaviour
	{
		public bool OnlyPlayWhenEnemyIsAlive = true;

		public AudioClip[] RandomClips = Array.Empty<AudioClip>();

		public AudioSource ThisAudio;

		public float AudioMinInterval = 6f;

		public float AudioMaxInterval = 16f;

		public float AudioChancePercent = 40f;

		private EnemyAI _enemyAI;

		private float _timer;

		private float _interval;

		private void Start()
		{
			_enemyAI = ((Component)((Component)this).transform.parent).GetComponent<EnemyAI>();
		}

		private void Update()
		{
			if (!NetworkUtils.IsServer || (OnlyPlayWhenEnemyIsAlive && (Object)(object)_enemyAI == (Object)null) || (OnlyPlayWhenEnemyIsAlive && _enemyAI.isEnemyDead))
			{
				return;
			}
			if (_timer >= _interval)
			{
				if (Utils.RandomPercent(AudioChancePercent))
				{
					PlayRandomAudioClientRpc(Random.Range(0, RandomClips.Length));
				}
				_timer = 0f;
				_interval = Random.Range(AudioChancePercent, AudioMaxInterval);
			}
			else
			{
				_timer += Time.deltaTime;
			}
		}

		[ClientRpc]
		public void PlayRandomAudioClientRpc(int clipIndex)
		{
			//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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3922081718u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, clipIndex);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3922081718u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					PlayAudio(clipIndex);
				}
			}
		}

		private void PlayAudio(int clipIndex)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)ThisAudio == (Object)null))
			{
				AudioClip val = RandomClips[clipIndex];
				ThisAudio.PlayOneShot(val, 1f);
				WalkieTalkie.TransmitOneShotAudio(ThisAudio, val, 1f);
				RoundManager.Instance.PlayAudibleNoise(((Component)ThisAudio).transform.position, 7f, 0.6f, 0, false, 0);
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_EnemyRandomPeriodicAudioPlayer()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3922081718u, new RpcReceiveHandler(__rpc_handler_3922081718));
		}

		private static void __rpc_handler_3922081718(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 clipIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref clipIndex);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((EnemyRandomPeriodicAudioPlayer)(object)target).PlayRandomAudioClientRpc(clipIndex);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "EnemyRandomPeriodicAudioPlayer";
		}
	}
	public class MaskedZombiesBehaviour : NetworkBehaviour
	{
		public GameObject AngryHeadPrefab;

		public GameObject HeartHeadPrefab;

		public AudioClip ElloSFX;

		public Material SuitMaterial;

		private MaskedPlayerEnemy _maskedPlayerEnemy;

		private GameObject _angryHeadObject;

		private GameObject _heartHeadObject;

		private AudioSource _voiceAudio;

		private void Start()
		{
			_maskedPlayerEnemy = ((Component)((Component)this).transform.parent).GetComponent<MaskedPlayerEnemy>();
			SetupRandomPeriodicAudioPlayer();
			SetSuitMaterial();
			DisableMaskObjects();
			MoveMaskFloodParticleObject();
			SpawnZombiesHeadObjects();
			SetZombiesHeadOnLocalClient(ZombiesVariantType.Angry);
		}

		private void SetupRandomPeriodicAudioPlayer()
		{
			_voiceAudio = ((Component)((Component)this).transform.parent.Find("VoiceSFX")).GetComponent<AudioSource>();
			((Component)this).GetComponent<EnemyRandomPeriodicAudioPlayer>().ThisAudio = _voiceAudio;
		}

		private void SetSuitMaterial()
		{
			if (!((Object)(object)SuitMaterial == (Object)null))
			{
				Material[] materials = (Material[])(object)new Material[1] { SuitMaterial };
				((Renderer)_maskedPlayerEnemy.rendererLOD0).materials = materials;
				((Renderer)_maskedPlayerEnemy.rendererLOD1).materials = materials;
				((Renderer)_maskedPlayerEnemy.rendererLOD2).materials = materials;
			}
		}

		private void DisableMaskObjects()
		{
			Transform maskedHeadTransform = GetMaskedHeadTransform();
			((Component)maskedHeadTransform.Find("HeadMaskComedy")).gameObject.SetActive(false);
			((Component)maskedHeadTransform.Find("HeadMaskTragedy")).gameObject.SetActive(false);
		}

		private void MoveMaskFloodParticleObject()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			Transform val = GetMaskedHeadTransform().Find("MaskFloodParticle");
			Vector3 localPosition = val.localPosition;
			localPosition.y = 0f;
			val.localPosition = localPosition;
		}

		private void SpawnZombiesHeadObjects()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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)
			Transform maskedHeadTransform = GetMaskedHeadTransform();
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(0f, 0.184f, 0.019f);
			_angryHeadObject = Object.Instantiate<GameObject>(AngryHeadPrefab, maskedHeadTransform);
			_angryHeadObject.transform.SetLocalPositionAndRotation(val, Quaternion.identity);
			_heartHeadObject = Object.Instantiate<GameObject>(HeartHeadPrefab, maskedHeadTransform);
			_heartHeadObject.transform.SetLocalPositionAndRotation(val, Quaternion.identity);
		}

		[ServerRpc]
		public void SetZombiesHeadServerRpc(ZombiesVariantType state)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(313935504u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<ZombiesVariantType>(ref state, default(ForEnums));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 313935504u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SetZombiesHeadClientRpc(state);
				SetZombiesHeadOnLocalClient(state);
			}
		}

		[ClientRpc]
		public void SetZombiesHeadClientRpc(ZombiesVariantType state)
		{
			//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(3571659928u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<ZombiesVariantType>(ref state, default(ForEnums));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3571659928u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !NetworkUtils.IsServer)
				{
					SetZombiesHeadOnLocalClient(state);
				}
			}
		}

		public void SetZombiesHeadOnLocalClient(ZombiesVariantType state)
		{
			_angryHeadObject.SetActive(state == ZombiesVariantType.Angry);
			_heartHeadObject.SetActive(state == ZombiesVariantType.Heart);
			if (state == ZombiesVariantType.Heart)
			{
				PlayOneShotVoiceAudio(ElloSFX);
			}
		}

		private void PlayOneShotVoiceAudio(AudioClip audioClip)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)audioClip == (Object)null))
			{
				_voiceAudio.PlayOneShot(audioClip);
				WalkieTalkie.TransmitOneShotAudio(_voiceAudio, audioClip, 1f);
				RoundManager.Instance.PlayAudibleNoise(((Component)_voiceAudio).transform.position, 7f, 0.6f, 0, false, 0);
			}
		}

		private Transform GetMaskedHeadTransform()
		{
			return ((Component)this).transform.parent.GetChild(0).GetChild(3).GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0)
				.GetChild(2);
		}

		public override void OnNetworkDespawn()
		{
			Object.Destroy((Object)(object)_angryHeadObject);
			Object.Destroy((Object)(object)_heartHeadObject);
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_MaskedZombiesBehaviour()
		{
			//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(313935504u, new RpcReceiveHandler(__rpc_handler_313935504));
			NetworkManager.__rpc_func_table.Add(3571659928u, new RpcReceiveHandler(__rpc_handler_3571659928));
		}

		private static void __rpc_handler_313935504(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				ZombiesVariantType zombiesHeadServerRpc = default(ZombiesVariantType);
				((FastBufferReader)(ref reader)).ReadValueSafe<ZombiesVariantType>(ref zombiesHeadServerRpc, default(ForEnums));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MaskedZombiesBehaviour)(object)target).SetZombiesHeadServerRpc(zombiesHeadServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3571659928(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)
			{
				ZombiesVariantType zombiesHeadClientRpc = default(ZombiesVariantType);
				((FastBufferReader)(ref reader)).ReadValueSafe<ZombiesVariantType>(ref zombiesHeadClientRpc, default(ForEnums));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((MaskedZombiesBehaviour)(object)target).SetZombiesHeadClientRpc(zombiesHeadClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "MaskedZombiesBehaviour";
		}
	}
	internal class PluginNetworkBehaviour : NetworkBehaviour
	{
		public static PluginNetworkBehaviour Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)this);
			}
			else
			{
				Instance = this;
			}
		}

		[ClientRpc]
		public void UpdateItemPropertiesClientRpc(string itemName, bool twoHanded, int carryWeight, int minValue, int maxValue, ClientRpcParams clientRpcParams = default(ClientRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2631425246u, clientRpcParams, (RpcDelivery)0);
				bool flag = itemName != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(itemName, false);
				}
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref twoHanded, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val, carryWeight);
				BytePacker.WriteValueBitPacked(val, minValue);
				BytePacker.WriteValueBitPacked(val, maxValue);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 2631425246u, clientRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !NetworkUtils.IsServer)
			{
				if (ItemHelper.TryGetItemByName(itemName, out var item))
				{
					ItemHelper.UpdateItemProperties(item, twoHanded, carryWeight, minValue, maxValue);
				}
				else
				{
					Plugin.Logger.LogError((object)("Failed to update item properties. Item by the name of \"" + itemName + "\" could not be found."));
				}
			}
		}

		[ClientRpc]
		public void SpawnExplosionClientRpc(Vector3 position, int damage, float maxDamageRange)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_007e: 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_009d: 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_00f1: 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(627078499u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
					BytePacker.WriteValueBitPacked(val2, damage);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref maxDamageRange, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 627078499u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Utils.CreateExplosion(position, spawnExplosionEffect: true, damage, 0f, maxDamageRange, 6, (CauseOfDeath)3);
				}
			}
		}

		[ClientRpc]
		public void SetScrapValueClientRpc(NetworkObjectReference networkObjectReference, int scrapValue)
		{
			//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)
			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(3390986894u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref networkObjectReference, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, scrapValue);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3390986894u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost) || NetworkUtils.IsServer)
			{
				return;
			}
			NetworkObject val3 = default(NetworkObject);
			if (((NetworkObjectReference)(ref networkObjectReference)).TryGet(ref val3, (NetworkManager)null))
			{
				GrabbableObject val4 = default(GrabbableObject);
				if (((Component)val3).TryGetComponent<GrabbableObject>(ref val4))
				{
					val4.SetScrapValue(scrapValue);
				}
				else
				{
					Plugin.Logger.LogError((object)"Failed to set scrapValue on item. Could not find GrabbableObject.");
				}
			}
			else
			{
				Plugin.Logger.LogError((object)"Failed to set scrapValue on item. Could not find NetworkObject.");
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void DamagePlayerServerRpc(ulong targetClientId, int damage, CauseOfDeath causeOfDeath)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_007e: 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_009d: 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_00f4: 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 != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2617461259u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, targetClientId);
					BytePacker.WriteValueBitPacked(val2, damage);
					((FastBufferWriter)(ref val2)).WriteValueSafe<CauseOfDeath>(ref causeOfDeath, default(ForEnums));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2617461259u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					DamagePlayerClientRpc(targetClientId, damage, causeOfDeath);
				}
			}
		}

		[ClientRpc]
		public void DamagePlayerClientRpc(ulong targetClientId, int damage, CauseOfDeath causeOfDeath)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_007e: 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_009d: 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_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			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(2134151679u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, targetClientId);
				BytePacker.WriteValueBitPacked(val2, damage);
				((FastBufferWriter)(ref val2)).WriteValueSafe<CauseOfDeath>(ref causeOfDeath, default(ForEnums));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2134151679u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && NetworkUtils.IsLocalClientId(targetClientId))
			{
				PlayerControllerB localPlayerScript = PlayerUtils.GetLocalPlayerScript();
				if (!((Object)(object)localPlayerScript == (Object)null))
				{
					localPlayerScript.DamagePlayer(damage, true, true, causeOfDeath, 0, false, default(Vector3));
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_PluginNetworkBehaviour()
		{
			//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
			NetworkManager.__rpc_func_table.Add(2631425246u, new RpcReceiveHandler(__rpc_handler_2631425246));
			NetworkManager.__rpc_func_table.Add(627078499u, new RpcReceiveHandler(__rpc_handler_627078499));
			NetworkManager.__rpc_func_table.Add(3390986894u, new RpcReceiveHandler(__rpc_handler_3390986894));
			NetworkManager.__rpc_func_table.Add(2617461259u, new RpcReceiveHandler(__rpc_handler_2617461259));
			NetworkManager.__rpc_func_table.Add(2134151679u, new RpcReceiveHandler(__rpc_handler_2134151679));
		}

		private static void __rpc_handler_2631425246(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_0067: 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_0076: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string itemName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref itemName, false);
				}
				bool twoHanded = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref twoHanded, default(ForPrimitives));
				int carryWeight = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref carryWeight);
				int minValue = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref minValue);
				int maxValue = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref maxValue);
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PluginNetworkBehaviour)(object)target).UpdateItemPropertiesClientRpc(itemName, twoHanded, carryWeight, minValue, maxValue, client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_627078499(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				int damage = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref damage);
				float maxDamageRange = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref maxDamageRange, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PluginNetworkBehaviour)(object)target).SpawnExplosionClientRpc(position, damage, maxDamageRange);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3390986894(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_005c: 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)
			{
				NetworkObjectReference networkObjectReference = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref networkObjectReference, default(ForNetworkSerializable));
				int scrapValue = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref scrapValue);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PluginNetworkBehaviour)(object)target).SetScrapValueClientRpc(networkObjectReference, scrapValue);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2617461259(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong targetClientId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref targetClientId);
				int damage = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref damage);
				CauseOfDeath causeOfDeath = default(CauseOfDeath);
				((FastBufferReader)(ref reader)).ReadValueSafe<CauseOfDeath>(ref causeOfDeath, default(ForEnums));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PluginNetworkBehaviour)(object)target).DamagePlayerServerRpc(targetClientId, damage, causeOfDeath);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2134151679(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong targetClientId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref targetClientId);
				int damage = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref damage);
				CauseOfDeath causeOfDeath = default(CauseOfDeath);
				((FastBufferReader)(ref reader)).ReadValueSafe<CauseOfDeath>(ref causeOfDeath, default(ForEnums));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PluginNetworkBehaviour)(object)target).DamagePlayerClientRpc(targetClientId, damage, causeOfDeath);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "PluginNetworkBehaviour";
		}
	}
	public class PoopBehaviour : StunGrenadeItem
	{
		[Space(20f)]
		[Header("Poop")]
		[Space(5f)]
		public StunGrenadeItemDamageTrigger DamageTrigger;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			PlayerControllerB playerHeldBy = ((GrabbableObject)this).playerHeldBy;
			((StunGrenadeItem)this).ItemActivate(used, buttonDown);
			DamageTrigger.WasThrown(playerHeldBy);
		}

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

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "PoopBehaviour";
		}
	}
	[RequireComponent(typeof(BoxCollider))]
	public class StunGrenadeItemDamageTrigger : MonoBehaviour
	{
		public StunGrenadeItem StunGrenadeItem;

		public int PlayerDamage = 10;

		public int EnemyDamage = 1;

		public float CollisionCheckDuration = 3f;

		private PlayerControllerB _playerThrownBy;

		private bool _checkForCollision;

		private float _collisionCheckTimer;

		private void Start()
		{
			((Collider)((Component)this).GetComponent<BoxCollider>()).isTrigger = true;
		}

		public void WasThrown(PlayerControllerB playerThrownBy)
		{
			_checkForCollision = true;
			_playerThrownBy = playerThrownBy;
		}

		private void Update()
		{
			if (_checkForCollision)
			{
				if (_collisionCheckTimer >= CollisionCheckDuration)
				{
					_collisionCheckTimer = 0f;
					_checkForCollision = false;
				}
				else
				{
					_collisionCheckTimer += Time.deltaTime;
				}
			}
		}

		private void OnTriggerEnter(Collider other)
		{
			if (!((GrabbableObject)StunGrenadeItem).isHeld && _checkForCollision)
			{
				CheckIfHitPlayer(other);
				CheckIfHitEnemy(other);
			}
		}

		private void CheckIfHitPlayer(Collider other)
		{
			GameObject gameObject = ((Component)other).gameObject;
			bool flag = false;
			if (((Object)gameObject).name == "PlayerPhysicsBox")
			{
				gameObject = ((Component)gameObject.transform.parent).gameObject;
				flag = true;
			}
			PlayerControllerB val = default(PlayerControllerB);
			if (gameObject.TryGetComponent<PlayerControllerB>(ref val) && !val.isPlayerDead && !((Object)(object)val == (Object)(object)_playerThrownBy) && (!flag || val.isHostPlayerObject) && (!flag || !NetworkUtils.IsServer))
			{
				PluginNetworkBehaviour.Instance.DamagePlayerServerRpc(val.actualClientId, PlayerDamage, (CauseOfDeath)0);
				Plugin.Instance.LogInfoExtended($"[{((Object)StunGrenadeItem).name}] Hit player \"{val.playerUsername}\" for {PlayerDamage} damage.");
			}
		}

		private void CheckIfHitEnemy(Collider other)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			IHittable val = default(IHittable);
			if (!((Component)other).gameObject.CompareTag("Player") && ((Component)other).TryGetComponent<IHittable>(ref val))
			{
				PlayerControllerB localPlayerScript = PlayerUtils.GetLocalPlayerScript();
				val.Hit(EnemyDamage, ((Component)localPlayerScript.gameplayCamera).transform.forward, localPlayerScript, true, 1);
				EnemyAICollisionDetect val2 = default(EnemyAICollisionDetect);
				if (((Component)other).TryGetComponent<EnemyAICollisionDetect>(ref val2))
				{
					LogInfoExtended($"Hit enemy \"{val2.mainScript.enemyType.enemyName}\" for {EnemyDamage} damage.");
				}
				else
				{
					LogInfoExtended($"Hit \"{((Object)((Component)other).gameObject).name}\" for {EnemyDamage} damage.");
				}
			}
		}

		private void LogInfoExtended(object data)
		{
			Plugin.Instance.LogInfoExtended($"[{((Object)StunGrenadeItem).name}] {data}");
		}
	}
	public class ZombiesBehaviour : AdvancedNoisemakerProp
	{
		[Space(20f)]
		[Header("Smol Zombies")]
		[Space(5f)]
		public ZombiesVariantData[] Variants = Array.Empty<ZombiesVariantData>();

		public AudioSourceGroup MusicAudio;

		public AudioClipGroupWithData<ZombiesOtherSFX>[] OtherSFX = Array.Empty<AudioClipGroupWithData<ZombiesOtherSFX>>();

		public float OtherPlushieInteractionRadius = 2.5f;

		public GameObject AngrySymbolObject;

		[Space(10f)]
		public float HappinessDrainAmount = 20f;

		[Space(10f)]
		public float ForceAngryStateDuration = 1.75f;

		public float AngryCooldownDuration = 10f;

		public float AngryDamageInterval = 3f;

		public int AngryDamageAmount = 5;

		public int AngryExplosionDamage = 90;

		public float AngryExplosionMaxDamageRange = 6.5f;

		[Space(10f)]
		public float ScaredInterval = 0.5f;

		public float ScaredRaduis = 15f;

		public float ScaredDuration = 5f;

		public Transform PoopSpawnPosTransform;

		public float PoopSpawnDuration = 30f;

		public int PoopValue = 3;

		public int GoldenPoopValue = 69;

		public int GoldenPoopSpawnPercentChance = 5;

		[Space(10f)]
		public float DrunkDuration = 5f;

		private float _happiness = 100f;

		private bool _isScared;

		private bool _keepScaredState;

		private bool _isDrunk;

		private bool _isHeart;

		private bool _isPlayingMusic = true;

		private bool _isSpecialVariant;

		private int _specialVariantIndex;

		private bool _ignoreDamageEvent;

		private float _angryDamageTimer;

		private bool _forceAngryState;

		private float _forceAngryStateTimer;

		private bool _isCoolFromAngry = true;

		private float _scaredIntervalTimer;

		private float _scaredHeldTimer;

		private bool _spawnedPoop;

		private float _drunkTimer;

		private bool _isCoolFromDrunk = true;

		private bool _wasHeldByEnemy;

		private bool _isExploding;

		private bool _isDoingSmolTakeyInteration;

		private bool _isGivingPrize;

		private bool _isPooping;

		private Coroutine _cooldownFromAngryAfterTime;

		public bool IsHeldByLocalPlayer => PlayerUtils.IsLocalPlayer(((GrabbableObject)this).playerHeldBy);

		public ZombiesVariantType ZombieState { get; private set; } = ZombiesVariantType.Happy;


		public AudioClipGroupWithWeight[] PickupSFX => GetVariantData()?.PickupSFX;

		public AudioClipGroupWithWeight[] SqueezeSFX => GetVariantData()?.SqueezeSFX;

		public AudioClipGroupWithWeight[] TransformSFX => GetVariantData()?.TransformSFX;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			LoadSettings();
			if (NetworkUtils.IsServer)
			{
				SetIsPlayingMusicOnServer(_isPlayingMusic);
			}
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (NetworkUtils.IsServer)
			{
				ServerUpdate();
			}
			ClientUpdate();
		}

		public override void LoadItemSaveData(int saveData)
		{
			base.LoadItemSaveData(saveData);
			if (NetworkUtils.IsServer)
			{
				LogInfoExtended("Loading item save data.");
				_isSpecialVariant = SaveSystem.LoadData(base.SaveKey + "__isSpecialVariant", defaultValue: false);
				_specialVariantIndex = SaveSystem.LoadData(base.SaveKey + "__specialVariantIndex", 7);
				SetHappinessOnServer(SaveSystem.LoadData(base.SaveKey + "__happiness", 100f), updateZombieState: false);
				SetIsScaredOnServer(SaveSystem.LoadData(base.SaveKey + "__isScared", defaultValue: false), updateZombieState: false);
				SetIsDrunkOnServer(SaveSystem.LoadData(base.SaveKey + "__isDrunk", defaultValue: false), updateZombieState: false);
				SetIsHeartOnServer(SaveSystem.LoadData(base.SaveKey + "__isHeart", defaultValue: false), updateZombieState: false);
				SetIsPlayingMusicOnLocalClient(SaveSystem.LoadData(base.SaveKey + "__isPlayingMusic", defaultValue: false));
				_keepScaredState = SaveSystem.LoadData(base.SaveKey + "__keepScaredState", defaultValue: false);
				UpdateZombieStateOnServer();
			}
		}

		public override int GetItemDataToSave()
		{
			SaveItemData();
			return base.GetItemDataToSave();
		}

		private void SaveItemData()
		{
			if (NetworkUtils.IsServer)
			{
				SaveSystem.SaveData(base.SaveKey + "__happiness", _happiness);
				SaveSystem.SaveData(base.SaveKey + "__isScared", _isScared);
				SaveSystem.SaveData(base.SaveKey + "__isDrunk", _isDrunk);
				SaveSystem.SaveData(base.SaveKey + "__isHeart", _isHeart);
				SaveSystem.SaveData(base.SaveKey + "__isPlayingMusic", _isPlayingMusic);
				SaveSystem.SaveData(base.SaveKey + "__keepScaredState", _keepScaredState);
				SaveSystem.SaveData(base.SaveKey + "__isSpecialVariant", _isSpecialVariant);
				SaveSystem.SaveData(base.SaveKey + "__specialVariantIndex", _specialVariantIndex);
				LogInfoExtended($"Saved item data. _happiness: {_happiness}, _isScared: {_isScared}, _isDrunk: {_isDrunk}, _isHeart: {_isHeart}, _isPlayingMusic: {_isPlayingMusic}, _keepScaredState: {_keepScaredState}, _isSpecialVariant: {_isSpecialVariant}, _specialVariantIndex: {_specialVariantIndex}");
			}
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			LogInfoExtended($"GrabItem() wasHeldByEnemy: {_wasHeldByEnemy}");
			if (!NetworkUtils.IsServer)
			{
				return;
			}
			if (_cooldownFromAngryAfterTime != null)
			{
				((MonoBehaviour)this).StopCoroutine(_cooldownFromAngryAfterTime);
			}
			bool wasHeldByEnemy = _wasHeldByEnemy;
			if (wasHeldByEnemy)
			{
				SetIsHeartOnServer(value: true, updateZombieState: false);
				_wasHeldByEnemy = false;
			}
			if (_isCoolFromAngry)
			{
				SetHappinessOnServer(100f, updateZombieState: false);
			}
			if (_isCoolFromDrunk)
			{
				SetIsDrunkOnServer(value: false, updateZombieState: false);
			}
			if (!IsEnemyNearby())
			{
				SetIsScaredOnServer(value: false, updateZombieState: false);
				_keepScaredState = false;
			}
			if (_isPlayingMusic)
			{
				SetIsPlayingMusicOnServer(value: false, updateZombieState: false);
			}
			UpdateZombieStateOnServer();
			if (!_isDoingSmolTakeyInteration && !_isGivingPrize && !_isPooping)
			{
				if (wasHeldByEnemy)
				{
					PlayOtherSFXOnServer(ZombiesOtherSFX.RescuedSFX);
				}
				else
				{
					PlayPickupSFXOnServer();
				}
			}
		}

		public override void GrabItemFromEnemy(EnemyAI enemy)
		{
			((GrabbableObject)this).GrabItemFromEnemy(enemy);
			LogInfoExtended("GrabItemFromEnemy() \"" + enemy.enemyType.enemyName + "\"");
			_wasHeldByEnemy = true;
			SetIsScaredOnServer(value: true);
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			UpdateModel();
		}

		public override void EnableItemMeshes(bool enable)
		{
			((GrabbableObject)this).EnableItemMeshes(enable);
			UpdateModel();
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			if (!_isDoingSmolTakeyInteration && !_isGivingPrize && !_isPooping && NoiseSFX.Length != 0 && NoiseSFX.Length == SqueezeSFX.Length)
			{
				int randomIndexFromWeightList = Utils.GetRandomIndexFromWeightList(SqueezeSFX.Select((AudioClipGroupWithWeight _) => _.Weight).ToList());
				PlaySound(randomIndexFromWeightList);
			}
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			UpdateModel();
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			UpdateModel();
			_angryDamageTimer = 0f;
			_forceAngryStateTimer = 0f;
			if (NetworkUtils.IsServer && _happiness < 100f)
			{
				if (_cooldownFromAngryAfterTime != null)
				{
					((MonoBehaviour)this).StopCoroutine(_cooldownFromAngryAfterTime);
				}
				_cooldownFromAngryAfterTime = ((MonoBehaviour)this).StartCoroutine(CooldownFromAngryAfterTimeOnServer(AngryCooldownDuration));
				LogInfoExtended("Started CooldownFromAngryAfterTimeOnServer Coroutine.");
			}
		}

		public override void PlayDropSFX()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).PlayDropSFX();
			if (NetworkUtils.IsServer && !_isPooping)
			{
				if (TakeyPlushProxy.Enabled && TakeyPlushProxy.HasSmolTakeyNearby(((Component)this).transform.position, OtherPlushieInteractionRadius) && !_isDoingSmolTakeyInteration)
				{
					((MonoBehaviour)this).StartCoroutine(StartSmolTakeyInterationOnServer());
				}
				else if (CanGivePrize() && !_isGivingPrize)
				{
					((MonoBehaviour)this).StartCoroutine(StartGivePrizeInteraction());
				}
			}
		}

		private ZombiesVariantData GetVariantData()
		{
			ZombiesVariantData[] variants = Variants;
			foreach (ZombiesVariantData zombiesVariantData in variants)
			{
				if (zombiesVariantData.VariantType == ZombieState)
				{
					return zombiesVariantData;
				}
			}
			return null;
		}

		private ZombiesVariantData GetVariantData(ZombiesVariantType variantType)
		{
			ZombiesVariantData[] variants = Variants;
			foreach (ZombiesVariantData zombiesVariantData in variants)
			{
				if (zombiesVariantData.VariantType == variantType)
				{
					return zombiesVariantData;
				}
			}
			return null;
		}

		private bool IsVariantType(ZombiesVariantType variantType)
		{
			return ZombieState == variantType;
		}

		private bool IsVariantType(params ZombiesVariantType[] variantTypes)
		{
			foreach (ZombiesVariantType zombiesVariantType in variantTypes)
			{
				if (zombiesVariantType == ZombieState)
				{
					return true;
				}
			}
			return false;
		}

		protected override void OnClientConnected(ulong clientId)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkUtils.IsLocalClientId(clientId))
			{
				Cl