Decompiled source of MischievousPlushies v0.3.0

MischievousPlushies.dll

Decompiled 16 hours 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.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using MischevoiusPlushies;
using MischievousPlushies;
using MischievousPlushies.NetcodePatcher;
using MischievousPlushies.Patches;
using MischievousPlushies.PlushCode;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;

[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("MischievousPlushies")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+360afb79b1f186180d2ab384ed6ff5b2b438a11d")]
[assembly: AssemblyProduct("MischievousPlushies")]
[assembly: AssemblyTitle("MischievousPlushies")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 MischevoiusPlushies
{
	public class NetworkerPatch
	{
		private static GameObject networkerPrefab = global::MischievousPlushies.MischievousPlushies.networkerPrefab;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		public static void AddPrefab(ref GameNetworkManager __instance)
		{
			networkerPrefab.AddComponent<PlushNetworker>();
			NetworkManager.Singleton.AddNetworkPrefab(networkerPrefab);
			global::MischievousPlushies.MischievousPlushies.Logger.LogInfo((object)"xˬx PlushNet launchning. xˬx");
			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);
					}
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkHandler()
		{
			//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)
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(networkerPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}
	}
}
namespace MischievousPlushies
{
	[BepInPlugin("Kuodos.MischievousPlushies", "MischievousPlushies", "0.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MischievousPlushies : BaseUnityPlugin
	{
		public const string GUID = "Kuodos.MischievousPlushies";

		public const string NAME = "MischievousPlushies";

		public const string VERSION = "0.3.0";

		private static AssetBundle plushieAssets { get; set; }

		public static GameObject networkerPrefab { get; set; }

		public static MischievousPlushies Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony harmony { get; set; }

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			harmony = new Harmony("Kuodos.MischievousPlushies");
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			plushieAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "plushiesbundle"));
			if ((Object)(object)plushieAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			int num = 25;
			Item[] array = plushieAssets.LoadAllAssets<Item>();
			Item[] array2 = array;
			foreach (Item val in array2)
			{
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Items.RegisterScrap(val, num, (LevelTypes)(-1));
			}
			PlushCosplayer.PlushieAllowList = array.ToList();
			networkerPrefab = plushieAssets.LoadAsset<GameObject>("PlushNetworker");
			Logger.LogInfo((object)harmony.Id);
			Harmony.CreateAndPatchAll(typeof(NetworkerPatch), (string)null);
			Harmony.CreateAndPatchAll(typeof(ReportDeathsPatch), (string)null);
			Logger.LogInfo((object)"MischievousPlushies is loaded! xˬx ");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			harmony.UnpatchSelf();
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public class PlushNetworker : NetworkBehaviour
	{
		public static PlushNetworker Instance { get; private set; }

		public static List<ulong>? AlivePlayersNetworkObjects { get; private set; }

		public override void OnNetworkSpawn()
		{
			Instance = this;
			MischievousPlushies.Logger.LogInfo((object)"xˬx PlushNet operational. Launching nuclear missiles. xˬx");
			AlivePlayersNetworkObjects = new List<ulong>();
			UpdateAlivePlayerListServerRPC();
			if (!((NetworkBehaviour)this).IsHost)
			{
			}
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		[ServerRpc(RequireOwnership = false)]
		public void UpdateAlivePlayerListServerRPC()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1676187354u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1676187354u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost) || AlivePlayersNetworkObjects == null)
			{
				return;
			}
			AlivePlayersNetworkObjects.Clear();
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			PlayerControllerB[] array = allPlayerScripts;
			foreach (PlayerControllerB val3 in array)
			{
				if (!val3.isPlayerDead && val3.isPlayerControlled)
				{
					AlivePlayersNetworkObjects.Add(((Component)val3).GetComponent<NetworkObject>().NetworkObjectId);
				}
			}
			LifeboundExploderCheckOwners();
		}

		[ServerRpc(RequireOwnership = false)]
		public void RequestCosplayerListServerRPC(ulong clientId)
		{
			//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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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 != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2647887876u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2647887876u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			ClientRpcParams val3 = default(ClientRpcParams);
			val3.Send = new ClientRpcSendParams
			{
				TargetClientIds = new ulong[1] { clientId }
			};
			ClientRpcParams clientRpcParams = val3;
			PlushCosplayer.PruneConvertedList();
			List<GrabbableObject> convertedPlushies = PlushCosplayer.ConvertedPlushies;
			List<ulong> list = new List<ulong>();
			foreach (GrabbableObject item in convertedPlushies)
			{
				list.Add(((NetworkBehaviour)item).NetworkObjectId);
			}
			SendCosplayerListClientRPC(list.ToArray(), clientRpcParams);
		}

		[ClientRpc]
		public void SendCosplayerListClientRPC(ulong[] CosplayerList, ClientRpcParams clientRpcParams)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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(3160392204u, clientRpcParams, (RpcDelivery)0);
				bool flag = CosplayerList != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(CosplayerList, default(ForPrimitives));
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3160392204u, clientRpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsOwner)
			{
				PlushCosplayer.SetConvertedPlushies(CosplayerList);
				MischievousPlushies.Logger.LogInfo((object)"xˬx PlushNet: Sent convertees list. xˬx");
			}
		}

		[ClientRpc]
		public void CosplayClientRPC(ulong source, ulong target)
		{
			//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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2520982718u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, source);
					BytePacker.WriteValueBitPacked(val2, target);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2520982718u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					NetworkObject val3 = NetworkManager.Singleton.SpawnManager.SpawnedObjects[source];
					NetworkObject val4 = NetworkManager.Singleton.SpawnManager.SpawnedObjects[target];
					GrabbableObject component = ((Component)val4).GetComponent<GrabbableObject>();
					((Component)val3).GetComponent<PlushCosplayer>().PlushConvert(component);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetLifeboundExploderServerRPC(ulong sourceId, ulong targetId)
		{
			//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)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(167281621u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, sourceId);
					BytePacker.WriteValueBitPacked(val2, targetId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 167281621u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SetLifeboundExploderClientRPC(sourceId, targetId);
				}
			}
		}

		[ClientRpc]
		public void SetLifeboundExploderClientRPC(ulong sourceId, ulong targetId)
		{
			//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)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(409653895u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, sourceId);
					BytePacker.WriteValueBitPacked(val2, targetId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 409653895u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					NetworkObject val3 = NetworkManager.Singleton.SpawnManager.SpawnedObjects[sourceId];
					NetworkObject val4 = NetworkManager.Singleton.SpawnManager.SpawnedObjects[targetId];
					((Component)val3).GetComponent<PlushLifeboundExploder>().SetOwner(((Component)val4).GetComponent<PlayerControllerB>());
				}
			}
		}

		[ClientRpc]
		public void ExplodeLifeboundExploderClientRPC(ulong sourceId)
		{
			//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(3291351358u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, sourceId);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3291351358u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					NetworkObject val3 = NetworkManager.Singleton.SpawnManager.SpawnedObjects[sourceId];
					((Component)val3).GetComponent<PlushLifeboundExploder>().Explode();
				}
			}
		}

		[ClientRpc]
		public void TeleportPlayerClientRPC(ulong playerId, Vector3 pos)
		{
			//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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			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(1754041960u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, playerId);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref pos);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1754041960u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					NetworkObject val3 = NetworkManager.Singleton.SpawnManager.SpawnedObjects[playerId];
					((Component)val3).GetComponent<PlayerControllerB>().TeleportPlayer(pos, false, 0f, false, true);
				}
			}
		}

		[ClientRpc]
		public void TeleportItemClientRPC(ulong itemId, Vector3 pos)
		{
			//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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			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(653386491u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, itemId);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref pos);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 653386491u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				GrabbableObject component = ((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[itemId]).GetComponent<GrabbableObject>();
				if ((Object)(object)component.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					component.DiscardItemClientRpc();
				}
				component.targetFloorPosition = pos;
			}
		}

		public void LifeboundExploderCheckOwners()
		{
			PlushLifeboundExploder[] array = Object.FindObjectsByType<PlushLifeboundExploder>((FindObjectsSortMode)0);
			foreach (PlushLifeboundExploder plushLifeboundExploder in array)
			{
				if (plushLifeboundExploder.isOwnerDead())
				{
					ExplodeLifeboundExploderClientRPC(((Component)plushLifeboundExploder).GetComponent<NetworkObject>().NetworkObjectId);
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_PlushNetworker()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1676187354u, new RpcReceiveHandler(__rpc_handler_1676187354));
			NetworkManager.__rpc_func_table.Add(2647887876u, new RpcReceiveHandler(__rpc_handler_2647887876));
			NetworkManager.__rpc_func_table.Add(3160392204u, new RpcReceiveHandler(__rpc_handler_3160392204));
			NetworkManager.__rpc_func_table.Add(2520982718u, new RpcReceiveHandler(__rpc_handler_2520982718));
			NetworkManager.__rpc_func_table.Add(167281621u, new RpcReceiveHandler(__rpc_handler_167281621));
			NetworkManager.__rpc_func_table.Add(409653895u, new RpcReceiveHandler(__rpc_handler_409653895));
			NetworkManager.__rpc_func_table.Add(3291351358u, new RpcReceiveHandler(__rpc_handler_3291351358));
			NetworkManager.__rpc_func_table.Add(1754041960u, new RpcReceiveHandler(__rpc_handler_1754041960));
			NetworkManager.__rpc_func_table.Add(653386491u, new RpcReceiveHandler(__rpc_handler_653386491));
		}

		private static void __rpc_handler_1676187354(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PlushNetworker)(object)target).UpdateAlivePlayerListServerRPC();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2647887876(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong clientId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PlushNetworker)(object)target).RequestCosplayerListServerRPC(clientId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3160392204(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_0068: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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));
				ulong[] cosplayerList = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref cosplayerList, default(ForPrimitives));
				}
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PlushNetworker)(object)target).SendCosplayerListClientRPC(cosplayerList, client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2520982718(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)
			{
				ulong source = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref source);
				ulong target2 = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref target2);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PlushNetworker)(object)target).CosplayClientRPC(source, target2);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_167281621(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)
			{
				ulong sourceId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref sourceId);
				ulong targetId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref targetId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PlushNetworker)(object)target).SetLifeboundExploderServerRPC(sourceId, targetId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_409653895(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)
			{
				ulong sourceId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref sourceId);
				ulong targetId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref targetId);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PlushNetworker)(object)target).SetLifeboundExploderClientRPC(sourceId, targetId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3291351358(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong sourceId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref sourceId);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PlushNetworker)(object)target).ExplodeLifeboundExploderClientRPC(sourceId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1754041960(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0052: 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)
			{
				ulong playerId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				Vector3 pos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref pos);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PlushNetworker)(object)target).TeleportPlayerClientRPC(playerId, pos);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_653386491(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0052: 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)
			{
				ulong itemId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref itemId);
				Vector3 pos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref pos);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((PlushNetworker)(object)target).TeleportItemClientRPC(itemId, pos);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "PlushNetworker";
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MischievousPlushies";

		public const string PLUGIN_NAME = "MischievousPlushies";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace MischievousPlushies.PlushCode
{
	public class PlushAFKTeleporter : MonoBehaviour
	{
		private static bool isActivePlayerOnShip = false;

		private float checkAFK_Cur = 60f;

		private static float checkAFK_Timer = 30f;

		private static bool teleporting = false;

		private static bool setup = false;

		private GrabbableObject plushObj { get; set; } = null;


		private static bool isHost => ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost;

		private static ShipLights shipLights { get; set; } = null;


		private static InteractTrigger lightSwitch { get; set; } = null;


		private static PlayerControllerB[] Players { get; set; } = null;


		private static Dictionary<PlayerControllerB, Vector3> PlayerRots { get; set; } = null;


		private static List<PlayerControllerB> AfkPlayers { get; set; } = null;


		private void Awake()
		{
			plushObj = ((Component)this).GetComponent<GrabbableObject>();
			if (isHost && !setup)
			{
				Init();
			}
		}

		private void Init()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			setup = true;
			shipLights = Object.FindFirstObjectByType<ShipLights>();
			lightSwitch = GameObject.Find("LightSwitchContainer").GetComponentInChildren<InteractTrigger>();
			AfkPlayers = new List<PlayerControllerB>();
			PlayerRots = new Dictionary<PlayerControllerB, Vector3>();
			Players = StartOfRound.Instance.allPlayerScripts;
			PlayerControllerB[] players = Players;
			foreach (PlayerControllerB val in players)
			{
				Dictionary<PlayerControllerB, Vector3> playerRots = PlayerRots;
				Quaternion rotation = ((Component)val).transform.rotation;
				playerRots.Add(val, ((Quaternion)(ref rotation)).eulerAngles);
			}
		}

		private void Update()
		{
			if (isHost && plushObj.isInShipRoom)
			{
				checkAFK_Cur -= Time.deltaTime;
				if (checkAFK_Cur < 0f)
				{
					checkAFK_Cur = checkAFK_Timer;
					ScanAFK();
				}
			}
		}

		private static void ScanAFK()
		{
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			isActivePlayerOnShip = false;
			GrabbableObject val = null;
			if (StartOfRound.Instance.inShipPhase || StartOfRound.Instance.shipIsLeaving || teleporting)
			{
				return;
			}
			PlushAFKTeleporter[] array = Object.FindObjectsByType<PlushAFKTeleporter>((FindObjectsSortMode)0);
			foreach (PlushAFKTeleporter plushAFKTeleporter in array)
			{
				if (plushAFKTeleporter.plushObj.isInShipRoom && !plushAFKTeleporter.plushObj.isHeld)
				{
					val = plushAFKTeleporter.plushObj;
					break;
				}
			}
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			PlayerControllerB[] players = Players;
			foreach (PlayerControllerB val2 in players)
			{
				if (isPlayerAFK(val2))
				{
					if (AfkPlayers.Contains(val2))
					{
						if (!isActivePlayerOnShip)
						{
							MischievousPlushies.Logger.LogInfo((object)"xˬx target locked xˬx");
							((Component)val).GetComponent<PlushAFKTeleporter>().StartTeleportSequence(val2);
						}
						AfkPlayers.Clear();
					}
					else
					{
						AfkPlayers.Add(val2);
					}
				}
				else if (AfkPlayers.Contains(val2))
				{
					AfkPlayers.Remove(val2);
				}
				Dictionary<PlayerControllerB, Vector3> playerRots = PlayerRots;
				Quaternion rotation = ((Component)val2).transform.rotation;
				playerRots[val2] = ((Quaternion)(ref rotation)).eulerAngles;
			}
		}

		private static bool isPlayerAFK(PlayerControllerB player)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (player.isPlayerDead)
			{
				return false;
			}
			if (player.inTerminalMenu)
			{
				return false;
			}
			if (player.isInHangarShipRoom)
			{
				Vector3 val = PlayerRots[player];
				Quaternion rotation = ((Component)player).transform.rotation;
				Vector3 val2 = val - ((Quaternion)(ref rotation)).eulerAngles;
				float magnitude = ((Vector3)(ref val2)).magnitude;
				if (player.timeSincePlayerMoving > checkAFK_Timer && magnitude < 0.5f)
				{
					return true;
				}
				isActivePlayerOnShip = true;
			}
			return false;
		}

		public void StartTeleportSequence(PlayerControllerB player)
		{
			teleporting = true;
			((MonoBehaviour)this).StartCoroutine(TeleportPlayerSequence(player));
		}

		private IEnumerator TeleportPlayerSequence(PlayerControllerB player)
		{
			ShipTeleporter teleporter = null;
			ShipTeleporter[] array = Object.FindObjectsByType<ShipTeleporter>((FindObjectsSortMode)0);
			foreach (ShipTeleporter tp in array)
			{
				if (tp.isInverseTeleporter && tp.CanUseInverseTeleporter())
				{
					teleporter = tp;
				}
			}
			if ((Object)(object)teleporter != (Object)null)
			{
				if (shipLights.areLightsOn)
				{
					lightSwitch.Interact(((Component)player).transform);
				}
				yield return (object)new WaitForSeconds(15f);
				if (!isPlayerAFK(player))
				{
					teleporting = false;
					yield break;
				}
				MischievousPlushies.Logger.LogInfo((object)"xˬx teleporting xˬx");
				Vector3 buttonPos = ((Component)teleporter).transform.GetChild(1).GetChild(0).GetChild(0)
					.position - ((Component)this).transform.parent.position + Vector3.up * 0.05f;
				PlushNetworker.Instance.TeleportItemClientRPC(((NetworkBehaviour)plushObj).NetworkObjectId, buttonPos);
				PlushNetworker.Instance.TeleportPlayerClientRPC(((NetworkBehaviour)player).NetworkObjectId, teleporter.teleporterPosition.position);
				teleporter.PressTeleportButtonServerRpc();
				teleporting = false;
			}
			else
			{
				teleporting = false;
			}
		}
	}
	public class PlushCosplayer : MonoBehaviour
	{
		private static float cosplayTimer = 120f;

		private static float cosplayTimerMax = 60f;

		private static float cosplayRange = 5f;

		private static bool cosplayAnywhere = true;

		private static bool ignoreAllowList = true;

		private GrabbableObject PlushObj { get; set; } = null;


		private static List<GrabbableObject> PlushiesList { get; set; } = null;


		public static List<Item> PlushieAllowList { get; set; } = null;


		public static List<GrabbableObject> ConvertedPlushies { get; set; } = null;


		private static bool isHost => ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost;

		private void Start()
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			PlushObj = ((Component)this).GetComponent<GrabbableObject>();
			PlushiesList = new List<GrabbableObject>();
			if (ConvertedPlushies == null)
			{
				ConvertedPlushies = new List<GrabbableObject>();
			}
			if (PlushieAllowList == null)
			{
				PlushieAllowList = new List<Item>();
			}
			if (isHost)
			{
				ConvertedPlushies.Add(PlushObj);
				UpdatePlushList();
			}
			else
			{
				PlushNetworker.Instance.RequestCosplayerListServerRPC(NetworkManager.Singleton.LocalClientId);
			}
			((UnityEvent)StartOfRound.Instance.StartNewRoundEvent).AddListener(new UnityAction(MassConvert));
		}

		private void OnDestroy()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((UnityEvent)StartOfRound.Instance.StartNewRoundEvent).RemoveListener(new UnityAction(MassConvert));
		}

		public static void SetConvertedPlushies(ulong[] Cosplayers)
		{
			ConvertedPlushies.Clear();
			foreach (ulong key in Cosplayers)
			{
				ConvertedPlushies.Add(((Component)((Component)NetworkManager.Singleton.SpawnManager.SpawnedObjects[key]).transform).GetComponent<GrabbableObject>());
			}
			Object.FindAnyObjectByType<PlushCosplayer>().MassConvert();
		}

		public void MassConvert()
		{
			PruneConvertedList();
			foreach (GrabbableObject convertedPlushy in ConvertedPlushies)
			{
				PlushConvert(convertedPlushy);
			}
		}

		public static void UpdatePlushList()
		{
			GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0);
			PlushiesList.Clear();
			GrabbableObject[] array2 = array;
			foreach (GrabbableObject val in array2)
			{
				if ((val.itemProperties.itemName.ToLower().Contains("plush") || val.itemProperties.itemName.ToLower().Contains("fumo")) && !ConvertedPlushies.Contains(val) && !PlushiesList.Contains(val) && (PlushieAllowList.Contains(val.itemProperties) || ignoreAllowList))
				{
					PlushiesList.Add(val);
				}
			}
			PruneConvertedList();
		}

		public static void PruneConvertedList()
		{
			ConvertedPlushies.RemoveAll((GrabbableObject plush) => (Object)(object)plush == (Object)null);
		}

		private void Update()
		{
			//IL_00bc: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			if (!isHost || (!PlushObj.isInShipRoom && !cosplayAnywhere))
			{
				return;
			}
			cosplayTimer -= Time.deltaTime;
			if (!(cosplayTimer < 0f))
			{
				return;
			}
			UpdatePlushList();
			cosplayTimer = cosplayTimerMax;
			GrabbableObject val = null;
			float num = cosplayRange;
			if (PlushiesList.Count == 0)
			{
				return;
			}
			foreach (GrabbableObject plushies in PlushiesList)
			{
				if (plushies.isInShipRoom || cosplayAnywhere)
				{
					Vector3 val2 = ((Component)plushies).transform.position - ((Component)PlushObj).transform.position;
					float magnitude = ((Vector3)(ref val2)).magnitude;
					if (magnitude < num)
					{
						num = magnitude;
						val = plushies;
					}
				}
			}
			if ((Object)(object)val != (Object)null && !((Object)(object)PlushNetworker.Instance == (Object)null))
			{
				ConvertedPlushies.Add(val);
				PlushiesList.Remove(val);
				ulong networkObjectId = ((NetworkBehaviour)val).NetworkObjectId;
				PlushNetworker.Instance.CosplayClientRPC(((NetworkBehaviour)PlushObj).NetworkObjectId, networkObjectId);
			}
		}

		public void PlushConvert(GrabbableObject obj)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			MeshFilter val = ((!((Object)(object)obj.mainObjectRenderer != (Object)null)) ? ((Component)obj).GetComponent<MeshFilter>() : ((Component)((Component)obj.mainObjectRenderer).transform).GetComponent<MeshFilter>());
			Bounds bounds = val.mesh.bounds;
			float num = ((Bounds)(ref bounds)).size.y * ((Component)val).transform.lossyScale.y;
			bounds = ((Component)PlushObj).GetComponent<MeshFilter>().mesh.bounds;
			float num2 = ((Bounds)(ref bounds)).size.y * ((Component)((Component)PlushObj).GetComponent<MeshFilter>()).transform.lossyScale.y;
			MeshRenderer[] componentsInChildren = ((Component)((Component)obj).transform).GetComponentsInChildren<MeshRenderer>();
			foreach (MeshRenderer val2 in componentsInChildren)
			{
				((Renderer)val2).forceRenderingOff = true;
			}
			GameObject val3 = new GameObject("fake plush");
			((Renderer)val3.AddComponent<MeshRenderer>()).materials = ((Renderer)((Component)PlushObj).GetComponent<MeshRenderer>()).materials;
			val3.AddComponent<MeshFilter>().mesh = ((Component)PlushObj).GetComponent<MeshFilter>().mesh;
			val3.transform.rotation = ((Component)obj).transform.rotation;
			val3.transform.Rotate(0f - obj.itemProperties.restingRotation.x, 0f, 0f);
			val3.transform.position = ((Component)obj).transform.position;
			val3.transform.localScale = Vector3.one * num / num2 * PlushObj.originalScale.y;
			val3.transform.parent = ((Component)obj).transform;
			((Component)obj).GetComponentInChildren<ScanNodeProperties>().headerText = ((Component)PlushObj).GetComponentInChildren<ScanNodeProperties>().headerText;
			obj.customGrabTooltip = PlushObj.customGrabTooltip;
		}
	}
	public class PlushGambler
	{
	}
	public class PlushGrabbableObject : GrabbableObject
	{
		private static string recordings;

		public AudioClip defaultNoise;

		public UnityEvent onGrabEvent;

		public override void OnNetworkSpawn()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (recordings == null)
			{
				recordings = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
			}
			if (onGrabEvent == null)
			{
				onGrabEvent = new UnityEvent();
			}
			if (Object.op_Implicit((Object)(object)((Component)this).GetComponent<PlushLifeboundExploder>()))
			{
				((Component)this).GetComponent<PlushLifeboundExploder>().Init();
			}
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			onGrabEvent.Invoke();
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
		}

		public override void OnDestroy()
		{
			((UnityEventBase)onGrabEvent).RemoveAllListeners();
			((NetworkBehaviour)this).OnDestroy();
		}

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

		protected internal override string __getTypeName()
		{
			return "PlushGrabbableObject";
		}
	}
	public class PlushLifeboundExploder : MonoBehaviour
	{
		public AudioClip? explodeClip;

		private bool ignoreNewOwners = false;

		private bool exploded = false;

		private PlushGrabbableObject plushObj { get; set; } = null;


		private PlayerControllerB ownerObj { get; set; } = null;


		private static bool isHost => ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost;

		public void Init()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			if ((Object)(object)plushObj == (Object)null)
			{
				plushObj = ((Component)this).GetComponent<PlushGrabbableObject>();
			}
			plushObj.onGrabEvent.AddListener(new UnityAction(OnGrab));
		}

		public void OnGrab()
		{
			if ((Object)(object)ownerObj == (Object)null && !ignoreNewOwners)
			{
				ulong networkObjectId = ((Component)((Component)this).transform).GetComponent<NetworkObject>().NetworkObjectId;
				ulong networkObjectId2 = ((Component)GameNetworkManager.Instance.localPlayerController).GetComponent<NetworkObject>().NetworkObjectId;
				PlushNetworker.Instance.SetLifeboundExploderServerRPC(networkObjectId, networkObjectId2);
				ignoreNewOwners = true;
			}
		}

		public void SetOwner(PlayerControllerB owner)
		{
			if (!ignoreNewOwners)
			{
				ownerObj = owner;
				ignoreNewOwners = true;
			}
		}

		public bool isOwnerDead()
		{
			if ((Object)(object)ownerObj == (Object)null)
			{
				return false;
			}
			if (ownerObj.isPlayerDead || !ownerObj.isPlayerControlled)
			{
				return true;
			}
			return false;
		}

		public void Explode()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (!exploded)
			{
				exploded = true;
				if ((Object)(object)explodeClip != (Object)null)
				{
					((Component)this).GetComponent<AudioSource>().PlayOneShot(explodeClip, 1f);
				}
				Landmine.SpawnExplosion(((Component)plushObj).transform.position, true, 2f, 5f, 50, 0f, (GameObject)null, false);
				((Component)((Component)plushObj).transform).gameObject.SetActive(false);
			}
		}
	}
	public class PlushShovelStealer : MonoBehaviour
	{
		private GrabbableObject plushObj { get; set; } = null;


		private static bool isHost => ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost;

		private void Start()
		{
			plushObj = ((Component)this).GetComponent<GrabbableObject>();
			if (!isHost)
			{
			}
		}
	}
}
namespace MischievousPlushies.Patches
{
	public class ReportDeathsPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "KillPlayerServerRpc")]
		private static void ReportDeath()
		{
			PlushNetworker.Instance.UpdateAlivePlayerListServerRPC();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "PlayerHasRevivedServerRpc")]
		private static void ReportRevive()
		{
			PlushNetworker.Instance.UpdateAlivePlayerListServerRPC();
		}
	}
}
namespace MischievousPlushies.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}