Decompiled source of Super Ultimate Inverse Teleporter Gambit v1.0.0

BepInEx/plugins/superultimateinverseteleportergambit.dll

Decompiled 2 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.AI;

[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("superultimateinverseteleportergambit")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Super Ultimate Inverse Teleporter Gambit")]
[assembly: AssemblyTitle("superultimateinverseteleportergambit")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 Super_Ultimate_Inverse_Teleporter_Gambit
{
	[BepInPlugin("superultimateinverseteleportergambit", "Super Ultimate Inverse Teleporter Gambit", "1.0.0")]
	public class Super_Ultimate_Inverse_Teleporter_Gambit : BaseUnityPlugin
	{
		internal static ConfigEntry<int> MaxInverses;

		internal static ConfigEntry<bool> LimitInverses;

		internal static ConfigEntry<float> PreventInverseRevivesAfterTime;

		public static Super_Ultimate_Inverse_Teleporter_Gambit Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			LimitInverses = ((BaseUnityPlugin)this).Config.Bind<bool>("Super Ultimate Inverse Teleporter Gambit", "Limit Inverse Revives", true, (ConfigDescription)null);
			MaxInverses = ((BaseUnityPlugin)this).Config.Bind<int>("Super Ultimate Inverse Teleporter Gambit", "Max Inverse Revives", 3, (ConfigDescription)null);
			PreventInverseRevivesAfterTime = ((BaseUnityPlugin)this).Config.Bind<float>("Super Ultimate Inverse Teleporter Gambit", "Prevent Inverse Revives After Time", 0.9f, new ConfigDescription("0 is start of day, 1 is end of day.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			Patch();
			Logger.LogInfo((object)"superultimateinverseteleportergambit v1.0.0 has loaded!");
		}

		internal 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("superultimateinverseteleportergambit");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching! prepare for just soooo much teleportation, like gargantuan amounts ofg it its insaene really its sooooo craazyyyyyy what the heeeeellllllll wgatttt/????? what poob");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "StartGame")]
	internal static class ResetRevives
	{
		internal static void Prefix()
		{
			DoTheThing.currentTps = 0;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
	internal static class DoTheThing
	{
		public static int currentTps;

		internal static bool Prefix(PlayerControllerB __instance)
		{
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			ShipTeleporter[] array = Object.FindObjectsByType<ShipTeleporter>((FindObjectsSortMode)0);
			Debug.Log((object)"PatchIsWorking");
			ShipTeleporter val = null;
			ShipTeleporter[] array2 = array;
			foreach (ShipTeleporter val2 in array2)
			{
				if (val2.isInverseTeleporter)
				{
					val = val2;
				}
			}
			if ((Super_Ultimate_Inverse_Teleporter_Gambit.LimitInverses.Value && currentTps >= Super_Ultimate_Inverse_Teleporter_Gambit.MaxInverses.Value) || Super_Ultimate_Inverse_Teleporter_Gambit.PreventInverseRevivesAfterTime.Value < TimeOfDay.Instance.currentDayTime / TimeOfDay.Instance.totalTime)
			{
				return true;
			}
			if ((Object)(object)val != (Object)null && Object.op_Implicit((Object)(object)__instance))
			{
				Debug.Log((object)"YouGotTheInverse");
				int num = 1537;
				int num2 = 1375734017;
				int num3 = Mathf.Min(12, RoundManager.Instance.insideAINodes.Length);
				Vector3 val3 = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
				NavMeshHit val4 = default(NavMeshHit);
				Vector3 val5 = default(Vector3);
				Ray val6 = default(Ray);
				RaycastHit val7 = default(RaycastHit);
				for (int j = 0; j < num3; j++)
				{
					if (j != 0)
					{
						val3 = RoundManager.Instance.insideAINodes[Random.Range(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
					}
					val3 = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(val3, 10f, default(NavMeshHit), new Random(StartOfRound.Instance.randomMapSeed + 17 + (int)GameNetworkManager.Instance.localPlayerController.playerClientId), num, 1f);
					if (!RoundManager.Instance.GotNavMeshPositionResult || !NavMesh.FindClosestEdge(val3, ref val4, num))
					{
						continue;
					}
					if (((NavMeshHit)(ref val4)).position == val3)
					{
						((Vector3)(ref val5))..ctor(RoundManager.Instance.randomPositionInBoxRadius.x, ((NavMeshHit)(ref val4)).position.y, RoundManager.Instance.randomPositionInBoxRadius.z);
						((Ray)(ref val6))..ctor(((NavMeshHit)(ref val4)).position + Vector3.up * 0.5f, ((NavMeshHit)(ref val4)).position - val5);
					}
					else
					{
						((Ray)(ref val6))..ctor(((NavMeshHit)(ref val4)).position + Vector3.up * 0.5f, val3 - ((NavMeshHit)(ref val4)).position);
					}
					if (Physics.Raycast(val6, ref val7, 5f, num2, (QueryTriggerInteraction)1))
					{
						if (((RaycastHit)(ref val7)).distance >= 0.35f)
						{
							val3 = RoundManager.Instance.GetNavMeshPosition(((Ray)(ref val6)).GetPoint(((RaycastHit)(ref val7)).distance / 2f), default(NavMeshHit), 2f, num);
							break;
						}
						((Ray)(ref val6)).origin = ((Ray)(ref val6)).origin + Vector3.Normalize(((Ray)(ref val6)).direction * 1000f) * 0.4f;
						if (!Physics.Raycast(val6, ref val7, 5f, num2, (QueryTriggerInteraction)1))
						{
							val3 = RoundManager.Instance.GetNavMeshPosition(((Ray)(ref val6)).GetPoint(2.5f), default(NavMeshHit), 2f, num);
							break;
						}
						if (((RaycastHit)(ref val7)).distance > 0.35f)
						{
							val3 = RoundManager.Instance.GetNavMeshPosition(((Ray)(ref val6)).GetPoint(((RaycastHit)(ref val7)).distance / 2f), default(NavMeshHit), 2f, num);
							break;
						}
					}
					val3 = RoundManager.Instance.GetNavMeshPosition(((Ray)(ref val6)).GetPoint(2.5f), default(NavMeshHit), 2f, num);
				}
				Debug.Log((object)"AttemptingTp");
				Debug.Log((object)val3);
				val.TeleportPlayerOutWithInverseTeleporter((int)__instance.playerClientId, val3);
				currentTps++;
				return false;
			}
			return true;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "superultimateinverseteleportergambit";

		public const string PLUGIN_NAME = "Super Ultimate Inverse Teleporter Gambit";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}