Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ACompass revived v1.3.2
ACompass.dll
Decompiled 10 months agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using ACompass.NetcodePatcher; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Friskzips.patch; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.UI; [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: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: AssemblyCompany("ACompass")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.3.0")] [assembly: AssemblyInformationalVersion("1.0.3-alpha.0.2+8b2da66df728d4504593eb40d1802a75a0321995")] [assembly: AssemblyProduct("ACompass")] [assembly: AssemblyTitle("ACompass")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } 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 Friskzips { public class LethalConfigCompatibility { private static bool? _enabled; public static bool enabled { get { if (!_enabled.HasValue) { _enabled = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); } return _enabled.Value; } } internal static void initLethalConfig() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown EnumDropDownConfigItem<Plugin.configHudPosition> val = new EnumDropDownConfigItem<Plugin.configHudPosition>(Plugin.position, new EnumDropDownOptions { RequiresRestart = false }); ConfigEntry<int> x_offset = Plugin.x_offset; IntSliderOptions val2 = new IntSliderOptions(); ((BaseRangeOptions<int>)val2).Min = -100; ((BaseRangeOptions<int>)val2).Max = 100; ((BaseOptions)val2).RequiresRestart = false; IntSliderConfigItem val3 = new IntSliderConfigItem(x_offset, val2); BoolCheckBoxConfigItem val4 = new BoolCheckBoxConfigItem(Plugin.oldTexture, new BoolCheckBoxOptions { RequiresRestart = false }); BoolCheckBoxConfigItem val5 = new BoolCheckBoxConfigItem(Plugin.alignToShipRadar, new BoolCheckBoxOptions { RequiresRestart = false }); BoolCheckBoxConfigItem val6 = new BoolCheckBoxConfigItem(Plugin.hideWhenInOrbit, new BoolCheckBoxOptions { RequiresRestart = false }); BoolCheckBoxConfigItem val7 = new BoolCheckBoxConfigItem(Plugin.hideWhenInside, new BoolCheckBoxOptions { RequiresRestart = false }); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val5); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val7); LethalConfigManager.SetModDescription("Original mod by alekso56"); LethalConfigManager.SkipAutoGen(); } } [BepInPlugin("Friskzips.ACompass", "ACompass revived", "1.3.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public enum configHudPosition { Bottom, Top } private readonly Harmony _harmony = new Harmony("Friskzips.ACompass"); public static Plugin Instance { get; set; } public static ConfigEntry<int> x_offset { get; private set; } public static ConfigEntry<configHudPosition> position { get; private set; } public static ConfigEntry<bool> oldTexture { get; private set; } public static ConfigEntry<bool> alignToShipRadar { get; private set; } public static ConfigEntry<bool> hideWhenInOrbit { get; private set; } public static ConfigEntry<bool> hideWhenInside { get; private set; } public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger; public Plugin() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown Instance = this; } private void Awake() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0079: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00aa: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00db: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_010c: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown //IL_013d: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_016e: Expected O, but got Unknown Log.LogInfo((object)"Applying patches..."); ApplyPluginPatch(); Log.LogInfo((object)"Patches applied!"); Log.LogInfo((object)"Loading assets..."); Friskzips.patch.ACompass.loadAssets(); Log.LogInfo((object)"Loading config..."); position = ((BaseUnityPlugin)this).Config.Bind<configHudPosition>(new ConfigDefinition("Hud", "Position"), configHudPosition.Bottom, new ConfigDescription("The compass position it can be Bottom or Top.\nDefault: Bottom", (AcceptableValueBase)null, Array.Empty<object>())); x_offset = ((BaseUnityPlugin)this).Config.Bind<int>(new ConfigDefinition("Hud", "X-axis offset"), 0, new ConfigDescription("The position of the compass on the x-axis", (AcceptableValueBase)null, Array.Empty<object>())); oldTexture = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Hud", "Old texture"), false, new ConfigDescription("If you want the old texture of the original mod.\nDefault: False", (AcceptableValueBase)null, Array.Empty<object>())); alignToShipRadar = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Hud", "Align to the ship monitor"), true, new ConfigDescription("If you want the compass to align to the ship monitor.\nDefault: True", (AcceptableValueBase)null, Array.Empty<object>())); hideWhenInOrbit = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Hud", "Hide when in orbit"), true, new ConfigDescription("If you want the compass to be hidden in orbit.\nDefault: True", (AcceptableValueBase)null, Array.Empty<object>())); hideWhenInside = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Hud", "Hide when inside the dungeon"), true, new ConfigDescription("If you want the compass to be hidden inside the dungeon.\nDefault: True", (AcceptableValueBase)null, Array.Empty<object>())); Log.LogInfo((object)"Config loaded!"); Log.LogDebug((object)"Looking for lethal config..."); if (LethalConfigCompatibility.enabled) { Log.LogInfo((object)"LethalConfig found!"); LethalConfigCompatibility.initLethalConfig(); } Log.LogInfo((object)"ACompass revived loaded!"); Log.LogInfo((object)"Original mod by alekso56"); } private void ApplyPluginPatch() { _harmony.PatchAll(typeof(Friskzips.patch.ACompass)); } } public static class PluginInfo { public const string PLUGIN_GUID = "Friskzips.ACompass"; public const string PLUGIN_NAME = "ACompass revived"; public const string PLUGIN_VERSION = "1.3.2"; } } namespace Friskzips.patch { internal class ACompass : MonoBehaviour { public class CompassUpdater : MonoBehaviour { public RawImage CompassImage; public Transform toFollow; private RawImage m_RawImage; private readonly Texture m_TextureOld = (Texture)(object)CompassAssets.LoadAsset<Texture2D>("compass_shifted"); private readonly Texture m_Texture = (Texture)(object)CompassAssets.LoadAsset<Texture2D>("compass_shifted2"); public void setFollow(Transform user) { toFollow = user; } private void LateUpdate() { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: 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_01bb: Unknown result type (might be due to invalid IL or missing references) UpdateCompassHeading(); if (oldTexture != Plugin.oldTexture.Value || !firstTimeTexture) { oldTexture = Plugin.oldTexture.Value; firstTimeTexture = true; if (!Plugin.oldTexture.Value) { CompassImage.texture = m_Texture; } if (Plugin.oldTexture.Value) { CompassImage.texture = m_TextureOld; } } rt = ((Component)this).GetComponent<RectTransform>(); if (default_x_value == 0) { default_x_value = (int)((Component)this).transform.localPosition.x; } float num = Mathf.Clamp((float)Plugin.x_offset.Value, -100f, 100f); Vector2 anchoredPosition = rt.anchoredPosition; anchoredPosition.x = num; Rect rect = ((RectTransform)((Transform)rt).parent).rect; float width = ((Rect)(ref rect)).width; float x = num / 100f * (width / 2f); Vector2 anchoredPosition2 = rt.anchoredPosition; anchoredPosition2.x = x; rt.anchoredPosition = anchoredPosition2; if (position != (int)Plugin.position.Value) { position = (int)Plugin.position.Value; if (position == 0) { ((Component)this).transform.localPosition = new Vector3(0f, -224.4849f, 0f); } if (position == 1) { ((Component)this).transform.localPosition = new Vector3(0f, 218.5156f, 0f); } Plugin.Log.LogDebug((object)("pos " + ((Component)this).transform.localPosition.x + ", " + ((Component)this).transform.localPosition.y + ", " + ((Component)this).transform.localPosition.z)); Plugin.Log.LogDebug((object)("pos enum " + position)); } } private void UpdateCompassHeading() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if ((Object)GameNetworkManager.Instance == (Object)null || (Object)(GameNetworkManager.Instance.localPlayerController?.turnCompassCamera) == (Object)null) { return; } toFollow = ((Component)GameNetworkManager.Instance.localPlayerController.turnCompassCamera).transform; if (!((Object)CompassImage == (Object)null) && !((Object)toFollow == (Object)null)) { Quaternion val; if (Plugin.alignToShipRadar.Value) { Vector2 right = Vector2.right; Quaternion rotation = toFollow.rotation; val = rotation; Vector2 val2 = right * ((((Quaternion)(ref val)).eulerAngles.y + 45f - 45f) / 360f); CompassImage.uvRect = new Rect(val2, Vector2.one); } else { Vector2 right2 = Vector2.right; Quaternion rotation2 = toFollow.rotation; val = rotation2; Vector2 val3 = right2 * ((((Quaternion)(ref val)).eulerAngles.y - 45f) / 360f); CompassImage.uvRect = new Rect(val3, Vector2.one); } } } } private static CompassUpdater updater; public static AssetBundle CompassAssets; public static bool loaded = false; public static bool oldTexture = false; public static bool firstTimeTexture = false; public static bool spectating = false; public static bool spectatingFirstTime = false; public static bool inside = false; public static int position = 69; public static int default_x_value = 0; public static GameNetworkManager GameNetworkInstance; public static int x_value = 0; public static RectTransform rt; public static GameObject compassObject; public static bool inTerminal = false; public static void loadAssets() { if (!loaded) { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); CompassAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "compass")); if ((Object)(object)CompassAssets == (Object)null) { Plugin.Log.LogError((object)"Failed to load AssetBundle!"); return; } Plugin.Log.LogInfo((object)"AsssetBundle loaded!"); loaded = true; } } [HarmonyPatch(typeof(MenuManager), "OnEnable")] [HarmonyPostfix] public static void resetStuff() { spectatingFirstTime = false; } [HarmonyPatch(typeof(GameNetworkManager), "ConnectionApproval")] [HarmonyPostfix] public static void getNetworkInstance(GameNetworkManager __instance) { GameNetworkInstance = __instance; } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] public static void getPlayerData(PlayerControllerB __instance) { inTerminal = __instance.inTerminalMenu; inside = __instance.isInsideFactory; if (((NetworkBehaviour)__instance).IsClient) { spectating = __instance.isPlayerControlled; if (!spectatingFirstTime) { Plugin.Log.LogInfo((object)"got the spectating variable"); spectatingFirstTime = true; } } if ((Object)(object)GameNetworkInstance != (Object)null) { if ((Object)(object)GameNetworkInstance.localPlayerController != (Object)null) { if (!spectatingFirstTime) { Plugin.Log.LogInfo((object)"Found GameNetworkInstance.localPlayerController!"); spectatingFirstTime = true; } spectating = GameNetworkInstance.localPlayerController.isPlayerDead; } else { Plugin.Log.LogWarning((object)"Couldn't get GameNetworkInstance.localPlayerController, the mod can't detect when you are in spectator"); } } else if (!((NetworkBehaviour)__instance).IsClient) { Plugin.Log.LogWarning((object)"Couldn't get GameNetworkInstance, the mod can't detect when you are in spectator"); } } [HarmonyPatch(typeof(StartOfRound), "Update")] [HarmonyPostfix] public static void hideCompass(StartOfRound __instance) { if ((Object)(object)compassObject != (Object)null) { if ((__instance.inShipPhase && Plugin.hideWhenInOrbit.Value) || inTerminal || spectating || (inside && Plugin.hideWhenInside.Value)) { compassObject.SetActive(false); } else { compassObject.SetActive(true); } } } [HarmonyPatch(typeof(HUDManager), "Awake")] [HarmonyPostfix] public static void AddCompass(HUDManager __instance) { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) Transform val = __instance.HUDContainer.transform.Find("CompassImage (1)"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } else { Plugin.Log.LogWarning((object)("Couldn't find in \"" + ((object)__instance.HUDContainer)?.ToString() + "\" the CompassImage")); } Transform transform = __instance.HUDContainer.transform; Debug.Log((object)("Attaching compass to :" + (object)transform)); GameObject val2 = CompassAssets.LoadAsset<GameObject>("assets/compass/mask.prefab"); GameObject val3 = Object.Instantiate<GameObject>(val2); val3 = (compassObject = Object.Instantiate<GameObject>(val3, transform)); updater = val3.AddComponent<CompassUpdater>(); updater.CompassImage = ((Component)val3.transform.GetChild(0)).GetComponentInChildren<RawImage>(); Plugin.Log.LogDebug((object)val3.transform.position.y); Transform val4 = val3.transform.Find("Compass"); Transform val5 = ((Component)val4).transform.Find("Indicator"); val5.position = new Vector3(val5.position.x, val5.position.y - 0.017f, val5.position.z); val5.localScale = new Vector3(val5.localScale.x - 0.5f, val5.localScale.y - 0.7f, val5.localScale.z); position = 69; firstTimeTexture = false; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace ACompass.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }