Decompiled source of FastNFurious v0.1.0
FastNFurious.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LokiMoonLabs.FastNFurious { internal sealed class FastWindow : IDisposable { private readonly Plugin plugin; private readonly MinimapLauncher launcher; private readonly Dictionary<ConfigEntryBase, object> draft = new Dictionary<ConfigEntryBase, object>(); private readonly List<Action> updateLabels = new List<Action>(); private readonly List<InputField> fields = new List<InputField>(); private readonly List<(Text label, string caption)> captions = new List<(Text, string)>(); private int refreshCaptionsAt = -1; private GameObject panel; private RectTransform rect; private Font font; private Image buttonSkin; private Text status; private UIGame owner; private bool opened; internal bool Blocking { get { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!launcher.Blocking) { if (opened && (Object)(object)rect != (Object)null) { return RectTransformUtility.RectangleContainsScreenPoint(rect, Vector2.op_Implicit(Input.mousePosition), (Camera)null); } return false; } return true; } } internal bool Editing { get { if (opened) { return fields.Exists((InputField input) => input.isFocused); } return false; } } internal FastWindow(Plugin plugin) { this.plugin = plugin; launcher = new MinimapLauncher(Toggle, delegate { }); } internal void Update(UIGame game) { if ((Object)(object)owner != (Object)(object)game) { DestroyPanel(); launcher.Dispose(); owner = game; } if ((Object)(object)game == (Object)null) { return; } launcher.Update(game.gameMenu, game.lowGroup); if (opened && !Editing && Input.GetKeyDown((KeyCode)27)) { Close(); } if (!opened || refreshCaptionsAt < 0 || Time.frameCount < refreshCaptionsAt) { return; } refreshCaptionsAt = -1; foreach (var caption in captions) { caption.label.text = caption.caption; } foreach (var caption2 in captions) { ((Graphic)caption2.label).SetAllDirty(); } } private void Toggle() { if (opened) { Close(); } else { if ((Object)(object)owner == (Object)null || (Object)(object)owner.lowGroup == (Object)null || (Object)(object)owner.controlPanelWindow == (Object)null) { return; } if ((Object)(object)panel == (Object)null) { Build(); } foreach (ConfigEntryBase setting in plugin.Settings) { draft[setting] = setting.BoxedValue; } foreach (Action updateLabel in updateLabels) { updateLabel(); } status.text = "Changes take effect when you click Apply."; panel.SetActive(true); panel.transform.SetAsLastSibling(); opened = true; refreshCaptionsAt = Time.frameCount + 1; } } private void Close() { if ((Object)(object)panel != (Object)null) { panel.SetActive(false); } opened = false; } private void Build() { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0363: 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_0407: Unknown result type (might be due to invalid IL or missing references) UIControlPanelWindow controlPanelWindow = owner.controlPanelWindow; font = (((Object)(object)controlPanelWindow.FONT_SAIRASB != (Object)null) ? controlPanelWindow.FONT_SAIRASB : controlPanelWindow.leftEmptyTip.font); UIControlPanelObjectEntry[] objectEntryPrefabs = controlPanelWindow.objectEntryPrefabs; object obj; if (objectEntryPrefabs == null) { obj = null; } else { UIControlPanelObjectEntry? obj2 = ((IEnumerable<UIControlPanelObjectEntry>)objectEntryPrefabs).FirstOrDefault((Func<UIControlPanelObjectEntry, bool>)((UIControlPanelObjectEntry entry) => (Object)(object)entry != (Object)null && (Object)(object)entry.selectButton != (Object)null)); obj = ((obj2 != null) ? ((Component)obj2.selectButton).GetComponent<Image>() : null); } buttonSkin = (Image)obj; panel = new GameObject("Fast N Furious window", new Type[2] { typeof(RectTransform), typeof(Image) }); panel.SetActive(false); rect = (RectTransform)panel.transform; ((Transform)rect).SetParent((Transform)(object)owner.lowGroup, false); RectTransform obj3 = rect; RectTransform obj4 = rect; RectTransform obj5 = rect; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); obj5.pivot = val; Vector2 anchorMin = (obj4.anchorMax = val); obj3.anchorMin = anchorMin; rect.sizeDelta = new Vector2(760f, 560f); Image component = panel.GetComponent<Image>(); ((Graphic)component).color = new Color(0.1f, 0.19f, 0.24f, 0.97f); ((Graphic)component).raycastTarget = true; CopyBackdrop((RectTransform)((Component)controlPanelWindow).transform); Surface(1f, 1f, 758f, 558f, new Color(0.06f, 0.13f, 0.18f, 0.78f)); Surface(1f, 1f, 758f, 47f, new Color(0.19f, 0.31f, 0.39f, 0.86f)); Surface(14f, 54f, 732f, 407f, new Color(0.06f, 0.12f, 0.17f, 0.68f)); Label("Fast N Furious", rect, 22f, 14f, 360f, 31f, 25); Button("×", 707f, 14f, 32f, 28f, Close); ConfigEntryBase[] source = plugin.Settings.ToArray(); ConfigEntryBase[] source2 = source.Where((ConfigEntryBase entry) => entry.Definition.Section == "1. Factory").ToArray(); ConfigEntryBase[] array = source.Where((ConfigEntryBase entry) => entry.Definition.Section == "2. Generator").ToArray(); ConfigEntryBase[][] array2 = new ConfigEntryBase[3][] { source2.Take(7).ToArray(), source2.Skip(7).ToArray(), array }; string[] array3 = new string[3] { "Production", "Launch and logistics", "Power generation" }; for (int num = 0; num < array2.Length; num++) { float num2 = 20 + num * 242; Surface(num2, 60f, 236f, 395f, new Color(0.11f, 0.2f, 0.25f, 0.73f)); Surface(num2 + 6f, 66f, 224f, 25f, new Color(0.19f, 0.32f, 0.4f, 0.76f)); Label(array3[num], rect, num2 + 13f, 66f, 210f, 25f, 17); for (int num3 = 0; num3 < array2[num].Length; num3++) { float y = 96 + num3 * 44; Surface(num2 + 6f, y, 224f, 40f, new Color(0.23f, 0.4f, 0.47f, 0.48f)); AddSetting(array2[num][num3], num2 + 12f, y); } } ConfigEntry<bool> enabled = source.OfType<ConfigEntry<bool>>().Single(); Text enabledText = null; enabledText = Button("", 22f, 475f, 185f, 30f, delegate { draft[(ConfigEntryBase)(object)enabled] = !(bool)draft[(ConfigEntryBase)(object)enabled]; enabledText.text = (((bool)draft[(ConfigEntryBase)(object)enabled]) ? "Overclock enabled" : "Overclock disabled"); }); updateLabels.Add(delegate { enabledText.text = (((bool)draft[(ConfigEntryBase)(object)enabled]) ? "Overclock enabled" : "Overclock disabled"); }); status = Label("", rect, 22f, 518f, 660f, 26f, 15); Button("Apply", 601f, 475f, 137f, 32f, delegate { try { foreach (InputField field in fields) { if (field.isFocused) { field.DeactivateInputField(true); } } plugin.Apply(draft); status.text = "Settings saved and applied."; } catch (Exception ex) { status.text = "Apply failed: " + ex.Message; } }); } private void AddSetting(ConfigEntryBase entry, float x, float y) { string key = entry.Definition.Key; Label(DisplayName(key), rect, x, y, 212f, 18f, 16); bool decimalValue = entry.SettingType == typeof(double); InputField value = NumberField(x + 79f, y + 18f, decimalValue); Label("×", rect, x + 132f, y + 18f, 14f, 20f, 14); updateLabels.Add(UpdateValue); ((UnityEvent<string>)(object)value.onEndEdit).AddListener((UnityAction<string>)delegate(string input) { int result2; if (decimalValue && double.TryParse(input.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var result)) { draft[entry] = entry.Description.AcceptableValues.Clamp((object)result); } else if (!decimalValue && int.TryParse(input, NumberStyles.None, CultureInfo.InvariantCulture, out result2)) { draft[entry] = entry.Description.AcceptableValues.Clamp((object)result2); } UpdateValue(); }); Button("-", x + 50f, y + 18f, 24f, 20f, delegate { Shift(-1); }); Button("+", x + 149f, y + 18f, 24f, 20f, delegate { Shift(1); }); void Shift(int direction) { if (entry.Description.AcceptableValues is AcceptableValueList<int> val) { int[] acceptableValues = val.AcceptableValues; int num = Array.IndexOf(acceptableValues, (int)draft[entry]); draft[entry] = acceptableValues[Mathf.Clamp(num + direction, 0, acceptableValues.Length - 1)]; } else if (entry.Description.AcceptableValues is AcceptableValueRange<int> val2) { int num2 = (Plugin.IsLauncher(entry) ? 10 : val2.MaxValue); draft[entry] = Mathf.Clamp((int)draft[entry] + direction, val2.MinValue, num2); } else if (entry.Description.AcceptableValues is AcceptableValueRange<double> val3) { double val4 = Math.Round((double)draft[entry] + (double)direction * 0.1, 1); draft[entry] = Math.Min(val3.MaxValue, Math.Max(val3.MinValue, val4)); } UpdateValue(); } void UpdateValue() { value.SetTextWithoutNotify(Convert.ToString(draft[entry], CultureInfo.InvariantCulture)); } } private InputField NumberField(float x, float y, bool decimalValue) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Multiplier", new Type[3] { typeof(RectTransform), typeof(Image), typeof(InputField) }); RectTransform parent = Place(val, rect, x, y, 50f, 20f); Image component = val.GetComponent<Image>(); ((Graphic)component).color = new Color(0.06f, 0.14f, 0.2f, 0.94f); Text val2 = Label("", parent, 3f, 0f, 44f, 20f, 15); val2.alignment = (TextAnchor)4; InputField component2 = val.GetComponent<InputField>(); ((Selectable)component2).targetGraphic = (Graphic)(object)component; component2.textComponent = val2; component2.lineType = (LineType)0; component2.contentType = (ContentType)(decimalValue ? 3 : 2); component2.characterLimit = 7; fields.Add(component2); return component2; } private static string DisplayName(string key) { return key switch { "smeltMultiplier" => "Smelters", "chemicalMultiplier" => "Chemical plants", "refineMultiplier" => "Refineries", "assembleMultiplier" => "Assemblers", "particleMultiplier" => "Particle colliders", "labMultiplier" => "Matrix labs", "fractionateMultiplier" => "Fractionators", "ejectorMultiplier" => "EM Rail Ejectors", "siloMultiplier" => "Launching silos", "gammaMultiplier" => "Ray receivers", "miningMultiplier" => "Miners", "sorterMultiplier" => "Sorters", "turretMultiplier" => "Turrets", "beltMultiplier" => "Belts", "drawMultipler" => "Power draw", "generatorWindMultiplier" => "Wind turbines", "generatorSolarMultiplier" => "Solar panels", "generatorGeothermalMultiplier" => "Geothermal plants", "generatorThermalMultiplier" => "Thermal plants", "generatorFusionMultiplier" => "Fusion plants", "generatorArtificialStarMultiplier" => "Artificial stars", "generatorExchangerMultiplier" => "Energy exchangers", _ => key, }; } private Text Button(string title, float x, float y, float width, float height, Action click) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(title, new Type[3] { typeof(RectTransform), typeof(Image), typeof(Button) }); RectTransform parent = Place(val, rect, x, y, width, height); Image component = val.GetComponent<Image>(); if ((Object)(object)buttonSkin != (Object)null) { component.sprite = buttonSkin.sprite; component.type = buttonSkin.type; } ((Graphic)component).color = new Color(0.32f, 0.55f, 0.63f, 1f); Button component2 = val.GetComponent<Button>(); ((Selectable)component2).targetGraphic = (Graphic)(object)component; ((UnityEvent)component2.onClick).AddListener((UnityAction)delegate { click(); }); Text obj = Label(title, parent, 0f, 0f, width, height, 16); obj.alignment = (TextAnchor)4; return obj; } private Text Label(string title, RectTransform parent, float x, float y, float width, float height, int size) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Text", new Type[2] { typeof(RectTransform), typeof(Text) }); Place(val, parent, x, y, width, height); Text component = val.GetComponent<Text>(); component.font = font; component.fontSize = size; ((Graphic)component).color = Color.white; component.alignment = (TextAnchor)3; ((Graphic)component).raycastTarget = false; component.horizontalOverflow = (HorizontalWrapMode)1; component.verticalOverflow = (VerticalWrapMode)1; if (title.Length != 0) { captions.Add((component, title)); } return component; } private void Surface(float x, float y, float width, float height, Color color) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Panel surface", new Type[2] { typeof(RectTransform), typeof(Image) }); Place(val, rect, x, y, width, height); Image component = val.GetComponent<Image>(); ((Graphic)component).color = color; ((Graphic)component).raycastTarget = false; } private void CopyBackdrop(RectTransform source) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: 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_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: 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_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Expected O, but got Unknown //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) Rect val = source.rect; if (((Rect)(ref val)).width <= 0f || ((Rect)(ref val)).height <= 0f) { return; } Vector3[] array = (Vector3[])(object)new Vector3[4]; Graphic[] componentsInChildren = ((Component)source).GetComponentsInChildren<Graphic>(true); foreach (Graphic val2 in componentsInChildren) { if (!((Behaviour)val2).enabled || (!(val2 is Image) && !(val2 is RawImage))) { continue; } RectTransform rectTransform = val2.rectTransform; rectTransform.GetWorldCorners(array); Vector3 val3 = ((Transform)source).InverseTransformPoint(array[0]); Vector3 val4 = ((Transform)source).InverseTransformPoint(array[2]); if (Mathf.Abs(val4.x - val3.x) < ((Rect)(ref val)).width * 0.9f || Mathf.Abs(val4.y - val3.y) < ((Rect)(ref val)).height * 0.8f) { continue; } bool flag = true; Transform val5 = (Transform)(object)rectTransform; while ((Object)(object)val5 != (Object)null && (Object)(object)val5 != (Object)(object)source) { if (!((Component)val5).gameObject.activeSelf) { flag = false; break; } val5 = val5.parent; } if (flag) { GameObject val6 = new GameObject("Native window backing", new Type[1] { typeof(RectTransform) }); RectTransform val7 = (RectTransform)val6.transform; ((Transform)val7).SetParent((Transform)(object)rect, false); val7.anchorMin = new Vector2((val3.x - ((Rect)(ref val)).xMin) / ((Rect)(ref val)).width, (val3.y - ((Rect)(ref val)).yMin) / ((Rect)(ref val)).height); val7.anchorMax = new Vector2((val4.x - ((Rect)(ref val)).xMin) / ((Rect)(ref val)).width, (val4.y - ((Rect)(ref val)).yMin) / ((Rect)(ref val)).height); Vector2 offsetMin = (val7.offsetMax = Vector2.zero); val7.offsetMin = offsetMin; Image val8 = (Image)(object)((val2 is Image) ? val2 : null); Graphic val9; if (val8 != null) { Image obj = val6.AddComponent<Image>(); obj.sprite = val8.sprite; obj.type = val8.type; obj.fillCenter = val8.fillCenter; val9 = (Graphic)(object)obj; } else { RawImage val10 = (RawImage)val2; RawImage obj2 = val6.AddComponent<RawImage>(); obj2.texture = val10.texture; obj2.uvRect = val10.uvRect; val9 = (Graphic)(object)obj2; } val9.color = val2.color; val9.material = val2.material; val9.raycastTarget = false; } } } private static RectTransform Place(GameObject go, RectTransform parent, float x, float y, float width, float height) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown RectTransform val = (RectTransform)go.transform; ((Transform)val).SetParent((Transform)(object)parent, false); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 1f); val.pivot = val2; Vector2 anchorMin = (val.anchorMax = val2); val.anchorMin = anchorMin; val.anchoredPosition = new Vector2(x, 0f - y); val.sizeDelta = new Vector2(width, height); return val; } private void DestroyPanel() { Close(); if ((Object)(object)panel != (Object)null) { Object.Destroy((Object)(object)panel); } panel = null; rect = null; updateLabels.Clear(); captions.Clear(); fields.Clear(); draft.Clear(); } public void Dispose() { DestroyPanel(); launcher.Dispose(); } } internal sealed class LauncherClickGate { private int lastFrame = -1; public bool Accept(int frame) { if (lastFrame == frame) { return false; } lastFrame = frame; return true; } } internal static class LauncherLayout { public static Vector2 Position(Vector2 hub, Vector2 mecha, Vector2 production, float mechHeight, float nativeHeight, float buttonHeight) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) float num = production.x - mecha.x; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(mecha.x - num, production.y + (nativeHeight + buttonHeight) * 0.5f - 6f); Vector2 val2 = mecha + Vector2.up * ((mechHeight + buttonHeight) * 0.5f - 6f); Vector2 val3 = val2 - hub; float magnitude = ((Vector2)(ref val3)).magnitude; if (magnitude < 1f) { return val + new Vector2(0f - num, (0f - buttonHeight) * 0.55f); } float num2 = val.x - hub.x; if (Mathf.Abs(num2) < magnitude) { val.y = hub.y + Mathf.Sqrt(magnitude * magnitude - num2 * num2); } float num3 = 2f * Mathf.Asin(Mathf.Clamp01(Vector2.Distance(val2, val) / (2f * magnitude))); val3 = val - hub; Vector2 normalized = ((Vector2)(ref val3)).normalized; Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0f - normalized.y, normalized.x); return hub + magnitude * (normalized * Mathf.Cos(num3) + val4 * Mathf.Sin(num3)); } } internal sealed class MinimapLauncher : IDisposable { private readonly Action toggle; private readonly Action<string> report; private UIGameMenu owner; private GameObject root; private RectTransform rect; private Image icon; private Texture2D fillTexture; private Texture2D glyphTexture; private Sprite glyphSprite; private Sprite fillSprite; private readonly LauncherClickGate clicks = new LauncherClickGate(); public bool Blocking { get { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root != (Object)null && root.activeInHierarchy) { return RectTransformUtility.RectangleContainsScreenPoint(rect, Vector2.op_Implicit(Input.mousePosition), (Camera)null); } return false; } } public MinimapLauncher(Action toggle, Action<string> report) { this.toggle = toggle; this.report = report; } public void Update(UIGameMenu menu, RectTransform parent) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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 //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected O, but got Unknown //IL_01ae: 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_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_01c1: 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_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: 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_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)owner != (Object)(object)menu || ((Object)(object)owner != (Object)null && (Object)(object)root == (Object)null)) { Dispose(); owner = menu; } if (!((Object)(object)menu == (Object)null) && !((Object)(object)menu.button0 == (Object)null) && !((Object)(object)menu.button5 == (Object)null) && !((Object)(object)menu.button2 == (Object)null) && !((Object)(object)parent == (Object)null)) { if ((Object)(object)root == (Object)null) { Create(menu.button2, parent); } RectTransform val = (RectTransform)((Component)menu.button2).transform; RectTransform val2 = (RectTransform)((Component)menu.button5).transform; Vector3 lossyScale = ((Transform)val).lossyScale; Vector3 lossyScale2 = ((Transform)parent).lossyScale; ((Transform)rect).localScale = new Vector3(lossyScale.x / lossyScale2.x * 0.86f, lossyScale.y / lossyScale2.y * 0.86f, 1f); Rect val3 = val.rect; Vector2 val4 = Vector2.op_Implicit(((Transform)parent).InverseTransformPoint(((Transform)val).TransformPoint(Vector2.op_Implicit(((Rect)(ref val3)).center)))); val3 = val2.rect; Vector2 val5 = Vector2.op_Implicit(((Transform)parent).InverseTransformPoint(((Transform)val2).TransformPoint(Vector2.op_Implicit(((Rect)(ref val3)).center)))); val3 = val2.rect; Vector2 center = ((Rect)(ref val3)).center; Vector2 up = Vector2.up; val3 = val2.rect; Vector2 val6 = Vector2.op_Implicit(((Transform)parent).InverseTransformPoint(((Transform)val2).TransformPoint(Vector2.op_Implicit(center + up * ((Rect)(ref val3)).height * 0.5f)))); RectTransform val7 = (RectTransform)((Component)menu.button0).transform; val3 = val7.rect; Vector2 hub = Vector2.op_Implicit(((Transform)parent).InverseTransformPoint(((Transform)val7).TransformPoint(Vector2.op_Implicit(((Rect)(ref val3)).center)))); val3 = val.rect; Vector2 center2 = ((Rect)(ref val3)).center; Vector2 up2 = Vector2.up; val3 = val.rect; Vector2 val8 = Vector2.op_Implicit(((Transform)parent).InverseTransformPoint(((Transform)val).TransformPoint(Vector2.op_Implicit(center2 + up2 * ((Rect)(ref val3)).height * 0.5f)))); RectTransform obj = rect; float mechHeight = Math.Abs(val8.y - val4.y) * 2f; float nativeHeight = Math.Abs(val6.y - val5.y) * 2f; val3 = rect.rect; ((Transform)obj).position = ((Transform)parent).TransformPoint(Vector2.op_Implicit(LauncherLayout.Position(hub, val4, val5, mechHeight, nativeHeight, ((Rect)(ref val3)).height * ((Transform)rect).localScale.y))); root.SetActive(((Component)menu.button2).gameObject.activeInHierarchy); } } private void Create(Button template, RectTransform parent) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_038d: 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_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_0567: 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_018b: Unknown result type (might be due to invalid IL or missing references) root = Object.Instantiate<GameObject>(((Component)template).gameObject, (Transform)(object)parent, false); ((Object)root).name = "Fast N Furious HUD button"; rect = root.GetComponent<RectTransform>(); rect.pivot = new Vector2(0.5f, 0.5f); Button component = root.GetComponent<Button>(); ((Behaviour)component).enabled = true; ((Selectable)component).interactable = true; root.transform.SetAsLastSibling(); component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener(new UnityAction(Click)); GameObject val = new GameObject("Dark button face", new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(root.transform, false); val.transform.SetAsFirstSibling(); fillTexture = new Texture2D(64, 64, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { double num = ((double)j + 0.5) / 32.0 - 1.0; double num2 = ((double)i + 0.5) / 32.0 - 1.0; array[i * 64 + j] = new Color32((byte)8, (byte)20, (byte)28, (byte)((num * num + num2 * num2 <= 1.0) ? 230u : 0u)); } } fillTexture.SetPixels32(array); fillTexture.Apply(false, true); fillSprite = Sprite.Create(fillTexture, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f); Image component2 = val.GetComponent<Image>(); component2.sprite = fillSprite; ((Graphic)component2).color = Color.white; ((Graphic)component2).raycastTarget = true; RectTransform rectTransform = ((Graphic)component2).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = new Vector2(2f, 2f); rectTransform.offsetMax = new Vector2(-2f, -2f); Graphic[] componentsInChildren = root.GetComponentsInChildren<Graphic>(true); foreach (Graphic val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)(object)component2) { Color color = val2.color; color.a *= 0.65f; val2.color = color; } if ((Object)(object)((Component)val2).transform != (Object)(object)root.transform && ((Object)val2).name.IndexOf("icon", StringComparison.OrdinalIgnoreCase) >= 0) { ((Behaviour)val2).enabled = false; } } UIButton obj = root.GetComponent<UIButton>() ?? root.AddComponent<UIButton>(); TipSettings tips = obj.tips; ((Behaviour)obj).enabled = true; obj.button = component; obj.eventReceiver = null; obj.onClick += delegate { Click(); }; obj.tips = new TipSettings { tipTitle = "Fast N Furious", tipText = "Adjust factory overclock settings.\nClick to open or close.", width = 260, delay = 0.35f, corner = tips.corner, offset = tips.offset, topLevel = tips.topLevel, level = tips.level, simpleGeneralTipPrefab = tips.simpleGeneralTipPrefab, type = (ItemTipType)(-1) }; obj.tipTitleFormatString = obj.tips.tipTitle; obj.tipTextFormatString = obj.tips.tipText; GameObject val3 = new GameObject("Speedometer icon", new Type[2] { typeof(RectTransform), typeof(Image) }); val3.transform.SetParent(root.transform, false); Image val4 = (icon = val3.GetComponent<Image>()); BuildGlyph(); val4.sprite = glyphSprite; val4.preserveAspect = true; ((Graphic)val4).color = Color.white; ((Graphic)val4).raycastTarget = true; RectTransform rectTransform2 = ((Graphic)val4).rectTransform; Vector2 val5 = default(Vector2); ((Vector2)(ref val5))..ctor(0.5f, 0.5f); rectTransform2.pivot = val5; Vector2 anchorMin = (rectTransform2.anchorMax = val5); rectTransform2.anchorMin = anchorMin; Rect val7 = rect.rect; float width = ((Rect)(ref val7)).width; val7 = rect.rect; float num3 = Mathf.Min(width, ((Rect)(ref val7)).height) * 0.82f; rectTransform2.sizeDelta = new Vector2(num3, num3); GameObject val8 = new GameObject("Launcher hit surface", new Type[2] { typeof(RectTransform), typeof(Image) }); val8.transform.SetParent(root.transform, false); Image component3 = val8.GetComponent<Image>(); ((Graphic)component3).color = Color.clear; ((Graphic)component3).raycastTarget = true; RectTransform rectTransform3 = ((Graphic)component3).rectTransform; rectTransform3.anchorMin = Vector2.zero; rectTransform3.anchorMax = Vector2.one; anchorMin = (rectTransform3.offsetMax = Vector2.zero); rectTransform3.offsetMin = anchorMin; root.SetActive(true); } private void BuildGlyph() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_01fa: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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) glyphTexture = new Texture2D(64, 64, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[4096]; Vector2 val = default(Vector2); for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { ((Vector2)(ref val))..ctor((float)j - 31.5f, (float)i - 29f); float num = Mathf.Atan2(val.y, val.x) * 57.29578f; if (num < -30f) { num += 360f; } float num2 = Mathf.Abs(((Vector2)(ref val)).magnitude - 22f); bool num3 = num >= -25f && num <= 205f && num2 < 1.9f; bool flag = ((Vector2)(ref val)).magnitude >= 16f && ((Vector2)(ref val)).magnitude <= 21f && num >= 0f && num <= 180f && Mathf.Abs(num - Mathf.Round(num / 45f) * 45f) < 4f; bool flag2 = (val.x >= -3f && val.x <= 12f && val.y >= -1f && val.y <= val.x * 0.65f + 3f) || (val.x >= -7f && val.x <= 5f && val.y <= 2f && val.y >= val.x * 1.2f - 4f); if (num3 || flag || flag2) { array[i * 64 + j] = new Color32((byte)245, (byte)251, byte.MaxValue, byte.MaxValue); } } } glyphTexture.SetPixels32(array); glyphTexture.Apply(false, true); glyphSprite = Sprite.Create(glyphTexture, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); } private void Click() { if (clicks.Accept(Time.frameCount)) { toggle(); } } public void Dispose() { if ((Object)(object)root != (Object)null) { Object.Destroy((Object)(object)root); } if ((Object)(object)fillSprite != (Object)null) { Object.Destroy((Object)(object)fillSprite); } if ((Object)(object)fillTexture != (Object)null) { Object.Destroy((Object)(object)fillTexture); } fillSprite = null; fillTexture = null; if ((Object)(object)glyphSprite != (Object)null) { Object.Destroy((Object)(object)glyphSprite); } if ((Object)(object)glyphTexture != (Object)null) { Object.Destroy((Object)(object)glyphTexture); } root = null; rect = null; icon = null; owner = null; } } public static class PluginConfig { public static ConfigEntry<int> smeltMultiplier; public static ConfigEntry<int> chemicalMultiplier; public static ConfigEntry<int> refineMultiplier; public static ConfigEntry<int> assembleMultiplier; public static ConfigEntry<int> particleMultiplier; public static ConfigEntry<int> miningMultiplier; private static ConfigEntry<int> _labMultiplier; private static ConfigEntry<int> _fractionatorMultiplier; private static ConfigEntry<int> _ejectorMultiplier; private static ConfigEntry<int> _siloMultiplier; public static ConfigEntry<int> gammaMultiplier; private static ConfigEntry<int> _inserterMultiplier; private static ConfigEntry<int> _turretMultiplier; private static ConfigEntry<int> _beltMultiplier; public static ConfigEntry<double> drawMultiplier; private static ConfigEntry<int> _genWindMultiplier; private static ConfigEntry<int> _genSolarMultiplier; private static ConfigEntry<int> _genGeoMultiplier; private static ConfigEntry<int> _genThermalMultiplier; private static ConfigEntry<int> _genFusionMultiplier; private static ConfigEntry<int> _genStarMultiplier; private static ConfigEntry<int> _genExchMultiplier; public static ConfigEntry<bool> multiplierEnabled; public static int genWindMultiplier { get { if (!multiplierEnabled.Value) { return 1; } return _genWindMultiplier.Value; } } public static int genSolarMultiplier { get { if (!multiplierEnabled.Value) { return 1; } return _genSolarMultiplier.Value; } } public static int genGeoMultiplier { get { if (!multiplierEnabled.Value) { return 1; } return _genGeoMultiplier.Value; } } public static int genThermalMultiplier { get { if (!multiplierEnabled.Value) { return 1; } return _genThermalMultiplier.Value; } } public static int genFusionMultiplier { get { if (!multiplierEnabled.Value) { return 1; } return _genFusionMultiplier.Value; } } public static int genStarMultiplier { get { if (!multiplierEnabled.Value) { return 1; } return _genStarMultiplier.Value; } } public static int genExchMultiplier { get { if (!multiplierEnabled.Value) { return 1; } return _genExchMultiplier.Value; } } public static int siloMultiplier { get { if (!multiplierEnabled.Value) { return 1; } return _siloMultiplier.Value; } } public static int inserterMultiplier { get { if (!multiplierEnabled.Value) { return 1; } return _inserterMultiplier.Value; } } public static int beltMultiplier { get { if (!multiplierEnabled.Value) { return 1; } return _beltMultiplier.Value; } } public static int ejectorMultiplier { get { if (!multiplierEnabled.Value) { return 1; } return _ejectorMultiplier.Value; } } public static int fractionatorMultiplier { get { if (!multiplierEnabled.Value) { return 1; } return _fractionatorMultiplier.Value; } } public static int labMultiplier { get { if (!multiplierEnabled.Value) { return 1; } return _labMultiplier.Value; } } public static int turretMultiplier { get { if (!multiplierEnabled.Value) { return 1; } return _turretMultiplier.Value; } } public static void InitConfig(ConfigFile confFile) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Expected O, but got Unknown //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Expected O, but got Unknown //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Expected O, but got Unknown //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Expected O, but got Unknown //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Expected O, but got Unknown //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Expected O, but got Unknown //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Expected O, but got Unknown //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Expected O, but got Unknown //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Expected O, but got Unknown //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Expected O, but got Unknown //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Expected O, but got Unknown //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Expected O, but got Unknown smeltMultiplier = confFile.Bind<int>("1. Factory", "smeltMultiplier", 2, new ConfigDescription("Multiplies speed of smelters", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); chemicalMultiplier = confFile.Bind<int>("1. Factory", "chemicalMultiplier", 2, new ConfigDescription("Multiplies speed of chemical plants", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); refineMultiplier = confFile.Bind<int>("1. Factory", "refineMultiplier", 2, new ConfigDescription("Multiplies speed of refineries", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); assembleMultiplier = confFile.Bind<int>("1. Factory", "assembleMultiplier", 2, new ConfigDescription("Multiplies speed of assemblers", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); particleMultiplier = confFile.Bind<int>("1. Factory", "particleMultiplier", 2, new ConfigDescription("Multiplies speed of particle colliders", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); _labMultiplier = confFile.Bind<int>("1. Factory", "labMultiplier", 2, new ConfigDescription("Multiplies speed of laboratories", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); _fractionatorMultiplier = confFile.Bind<int>("1. Factory", "fractionateMultiplier", 2, new ConfigDescription("Multiplies % of fractionators", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); _ejectorMultiplier = confFile.Bind<int>("1. Factory", "ejectorMultiplier", 2, new ConfigDescription("Multiplies speed of EM rail ejectors", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>())); _siloMultiplier = confFile.Bind<int>("1. Factory", "siloMultiplier", 2, new ConfigDescription("Multiplies speed of silos", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>())); gammaMultiplier = confFile.Bind<int>("1. Factory", "gammaMultiplier", 2, new ConfigDescription("Multiplies speed of ray recievers", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 1000), Array.Empty<object>())); miningMultiplier = confFile.Bind<int>("1. Factory", "miningMultiplier", 2, new ConfigDescription("Multiplies speed of mining machines", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); _inserterMultiplier = confFile.Bind<int>("1. Factory", "sorterMultiplier", 2, new ConfigDescription("Multiplies speed of sorter", (AcceptableValueBase)(object)new AcceptableValueList<int>(new int[4] { 1, 2, 4, 8 }), Array.Empty<object>())); _turretMultiplier = confFile.Bind<int>("1. Factory", "turretMultiplier", 2, new ConfigDescription("Multiplies speed of turrets", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); _beltMultiplier = confFile.Bind<int>("1. Factory", "beltMultiplier", 1, new ConfigDescription("Multiplies speed of belts (max 2x)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 2), Array.Empty<object>())); drawMultiplier = confFile.Bind<double>("1. Factory", "drawMultipler", 1.0, new ConfigDescription("Multiplies how much your factory will draw on top of your normal overclock", (AcceptableValueBase)(object)new AcceptableValueRange<double>(0.1, 10.0), Array.Empty<object>())); _genWindMultiplier = confFile.Bind<int>("2. Generator", "generatorWindMultiplier", 2, new ConfigDescription("Multiplies speed of wind turbines", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>())); _genSolarMultiplier = confFile.Bind<int>("2. Generator", "generatorSolarMultiplier", 2, new ConfigDescription("Multiplies speed of solar panels", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>())); _genGeoMultiplier = confFile.Bind<int>("2. Generator", "generatorGeothermalMultiplier", 2, new ConfigDescription("Multiplies speed of geothermal plants", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>())); _genThermalMultiplier = confFile.Bind<int>("2. Generator", "generatorThermalMultiplier", 2, new ConfigDescription("Multiplies speed of thermal plants", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>())); _genFusionMultiplier = confFile.Bind<int>("2. Generator", "generatorFusionMultiplier", 2, new ConfigDescription("Multiplies speed of fusion power plants", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>())); _genStarMultiplier = confFile.Bind<int>("2. Generator", "generatorArtificialStarMultiplier", 2, new ConfigDescription("Multiplies speed of artificial stars", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>())); _genExchMultiplier = confFile.Bind<int>("2. Generator", "generatorExchangerMultiplier", 2, new ConfigDescription("Multiplies speed of energy exchangers", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>())); multiplierEnabled = confFile.Bind<bool>("3. Advanced", "multiplierEnabled", true, "Determine whether we are currently multiplying values"); } public static int GetMultiplierByRecipe(ERecipeType eRecipeType) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected I4, but got Unknown if (!multiplierEnabled.Value) { return 1; } return (eRecipeType - 1) switch { 3 => assembleMultiplier.Value, 1 => chemicalMultiplier.Value, 5 => 1, 7 => fractionatorMultiplier, 4 => particleMultiplier.Value, 2 => refineMultiplier.Value, 14 => labMultiplier, 0 => smeltMultiplier.Value, 6 => gammaMultiplier.Value, _ => 1, }; } } public static class ItemUtil { private static readonly ERecipeType[] _recipeByProtoId = (ERecipeType[])(object)new ERecipeType[15000]; private static readonly bool[] _recipeCacheInit = new bool[15000]; private static readonly bool[] _rayPhotonReceiverProtosArray = new bool[15000]; private static bool _rayPhotonReceiverProtosInit = false; public static ERecipeType GetRecipeByProtoId(int protoId) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_004d: Expected I4, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (protoId < 0 || protoId >= 15000) { return (ERecipeType)0; } if (_recipeCacheInit[protoId]) { return _recipeByProtoId[protoId]; } ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(protoId); if (val?.prefabDesc != null) { ERecipeType assemblerRecipeType = val.prefabDesc.assemblerRecipeType; _recipeByProtoId[protoId] = (ERecipeType)(int)assemblerRecipeType; _recipeCacheInit[protoId] = true; return assemblerRecipeType; } return (ERecipeType)0; } public static bool IsPhotonRayReceiver(int protoId) { if (protoId < 0 || protoId >= 15000) { return false; } if (!_rayPhotonReceiverProtosInit) { ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray; foreach (ItemProto val in dataArray) { if (val.prefabDesc.gammaRayReceiver && ((Proto)val).ID >= 0 && ((Proto)val).ID < 15000) { _rayPhotonReceiverProtosArray[((Proto)val).ID] = true; } } _rayPhotonReceiverProtosInit = true; } return _rayPhotonReceiverProtosArray[protoId]; } } public static class BeltPatcher { private static readonly FieldRef<CargoPath, int> ChunkCount = AccessTools.FieldRefAccess<CargoPath, int>("chunkCount"); [HarmonyPrefix] [HarmonyPatch(typeof(CargoTraffic), "NewBeltComponent")] [HarmonyPatch(typeof(CargoTraffic), "UpgradeBeltComponent")] public static void Belt_Prefix(ref int speed) { int beltMultiplier = PluginConfig.beltMultiplier; if (beltMultiplier > 1 && speed <= 10) { speed = Math.Min(10, speed * beltMultiplier); } } [MethodImpl(MethodImplOptions.NoInlining)] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(CargoTraffic), "UpdateSplitter")] public static void CallOriginalUpdateSplitter(CargoTraffic instance, ref SplitterComponent sp) { throw new NotImplementedException(); } [MethodImpl(MethodImplOptions.NoInlining)] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(PilerComponent), "InternalUpdate")] public static void CallOriginalPilerUpdate(ref PilerComponent instance, CargoTraffic _traffic, AnimData[] _animPool) { throw new NotImplementedException(); } [HarmonyPostfix] [HarmonyPatch(typeof(CargoTraffic), "UpdateSplitter")] public static void UpdateSplitter_Postfix(ref SplitterComponent sp, CargoTraffic __instance) { if (PluginConfig.multiplierEnabled.Value && PluginConfig.beltMultiplier > 1) { for (int i = 0; i < PluginConfig.beltMultiplier - 1; i++) { CallOriginalUpdateSplitter(__instance, ref sp); } } } [HarmonyPostfix] [HarmonyPatch(typeof(PilerComponent), "InternalUpdate")] public static void Piler_InternalUpdate_Postfix(ref PilerComponent __instance, CargoTraffic _traffic, AnimData[] _animPool) { if (PluginConfig.multiplierEnabled.Value && PluginConfig.beltMultiplier > 1) { __instance.cacheCdTick = 0; if (__instance.timeSpend < 10000) { __instance.timeSpend = 10000; } for (int i = 0; i < PluginConfig.beltMultiplier - 1; i++) { CallOriginalPilerUpdate(ref __instance, _traffic, _animPool); __instance.cacheCdTick = 0; } } } [HarmonyPrefix] [HarmonyPatch(typeof(FractionatorComponent), "InternalUpdate")] public static void Fractionator_InternalUpdate_Prefix(ref FractionatorComponent __instance, PlanetFactory factory) { if (!PluginConfig.multiplierEnabled.Value || PluginConfig.beltMultiplier <= 1) { return; } int beltMultiplier = PluginConfig.beltMultiplier; CargoTraffic cargoTraffic = factory.cargoTraffic; byte b = default(byte); byte b2 = default(byte); byte b3 = default(byte); byte b4 = default(byte); byte b5 = default(byte); byte b6 = default(byte); for (int i = 0; i < beltMultiplier - 1; i++) { if (__instance.fluidInputCount >= __instance.fluidInputMax) { break; } if (__instance.belt1 > 0 && !__instance.isOutput1) { if (__instance.fluidId > 0) { if (cargoTraffic.TryPickItemAtRear(__instance.belt1, __instance.fluidId, (int[])null, ref b, ref b2) > 0) { __instance.fluidInputCount += b; __instance.fluidInputInc += b2; __instance.fluidInputCargoCount += 1f; } } else { int num = cargoTraffic.TryPickItemAtRear(__instance.belt1, 0, RecipeProto.fractionatorNeeds, ref b3, ref b4); if (num > 0) { __instance.fluidInputCount += b3; __instance.fluidInputInc += b4; __instance.fluidInputCargoCount += 1f; ((FractionatorComponent)(ref __instance)).SetRecipe(num, factory.entitySignPool); } } } if (__instance.belt2 > 0 && !__instance.isOutput2 && __instance.fluidInputCount < __instance.fluidInputMax && __instance.fluidId > 0 && cargoTraffic.TryPickItemAtRear(__instance.belt2, __instance.fluidId, (int[])null, ref b5, ref b6) > 0) { __instance.fluidInputCount += b5; __instance.fluidInputInc += b6; __instance.fluidInputCargoCount += 1f; } } } [HarmonyTranspiler] [HarmonyPatch(typeof(FractionatorComponent), "InternalUpdate")] public static IEnumerable<CodeInstruction> Fractionator_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_R8 && (double)list[i].operand == 30.0) { list[i].opcode = OpCodes.Call; list[i].operand = AccessTools.Method(typeof(BeltPatcher), "GetFractionatorLimit", (Type[])null, (Type[])null); } if (list[i].opcode == OpCodes.Ldc_I4_1 && i + 2 < list.Count && list[i + 1].opcode == OpCodes.Ldc_I4_0 && list[i + 2].opcode == OpCodes.Callvirt && list[i + 2].operand.ToString().Contains("TryInsertItemAtHead")) { list[i].opcode = OpCodes.Call; list[i].operand = AccessTools.Method(typeof(BeltPatcher), "GetBeltMultiplier", (Type[])null, (Type[])null); } if (list[i].opcode == OpCodes.Ldc_I4_1 && i + 2 < list.Count && list[i + 2].opcode == OpCodes.Callvirt && list[i + 2].operand.ToString().Contains("TryUpdateItemAtHeadAndFillBlank")) { list[i].opcode = OpCodes.Call; list[i].operand = AccessTools.Method(typeof(BeltPatcher), "GetBeltMultiplier", (Type[])null, (Type[])null); } } return list; } [HarmonyPostfix] [HarmonyPatch(typeof(FractionatorComponent), "InternalUpdate")] public static void Fractionator_InternalUpdate_Postfix(ref FractionatorComponent __instance, PlanetFactory factory) { if (!PluginConfig.multiplierEnabled.Value || PluginConfig.beltMultiplier <= 1) { return; } CargoTraffic cargoTraffic = factory.cargoTraffic; int beltMultiplier = PluginConfig.beltMultiplier; for (int i = 0; i < beltMultiplier - 1; i++) { if (__instance.productOutputCount <= 0) { break; } if (__instance.belt0 <= 0) { break; } if (!__instance.isOutput0) { break; } if (!cargoTraffic.TryInsertItemAtHead(__instance.belt0, __instance.productId, (byte)1, (byte)0)) { break; } __instance.productOutputCount--; } for (int j = 0; j < beltMultiplier - 1; j++) { if (__instance.fluidOutputCount <= 0) { break; } int num = ((__instance.belt1 > 0 && __instance.isOutput1) ? __instance.belt1 : ((__instance.belt2 > 0 && __instance.isOutput2) ? __instance.belt2 : 0)); if (num != 0) { CargoPath cargoPath = cargoTraffic.GetCargoPath(cargoTraffic.beltPool[num].segPathId); if (cargoPath != null) { int num2 = __instance.fluidOutputInc / __instance.fluidOutputCount; if (cargoPath.TryUpdateItemAtHeadAndFillBlank(__instance.fluidId, 4, (byte)1, (byte)num2)) { __instance.fluidOutputCount--; __instance.fluidOutputInc -= num2; continue; } break; } break; } break; } } public static double GetFractionatorLimit() { if (!PluginConfig.multiplierEnabled.Value) { return 30.0; } return (double)PluginConfig.beltMultiplier * 30.0; } public static int GetBeltMultiplier() { if (!PluginConfig.multiplierEnabled.Value) { return 1; } return PluginConfig.beltMultiplier; } public static void SyncBelts(PlanetFactory factory) { CargoTraffic cargoTraffic = factory.cargoTraffic; if (cargoTraffic == null) { return; } int beltMultiplier = PluginConfig.beltMultiplier; for (int i = 1; i < cargoTraffic.beltCursor; i++) { if (cargoTraffic.beltPool[i].id != i) { continue; } int entityId = cargoTraffic.beltPool[i].entityId; int protoId = factory.entityPool[entityId].protoId; ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(protoId); if (val != null) { int num = val.prefabDesc.beltSpeed * beltMultiplier; if (num > 10) { num = 10; } cargoTraffic.beltPool[i].speed = num; } } for (int j = 1; j < cargoTraffic.pathCursor; j++) { CargoPath val2 = cargoTraffic.pathPool[j]; if (val2 == null || val2.id != j || val2.chunks == null) { continue; } int num2 = Math.Min(ChunkCount.Invoke(val2), val2.chunks.Length / 3); for (int k = 0; k < num2; k++) { int num3 = val2.chunks[k * 3]; int num4 = 1; if (val2.belts != null) { int num5 = -1; foreach (int belt in val2.belts) { if (belt > 0 && belt < cargoTraffic.beltCursor) { ref BeltComponent reference = ref cargoTraffic.beltPool[belt]; if (reference.id == belt && reference.segIndex <= num3 && reference.segIndex > num5) { num5 = reference.segIndex; num4 = reference.speed; } } } } val2.chunks[k * 3 + 2] = num4; } } } } public static class BuildingPatcher { private static readonly ConcurrentDictionary<int, int> _inserterDelayByProtoId = new ConcurrentDictionary<int, int>(); [HarmonyPrefix] [HarmonyPatch(typeof(InserterComponent), "InternalUpdate")] [HarmonyPatch(typeof(InserterComponent), "InternalUpdateNoAnim")] [HarmonyPatch(typeof(InserterComponent), "InternalUpdate_Bidirectional")] public static void Inserter_InternalUpdate_Prefix(ref InserterComponent __instance, ref float power, PlanetFactory factory) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) if (__instance.id == 0 || __instance.entityId == 0) { return; } int inserterMultiplier = PluginConfig.inserterMultiplier; if (inserterMultiplier > 1) { power *= inserterMultiplier; int protoId = factory.entityPool[__instance.entityId].protoId; if (!_inserterDelayByProtoId.TryGetValue(protoId, out var value)) { ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(protoId); int num = (_inserterDelayByProtoId[protoId] = (val?.prefabDesc?.inserterDelay).GetValueOrDefault()); value = num; } if (value > 0) { __instance.delay = value / inserterMultiplier; } if (!__instance.bidirectional && (int)__instance.stage == 0 && __instance.itemId > 0) { __instance.time += 10000 * (inserterMultiplier - 1); } } } [HarmonyTranspiler] [HarmonyPatch(typeof(InserterComponent), "InternalUpdate_Bidirectional")] public static IEnumerable<CodeInstruction> Inserter_Bidirectional_Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_I4_1 && i + 1 < list.Count && (list[i + 1].opcode == OpCodes.Stloc_0 || list[i + 1].opcode == OpCodes.Stloc_1 || list[i + 1].opcode == OpCodes.Stloc_2 || list[i + 1].opcode == OpCodes.Stloc_3)) { list[i].opcode = OpCodes.Call; list[i].operand = AccessTools.PropertyGetter(typeof(PluginConfig), "inserterMultiplier"); } } return list; } } public static class FactorySystemPatcher { private static readonly ConcurrentDictionary<int, int> _baseSpeedByProtoId = new ConcurrentDictionary<int, int>(); private static readonly ConcurrentDictionary<int, int> _labBaseSpeedByProtoId = new ConcurrentDictionary<int, int>(); private static readonly ConcurrentDictionary<int, int> _minerBaseSpeedByProtoId = new ConcurrentDictionary<int, int>(); public static void SyncAll(FactorySystem factorySystem) { SyncAssemblers(factorySystem); SyncLabs(factorySystem); SyncMiners(factorySystem); } public static void SyncMiners(FactorySystem factorySystem) { for (int i = 1; i < factorySystem.minerCursor; i++) { if (factorySystem.minerPool[i].id == i) { SyncMiner(ref factorySystem.minerPool[i], factorySystem.factory); } } } public static void SyncMiner(ref MinerComponent miner, PlanetFactory factory) { int protoId = factory.entityPool[miner.entityId].protoId; int num = ((!PluginConfig.multiplierEnabled.Value) ? 1 : PluginConfig.miningMultiplier.Value); if (!_minerBaseSpeedByProtoId.TryGetValue(protoId, out var value)) { value = 10000; _minerBaseSpeedByProtoId[protoId] = value; } miner.speed = num * value; } public static void SyncLabs(FactorySystem factorySystem) { for (int i = 1; i < factorySystem.labCursor; i++) { if (factorySystem.labPool[i].id == i) { SyncLab(ref factorySystem.labPool[i], factorySystem.factory); } } } public static void SyncLab(ref LabComponent lab, PlanetFactory factory) { int protoId = factory.entityPool[lab.entityId].protoId; int labMultiplier = PluginConfig.labMultiplier; if (!_labBaseSpeedByProtoId.TryGetValue(protoId, out var value)) { ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(protoId); int num = (_labBaseSpeedByProtoId[protoId] = val?.prefabDesc?.labAssembleSpeed ?? 10000); value = num; } if (lab.replicating && lab.speed > 0) { double num3 = (double)lab.speedOverride / (double)lab.speed; lab.speedOverride = (int)(num3 * (double)labMultiplier * (double)value); } lab.speed = labMultiplier * value; } public static void SyncAssemblers(FactorySystem factorySystem) { for (int i = 1; i < factorySystem.assemblerCursor; i++) { if (factorySystem.assemblerPool[i].id == i) { SyncAssembler(ref factorySystem.assemblerPool[i], factorySystem.factory); } } } public static void SyncAssembler(ref AssemblerComponent assembler, PlanetFactory factory) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) int protoId = factory.entityPool[assembler.entityId].protoId; if (!_baseSpeedByProtoId.TryGetValue(protoId, out var value)) { ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(protoId); int num = (_baseSpeedByProtoId[protoId] = val?.prefabDesc?.assemblerSpeed ?? 10000); value = num; } int multiplierByRecipe = PluginConfig.GetMultiplierByRecipe((assembler.recipeId > 0) ? assembler.recipeType : ItemUtil.GetRecipeByProtoId(protoId)); if (assembler.replicating && assembler.speed > 0) { double num3 = (double)assembler.speedOverride / (double)assembler.speed; assembler.speedOverride = (int)(num3 * (double)multiplierByRecipe * (double)value); } assembler.speed = multiplierByRecipe * value; } [HarmonyPostfix] [HarmonyPatch(typeof(FactorySystem), "NewAssemblerComponent")] public static void NewAssemblerComponent_Postfix(FactorySystem __instance, int __result) { if (__result > 0) { SyncAssembler(ref __instance.assemblerPool[__result], __instance.factory); } } [HarmonyPostfix] [HarmonyPatch(typeof(FactorySystem), "NewLabComponent")] public static void NewLabComponent_Postfix(FactorySystem __instance, int __result) { if (__result > 0) { SyncLab(ref __instance.labPool[__result], __instance.factory); } } [HarmonyPostfix] [HarmonyPatch(typeof(FactorySystem), "NewMinerComponent")] public static void NewMinerComponent_Postfix(FactorySystem __instance, int __result) { if (__result > 0) { SyncMiner(ref __instance.minerPool[__result], __instance.factory); } } [HarmonyPrefix] [HarmonyPatch(typeof(LabComponent), "InternalUpdateResearch")] private static void MultiplyLabResearch(ref float research_speed) { if (PluginConfig.multiplierEnabled.Value && PluginConfig.labMultiplier > 1) { research_speed *= PluginConfig.labMultiplier; } } } public static class PowerConsumptionPatcher { public static void SyncPowerSystems(PowerSystem powerSystem) { for (int i = 1; i < powerSystem.consumerCursor; i++) { if (powerSystem.consumerPool[i].id == i) { SyncConsumer(ref powerSystem.consumerPool[i], powerSystem.factory); } } } public static void SyncConsumer(ref PowerConsumerComponent consumer, PlanetFactory factory) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) int entityId = consumer.entityId; if (entityId <= 0) { return; } ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select((int)factory.entityPool[entityId].protoId); if (val == null) { return; } PrefabDesc prefabDesc = val.prefabDesc; if ((int)val.Type != 5 && !prefabDesc.isStation && !prefabDesc.isPowerExchanger && ((Proto)val).ID != 3009) { int num = 1; if (prefabDesc.isAssembler) { num = PluginConfig.GetMultiplierByRecipe(ItemUtil.GetRecipeByProtoId(((Proto)val).ID)); } else if (prefabDesc.isLab) { num = PluginConfig.labMultiplier; } else if ((int)prefabDesc.minerType != 0) { num = ((!PluginConfig.multiplierEnabled.Value) ? 1 : PluginConfig.miningMultiplier.Value); } else if (prefabDesc.isTurret) { num = PluginConfig.turretMultiplier; } else if (prefabDesc.isSilo) { num = PluginConfig.siloMultiplier; } else if (prefabDesc.isFractionator) { num = PluginConfig.fractionatorMultiplier; } else if (prefabDesc.isEjector) { num = PluginConfig.ejectorMultiplier; } consumer.workEnergyPerTick = (long)((PluginConfig.multiplierEnabled.Value ? PluginConfig.drawMultiplier.Value : 1.0) * (double)num * (double)prefabDesc.workEnergyPerTick); } } [HarmonyPostfix] [HarmonyPatch(typeof(PowerSystem), "NewConsumerComponent")] public static void NewConsumerComponent_Postfix(PowerSystem __instance, int __result) { if (__result > 0) { SyncConsumer(ref __instance.consumerPool[__result], __instance.factory); } } } public static class PowerGenerationPatcher { public static void SyncGenerators(PowerSystem powerSystem) { for (int i = 1; i < powerSystem.genCursor; i++) { if (powerSystem.genPool[i].id == i) { SyncGenerator(ref powerSystem.genPool[i], powerSystem.factory); } } for (int j = 1; j < powerSystem.excCursor; j++) { if (powerSystem.excPool[j].id == j) { ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select((int)powerSystem.factory.entityPool[powerSystem.excPool[j].entityId].protoId); if (val != null) { powerSystem.excPool[j].energyPerTick = val.prefabDesc.exchangeEnergyPerTick * PluginConfig.genExchMultiplier; } } } } public static void SyncGenerator(ref PowerGeneratorComponent gen, PlanetFactory factory) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select((int)factory.entityPool[gen.entityId].protoId); if (val == null) { return; } if (gen.photovoltaic) { gen.genEnergyPerTick = val.prefabDesc.genEnergyPerTick * PluginConfig.genSolarMultiplier; } else if (gen.wind) { gen.genEnergyPerTick = val.prefabDesc.genEnergyPerTick * PluginConfig.genWindMultiplier; } else if (gen.geothermal) { gen.genEnergyPerTick = val.prefabDesc.genEnergyPerTick * PluginConfig.genGeoMultiplier; } else if (gen.gamma) { gen.genEnergyPerTick = val.prefabDesc.genEnergyPerTick * ((!PluginConfig.multiplierEnabled.Value) ? 1 : PluginConfig.gammaMultiplier.Value); } else if (IsFuelConsumer(gen)) { int num = 1; if ((gen.fuelMask & 1) != 0) { num = PluginConfig.genThermalMultiplier; } else if ((gen.fuelMask & 2) != 0) { num = PluginConfig.genFusionMultiplier; } else if ((gen.fuelMask & 4) != 0) { num = PluginConfig.genStarMultiplier; } gen.genEnergyPerTick = val.prefabDesc.genEnergyPerTick * num; gen.useFuelPerTick = val.prefabDesc.useFuelPerTick * num; } } [HarmonyPostfix] [HarmonyPatch(typeof(PowerSystem), "NewGeneratorComponent")] public static void NewGeneratorComponent_Postfix(PowerSystem __instance, int __result) { if (__result > 0) { SyncGenerator(ref __instance.genPool[__result], __instance.factory); } } [HarmonyPostfix] [HarmonyPatch(typeof(PowerSystem), "NewExchangerComponent")] public static void NewExchangerComponent_Postfix(PowerSystem __instance, int __result) { if (__result > 0) { ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select((int)__instance.factory.entityPool[__instance.excPool[__result].entityId].protoId); if (val != null) { __instance.excPool[__result].energyPerTick = val.prefabDesc.exchangeEnergyPerTick * PluginConfig.genExchMultiplier; } } } private static bool IsFuelConsumer(PowerGeneratorComponent gen) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) int[] array = ItemProto.fuelNeeds[gen.fuelMask]; if (array != null) { return array.Length != 0; } return false; } } public static class StationPatcher { public static class MoreMegaStructureCompat { private static FastInvokeHandler _updateOutputSlotsHandler; private static FastInvokeHandler _updateInputSlotsHandler; private static bool _handlersInitialized; private static void InitHandlers(object instance) { if (!_handlersInitialized) { Type type = instance.GetType(); MethodInfo method = type.GetMethod("UpdateOutputSlots"); if (method != null) { _updateOutputSlotsHandler = MethodInvoker.GetHandler(method, false); } MethodInfo method2 = type.GetMethod("UpdateInputSlots"); if (method2 != null) { _updateInputSlotsHandler = MethodInvoker.GetHandler(method2, false); } _handlersInitialized = true; } } [HarmonyPrefix] [HarmonyPatch("MoreMegaStructure.ExchangeStationComponent", "UpdateOutputSlots")] public static bool ExchangeStation_UpdateOutputSlots_Prefix(object __instance, CargoTraffic traffic, SignData[] signPool, int maxPilerCount, bool active) { if (_isLooping || !PluginConfig.multiplierEnabled.Value || PluginConfig.beltMultiplier <= 1) { return true; } _isLooping = true; InitHandlers(__instance); try { if (_updateOutputSlotsHandler != null) { object[] array = new object[4] { traffic, signPool, maxPilerCount, active }; for (int i = 0; i < PluginConfig.beltMultiplier; i++) { _updateOutputSlotsHandler.Invoke(__instance, array); } } } finally { _isLooping = false; } return false; } [HarmonyPrefix] [HarmonyPatch("MoreMegaStructure.ExchangeStationComponent", "UpdateInputSlots")] public static bool ExchangeStation_UpdateInputSlots_Prefix(object __instance, CargoTraffic traffic, SignData[] signPool, int maxPilerCount, bool active) { if (_isLooping || !PluginConfig.multiplierEnabled.Value || PluginConfig.beltMultiplier <= 1) { return true; } _isLooping = true; InitHandlers(__instance); try { if (_updateInputSlotsHandler != null) { object[] array = new object[4] { traffic, signPool, maxPilerCount, active }; for (int i = 0; i < PluginConfig.beltMultiplier; i++) { _updateInputSlotsHandler.Invoke(__instance, array); } } } finally { _isLooping = false; } return false; } [HarmonyTranspiler] [HarmonyPatch("MoreMegaStructure.ExchangeStationComponent", "UpdateOutputSlots")] [HarmonyPatch("MoreMegaStructure.ExchangeStationComponent", "UpdateInputSlots")] [HarmonyPatch("MoreMegaStructure.ExchangeStationComponent", "UpdateSlots")] public static IEnumerable<CodeInstruction> MoreMegaStructure_UpdateSlots_Transpiler(IEnumerable<CodeInstruction> instructions) { return StationComponent_UpdateSlots_Transpiler(instructions); } } [ThreadStatic] private static bool _isLooping; [HarmonyPrefix] [HarmonyPatch(typeof(StationComponent), "UpdateOutputSlots")] public static bool UpdateOutputSlots_Prefix(StationComponent __instance, CargoTraffic traffic, SignData[] signPool, int maxPilerCount, bool active) { if (_isLooping || !PluginConfig.multiplierEnabled.Value || PluginConfig.beltMultiplier <= 1) { return true; } _isLooping = true; try { int beltMultiplier = PluginConfig.beltMultiplier; for (int i = 0; i < beltMultiplier; i++) { __instance.UpdateOutputSlots(traffic, signPool, maxPilerCount, active); } } finally { _isLooping = false; } return false; } [HarmonyPostfix] [HarmonyPatch(typeof(StationComponent), "UpdateInputSlots")] public static void UpdateInputSlots_Postfix(StationComponent __instance, CargoTraffic traffic, SignData[] signPool, bool active) { if (_isLooping || !PluginConfig.multiplierEnabled.Value || PluginConfig.beltMultiplier <= 1) { return; } _isLooping = true; try { int beltMultiplier = PluginConfig.beltMultiplier; for (int i = 0; i < beltMultiplier - 1; i++) { __instance.UpdateInputSlots(traffic, signPool, active); } } finally { _isLooping = false; } } [HarmonyTranspiler] [HarmonyPatch(typeof(StationComponent), "UpdateOutputSlots")] [HarmonyPatch(typeof(StationComponent), "UpdateInputSlots")] public static IEnumerable<CodeInstruction> StationComponent_UpdateSlots_Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_I4_1 && i + 1 < list.Count && list[i + 1].opcode == OpCodes.Stfld && list[i + 1].operand.ToString().Contains("counter")) { list[i].opcode = OpCodes.Call; list[i].operand = AccessTools.Method(typeof(StationPatcher), "GetSlotCounterValue", (Type[])null, (Type[])null); } } return list; } public static int GetSlotCounterValue() { if (!PluginConfig.multiplierEnabled.Value || PluginConfig.beltMultiplier <= 1) { return 1; } return 0; } [HarmonyPrefix] [HarmonyPatch(typeof(StationComponent), "UpdateCollection")] public static void UpdateCollection_Prefix(StationComponent __instance, ref float collectSpeedRate) { if (!PluginConfig.multiplierEnabled.Value) { return; } float num = ((collectSpeedRate < 0f) ? 0f : collectSpeedRate); float num2 = PluginConfig.beltMultiplier; float num3 = num * num2; if (__instance.isCollector && __instance.collectionPerTick != null) { float num4 = 0f; for (int i = 0; i < __instance.collectionPerTick.Length; i++) { if (__instance.collectionPerTick[i] > num4) { num4 = __instance.collectionPerTick[i]; } } if (num4 > 0.0001f) { float num5 = 1000f / num4; if (num3 > num5) { num3 = Math.Max(num, num5); } } } if (num3 > 1000000f) { num3 = 1000000f; } collectSpeedRate = num3; } } [HarmonyPatch(typeof(TurretComponent))] public static class TurretPatcher { [HarmonyPrefix] [HarmonyPatch("InternalUpdate")] [HarmonyPatch("Aim")] [HarmonyPatch("Shoot")] public static void Turret_Prefix(ref float power) { if (PluginConfig.multiplierEnabled.Value) { power *= PluginConfig.turretMultiplier; } } } [BepInPlugin("LokiMoonLabs.FastNFurious", "Fast N Furious", "0.1.0")] [BepInIncompatibility("com.Valoneu.FactoryOverclock")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(GameMain), "Begin")] private static class RestoreLaunchers { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix() { PlanetFactory[] array = GameMain.data?.factories; if (array == null) { return; } PlanetFactory[] array2 = array; foreach (PlanetFactory val in array2) { FactorySystem val2 = val?.factorySystem; if (val2 == null) { continue; } for (int j = 1; j < val2.ejectorCursor; j++) { ref EjectorComponent reference = ref val2.ejectorPool[j]; if (reference.id == j && reference.entityId > 0) { PrefabDesc val3 = ((ProtoSet<ItemProto>)(object)LDB.items).Select((int)val.entityPool[reference.entityId].protoId)?.prefabDesc; if (val3 != null) { RestoreTiming(ref reference.time, ref reference.chargeSpend, ref reference.coldSpend, reference.direction, val3.ejectorChargeFrame, val3.ejectorColdFrame); } } } for (int k = 1; k < val2.siloCursor; k++) { ref SiloComponent reference2 = ref val2.siloPool[k]; if (reference2.id == k && reference2.entityId > 0) { PrefabDesc val4 = ((ProtoSet<ItemProto>)(object)LDB.items).Select((int)val.entityPool[reference2.entityId].protoId)?.prefabDesc; if (val4 != null) { RestoreTiming(ref reference2.time, ref reference2.chargeSpend, ref reference2.coldSpend, reference2.direction, val4.siloChargeFrame, val4.siloColdFrame); } } } } } } [HarmonyPatch(typeof(EjectorComponent), "InternalUpdate")] private static class Ejector { private static void Prefix(ref float power) { Plugin instance = Instance; if (instance != null && instance.enabledEntry.Value) { power *= Math.Min(10, instance.ejector.Value); } } } [HarmonyPatch(typeof(SiloComponent), "InternalUpdate")] private static class Silo { private static void Prefix(ref float power) { Plugin instance = Instance; if (instance != null && instance.enabledEntry.Value) { power *= Math.Min(10, instance.silo.Value); } } } [HarmonyPatch(typeof(VFInput), "UpdateGameStates")] private static class BlockGameInput { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix() { FastWindow fastWindow = Instance?.window; if (fastWindow != null && (fastWindow.Blocking || fastWindow.Editing)) { VFInput.onGUI = true; VFInput.onGUIOperate = true; VFInput.inScrollView = true; if (fastWindow.Editing) { VFInput.inputing = true; } } } } internal const string Guid = "LokiMoonLabs.FastNFurious"; internal const string Upstream = "com.Valoneu.FactoryOverclock"; internal static Plugin Instance; private Harmony harmony; private FastWindow window; private ConfigFile factoryConfig; private Action refresh; private ConfigEntry<int> ejector; private ConfigEntry<int> silo; private ConfigEntry<bool> enabledEntry; private FieldInfo honeyCargoLimit; private Func<double> originalCargoLimit; internal IEnumerable<ConfigEntryBase> Settings => (from pair in (IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)factoryConfig select pair.Value into entry where entry.Definition.Section == "1. Factory" || entry.Definition.Section == "2. Generator" select entry).Concat((IEnumerable<ConfigEntryBase>)(object)new ConfigEntryBase[1] { (ConfigEntryBase)enabledEntry }); private void Awake() { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown try { factoryConfig = ((BaseUnityPlugin)this).Config; factoryConfig.SaveOnConfigSet = false; PluginConfig.InitConfig(factoryConfig); factoryConfig.Save(); ejector = Entry<int>("1. Factory", "ejectorMultiplier"); silo = Entry<int>("1. Factory", "siloMultiplier"); enabledEntry = Entry<bool>("3. Advanced", "multiplierEnabled"); refresh = RefreshAllSystems; Instance = this; harmony = new Harmony("LokiMoonLabs.FastNFurious"); Type[] array = new Type[8] { typeof(Plugin), typeof(PowerConsumptionPatcher), typeof(PowerGenerationPatcher), typeof(FactorySystemPatcher), typeof(StationPatcher), typeof(BeltPatcher), typeof(BuildingPatcher), typeof(TurretPatcher) }; foreach (Type type in array) { harmony.PatchAll(type); } harmony.CreateClassProcessor(typeof(RestoreLaunchers)).Patch(); harmony.CreateClassProcessor(typeof(Ejector)).Patch(); harmony.CreateClassProcessor(typeof(Silo)).Patch(); harmony.CreateClassProcessor(typeof(BlockGameInput)).Patch(); if (Chainloader.PluginInfos.ContainsKey("jinxOAO.MoreMegaStructure")) { harmony.PatchAll(typeof(StationPatcher.MoreMegaStructureCompat)); } ConnectHoney(); window = new FastWindow(this); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Fast N Furious ready. Launcher multipliers apply once and are capped at 10x."); } catch (Exception ex) { Unpatch(); ((BaseUnityPlugin)this).Logger.LogError((object)("Fast N Furious could not start: " + ex)); } } private void ConnectHoney() { if (Chainloader.PluginInfos.TryGetValue("LokiMoonLabs.HoneyIShrunkTheFactory", out var value)) { Type type = ((object)value.Instance)?.GetType().Assembly.GetType("LokiMoonLabs.HoneyIShrunkTheFactory.Fractionation"); FieldInfo fieldInfo = ((type == null) ? null : AccessTools.Field(type, "CargoLimit")); if (!(fieldInfo?.FieldType != typeof(Func<double>))) { originalCargoLimit = (Func<double>)fieldInfo.GetValue(null); fieldInfo.SetValue(null, new Func<double>(BeltPatcher.GetFractionatorLimit)); honeyCargoLimit = fieldInfo; } } } [HarmonyPatch(typeof(GameMain), "Begin")] [HarmonyPostfix] private static void GameBegin() { Instance?.RefreshAllSystems(); } private void RefreshAllSystems() { PlanetFactory[] array = GameMain.data?.factories; if (array == null) { return; } PlanetFactory[] array2 = array; foreach (PlanetFactory val in array2) { if (val != null) { if (val.powerSystem != null) { PowerGenerationPatcher.SyncGenerators(val.powerSystem); PowerConsumptionPatcher.SyncPowerSystems(val.powerSystem); } if (val.factorySystem != null) { FactorySystemPatcher.SyncAll(val.factorySystem); } if (val.cargoTraffic != null) { BeltPatcher.SyncBelts(val); } } } } internal ConfigEntry<T> Entry<T>(string section, string key) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown ConfigEntry<T> result = default(ConfigEntry<T>); if (!factoryConfig.TryGetEntry<T>(new ConfigDefinition(section, key), ref result)) { throw new InvalidOperationException("Missing FactoryOverclock setting " + key); } return result; } internal static bool IsLauncher(ConfigEntryBase entry) { if (!(entry.Definition.Key == "ejectorMultiplier")) { return entry.Definition.Key == "siloMultiplier"; } return true; } private void CapLaunchers() { if (ejector.Value > 10) { ejector.Value = 10; } if (silo.Value > 10) { silo.Value = 10; } } internal void Apply(IReadOnlyDictionary<ConfigEntryBase, object> values) { Dictionary<ConfigEntryBase, object> dictionary = values.ToDictionary((KeyValuePair<Co