Please disclose if your mod was created primarily 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 EasyNavigation v0.3.0
EasyNavigation.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GUIHandler; using GameNetcodeStuff; using HarmonyLib; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("EasyNavigation")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("EasyNavigation")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9b1e2aa8-f654-41ff-b7c4-9ea84f8640bf")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch { private static GameObject trailObject; private static GameObject guiObject; private static TrailRenderer tr; private static ManualLogSource mls; public static bool isPermanentTrailEnabled = false; public static bool showPermanentTrailGUI = false; private static float debounceTime = 0.5f; private static float lastToggleTime = 0f; public static bool showOutsideTrailGUI = false; public static bool isOutsideTrailEnabled = false; public static bool playerInsideHangarShip = false; private static bool lastFramePlayerInsideFactory = false; public static bool trailEnabled; [HarmonyPatch("Awake")] [HarmonyPostfix] private static async void SpawnTrailRenderer() { trailEnabled = EasyNavigation.trailEnabled.Value; if (!trailEnabled) { return; } await WaitSeconds(); mls = Logger.CreateLogSource("BREADFPV.EasyNavigation"); if ((Object)(object)trailObject == (Object)null) { trailObject = new GameObject("TrailObject"); trailObject.transform.parent = ((Component)GameNetworkManager.Instance.localPlayerController.thisPlayerModel).transform; trailObject.transform.localPosition = Vector3.zero; trailObject.transform.localPosition = new Vector3(22.28f, 0.16f, -11.6f); tr = trailObject.AddComponent<TrailRenderer>(); Material trailMaterial = ((Component)tr).GetComponent<Renderer>().material; trailMaterial.EnableKeyword("_EMISSION"); trailMaterial.shader = Shader.Find("HDRP/Lit"); Dictionary<string, Color> namedColors = new Dictionary<string, Color> { { "black", Color.black }, { "blue", Color.blue }, { "clear", Color.clear }, { "cyan", Color.cyan }, { "gray", Color.gray }, { "green", Color.green }, { "grey", Color.grey }, { "magenta", Color.magenta }, { "red", Color.red }, { "white", Color.white }, { "yellow", Color.yellow } }; if (!namedColors.TryGetValue(EasyNavigation.trailColor.Value.ToLower(), out var color)) { ColorUtility.TryParseHtmlString(EasyNavigation.trailColor.Value, ref color); } ManualLogSource obj = mls; Color val = color; obj.LogInfo((object)("Color: " + ((object)(Color)(ref val)).ToString())); trailMaterial.SetColor("_BaseColor", color); trailMaterial.SetColor("_EmissiveColor", color); trailMaterial.SetFloat("_EmissiveIntensity", 4f); trailMaterial.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1; tr.startWidth = EasyNavigation.trailWidth.Value; tr.endWidth = EasyNavigation.trailWidth.Value; tr.time = EasyNavigation.trailDuration.Value; mls.LogInfo((object)"EasyNavigation has loaded the TrailRenderer!"); } if ((Object)(object)guiObject == (Object)null) { guiObject = new GameObject("GUIObject"); guiObject.AddComponent<HandleGUI>(); mls.LogInfo((object)"EasyNavigation has loaded the GUIObject!"); } } [HarmonyPatch("Update")] [HarmonyPostfix] private static async void UpdateLineRenderer() { if (!trailEnabled) { return; } await WaitSeconds(); string permanentTrailBindingKey = EasyNavigation.permanentTrailBinding.Value; Key permanentTrailBindingUserKey; bool validPermanentTrailBindingKey = Enum.TryParse<Key>(permanentTrailBindingKey, ignoreCase: true, out permanentTrailBindingUserKey); string outsideTrailBindingKey = EasyNavigation.outsideTrailBinding.Value; Key outsideTrailBindingUserKey; bool validOutsideTrailBindingKey = Enum.TryParse<Key>(outsideTrailBindingKey, ignoreCase: true, out outsideTrailBindingUserKey); if (Time.time - lastToggleTime > debounceTime) { if (validPermanentTrailBindingKey && ((ButtonControl)Keyboard.current[permanentTrailBindingUserKey]).wasReleasedThisFrame) { isPermanentTrailEnabled = !isPermanentTrailEnabled; lastToggleTime = Time.time; showPermanentTrailGUI = true; } else { showPermanentTrailGUI = false; } if (validOutsideTrailBindingKey && ((ButtonControl)Keyboard.current[outsideTrailBindingUserKey]).wasReleasedThisFrame) { isOutsideTrailEnabled = !isOutsideTrailEnabled; lastToggleTime = Time.time; showOutsideTrailGUI = true; } else { showOutsideTrailGUI = false; } } string clearTrailBindingKey = EasyNavigation.clearTrailBinding.Value; Key clearTrailBindingUserKey; bool validClearTrailBindingKey = Enum.TryParse<Key>(clearTrailBindingKey, ignoreCase: true, out clearTrailBindingUserKey); bool playerInsideFactory = GameNetworkManager.Instance.localPlayerController.isInsideFactory; playerInsideHangarShip = GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom; if (validClearTrailBindingKey && ((ButtonControl)Keyboard.current[clearTrailBindingUserKey]).wasPressedThisFrame) { tr.Clear(); } if (playerInsideHangarShip && !isPermanentTrailEnabled) { tr.Clear(); } if (!isPermanentTrailEnabled && playerInsideFactory != lastFramePlayerInsideFactory) { tr.Clear(); } lastFramePlayerInsideFactory = playerInsideFactory; if (playerInsideFactory) { trailObject.SetActive(true); } else if (isOutsideTrailEnabled && !playerInsideHangarShip) { trailObject.SetActive(true); } else { trailObject.SetActive(false); } if (!isPermanentTrailEnabled && !isOutsideTrailEnabled && !playerInsideFactory) { trailObject.SetActive(false); tr.Clear(); } } private static async Task WaitSeconds() { await Task.Delay(TimeSpan.FromSeconds(3.0)); } } [BepInPlugin("BREADFPV.EasyNavigation", "EasyNavigation", "0.3.0")] public class EasyNavigation : BaseUnityPlugin { public const string modGUID = "BREADFPV.EasyNavigation"; private const string modName = "EasyNavigation"; private const string modVersion = "0.3.0"; public static ConfigEntry<bool> trailEnabled; public static ConfigEntry<float> trailDuration; public static ConfigEntry<string> clearTrailBinding; public static ConfigEntry<string> permanentTrailBinding; public static ConfigEntry<string> outsideTrailBinding; public static ConfigEntry<float> trailWidth; public static ConfigEntry<string> trailColor; private readonly Harmony harmony = new Harmony("BREADFPV.EasyNavigation"); private static EasyNavigation Instance; internal ManualLogSource mls; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("BREADFPV.EasyNavigation"); mls.LogInfo((object)"EasyNavigation has been loaded!"); harmony.PatchAll(typeof(EasyNavigation)); harmony.PatchAll(typeof(PlayerControllerBPatch)); trailEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Trail Enabled", true, "Change whether the trail is enabled or disabled!"); trailDuration = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Trail Duration", 240f, "Adjust how long the trail lasts for!"); clearTrailBinding = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Clear Trail Binding", "i", "Adjust what key is set for clearing the trail!"); permanentTrailBinding = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Permanent Trail Binding", "o", "Adjust what key is set for enabling or disabling the permanent trail bool!"); outsideTrailBinding = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Outside Trail Binding", "p", "Adjust what key is set for enabling or disabling the outside trail bool!"); trailWidth = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Trail Width", 0.1f, "Adjust the width for the trail!"); trailColor = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Trail Color", "magenta", "Adjust what color is used for the trail!"); } } namespace GUIHandler; public class HandleGUI : MonoBehaviour { private void OnGUI() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) string text = ((!PlayerControllerBPatch.isPermanentTrailEnabled) ? "Permanent Trail Disabled!" : "Permanent Trail Enabled!"); string text2 = ((!PlayerControllerBPatch.isOutsideTrailEnabled) ? "Outside Trail Disabled!" : "Outside Trail Enabled!"); if (PlayerControllerBPatch.showPermanentTrailGUI) { GUI.Box(new Rect((float)((Screen.width - 175) / 2), (float)((Screen.height - 30) / 2) / 8.4f, 175f, 30f), text); } if (PlayerControllerBPatch.showOutsideTrailGUI) { GUI.Box(new Rect((float)((Screen.width - 175) / 2), (float)((Screen.height - 30) / 2) / 8.4f, 175f, 30f), text2); } } }