using 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.Configuration; using BepInEx.Logging; using EquinoxsDebuggingTools; using EquinoxsModUtils; using FluffyUnderware.DevTools.Extensions; 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("QuickBuild")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("QuickBuild")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("eee8fd1d-c9a8-4a87-95ce-ced596eb7cda")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace QuickBuild; public class MenuItem { public string name; public string icon; public string buildable; } internal static class QuickBuildGUI { internal static bool shouldShowGUI = false; internal static string currentCategory = "Root"; internal static float sSinceClose = 0f; internal static float sSinceClick = 0f; private static bool initialisedGUI = false; private static bool loggedCategory = false; internal static Dictionary> categoryOptions = new Dictionary> { { "Root", new List { new MenuItem { name = "Logistics", icon = "Conveyor Belt" }, new MenuItem { name = "Production", icon = "Assembler" }, new MenuItem { name = "Structures", icon = "Calycite Platform (5x5)" }, new MenuItem { name = "Supports", icon = "Metal Rib Base (1x2)" }, new MenuItem { name = "Decorations", icon = "Ceiling Plant (1x1)" } } }, { "Root/Logistics", new List { new MenuItem { name = "Conveyors", icon = "Conveyor Belt" }, new MenuItem { name = "Inserters", icon = "Inserter" }, new MenuItem { name = "Monorails", icon = "Monorail Depot" }, new MenuItem { name = "Power", icon = "High Voltage Cable" }, new MenuItem { name = "Utility", icon = "Container" } } }, { "Root/Logistics/Conveyors", new List { new MenuItem { name = "Mk 1", icon = "Conveyor Belt", buildable = "Conveyor Belt" }, new MenuItem { name = "Mk 2", icon = "Conveyor Belt MKII", buildable = "Conveyor Belt MKII" }, new MenuItem { name = "Mk 3", icon = "Conveyor Belt MKIII", buildable = "Conveyor Belt MKIII" } } }, { "Root/Logistics/Inserters", new List { new MenuItem { name = "Normal", icon = "Inserter", buildable = "Inserter" }, new MenuItem { name = "Long", icon = "Long Inserter", buildable = "Long Inserter" }, new MenuItem { name = "Filter", icon = "Filter Inserter", buildable = "Filter Inserter" }, new MenuItem { name = "Fast", icon = "Fast Inserter", buildable = "Fast Inserter" }, new MenuItem { name = "Stack", icon = "Stack Inserter", buildable = "Stack Inserter" }, new MenuItem { name = "Stack Filter", icon = "Stack Filter Inserter", buildable = "Stack Filter Inserter" }, new MenuItem { name = "Long Stack Filter", icon = "Long Stack Filter Inserter", buildable = "Long Stack Filter Inserter" } } }, { "Root/Logistics/Monorails", new List { new MenuItem { name = "Depot", icon = "Monorail Depot", buildable = "Monorail Depot" }, new MenuItem { name = "Pole", icon = "Monorail Pole", buildable = "Monorail Pole" }, new MenuItem { name = "Track", icon = "Monorail Track", buildable = "Monorail Track" } } }, { "Root/Logistics/Power", new List { new MenuItem { name = "Accum.", icon = "Accumulator", buildable = "Accumulator" }, new MenuItem { name = "Voltage Stepper", icon = "Voltage Stepper", buildable = "Voltage Stepper" }, new MenuItem { name = "HVC", icon = "High Voltage Cable", buildable = "High Voltage Cable" } } }, { "Root/Logistics/Utility", new List { new MenuItem { name = "Chest", icon = "Container", buildable = "Container" }, new MenuItem { name = "Chest Mk 2", icon = "Container MKII", buildable = "Container MKII" }, new MenuItem { name = "Nexus", icon = "Nexus", buildable = "Nexus" } } }, { "Root/Production", new List { new MenuItem { name = "Miners", icon = "Mining Drill" }, new MenuItem { name = "Smelters", icon = "Smelter" }, new MenuItem { name = "Assemblers", icon = "Assembler" }, new MenuItem { name = "Plants", icon = "Thresher" }, new MenuItem { name = "Power", icon = "Crank Generator" } } }, { "Root/Production/Miners", new List { new MenuItem { name = "Mk 1", icon = "Mining Drill", buildable = "Mining Drill" }, new MenuItem { name = "Mk 2", icon = "Mining Drill MKII", buildable = "Mining Drill MKII" }, new MenuItem { name = "Blast", icon = "Blast Drill", buildable = "Blast Drill" }, new MenuItem { name = "Charge", icon = "Mining Charge", buildable = "Mining Charge" }, new MenuItem { name = "Sand Pump", icon = "Sand Pump", buildable = "Sand Pump" } } }, { "Root/Production/Smelters", new List { new MenuItem { name = "Mk 1", icon = "Smelter", buildable = "Smelter" }, new MenuItem { name = "Mk 2", icon = "Smelter MKII", buildable = "Smelter MKII" }, new MenuItem { name = "Mk 3", icon = "Smelter MKIII", buildable = "Smelter MKIII" }, new MenuItem { name = "Blast", icon = "Blast Smelter", buildable = "Blast Smelter" } } }, { "Root/Production/Assemblers", new List { new MenuItem { name = "Mk 1", icon = "Assembler", buildable = "Assembler" }, new MenuItem { name = "Mk 2", icon = "Assembler MKII", buildable = "Assembler MKII" }, new MenuItem { name = "Crusher", icon = "Crusher", buildable = "Crusher" } } }, { "Root/Production/Plants", new List { new MenuItem { name = "Planter", icon = "Planter", buildable = "Planter" }, new MenuItem { name = "Planter Mk 2", icon = "Planter MKII", buildable = "Planter MKII" }, new MenuItem { name = "Thr. Mk 1", icon = "Thresher", buildable = "Thresher" }, new MenuItem { name = "Thr. Mk 2", icon = "Thresher MKII", buildable = "Thresher MKII" } } }, { "Root/Production/Power", new List { new MenuItem { name = "Mk 1", icon = "Crank Generator", buildable = "Crank Generator" }, new MenuItem { name = "Mk 2", icon = "Crank Generator", buildable = "Crank Generator MKII" }, new MenuItem { name = "Water Wheel", icon = "Water Wheel", buildable = "Water Wheel" } } }, { "Root/Structures", new List { new MenuItem { name = "Floors", icon = "Calycite Platform (5x5)" }, new MenuItem { name = "Walls", icon = "Calycite Wall (3x3)" }, new MenuItem { name = "Caps", icon = "Calycite Wall Cap (3x1)" }, new MenuItem { name = "Gates", icon = "Calycite Gate (5x5)" }, new MenuItem { name = "Cutaways", icon = "Calycite Wall Cutaway (5x5)" }, new MenuItem { name = "Stairs", icon = "Metal Stairs (3x5)" }, new MenuItem { name = "Ramps", icon = "Calycite Ramp (1x5)" } } }, { "Root/Structures/Floors", new List { new MenuItem { name = "Power Floor", icon = "Power Floor", buildable = "Power Floor" }, new MenuItem { name = "1x1", icon = "Calycite Platform (1x1)", buildable = "Calycite Platform (1x1)" }, new MenuItem { name = "3x3", icon = "Calycite Platform (3x3)", buildable = "Calycite Platform (3x3)" }, new MenuItem { name = "5x5", icon = "Calycite Platform (5x5)", buildable = "Calycite Platform (5x5)" }, new MenuItem { name = "Catwalk 3x9", icon = "Catwalk (3x9)", buildable = "Catwalk (3x9)" }, new MenuItem { name = "Catwalk 5x9", icon = "Catwalk (5x9)", buildable = "Catwalk (5x9)" }, new MenuItem { name = "Disco 1x1", icon = "Disco Block (1x1)", buildable = "Disco Block (1x1)" }, new MenuItem { name = "Glow 1x1", icon = "Glow Block (1x1)", buildable = "Glow Block (1x1)" } } }, { "Root/Structures/Walls", new List { new MenuItem { name = "3x3", icon = "Calycite Wall (3x3)", buildable = "Calycite Wall (3x3)" }, new MenuItem { name = "5x3", icon = "Calycite Wall (5x3)", buildable = "Calycite Wall (5x3)" }, new MenuItem { name = "5x5", icon = "Calycite Wall (5x5)", buildable = "Calycite Wall (5x5)" } } }, { "Root/Structures/Caps", new List { new MenuItem { name = "Corner", icon = "Calycite Wall Corner (1x1)", buildable = "Calycite Wall Corner (1x1)" }, new MenuItem { name = "3x1", icon = "Calycite Wall Cap (3x1)", buildable = "Calycite Wall Cap (5x1)" }, new MenuItem { name = "5x1", icon = "Calycite Wall Cap (5x1)", buildable = "Calycite Wall Cap (5x1)" }, new MenuItem { name = "3x1", icon = "Calycite Vertical Wall Cap (3x1)", buildable = "Calycite Vertical Wall Cap (3x1)" }, new MenuItem { name = "5x1", icon = "Calycite Vertical Wall Cap (5x1)", buildable = "Calycite Vertical Wall Cap (5x1)" } } }, { "Root/Structures/Gates", new List { new MenuItem { name = "5x2", icon = "Calycite Gate (5x2)", buildable = "Calycite Gate (5x2)" }, new MenuItem { name = "5x5", icon = "Calycite Gate (5x5)", buildable = "Calycite Gate (5x5)" }, new MenuItem { name = "10x5", icon = "Calycite Gate (10x5)", buildable = "Calycite Gate (10x5)" } } }, { "Root/Structures/Cutaways", new List { new MenuItem { name = "2x2", icon = "Calycite Wall Cutaway (2x2)", buildable = "Calycite Wall Cutaway (2x2)" }, new MenuItem { name = "3x3", icon = "Calycite Wall Cutaway (3x3)", buildable = "Calycite Wall Cutaway (3x3)" }, new MenuItem { name = "5x3", icon = "Calycite Wall Cutaway (5x3)", buildable = "Calycite Wall Cutaway (5x3)" }, new MenuItem { name = "5x5", icon = "Calycite Wall Cutaway (5x5)", buildable = "Calycite Wall Cutaway (5x5)" } } }, { "Root/Structures/Stairs", new List { new MenuItem { name = "1x1", icon = "Metal Stairs (1x1)", buildable = "Metal Stairs (1x1)" }, new MenuItem { name = "3x1", icon = "Metal Stairs (3x1)", buildable = "Metal Stairs (3x1)" }, new MenuItem { name = "3x3", icon = "Metal Stairs (3x3)", buildable = "Metal Stairs (3x3)" }, new MenuItem { name = "3x5", icon = "Metal Stairs (3x5)", buildable = "Metal Stairs (3x5)" } } }, { "Root/Structures/Ramps", new List { new MenuItem { name = "1x1", icon = "Calycite Ramp (1x1)", buildable = "Calycite Ramp (1x1)" }, new MenuItem { name = "1x3", icon = "Calycite Ramp (1x3)", buildable = "Calycite Ramp (1x3)" }, new MenuItem { name = "1x5", icon = "Calycite Ramp (1x5)", buildable = "Calycite Ramp (1x5)" } } }, { "Root/Supports", new List { new MenuItem { name = "Beams", icon = "Calycite Beam (5x1)" }, new MenuItem { name = "Pillars", icon = "Calycite Pillar (1x5)" }, new MenuItem { name = "Arches", icon = "Metal Angle Support (5x2)" }, new MenuItem { name = "Ribs", icon = "Metal Rib Base (1x2)" } } }, { "Root/Supports/Beams", new List { new MenuItem { name = "Calycite 1x1", icon = "Calycite Beam (1x1)", buildable = "Calycite Beam (1x1)" }, new MenuItem { name = "Calycite 3x1", icon = "Calycite Beam (3x1)", buildable = "Calycite Beam (3x1)" }, new MenuItem { name = "Calycite 5x1", icon = "Calycite Beam (5x1)", buildable = "Calycite Beam (5x1)" }, new MenuItem { name = "Metal 1x1", icon = "Metal Beam (1x1)", buildable = "Metal Beam (1x1)" }, new MenuItem { name = "Metal 3x1", icon = "Metal Beam (1x3)", buildable = "Metal Beam (1x3)" }, new MenuItem { name = "Metal 5x1", icon = "Metal Beam (1x5)", buildable = "Metal Beam (1x5)" } } }, { "Root/Supports/Pillars", new List { new MenuItem { name = "Calycite 1x1", icon = "Calycite Pillar (1x1)", buildable = "Calycite Pillar (1x1)" }, new MenuItem { name = "Calycite 1x3", icon = "Calycite Pillar (1x3)", buildable = "Calycite Pillar (1x3)" }, new MenuItem { name = "Calycite 1x5", icon = "Calycite Pillar (1x5)", buildable = "Calycite Pillar (1x5)" }, new MenuItem { name = "Metal 1x1", icon = "Metal Pillar (1x1)", buildable = "Metal Pillar (1x1)" }, new MenuItem { name = "Metal 1x3", icon = "Metal Pillar (1x3)", buildable = "Metal Pillar (1x3)" }, new MenuItem { name = "Metal 1x5", icon = "Metal Pillar (1x5)", buildable = "Metal Pillar (1x5)" } } }, { "Root/Supports/Arches", new List { new MenuItem { name = "Calycite 3x3", icon = "Calycite Angle Support (3x3)", buildable = "Calycite Angle Support (3x3)" }, new MenuItem { name = "Metal 5x2", icon = "Metal Angle Support (5x2)", buildable = "Metal Angle Support (5x2)" } } }, { "Root/Supports/Ribs", new List { new MenuItem { name = "Base 1x2", icon = "Metal Rib Base (1x2)", buildable = "Metal Rib Base (1x2)" }, new MenuItem { name = "Middle 1x3", icon = "Metal Rib Middle (1x3)", buildable = "Metal Rib Middle (1x3)" } } }, { "Root/Decorations", new List { new MenuItem { name = "Lights", icon = "Wall Light (1x1)" }, new MenuItem { name = "Railings", icon = "Railing (3x1)" }, new MenuItem { name = "Plants", icon = "Ceiling Plant (1x1)" } } }, { "Root/Decorations/Lights", new List { new MenuItem { name = "Sticks", icon = "Light Stick" }, new MenuItem { name = "Overhead", icon = "Overhead Light", buildable = "Overhead Light" }, new MenuItem { name = "Lamp", icon = "Standing Lamp (1x5)", buildable = "Standing Lamp (1x5)" }, new MenuItem { name = "Wall 1x1", icon = "Wall Light (1x1)", buildable = "Wall Light (1x1)" }, new MenuItem { name = "Wall 3x1", icon = "Wall Light (3x1)", buildable = "Wall Light (3x1)" }, new MenuItem { name = "Ceiling 1x1", icon = "Hanging Lamp (1x1)", buildable = "Hanging Lamp (1x1)" }, new MenuItem { name = "Fan 7x2", icon = "Fan Lamp (7x2)", buildable = "Fan Lamp (7x2)" } } }, { "Root/Decorations/Railings", new List { new MenuItem { name = "1x1", icon = "Railing (1x1)", buildable = "Railing (1x1)" }, new MenuItem { name = "3x1", icon = "Railing (3x1)", buildable = "Railing (3x1)" }, new MenuItem { name = "5x1", icon = "Railing (5x1)", buildable = "Railing (5x1)" }, new MenuItem { name = "Corner 1x1", icon = "Railing Corner (1x1)", buildable = "Railing Corner (1x1)" }, new MenuItem { name = "Corner 3x3", icon = "Railing Corner (3x3)", buildable = "Railing Corner (3x3)" } } }, { "Root/Decorations/Plants", new List { new MenuItem { name = "Pot 1x1", icon = "Small Floor Pot", buildable = "Small Floor Pot" }, new MenuItem { name = "Wall Pot 3x1", icon = "Wall Pot", buildable = "Wall Pot" }, new MenuItem { name = "Pot 2x2", icon = "Medium Floor Pot", buildable = "Medium Floor Pot" }, new MenuItem { name = "Ceiling 1x1", icon = "Ceiling Plant (1x1)", buildable = "Ceiling Plant (1x1)" }, new MenuItem { name = "Ceiling 3x3", icon = "Ceiling Plant (3x3)", buildable = "Ceiling Plant (3x3)" }, new MenuItem { name = "Wall 1x1", icon = "Wall Plant (1x1)", buildable = "Wall Plant (1x1)" }, new MenuItem { name = "Wall 3x3", icon = "Wall Plant (3x3)", buildable = "Wall Plant (3x3)" } } } }; private static Texture2D oneNormal; private static Texture2D oneHover; private static Texture2D twoNormal; private static Texture2D twoHover; private static Texture2D threeNormal; private static Texture2D threeHover; private static Texture2D fourNormal; private static Texture2D fourHover; private static Texture2D fiveNormal; private static Texture2D fiveHover; private static Texture2D sixNormal; private static Texture2D sixHover; private static Texture2D sevenNormal; private static Texture2D sevenHover; private static Texture2D eightNormal; private static Texture2D eightHover; private static GUIStyle oneNormalStyle; private static GUIStyle oneHoverStyle; private static GUIStyle twoNormalStyle; private static GUIStyle twoHoverStyle; private static GUIStyle threeNormalStyle; private static GUIStyle threeHoverStyle; private static GUIStyle fourNormalStyle; private static GUIStyle fourHoverStyle; private static GUIStyle fiveNormalStyle; private static GUIStyle fiveHoverStyle; private static GUIStyle sixNormalStyle; private static GUIStyle sixHoverStyle; private static GUIStyle sevenNormalStyle; private static GUIStyle sevenHoverStyle; private static GUIStyle eightNormalStyle; private static GUIStyle eightHoverStyle; private static GUIStyle iconStyle; private static GUIStyle normalTextStyle; private static GUIStyle hoverTextStyle; private static float xPos => (float)(Screen.width - 512) / 2f; private static float yPos => (float)(Screen.height - 512) / 2f; internal static void LoadImages() { oneNormal = Images.LoadTexture2DFromFile("QuickBuild.Images.1-Normal.png", false, (Assembly)null); oneHover = Images.LoadTexture2DFromFile("QuickBuild.Images.1-Hover.png", false, (Assembly)null); twoNormal = Images.LoadTexture2DFromFile("QuickBuild.Images.2-Normal.png", false, (Assembly)null); twoHover = Images.LoadTexture2DFromFile("QuickBuild.Images.2-Hover.png", false, (Assembly)null); threeNormal = Images.LoadTexture2DFromFile("QuickBuild.Images.3-Normal.png", false, (Assembly)null); threeHover = Images.LoadTexture2DFromFile("QuickBuild.Images.3-Hover.png", false, (Assembly)null); fourNormal = Images.LoadTexture2DFromFile("QuickBuild.Images.4-Normal.png", false, (Assembly)null); fourHover = Images.LoadTexture2DFromFile("QuickBuild.Images.4-Hover.png", false, (Assembly)null); fiveNormal = Images.LoadTexture2DFromFile("QuickBuild.Images.5-Normal.png", false, (Assembly)null); fiveHover = Images.LoadTexture2DFromFile("QuickBuild.Images.5-Hover.png", false, (Assembly)null); sixNormal = Images.LoadTexture2DFromFile("QuickBuild.Images.6-Normal.png", false, (Assembly)null); sixHover = Images.LoadTexture2DFromFile("QuickBuild.Images.6-Hover.png", false, (Assembly)null); sevenNormal = Images.LoadTexture2DFromFile("QuickBuild.Images.7-Normal.png", false, (Assembly)null); sevenHover = Images.LoadTexture2DFromFile("QuickBuild.Images.7-Hover.png", false, (Assembly)null); eightNormal = Images.LoadTexture2DFromFile("QuickBuild.Images.8-Normal.png", false, (Assembly)null); eightHover = Images.LoadTexture2DFromFile("QuickBuild.Images.8-Hover.png", false, (Assembly)null); } internal static void CloseAndReset() { EMU.FreeCursor(false); shouldShowGUI = false; loggedCategory = false; currentCategory = "Root"; sSinceClose = 0f; } internal static void Draw() { EDT.PacedLog("General", "Drawing Quick Build Menu", 1f); if (!initialisedGUI) { InitialiseGUI(); } if (UnityInput.Current.GetMouseButtonDown(1) && sSinceClick > 0.2f) { sSinceClick = 0f; if (currentCategory != "Root") { GoBackOneLevel(); } else { CloseAndReset(); } } DrawSegmentBackgrounds(); DrawSegmentForegrounds(); } private static void DrawSegmentForegrounds() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) List list = categoryOptions[currentCategory]; foreach (MenuItem item in list) { int index = list.IndexOf(item); bool flag = ShouldHighlightItem(index, list.Count); Vector2 foregroundLocation = GetForegroundLocation(index, list.Count); GUI.Box(new Rect(foregroundLocation.x - 30f, foregroundLocation.y - 40f, 60f, 60f), (Texture)(object)Images.GetImageForResource(item.icon, false), iconStyle); GUI.Label(new Rect(foregroundLocation.x - 40f, foregroundLocation.y - 40f, 80f, 80f), item.name, flag ? hoverTextStyle : normalTextStyle); } } private static void DrawSegmentBackgrounds() { //IL_00a1: 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) List list = categoryOptions[currentCategory]; foreach (MenuItem item in list) { if (!loggedCategory) { EDT.Log("General", $"Drawing Item '{item.name}' at ({xPos},{yPos})"); loggedCategory = true; } bool flag = ShouldHighlightItem(list.IndexOf(item), list.Count); GUIStyle backgroundStyleForNumButtons = GetBackgroundStyleForNumButtons(list.Count, flag); GUI.Box(new Rect(xPos, yPos, 512f, 512f), "", backgroundStyleForNumButtons); if (UnityInput.Current.GetMouseButtonDown(0) && flag && sSinceClick > 0.2f) { OnMenuItemClicked(item); } GUIUtility.RotateAroundPivot(360f / (float)list.Count, new Vector2(xPos + 256f, yPos + 256f)); } } private static void InitialiseGUI() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0073: 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) //IL_008e: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //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_00c4: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //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_0115: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_0130: 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_014b: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Expected O, but got Unknown //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Expected O, but got Unknown //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown initialisedGUI = true; GUIStyle val = new GUIStyle(); val.normal.background = oneNormal; oneNormalStyle = val; GUIStyle val2 = new GUIStyle(); val2.normal.background = oneHover; oneHoverStyle = val2; GUIStyle val3 = new GUIStyle(); val3.normal.background = twoNormal; twoNormalStyle = val3; GUIStyle val4 = new GUIStyle(); val4.normal.background = twoHover; twoHoverStyle = val4; GUIStyle val5 = new GUIStyle(); val5.normal.background = threeNormal; threeNormalStyle = val5; GUIStyle val6 = new GUIStyle(); val6.normal.background = threeHover; threeHoverStyle = val6; GUIStyle val7 = new GUIStyle(); val7.normal.background = fourNormal; fourNormalStyle = val7; GUIStyle val8 = new GUIStyle(); val8.normal.background = fourHover; fourHoverStyle = val8; GUIStyle val9 = new GUIStyle(); val9.normal.background = fiveNormal; fiveNormalStyle = val9; GUIStyle val10 = new GUIStyle(); val10.normal.background = fiveHover; fiveHoverStyle = val10; GUIStyle val11 = new GUIStyle(); val11.normal.background = sixNormal; sixNormalStyle = val11; GUIStyle val12 = new GUIStyle(); val12.normal.background = sixHover; sixHoverStyle = val12; GUIStyle val13 = new GUIStyle(); val13.normal.background = sevenNormal; sevenNormalStyle = val13; GUIStyle val14 = new GUIStyle(); val14.normal.background = sevenHover; sevenHoverStyle = val14; GUIStyle val15 = new GUIStyle(); val15.normal.background = eightNormal; eightNormalStyle = val15; GUIStyle val16 = new GUIStyle(); val16.normal.background = eightHover; eightHoverStyle = val16; GUIStyle val17 = new GUIStyle(); val17.normal.background = null; iconStyle = val17; GUIStyle val18 = new GUIStyle { fontSize = 15, alignment = (TextAnchor)7 }; val18.normal.textColor = new Color(68f, 68f, 98f); normalTextStyle = val18; GUIStyle val19 = new GUIStyle { fontSize = 15, alignment = (TextAnchor)7 }; val19.normal.textColor = new Color(255f, 165f, 0f); hoverTextStyle = val19; } private static GUIStyle GetBackgroundStyleForNumButtons(int numButtons, bool isHighlighted) { //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown if (isHighlighted) { switch (numButtons) { case 1: return oneHoverStyle; case 2: return twoHoverStyle; case 3: return threeHoverStyle; case 4: return fourHoverStyle; case 5: return fiveHoverStyle; case 6: return sixHoverStyle; case 7: return sevenHoverStyle; case 8: return eightHoverStyle; default: QuickBuildPlugin.Log.LogError((object)$"Could not get hover style for numButtons: {numButtons}"); return new GUIStyle(); } } switch (numButtons) { case 1: return oneNormalStyle; case 2: return twoNormalStyle; case 3: return threeNormalStyle; case 4: return fourNormalStyle; case 5: return fiveNormalStyle; case 6: return sixNormalStyle; case 7: return sevenNormalStyle; case 8: return eightNormalStyle; default: QuickBuildPlugin.Log.LogError((object)$"Could not get normal style for numButtons: {numButtons}"); return new GUIStyle(); } } private static bool ShouldHighlightItem(int index, int numButtons) { //IL_0006: 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) float num = UnityInput.Current.mousePosition.x - (float)Screen.width / 2f; float num2 = UnityInput.Current.mousePosition.y - (float)Screen.height / 2f; float num3 = Mathf.Sqrt(Mathf.Pow(num, 2f) + Mathf.Pow(num2, 2f)); if (num3 < 156f) { return false; } float num4 = 57.29578f * Mathf.Atan2(num, num2); if (num4 < 0f) { num4 += 360f; } float num5 = 360f / (float)numButtons; float num6 = (float)index * num5; float num7 = (float)(index + 1) * num5; return num4 > num6 && num4 <= num7; } private static Vector2 GetForegroundLocation(int index, int numButtons) { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) float num = 360f / (float)numButtons; float num2 = 206f; float num3 = (float)(2 * index + 1) * num / 2f; num3 = 90f - num3; if (num3 < 0f) { num3 += 360f; } EDT.PacedLog("General", $"{index}/{numButtons} has theta {num3}", 1f); float num4 = num2 * Mathf.Cos(num3 * ((float)Math.PI / 180f)); float num5 = num2 * Mathf.Sin(num3 * ((float)Math.PI / 180f)); EDT.PacedLog("General", $"(x,y) = ({num4}, {num5})", 1f); float num6 = (float)Screen.width / 2f + num4; float num7 = (float)Screen.height / 2f - num5; EDT.PacedLog("General", $"(screenX, screenY) = ({num6},{num7})", 1f); return new Vector2(num6, num7); } private static void OnMenuItemClicked(MenuItem item) { if (string.IsNullOrEmpty(item.buildable)) { currentCategory = currentCategory + "/" + item.name; } else { StartBuilding(item); } EDT.Log("General", item.name + " clicked"); sSinceClick = 0f; } private static void StartBuilding(MenuItem item) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) ResourceInfo resourceInfoByName = Resources.GetResourceInfoByName(item.buildable, false); EyeDropContent val = (EyeDropContent)EMU.GetPrivateField("_currentEyeDropContent", Player.instance.builder); val.BuilderInfo = (BuilderInfo)resourceInfoByName; val.VariantIndex = 0; val.YawRotation = 0; EMU.SetPrivateField("_currentEyeDropContent", Player.instance.builder, (object)val); Player.instance.builder.CursorUI.Set(resourceInfoByName, false); EMU.SetPrivateField("_currentEyeDropState", Player.instance.builder, (object)(EEyeDropState)1); CloseAndReset(); } private static void GoBackOneLevel() { string[] array = currentCategory.Split(new char[1] { '/' }); array = ArrayExt.RemoveAt(array, array.Count() - 1); currentCategory = string.Join("/", array); } } [BepInPlugin("com.equinox.QuickBuild", "QuickBuild", "2.0.0")] public class QuickBuildPlugin : BaseUnityPlugin { private const string MyGUID = "com.equinox.QuickBuild"; private const string PluginName = "QuickBuild"; private const string VersionString = "2.0.0"; private static readonly Harmony Harmony = new Harmony("com.equinox.QuickBuild"); public static ManualLogSource Log = new ManualLogSource("QuickBuild"); public static ConfigEntry showMenuKey; private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: QuickBuild, VersionString: 2.0.0 is loading..."); Harmony.PatchAll(); CreateConfigEntries(); QuickBuildGUI.LoadImages(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: QuickBuild, VersionString: 2.0.0 is loaded."); Log = ((BaseUnityPlugin)this).Logger; } private void Update() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!LoadingStates.hasGameLoaded) { return; } QuickBuildGUI.sSinceClose += Time.deltaTime; QuickBuildGUI.sSinceClick += Time.deltaTime; if (UnityInput.Current.GetKeyDown(showMenuKey.Value)) { if (ShouldShowMenu()) { QuickBuildGUI.shouldShowGUI = true; EMU.FreeCursor(true); } else { QuickBuildGUI.CloseAndReset(); } } } private void OnGUI() { if (QuickBuildGUI.shouldShowGUI) { QuickBuildGUI.Draw(); } } public static void AddItem(string path, MenuItem item) { if (!QuickBuildGUI.categoryOptions.ContainsKey(path)) { Log.LogError((object)("Path '" + path + "' is not a valid path, please add it first")); } else { QuickBuildGUI.categoryOptions[path].Add(item); } } public static void InsertItem(string path, int index, MenuItem item) { if (!QuickBuildGUI.categoryOptions.ContainsKey(path)) { Log.LogError((object)("Path '" + path + "' is not a valid path, please add it first")); return; } if (index < 0) { Log.LogError((object)$"Index '{index}' cannot be < 0, you lemon"); return; } int count = QuickBuildGUI.categoryOptions[path].Count; if (index >= count) { Log.LogWarning((object)$"Index was >= than num options ({count}) for path '{path}'. Adding to end instead"); AddItem(path, item); } QuickBuildGUI.categoryOptions[path].Insert(index, item); } private void CreateConfigEntries() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown showMenuKey = ((BaseUnityPlugin)this).Config.Bind("General", "Show Menu Key", (KeyCode)96, new ConfigDescription("Hold this key to open the Quick Build menu", (AcceptableValueBase)null, Array.Empty())); } private bool ShouldShowMenu() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 return !QuickBuildGUI.shouldShowGUI && QuickBuildGUI.sSinceClose > 0.2f && (int)Player.instance.builder.CurrentConstructionMode == 0; } }