Decompiled source of BestTeleporter v1.0.0
bin/Release/netstandard2.1/BestTeleporter.dll
Decompiled 3 days agousing System; using System.Collections.Generic; using System.Diagnostics; 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 GameNetcodeStuff; 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("BestTeleporter")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A mod that enhances teleporter functionality")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c92bdc2467fea7add4a74f76d14ca55d56b6617d")] [assembly: AssemblyProduct("BestTeleporter")] [assembly: AssemblyTitle("BestTeleporter")] [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 BestTeleporter { [BepInPlugin("BestTeleporter", "BestTeleporter", "1.0.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("BestTeleporter"); private static ManualLogSource mls; private void Awake() { mls = Logger.CreateLogSource("BestTeleporter"); mls.LogInfo((object)"Plugin BestTeleporter has been loaded!"); harmony.PatchAll(typeof(Plugin)); harmony.PatchAll(typeof(TeleporterPatch)); mls.LogInfo((object)"Teleporter item drop prevention and cooldown removal patches have been applied."); } } [HarmonyPatch(typeof(ShipTeleporter))] internal class TeleporterPatch { private static readonly MethodInfo originalMethodInfo = typeof(PlayerControllerB).GetMethod("DropAllHeldItems", BindingFlags.Instance | BindingFlags.Public); private static readonly MethodInfo replaceMethodInfo = typeof(TeleporterPatch).GetMethod("PreventDrop", BindingFlags.Static | BindingFlags.NonPublic); private static readonly CodeMatch[] inverseTeleporterPatchIlMatch = (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdloc(i, (LocalBuilder)null)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 1L)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 0L)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, originalMethodInfo)), (string)null) }; private static readonly CodeMatch[] teleporterPatchIlMatch = (CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdarg(i, (int?)0)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 1L)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 0L)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, originalMethodInfo)), (string)null) }; [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static IEnumerable<CodeInstruction> TeleporterDropAllButHeldItem(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.End(); val.MatchBack(false, teleporterPatchIlMatch); val.Advance(2); val.RemoveInstructionsWithOffsets(0, 2); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4_0, (object)0) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4_1, (object)1) }); val.Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Callvirt, (object)replaceMethodInfo) }); return val.Instructions(); } [HarmonyTranspiler] [HarmonyPatch("TeleportPlayerOutWithInverseTeleporter")] public static IEnumerable<CodeInstruction> InverseTeleporterDropAllButHeldItem(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.Start(); val.MatchForward(false, inverseTeleporterPatchIlMatch); val.Advance(1); val.RemoveInstructionsWithOffsets(0, 2); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4_0, (object)1) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4_1, (object)1) }); val.Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Callvirt, (object)replaceMethodInfo) }); return val.Instructions(); } private static void PreventDrop(PlayerControllerB player, bool inverse = false, bool itemsFall = true) { } [HarmonyPatch("Awake")] [HarmonyPrefix] private static void Awake(ShipTeleporter __instance) { __instance.cooldownAmount = 0f; } } public static class PluginInfo { public const string PLUGIN_GUID = "BestTeleporter"; public const string PLUGIN_NAME = "BestTeleporter"; public const string PLUGIN_VERSION = "1.0.0"; } }
obj/Release/netstandard2.1/BestTeleporter.dll
Decompiled 3 days agousing System; using System.Collections.Generic; using System.Diagnostics; 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 GameNetcodeStuff; 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("BestTeleporter")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A mod that enhances teleporter functionality")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c92bdc2467fea7add4a74f76d14ca55d56b6617d")] [assembly: AssemblyProduct("BestTeleporter")] [assembly: AssemblyTitle("BestTeleporter")] [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 BestTeleporter { [BepInPlugin("BestTeleporter", "BestTeleporter", "1.0.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("BestTeleporter"); private static ManualLogSource mls; private void Awake() { mls = Logger.CreateLogSource("BestTeleporter"); mls.LogInfo((object)"Plugin BestTeleporter has been loaded!"); harmony.PatchAll(typeof(Plugin)); harmony.PatchAll(typeof(TeleporterPatch)); mls.LogInfo((object)"Teleporter item drop prevention and cooldown removal patches have been applied."); } } [HarmonyPatch(typeof(ShipTeleporter))] internal class TeleporterPatch { private static readonly MethodInfo originalMethodInfo = typeof(PlayerControllerB).GetMethod("DropAllHeldItems", BindingFlags.Instance | BindingFlags.Public); private static readonly MethodInfo replaceMethodInfo = typeof(TeleporterPatch).GetMethod("PreventDrop", BindingFlags.Static | BindingFlags.NonPublic); private static readonly CodeMatch[] inverseTeleporterPatchIlMatch = (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdloc(i, (LocalBuilder)null)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 1L)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 0L)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, originalMethodInfo)), (string)null) }; private static readonly CodeMatch[] teleporterPatchIlMatch = (CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdarg(i, (int?)0)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 1L)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 0L)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, originalMethodInfo)), (string)null) }; [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static IEnumerable<CodeInstruction> TeleporterDropAllButHeldItem(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.End(); val.MatchBack(false, teleporterPatchIlMatch); val.Advance(2); val.RemoveInstructionsWithOffsets(0, 2); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4_0, (object)0) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4_1, (object)1) }); val.Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Callvirt, (object)replaceMethodInfo) }); return val.Instructions(); } [HarmonyTranspiler] [HarmonyPatch("TeleportPlayerOutWithInverseTeleporter")] public static IEnumerable<CodeInstruction> InverseTeleporterDropAllButHeldItem(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.Start(); val.MatchForward(false, inverseTeleporterPatchIlMatch); val.Advance(1); val.RemoveInstructionsWithOffsets(0, 2); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4_0, (object)1) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4_1, (object)1) }); val.Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Callvirt, (object)replaceMethodInfo) }); return val.Instructions(); } private static void PreventDrop(PlayerControllerB player, bool inverse = false, bool itemsFall = true) { } [HarmonyPatch("Awake")] [HarmonyPrefix] private static void Awake(ShipTeleporter __instance) { __instance.cooldownAmount = 0f; } } public static class PluginInfo { public const string PLUGIN_GUID = "BestTeleporter"; public const string PLUGIN_NAME = "BestTeleporter"; public const string PLUGIN_VERSION = "1.0.0"; } }