using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInExPlugin; using HarmonyLib; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Frankys Debugger (FrankysDebugger)")] [assembly: AssemblyProduct("Frankys Debugger")] [assembly: AssemblyVersion("1.0.0.0")] namespace BepInExPlugin { [BepInPlugin("FrankysDebugger", "Frankys Debugger", "1.0.0")] public class Plugin : BaseUnityPlugin { public static ConfigEntry DebugValue; private 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("FrankysDebugger"); val.PatchAll(); Debug.Log((object)"FrankysDebugger loaded"); DebugValue = ((BaseUnityPlugin)this).Config.Bind("Debugging", "Node Viewer", false, ""); } } internal static class PluginInfo { public const string PLUGIN_NAME = "Frankys Debugger"; public const string PLUGIN_ID = "FrankysDebugger"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace FrankysDebugger { [HarmonyPatch(typeof(CarrierLayout), "Start")] public static class CarrierGraphDebugPatch { public class BillboardLabel : MonoBehaviour { private void LateUpdate() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Camera.main == (Object)null)) { ((Component)this).transform.rotation = ((Component)Camera.main).transform.rotation; } } } private static Material DebugMaterial; private static Material DebugLineMaterial; private static FieldInfo RegionFieldType = AccessTools.Field(typeof(Region), "_regionType"); private static void Postfix(CarrierLayout __instance) { if (Plugin.DebugValue.Value) { ((MonoBehaviour)__instance).StartCoroutine(DrawGraphDelayed()); } } private static IEnumerator DrawGraphDelayed() { yield return null; DrawGraph(); } private static void DrawGraph() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0086: 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_00b8: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Expected O, but got Unknown //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_0516: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_059c: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("DEBUG_GRAPH_ROOT"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } GameObject val2 = new GameObject("DEBUG_GRAPH_ROOT"); UnitMovementNode[] array = Object.FindObjectsOfType(); List list = new List(); if (array == null || array.Length == 0) { Debug.LogWarning((object)"No UnitMovementNodes found for debug drawing."); return; } if ((Object)(object)DebugMaterial == (Object)null) { DebugMaterial = new Material(Shader.Find("Standard")); DebugMaterial.color = Color.green; } if ((Object)(object)DebugLineMaterial == (Object)null) { DebugLineMaterial = new Material(Shader.Find("Sprites/Default")); DebugLineMaterial.color = Color.green; } HashSet hashSet = new HashSet(); UnitMovementNode[] array2 = array; foreach (UnitMovementNode val3 in array2) { GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)val4).name = "DEBUG_NODE_" + ((Object)val3).name; val4.transform.position = ((Component)val3).transform.position; val4.transform.localScale = Vector3.one * 0.75f; Object.Destroy((Object)(object)val4.GetComponent()); Renderer component = val4.GetComponent(); component.material = DebugMaterial; component.material.color = Color.green; val4.transform.SetParent(val2.transform); GameObject val5 = new GameObject("Label"); val5.transform.SetParent(val4.transform); val5.transform.localPosition = Vector3.up * 1.5f; TextMesh val6 = val5.AddComponent(); val5.AddComponent(); val6.text = ((Object)val3).name; val6.characterSize = 0.4f; val6.fontSize = 32; val6.anchor = (TextAnchor)4; val6.alignment = (TextAlignment)1; val6.color = Color.white; list.Clear(); ((NavigationNode)val3).GetConnections(list); foreach (NavigationConnection item2 in list) { if (item2 == null) { continue; } NavigationNode targetNode = item2.TargetNode; if ((Object)(object)targetNode == (Object)null) { continue; } int instanceID = ((Object)val3).GetInstanceID(); int instanceID2 = ((Object)targetNode).GetInstanceID(); string item = ((instanceID < instanceID2) ? (instanceID + "_" + instanceID2) : (instanceID2 + "_" + instanceID)); if (hashSet.Add(item)) { GameObject val7 = new GameObject("DEBUG_LINE_" + ((Object)val3).name + "_to_" + ((Object)targetNode).name); val7.transform.SetParent(val2.transform); LineRenderer val8 = val7.AddComponent(); ((Renderer)val8).material = DebugMaterial; val8.startColor = Color.green; val8.endColor = Color.green; val8.startWidth = 0.1f; val8.endWidth = 0.1f; val8.alignment = (LineAlignment)0; val8.positionCount = 2; val8.useWorldSpace = true; ((Renderer)val8).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val8).receiveShadows = false; Vector3 val9 = ((Component)val3).transform.position + Vector3.up * 0.3f; Vector3 val10 = ((Component)targetNode).transform.position + Vector3.up * 0.3f; val8.SetPosition(0, val9); val8.SetPosition(1, val10); Debug.Log((object)("Line made from " + ((Object)val3).name + " to " + ((Object)targetNode).name)); if (((Object)val3).name.Contains("Parking") || ((Object)targetNode).name.Contains("Parking")) { ((Renderer)val8).material.color = Color.blue; ((Renderer)val8).material.color = Color.blue; Debug.Log((object)("Set " + ((Object)val7).name + " to blue")); } else if (((Object)val3).name.Contains("Catapult") || ((Object)targetNode).name.Contains("Catapult")) { ((Renderer)val8).material.color = Color.red; ((Renderer)val8).material.color = Color.red; Debug.Log((object)("Set " + ((Object)val7).name + " to red")); } else if (((Object)val3).name.Contains("Repair") || ((Object)targetNode).name.Contains("Repair")) { ((Renderer)val8).material.color = Color.magenta; ((Renderer)val8).material.color = Color.magenta; Debug.Log((object)("Set " + ((Object)val7).name + " to magenta")); } else if (((Object)val3).name.Contains("Helicopter") || ((Object)targetNode).name.Contains("Helicopter")) { ((Renderer)val8).material.color = Color.yellow; ((Renderer)val8).material.color = Color.yellow; Debug.Log((object)("Set " + ((Object)val7).name + " to yellow")); } else if (((Object)val3).name.Contains("Junction") || ((Object)targetNode).name.Contains("Junction")) { ((Renderer)val8).material.color = Color.green; ((Renderer)val8).material.color = Color.green; Debug.Log((object)("Set " + ((Object)val7).name + " to green")); } } } } Debug.Log((object)$"Graph debug complete. Nodes found: {array.Length}"); } } }