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("FrankysDebugger (FrankysDebugger)")] [assembly: AssemblyProduct("FrankysDebugger")] [assembly: AssemblyVersion("1.0.2.0")] [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 GameObject debugRoot; private static void Postfix(CarrierLayout __instance) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown if (FrankysDebugger.DebugValue.Value) { ((MonoBehaviour)__instance).StartCoroutine(DrawGraphDelayed()); GameObject val = new GameObject("Debug_Controller"); val.AddComponent(); } } private static IEnumerator DrawGraphDelayed() { yield return null; DrawGraph(); } public static void ToggleGraph() { if ((Object)(object)debugRoot == (Object)null) { DrawGraph(); } else { debugRoot.SetActive(!debugRoot.activeSelf); } } private static void DrawGraph() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Expected O, but got Unknown //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_05a0: Unknown result type (might be due to invalid IL or missing references) //IL_05b2: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_0623: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)debugRoot != (Object)null) { Object.Destroy((Object)(object)debugRoot); } debugRoot = 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."); Object.Destroy((Object)(object)debugRoot); debugRoot = null; 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 val in array2) { GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)val2).name = "DEBUG_NODE_" + ((Object)val).name; val2.transform.position = ((Component)val).transform.position; val2.transform.localScale = Vector3.one * 0.75f; Object.Destroy((Object)(object)val2.GetComponent()); Renderer component = val2.GetComponent(); component.material = DebugMaterial; component.material.color = Color.green; val2.transform.SetParent(debugRoot.transform); GameObject val3 = new GameObject("Label"); val3.transform.SetParent(val2.transform); val3.transform.localPosition = Vector3.up * 1.5f; TextMesh val4 = val3.AddComponent(); val3.AddComponent(); val4.text = ((Object)val).name; val4.characterSize = 0.4f; val4.fontSize = 32; val4.anchor = (TextAnchor)4; val4.alignment = (TextAlignment)1; val4.color = Color.white; list.Clear(); ((NavigationNode)val).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)val).GetInstanceID(); int instanceID2 = ((Object)targetNode).GetInstanceID(); string item = ((instanceID < instanceID2) ? (instanceID + "_" + instanceID2) : (instanceID2 + "_" + instanceID)); if (hashSet.Add(item)) { GameObject val5 = new GameObject("DEBUG_LINE_" + ((Object)val).name + "_to_" + ((Object)targetNode).name); val5.transform.SetParent(debugRoot.transform); LineRenderer val6 = val5.AddComponent(); ((Renderer)val6).material = DebugMaterial; val6.startColor = Color.green; val6.endColor = Color.green; val6.startWidth = 0.1f; val6.endWidth = 0.1f; val6.alignment = (LineAlignment)0; val6.positionCount = 2; val6.useWorldSpace = true; ((Renderer)val6).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val6).receiveShadows = false; Vector3 val7 = ((Component)val).transform.position + Vector3.up * 0.3f; Vector3 val8 = ((Component)targetNode).transform.position + Vector3.up * 0.3f; val6.SetPosition(0, val7); val6.SetPosition(1, val8); Debug.Log((object)("Line made from " + ((Object)val).name + " to " + ((Object)targetNode).name)); if (((Object)val).name.Contains("Parking") || ((Object)targetNode).name.Contains("Parking")) { ((Renderer)val6).material.color = Color.blue; ((Renderer)val6).material.color = Color.blue; Debug.Log((object)("Set " + ((Object)val5).name + " to blue")); } else if (((Object)val).name.Contains("Catapult") || ((Object)targetNode).name.Contains("Catapult")) { ((Renderer)val6).material.color = Color.red; ((Renderer)val6).material.color = Color.red; Debug.Log((object)("Set " + ((Object)val5).name + " to red")); } else if (((Object)val).name.Contains("Repair") || ((Object)targetNode).name.Contains("Repair")) { ((Renderer)val6).material.color = Color.magenta; ((Renderer)val6).material.color = Color.magenta; Debug.Log((object)("Set " + ((Object)val5).name + " to magenta")); } else if (((Object)val).name.Contains("Helicopter") || ((Object)targetNode).name.Contains("Helicopter")) { ((Renderer)val6).material.color = Color.yellow; ((Renderer)val6).material.color = Color.yellow; Debug.Log((object)("Set " + ((Object)val5).name + " to yellow")); } else if (((Object)val).name.Contains("Junction") || ((Object)targetNode).name.Contains("Junction")) { ((Renderer)val6).material.color = Color.green; ((Renderer)val6).material.color = Color.green; Debug.Log((object)("Set " + ((Object)val5).name + " to green")); } } } } Debug.Log((object)$"Graph debug complete. Nodes found: {array.Length}"); } } public class DebugToggler : MonoBehaviour { private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(FrankysDebugger.ToggleKey.Value)) { CarrierGraphDebugPatch.ToggleGraph(); } } } namespace BepInExPlugin; [BepInPlugin("FrankysDebugger", "FrankysDebugger", "1.0.2")] public class FrankysDebugger : BaseUnityPlugin { public static ConfigEntry DebugValue; public static ConfigEntry ToggleKey; private void Awake() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown DebugValue = ((BaseUnityPlugin)this).Config.Bind("Debugging", "Master Toggle", false, ""); ToggleKey = ((BaseUnityPlugin)this).Config.Bind("Debugging", "Hotkey", (KeyCode)93, ""); Harmony val = new Harmony("FrankysDebugger"); val.PatchAll(); Debug.Log((object)"FrankysDebugger loaded"); } } internal static class PluginInfo { public const string PLUGIN_NAME = "FrankysDebugger"; public const string PLUGIN_ID = "FrankysDebugger"; public const string PLUGIN_VERSION = "1.0.2"; }