Decompiled source of SilentTeleporter v1.0.4

BepInEx/plugins/SilentTeleporter/SilentTeleporter.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SilentTeleporter")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4+3fdba997c4e89fae33b291c3ca14a4a1e5baa7de")]
[assembly: AssemblyProduct("SilentTeleporter")]
[assembly: AssemblyTitle("SilentTeleporter")]
[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 SilentTeleporter
{
	[BepInPlugin("Dev1A3.SilentTeleporter", "SilentTeleporter", "1.0.0")]
	internal class PluginLoader : BaseUnityPlugin
	{
		internal const string modGUID = "Dev1A3.SilentTeleporter";

		private readonly Harmony harmony = new Harmony("Dev1A3.SilentTeleporter");

		private const string modVersion = "1.0.0";

		private static bool initialized;

		internal static ManualLogSource logSource;

		public static PluginLoader Instance { get; private set; }

		private void Awake()
		{
			if (!initialized)
			{
				initialized = true;
				Instance = this;
				logSource = Logger.CreateLogSource("Dev1A3.SilentTeleporter");
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				harmony.PatchAll(executingAssembly);
				logSource.LogInfo((object)"Loaded SilentTeleporter");
			}
		}
	}
	[HarmonyPatch]
	internal static class TeleportPatch
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyTranspiler]
		public static IEnumerable<CodeInstruction> TranspileMoveNext(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>();
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			foreach (CodeInstruction instruction in instructions)
			{
				if (!flag && instruction.opcode == OpCodes.Call && instruction.operand.ToString() == "Void SetPlayerTeleporterId(GameNetcodeStuff.PlayerControllerB, Int32)")
				{
					flag2 = true;
				}
				else if (!flag && flag2 && instruction.opcode == OpCodes.Ldarg_0)
				{
					flag3 = true;
					flag = true;
				}
				else if (instruction.opcode == OpCodes.Ldstr && instruction.operand.ToString() == "Teleport A")
				{
					flag3 = false;
				}
				if (!flag3)
				{
					list.Add(instruction);
				}
			}
			return list.AsEnumerable();
		}
	}
	internal static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SilentTeleporter";

		public const string PLUGIN_NAME = "SilentTeleporter";

		public const string PLUGIN_VERSION = "1.0.4";
	}
}