using 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 GlobalSettings; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("None")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2020")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0.0+10b3fd1f52a5e89ecc52054247c20a66ecdad1fd")] [assembly: AssemblyProduct("AlwaysCompass")] [assembly: AssemblyTitle("AlwaysCompass")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AlwaysCompass { public static class Extensions { public static void Nop(this IReadOnlyList il, int index) { il.Nop(index, index); } public static void Nop(this IReadOnlyList il, int start, int end) { for (int i = start; i <= end; i++) { il[i].opcode = OpCodes.Nop; il[i].operand = null; } } } [BepInPlugin("greg.AlwaysCompass", "Always Compass", "1.0.0.0")] [UsedImplicitly] public class Plugin : BaseUnityPlugin { private const string UUID = "greg.AlwaysCompass"; public const BindingFlags FLAGS = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static ManualLogSource logSource; [UsedImplicitly] public void Awake() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) logSource = ((BaseUnityPlugin)this).Logger; Log((LogLevel)16, "greg.AlwaysCompass loaded."); Harmony val = new Harmony("greg.AlwaysCompass"); val.PatchAll(); foreach (MethodBase patchedMethod in val.GetPatchedMethods()) { Log((LogLevel)16, $"Patched: {patchedMethod.DeclaringType?.FullName}:{patchedMethod}"); } Log((LogLevel)16, "greg.AlwaysCompass patching done."); } public static void Log(LogLevel level, string msg) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) logSource.Log(level, (object)msg); } } } namespace AlwaysCompass.Patches { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [UsedImplicitly] public class AlwaysCompass1 { [HarmonyPrefix] [UsedImplicitly] public static bool Prefix(ref ToolItem __instance, ref bool __result) { if (IsToolForceEquipped(__instance)) { __result = true; return false; } return true; } public static bool IsToolForceEquipped(ToolItem tool) { return (Object)(object)tool == (Object)(object)Gameplay.CompassTool; } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [UsedImplicitly] public class AlwaysCompass2 { [HarmonyPrefix] [UsedImplicitly] public static bool Prefix(ref ToolStatus __instance, ref bool __result) { if (AlwaysCompass1.IsToolForceEquipped(__instance.tool)) { __result = true; return false; } return true; } } }