Decompiled source of HighlightMapPaths v3.0.3
HighlightMapPaths.dll
Decompiled 3 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("AtO_HighlightMapPaths")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("AtO_HighlightMapPaths")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("6313b719-7e51-4eae-a554-74446ebc19c8")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace AtO_HighlightMapPaths; [BepInPlugin("com.rjf.ato.highlightmappaths", "Highlight Map Paths", "3.0.3")] public class HighlightMapPaths : BaseUnityPlugin { [HarmonyPatch(typeof(MapManager))] public class MapManager_Patch { public static void GetPaths(Node start, Node end, HashSet<string> visitedNodes, List<string> pathList, List<List<string>> paths) { if (((object)start).Equals((object?)end)) { paths.Add(new List<string>(pathList)); return; } visitedNodes.Add(((Object)start).name); foreach (NodeData item in start.nodeData.NodesConnected.Where((NodeData n) => _availableNodes.Contains(n.NodeId))) { if (!visitedNodes.Contains(item.NodeId) && MapManager.Instance.CanTravelToThisNode(_mapNode[item.NodeId], start)) { pathList.Add(item.NodeId); GetPaths(_mapNode[item.NodeId], end, visitedNodes, pathList, paths); pathList.Remove(item.NodeId); } } visitedNodes.Remove(((Object)start).name); } public static List<List<string>> GetPaths(Node start, Node end) { HashSet<string> visitedNodes = new HashSet<string>(); List<List<string>> list = new List<List<string>>(); List<string> pathList = new List<string> { ((Object)start).name }; GetPaths(start, end, visitedNodes, pathList, list); return list; } public static void DrawArrow(Node _nodeSource, Node _nodeDestination, Color from, Color to) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) string text = _nodeSource.nodeData.NodeId + "-" + _nodeDestination.nodeData.NodeId; if (_roads.ContainsKey(text)) { Transform transform = ((Component)Object.Instantiate<Transform>(_roads[text], _roads[text].parent)).transform; ((Component)transform).gameObject.SetActive(true); LineRenderer component = ((Component)transform).GetComponent<LineRenderer>(); component.startColor = from; component.endColor = to; string text2 = Guid.NewGuid().ToString(); _roads[text + text2] = transform; _roadTemp.Add(text + text2); } } [HarmonyPatch("DrawArrowsTemp")] [HarmonyPostfix] public static void DrawArrowsTemp(ref MapManager __instance, Node _nodeSource) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) __instance.HideArrowsTemp(_nodeSource); ManualLogSource val = Logger.CreateLogSource("DrawArrowsTemp"); _mapNode = mapNode.GetValue(__instance) as Dictionary<string, Node>; _roads = roads.GetValue(__instance) as Dictionary<string, Transform>; _roadTemp = roadTemp.GetValue(__instance) as List<string>; _availableNodes = availableNodes.GetValue(__instance) as List<string>; object? value = availableNodes.GetValue(__instance); _tmpRoads = (Transform)((value is Transform) ? value : null); Node start = _mapNode[AtOManager.Instance.currentMapNode]; List<List<string>> paths = GetPaths(start, _nodeSource); for (int i = 0; i < paths.Count; i++) { List<string> list = paths[i]; Color mapArrowTemp = Globals.Instance.MapArrowTemp; ColorUtility.TryParseHtmlString(COLOR_CODES[i % COLOR_CODES.Length], ref mapArrowTemp); val.LogInfo((object)string.Format("Paths ({0}) {1}: {2}", COLOR_CODES[i % COLOR_CODES.Length], i, string.Join(" → ", list.Select((string p) => _mapNode[p].nodeData.NodeName + "[" + p + "]")))); for (int j = 0; j < list.Count - 1; j++) { Node nodeSource = _mapNode[list[j]]; Node nodeDestination = _mapNode[list[j + 1]]; DrawArrow(nodeSource, nodeDestination, mapArrowTemp, mapArrowTemp); } } } } public const string PLUGIN_GUID = "com.rjf.ato.highlightmappaths"; public static readonly string[] COLOR_CODES = new string[5] { "#75fbff", "#ff2fc7", "#8cff86", "#ffae62", "#d634ff" }; private static FieldInfo mapNode = typeof(MapManager).GetField("mapNode", BindingFlags.Instance | BindingFlags.NonPublic); private static Dictionary<string, Node> _mapNode; private static FieldInfo roads = typeof(MapManager).GetField("roads", BindingFlags.Instance | BindingFlags.NonPublic); private static Dictionary<string, Transform> _roads; private static FieldInfo roadTemp = typeof(MapManager).GetField("roadTemp", BindingFlags.Instance | BindingFlags.NonPublic); private static List<string> _roadTemp; private static FieldInfo availableNodes = typeof(MapManager).GetField("availableNodes", BindingFlags.Instance | BindingFlags.NonPublic); private static List<string> _availableNodes; private static FieldInfo tmpRoads = typeof(MapManager).GetField("tmpRoads", BindingFlags.Instance | BindingFlags.NonPublic); private static Transform _tmpRoads; private static Dictionary<string, Transform> roadsToRemove; public void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("com.rjf.ato.highlightmappaths"); val.PatchAll(); } }
plugins/HighlightMapPaths/HighlightMapPaths.dll
Decompiled 3 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("AtO_HighlightMapPaths")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("AtO_HighlightMapPaths")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("6313b719-7e51-4eae-a554-74446ebc19c8")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace AtO_HighlightMapPaths; [BepInPlugin("com.rjf.ato.highlightmappaths", "Highlight Map Paths", "3.0.3")] public class HighlightMapPaths : BaseUnityPlugin { [HarmonyPatch(typeof(MapManager))] public class MapManager_Patch { public static void GetPaths(Node start, Node end, HashSet<string> visitedNodes, List<string> pathList, List<List<string>> paths) { if (((object)start).Equals((object?)end)) { paths.Add(new List<string>(pathList)); return; } visitedNodes.Add(((Object)start).name); foreach (NodeData item in start.nodeData.NodesConnected.Where((NodeData n) => _availableNodes.Contains(n.NodeId))) { if (!visitedNodes.Contains(item.NodeId) && MapManager.Instance.CanTravelToThisNode(_mapNode[item.NodeId], start)) { pathList.Add(item.NodeId); GetPaths(_mapNode[item.NodeId], end, visitedNodes, pathList, paths); pathList.Remove(item.NodeId); } } visitedNodes.Remove(((Object)start).name); } public static List<List<string>> GetPaths(Node start, Node end) { HashSet<string> visitedNodes = new HashSet<string>(); List<List<string>> list = new List<List<string>>(); List<string> pathList = new List<string> { ((Object)start).name }; GetPaths(start, end, visitedNodes, pathList, list); return list; } public static void DrawArrow(Node _nodeSource, Node _nodeDestination, Color from, Color to) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) string text = _nodeSource.nodeData.NodeId + "-" + _nodeDestination.nodeData.NodeId; if (_roads.ContainsKey(text)) { Transform transform = ((Component)Object.Instantiate<Transform>(_roads[text], _roads[text].parent)).transform; ((Component)transform).gameObject.SetActive(true); LineRenderer component = ((Component)transform).GetComponent<LineRenderer>(); component.startColor = from; component.endColor = to; string text2 = Guid.NewGuid().ToString(); _roads[text + text2] = transform; _roadTemp.Add(text + text2); } } [HarmonyPatch("DrawArrowsTemp")] [HarmonyPostfix] public static void DrawArrowsTemp(ref MapManager __instance, Node _nodeSource) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) __instance.HideArrowsTemp(_nodeSource); ManualLogSource val = Logger.CreateLogSource("DrawArrowsTemp"); _mapNode = mapNode.GetValue(__instance) as Dictionary<string, Node>; _roads = roads.GetValue(__instance) as Dictionary<string, Transform>; _roadTemp = roadTemp.GetValue(__instance) as List<string>; _availableNodes = availableNodes.GetValue(__instance) as List<string>; object? value = availableNodes.GetValue(__instance); _tmpRoads = (Transform)((value is Transform) ? value : null); Node start = _mapNode[AtOManager.Instance.currentMapNode]; List<List<string>> paths = GetPaths(start, _nodeSource); for (int i = 0; i < paths.Count; i++) { List<string> list = paths[i]; Color mapArrowTemp = Globals.Instance.MapArrowTemp; ColorUtility.TryParseHtmlString(COLOR_CODES[i % COLOR_CODES.Length], ref mapArrowTemp); val.LogInfo((object)string.Format("Paths ({0}) {1}: {2}", COLOR_CODES[i % COLOR_CODES.Length], i, string.Join(" → ", list.Select((string p) => _mapNode[p].nodeData.NodeName + "[" + p + "]")))); for (int j = 0; j < list.Count - 1; j++) { Node nodeSource = _mapNode[list[j]]; Node nodeDestination = _mapNode[list[j + 1]]; DrawArrow(nodeSource, nodeDestination, mapArrowTemp, mapArrowTemp); } } } } public const string PLUGIN_GUID = "com.rjf.ato.highlightmappaths"; public static readonly string[] COLOR_CODES = new string[5] { "#75fbff", "#ff2fc7", "#8cff86", "#ffae62", "#d634ff" }; private static FieldInfo mapNode = typeof(MapManager).GetField("mapNode", BindingFlags.Instance | BindingFlags.NonPublic); private static Dictionary<string, Node> _mapNode; private static FieldInfo roads = typeof(MapManager).GetField("roads", BindingFlags.Instance | BindingFlags.NonPublic); private static Dictionary<string, Transform> _roads; private static FieldInfo roadTemp = typeof(MapManager).GetField("roadTemp", BindingFlags.Instance | BindingFlags.NonPublic); private static List<string> _roadTemp; private static FieldInfo availableNodes = typeof(MapManager).GetField("availableNodes", BindingFlags.Instance | BindingFlags.NonPublic); private static List<string> _availableNodes; private static FieldInfo tmpRoads = typeof(MapManager).GetField("tmpRoads", BindingFlags.Instance | BindingFlags.NonPublic); private static Transform _tmpRoads; private static Dictionary<string, Transform> roadsToRemove; public void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("com.rjf.ato.highlightmappaths"); val.PatchAll(); } }