Decompiled source of InverseOnly v2.0.0

InverseOnly.dll

Decompiled 6 months ago
#define DEBUG
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 System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using InverseOnly.Dependencies;
using InverseOnly.Networking;
using InverseOnly.Patches;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using TestAccount666.InverseOnly.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TestAccount666.InverseOnly")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Forces players to use the inverse teleporter")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0")]
[assembly: AssemblyProduct("InverseOnly")]
[assembly: AssemblyTitle("TestAccount666.InverseOnly")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.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 InverseOnly
{
	public class ConfigManager
	{
		internal ConfigEntry<bool> useInverseTeleporter = null;

		internal ConfigEntry<bool> dropAllItems = null;

		internal void Initialize(ConfigFile configFile)
		{
			dropAllItems = configFile.Bind<bool>("General", "1. Drop items before teleport", true, "If true, will drop player's items before teleport. Only effective, if option 2 is set to false.");
			useInverseTeleporter = configFile.Bind<bool>("General", "2. Use Inverse Teleporter instead", false, "If true, will unlock the invserse teleporter instead of playing Lunxara's voice lines and just teleporting everyone after that");
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("TestAccount666.InverseOnly", "InverseOnly", "2.0.0")]
	public class InverseOnly : BaseUnityPlugin
	{
		internal static GameObject? barrierPrefab;

		internal static Random random = null;

		internal static ConfigManager configManager = null;

		public static readonly List<AudioClip> VoiceLines = new List<AudioClip>();

		internal static ManualLogSource Logger { get; private set; } = null;


		private static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			random = new Random(DateTime.Now.Millisecond);
			configManager = new ConfigManager();
			configManager.Initialize(((BaseUnityPlugin)this).Config);
			if (DependencyChecker.IsLobbyCompatibilityInstalled())
			{
				Logger.LogInfo((object)"Found LobbyCompatibility Mod, initializing support :)");
				LobbyCompatibilitySupport.Initialize();
			}
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName ?? throw new FileNotFoundException("Could not find AssetBundle!", Assembly.GetExecutingAssembly().Location + "/../inverseonly"), "inverseonly"));
			barrierPrefab = val.LoadAllAssets<GameObject>().First();
			((MonoBehaviour)this).StartCoroutine(LoadAudioClips());
			Patch();
			InitializeNetcode();
			Logger.LogInfo((object)"TestAccount666.InverseOnly v2.0.0 has loaded!");
		}

		private static void InitializeNetcode()
		{
			if (configManager.useInverseTeleporter.Value)
			{
				return;
			}
			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 static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("TestAccount666.InverseOnly");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll(typeof(EntranceTeleportPatch));
			if (configManager.useInverseTeleporter.Value)
			{
				Harmony.PatchAll(typeof(PlayerControllerBPatch));
			}
			else
			{
				Harmony.PatchAll(typeof(GameNetworkManagerPatch));
				Harmony.PatchAll(typeof(HangarShipDoorPatch));
			}
			Logger.LogDebug((object)"Finished patching!");
		}

		private static IEnumerator LoadAudioClips()
		{
			string assemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			Debug.Assert(assemblyDirectory != null, "assemblyDirectory != null");
			string audioPath = Path.Combine(assemblyDirectory, "sounds");
			audioPath = (Directory.Exists(audioPath) ? audioPath : Path.Combine(assemblyDirectory));
			Logger.LogInfo((object)"Loading Lunxara voice lines...");
			string voiceLinesAudioPath2 = Path.Combine(audioPath, "voicelines");
			voiceLinesAudioPath2 = (Directory.Exists(voiceLinesAudioPath2) ? voiceLinesAudioPath2 : Path.Combine(assemblyDirectory));
			foreach (string file in Directory.EnumerateFiles(voiceLinesAudioPath2))
			{
				string fileName = Path.GetFileName(file);
				if (fileName.ToLower().EndsWith(".wav"))
				{
					Uri filePath = new Uri(file);
					string text = fileName;
					AudioClip voiceLineAudioClip = LoadAudioClipFromFile(filePath, text.Substring(0, text.Length - 4));
					if (voiceLineAudioClip != null)
					{
						VoiceLines.Add(voiceLineAudioClip);
						Logger.LogInfo((object)("Loaded line '" + ((Object)voiceLineAudioClip).name + "'!"));
					}
				}
			}
			yield break;
		}

		private static AudioClip? LoadAudioClipFromFile(Uri filePath, string name)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(filePath, (AudioType)20);
			try
			{
				UnityWebRequestAsyncOperation val = audioClip.SendWebRequest();
				while (!((AsyncOperation)val).isDone)
				{
					Thread.Sleep(100);
				}
				if ((int)audioClip.result != 1)
				{
					Logger.LogError((object)("Failed to load AudioClip: " + audioClip.error));
					return null;
				}
				AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip);
				((Object)content).name = name;
				return content;
			}
			finally
			{
				((IDisposable)audioClip)?.Dispose();
			}
		}

		internal static void HandleGameNetworkManagerStart()
		{
			if (!NetworkManager.Singleton.NetworkConfig.Prefabs.Contains(barrierPrefab))
			{
				NetworkManager.Singleton.AddNetworkPrefab(barrierPrefab);
				Logger.LogInfo((object)"Registered barrierPrefab as network prefab :>");
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "TestAccount666.InverseOnly";

		public const string PLUGIN_NAME = "InverseOnly";

		public const string PLUGIN_VERSION = "2.0.0";
	}
}
namespace InverseOnly.Patches
{
	[HarmonyPatch(typeof(EntranceTeleport))]
	public static class EntranceTeleportPatch
	{
		[HarmonyPatch("FindExitPoint")]
		[HarmonyPrefix]
		private static bool FindExitPointPrefix(EntranceTeleport __instance, ref bool __result)
		{
			if (__instance == null || !__instance.isEntranceToBuilding)
			{
				return true;
			}
			__result = false;
			return false;
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	public static class GameNetworkManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPostfix()
		{
			InverseOnly.HandleGameNetworkManagerStart();
		}
	}
	[HarmonyPatch(typeof(HangarShipDoor))]
	public static class HangarShipDoorPatch
	{
		[HarmonyPatch("SetDoorButtonsEnabled")]
		[HarmonyPrefix]
		private static void SetDoorButtonsEnabledPrefix(HangarShipDoor __instance, bool doorButtonsEnabled)
		{
			if ((((NetworkBehaviour)StartOfRound.Instance).IsHost || ((NetworkBehaviour)StartOfRound.Instance).IsServer) && !StartOfRound.Instance.inShipPhase && !StartOfRound.Instance.suckingPlayersOutOfShip)
			{
				SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
				if (currentLevel != null && currentLevel.planetHasTime && !StartOfRound.Instance.shipHasLanded && doorButtonsEnabled)
				{
					InverseOnly.Logger.LogDebug((object)"Starting Teleport Sequence!");
					StartTeleportSequence((Component)(object)__instance);
				}
			}
		}

		private static void StartTeleportSequence(Component hangarShipDoor)
		{
			GameObject val = SpawnBarrier(hangarShipDoor);
			global::InverseOnly.Networking.Barrier barrier = ((val != null) ? val.GetComponent<global::InverseOnly.Networking.Barrier>() : null);
			if (barrier != null)
			{
				PlayRandomVoiceLine(barrier);
				barrier.StartTeleportSequenceClientRpc();
			}
		}

		private static void PlayRandomVoiceLine(global::InverseOnly.Networking.Barrier networkBarrier)
		{
			Random random = InverseOnly.random;
			int clipIndex = random.Next(0, InverseOnly.VoiceLines.Count - 1);
			networkBarrier.PlayVoiceLineClientRpc(clipIndex);
		}

		private static GameObject? SpawnBarrier(Component hangarShipDoor)
		{
			InverseOnly.Logger.LogDebug((object)"Trying to spawn barrier...");
			if (InverseOnly.barrierPrefab == null)
			{
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(InverseOnly.barrierPrefab, hangarShipDoor.transform, true);
			val.GetComponent<NetworkObject>().Spawn(false);
			InverseOnly.Logger.LogDebug((object)"Barrier was spawned!");
			return val;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public static class PlayerControllerBPatch
	{
		[HarmonyPatch("LateUpdate")]
		[HarmonyPostfix]
		private static void LateUpdatePostfix(PlayerControllerB __instance)
		{
			if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.localPlayerController != (Object)(object)__instance)
			{
				return;
			}
			Terminal val = Object.FindObjectOfType<Terminal>();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			UnlockablesList unlockablesList = StartOfRound.Instance.unlockablesList;
			if ((Object)(object)unlockablesList == (Object)null)
			{
				return;
			}
			List<UnlockableItem> unlockables = unlockablesList.unlockables;
			if (unlockables == null)
			{
				return;
			}
			int unlockableId = 0;
			bool foundInverseTeleporter = false;
			UnlockableItem val2 = unlockables.Find(delegate(UnlockableItem item)
			{
				bool valueOrDefault = (item?.unlockableName?.ToLower().Contains("inverse")).GetValueOrDefault();
				if (foundInverseTeleporter || valueOrDefault)
				{
					foundInverseTeleporter = true;
				}
				else
				{
					unlockableId++;
				}
				return valueOrDefault;
			});
			if (foundInverseTeleporter && val2 != null && !val2.hasBeenUnlockedByPlayer)
			{
				StartOfRound.Instance.BuyShipUnlockableServerRpc(unlockableId, val.groupCredits);
			}
		}
	}
}
namespace InverseOnly.Networking
{
	public class Barrier : NetworkBehaviour
	{
		public override void OnNetworkSpawn()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			((NetworkBehaviour)this).OnNetworkSpawn();
			InverseOnly.Logger.LogDebug((object)"Spawned Barrier Network!");
			AutoParentToShip componentInChildren = ((Component)((Component)this).transform).GetComponentInChildren<AutoParentToShip>(true);
			componentInChildren.positionOffset = new Vector3(-7.558f, -0.038f, -6.503f);
			componentInChildren.startingPosition = new Vector3(-7.558f, -0.038f, -6.503f);
			componentInChildren.startingRotation = new Vector3(0f, 0f, -98f);
		}

		public override void OnNetworkDespawn()
		{
			((NetworkBehaviour)this).OnNetworkDespawn();
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		[ClientRpc]
		public void PlayVoiceLineClientRpc(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(3523249749u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, clipIndex);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3523249749u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					InverseOnly.Logger.LogDebug((object)("Playing clip: " + clipIndex));
					AudioClip clip = InverseOnly.VoiceLines[clipIndex];
					AudioSource speakerAudioSource = StartOfRound.Instance.speakerAudioSource;
					speakerAudioSource.PlayOneShot(StartOfRound.Instance.disableSpeakerSFX);
					speakerAudioSource.clip = clip;
					speakerAudioSource.Play();
				}
			}
		}

		[ClientRpc]
		public void StartTeleportSequenceClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1617458149u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1617458149u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					InverseOnly.Logger.LogDebug((object)"Received Teleport Sequence Rpc!");
					((MonoBehaviour)this).StartCoroutine(TeleportSequence());
				}
			}
		}

		private IEnumerator TeleportSequence()
		{
			PlayerControllerB localPlayer = StartOfRound.Instance.localPlayerController;
			AudioSource speakerAudioSource = StartOfRound.Instance.speakerAudioSource;
			float length = GetClipLength() - 0.5f;
			yield return (object)new WaitUntil((Func<bool>)delegate
			{
				InverseOnly.Logger.LogDebug((object)(speakerAudioSource.time + " -> " + length));
				return !speakerAudioSource.isPlaying || speakerAudioSource.time >= length;
			});
			localPlayer.beamOutBuildupParticle.Play();
			yield return (object)new WaitForSeconds(1f);
			PerformTeleport(localPlayer);
			if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer)
			{
				yield return (object)new WaitForSeconds(2f);
				DespawnBarrier();
			}
		}

		private void DespawnBarrier()
		{
			((Component)this).GetComponent<NetworkObject>().Despawn(true);
			InverseOnly.Logger.LogDebug((object)"Barrier Destroyed!");
		}

		private static float GetClipLength()
		{
			return StartOfRound.Instance.speakerAudioSource.clip.length;
		}

		private void PerformTeleport(PlayerControllerB localPlayer)
		{
			InverseOnly.Logger.LogDebug((object)"Initiating teleport!");
			if (InverseOnly.configManager.dropAllItems.Value)
			{
				localPlayer.DropAllHeldItemsAndSync();
			}
			TeleportPlayer(localPlayer);
			((MonoBehaviour)this).StartCoroutine(InvulnerabilityCoroutine());
		}

		private static void TeleportPlayer(PlayerControllerB localPlayer)
		{
			//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_003c: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			GameObject[] insideAINodes = RoundManager.Instance.insideAINodes;
			if (insideAINodes.Length == 0)
			{
				return;
			}
			Vector3 position = insideAINodes[InverseOnly.random.Next(0, insideAINodes.Length)].transform.position;
			RoundManager instance = RoundManager.Instance;
			Random random = InverseOnly.random;
			Vector3 randomNavMeshPositionInBoxPredictable = instance.GetRandomNavMeshPositionInBoxPredictable(position, 10f, default(NavMeshHit), random, -1);
			localPlayer.TeleportPlayer(randomNavMeshPositionInBoxPredictable, false, 0f, false, true);
			localPlayer.beamOutParticle.Play();
			HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			AudioReverbPresets val = Object.FindObjectOfType<AudioReverbPresets>();
			if (Object.op_Implicit((Object)(object)val))
			{
				val.audioPresets[2].ChangeAudioReverbForPlayer(localPlayer);
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val2 in allPlayerScripts)
			{
				if (val2 != null && val2.isPlayerControlled && !val2.isPlayerDead)
				{
					ResetPlayerState(val2);
				}
			}
		}

		private static void ResetPlayerState(PlayerControllerB player)
		{
			player.isInElevator = false;
			player.isInHangarShipRoom = false;
			player.isInsideFactory = true;
			GrabbableObject[] itemSlots = player.ItemSlots;
			foreach (GrabbableObject val in itemSlots)
			{
				if (val != null)
				{
					val.isInFactory = true;
				}
			}
		}

		private static IEnumerator InvulnerabilityCoroutine()
		{
			InverseOnly.Logger.LogDebug((object)"Player is now invulnerable!");
			StartOfRound.Instance.allowLocalPlayerDeath = false;
			yield return (object)new WaitForSeconds(1f);
			StartOfRound.Instance.allowLocalPlayerDeath = true;
			InverseOnly.Logger.LogDebug((object)"Player is no longer invulnerable!");
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_Barrier()
		{
			//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(3523249749u, new RpcReceiveHandler(__rpc_handler_3523249749));
			NetworkManager.__rpc_func_table.Add(1617458149u, new RpcReceiveHandler(__rpc_handler_1617458149));
		}

		private static void __rpc_handler_3523249749(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;
				((Barrier)(object)target).PlayVoiceLineClientRpc(clipIndex);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1617458149(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)2;
				((Barrier)(object)target).StartTeleportSequenceClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "Barrier";
		}
	}
}
namespace InverseOnly.Dependencies
{
	internal static class DependencyChecker
	{
		internal static bool IsLobbyCompatibilityInstalled()
		{
			return Chainloader.PluginInfos.Values.Any((PluginInfo metadata) => metadata.Metadata.GUID.Contains("LobbyCompatibility"));
		}
	}
	internal static class LobbyCompatibilitySupport
	{
		internal static void Initialize()
		{
			PluginHelper.RegisterPlugin("TestAccount666.InverseOnly", new Version("2.0.0"), (CompatibilityLevel)2, (VersionStrictness)2);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace TestAccount666.InverseOnly.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}