Decompiled source of SneakyTP v1.0.0

plugins/SneakyTP/SneakyTP.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 Fusion;
using Helpers.Collections;
using Microsoft.CodeAnalysis;
using On;
using SneakyTP.Patchs;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("SneakyTP")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c2aa5d0f95d7b37c753723a73557d872fd6ae7f6")]
[assembly: AssemblyProduct("SneakyTP")]
[assembly: AssemblyTitle("SneakyTP")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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 SneakyTP
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("LloydHawkeye.SneakyTP", "SneakyTP", "1.0.0")]
	[BepInProcess("Lycans.exe")]
	public class SneakyTP : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "LloydHawkeye.SneakyTP";

		public const string PLUGIN_AUTHOR = "LloydHawkeye";

		public const string PLUGIN_NAME = "SneakyTP";

		public const string PLUGIN_VERSION = "1.0.0";

		private void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			PlayerEffectsManagerPatcher.Patch();
			PortalPatcher.Patch();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SneakyTP";

		public const string PLUGIN_NAME = "SneakyTP";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace SneakyTP.Patchs
{
	internal class PlayerEffectsManagerPatcher
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_CheckTeleportation <0>__PlayerEffectsManager_CheckTeleportation;
		}

		public static void Patch()
		{
			//IL_0011: 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_001c: Expected O, but got Unknown
			object obj = <>O.<0>__PlayerEffectsManager_CheckTeleportation;
			if (obj == null)
			{
				hook_CheckTeleportation val = PlayerEffectsManager_CheckTeleportation;
				<>O.<0>__PlayerEffectsManager_CheckTeleportation = val;
				obj = (object)val;
			}
			PlayerEffectsManager.CheckTeleportation += (hook_CheckTeleportation)obj;
		}

		private static void PlayerEffectsManager_CheckTeleportation(orig_CheckTeleportation orig, PlayerEffectsManager self)
		{
			//IL_0021: 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)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			if (!((SimulationBehaviour)self).HasStateAuthority)
			{
				return;
			}
			TickTimer teleportationTimer = self.TeleportationTimer;
			if (!((TickTimer)(ref teleportationTimer)).Expired(((SimulationBehaviour)self).Runner) || NetworkBool.op_Implicit(self._playerController.IsDead))
			{
				return;
			}
			float num;
			if (((IEnumerable<KeyValuePair<PlayerRef, Vector3>>)(object)self.PlayerPositions).Any())
			{
				Dictionary<PlayerController, Vector3> dictionary = new Dictionary<PlayerController, Vector3>();
				Enumerator<PlayerRef, Vector3> enumerator = self.PlayerPositions.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						KeyValuePair<PlayerRef, Vector3> current = enumerator.Current;
						PlayerController player = PlayerRegistry.GetPlayer(current.Key);
						if ((Object)(object)player != (Object)null)
						{
							Vector3 position = ((Component)player).transform.position;
							Vector3 oldPosition = current.Value;
							if (!PlayerRegistry.Any((Predicate<PlayerController>)((PlayerController p) => Vector3.Distance(((Component)p).transform.position, oldPosition) < 0.5f)) && Vector3.Distance(position, oldPosition) >= 0.5f)
							{
								dictionary.Add(player, oldPosition);
							}
						}
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
				if (dictionary.Any())
				{
					PlayerController val = CollectionsUtil.Grab<PlayerController>(dictionary.Keys.ToList(), 1).First();
					Vector3 val2 = dictionary[val];
					Quaternion val3 = ((Component)self._playerController).transform.rotation;
					if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).transform != (Object)null)
					{
						Vector3 val4 = ((Component)val).transform.position - val2;
						val4.y = 0f;
						val3 = Quaternion.LookRotation(val4);
					}
					GameManager.Rpc_BroadcastFollowSound(((SimulationBehaviour)self).Runner, NetworkString<_16>.op_Implicit("TELEPORT_START"), ((Component)self._playerController).transform.position, 20f, 1f);
					self._playerController.CharacterMovementHandler.TeleportData = new NetworkTeleportData(val2, val3, true);
					self._playerController.IsClimbing = NetworkBool.op_Implicit(false);
					num = Random.Range(5f, 20f);
				}
				else
				{
					num = 0.5f;
				}
				self.PlayerPositions.Clear();
			}
			else
			{
				foreach (PlayerController item in PlayerRegistry.Where((Predicate<PlayerController>)((PlayerController p) => (Object)(object)p != (Object)(object)self._playerController && !NetworkBool.op_Implicit(p.IsDead) && !NetworkBool.op_Implicit(p.IsClimbing) && Vector3.Distance(((Component)self._playerController).transform.position, ((Component)p).transform.position) >= 35f)))
				{
					self.PlayerPositions.Add(item.Ref, ((Component)item).transform.position);
				}
				num = Random.Range(0.1f, 1f);
			}
			self.TeleportationTimer = TickTimer.CreateFromSeconds(((SimulationBehaviour)self).Runner, num);
		}
	}
	internal class PortalPatcher
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OnTriggerEnter <0>__Portal_OnTriggerEnter;
		}

		public static void Patch()
		{
			//IL_0011: 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_001c: Expected O, but got Unknown
			object obj = <>O.<0>__Portal_OnTriggerEnter;
			if (obj == null)
			{
				hook_OnTriggerEnter val = Portal_OnTriggerEnter;
				<>O.<0>__Portal_OnTriggerEnter = val;
				obj = (object)val;
			}
			Portal.OnTriggerEnter += (hook_OnTriggerEnter)obj;
		}

		private static void Portal_OnTriggerEnter(orig_OnTriggerEnter orig, Portal self, Collider other)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkBool.op_Implicit(self.Active))
			{
				return;
			}
			PlayerController component = ((Component)other).gameObject.GetComponent<PlayerController>();
			if ((Object)(object)component != (Object)null && !NetworkBool.op_Implicit(component.IsDead) && ((SimulationBehaviour)self).HasStateAuthority)
			{
				List<Portal> list = (from p in Object.FindObjectsOfType<Portal>().ToList()
					where (Object)(object)p != (Object)(object)self
					select p).ToList();
				if (list.Any())
				{
					self.StartActivationTimer();
					Portal val = CollectionsUtil.Grab<Portal>(list, 1).First();
					val.StartActivationTimer();
					Transform teleportPoint = val.teleportPoint;
					Vector3 position = ((Component)val).transform.position;
					self.Rpc_DisplayLight();
					val.Rpc_DisplayLight();
					GameManager.Rpc_BroadcastFollowSound(((SimulationBehaviour)self).Runner, NetworkString<_16>.op_Implicit("TELEPORT_START"), ((Component)self).transform.position, 30f, 1f);
					component.CharacterMovementHandler.TeleportData = new NetworkTeleportData(teleportPoint.position, teleportPoint.rotation, true);
				}
			}
		}
	}
}