using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FactoryMutiplier")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FactoryMutiplier")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("fc2031c0-0866-4377-acca-7189e241c495")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FactoryMultiplier;
internal sealed class FactoryMultiplierWindow
{
private readonly FactoryMultiplier owner;
private readonly Dictionary<FactoryMultiplier.MultiplierField, UIInputField> inputFields = new Dictionary<FactoryMultiplier.MultiplierField, UIInputField>();
private GameObject rootObject;
private UIInventoryWindow shellWindow;
private GameObject closeButtonGroup;
private RectTransform contentRoot;
private Text bodyTextTemplate;
private Text hotkeyText;
private Text statusText;
private UIToggle walkSpeedToggle;
public bool IsVisible => (Object)(object)rootObject != (Object)null && rootObject.activeSelf;
public FactoryMultiplierWindow(FactoryMultiplier owner)
{
this.owner = owner;
}
public void Tick(bool shouldShow)
{
if (!TryEnsureCreated())
{
return;
}
if (shouldShow)
{
if (!IsVisible)
{
Show();
}
UICursor.forceShowCursor = true;
RefreshStatus();
RefreshWalkSpeedToggle();
}
else if (IsVisible)
{
Hide();
}
}
public void Dispose()
{
if ((Object)(object)rootObject != (Object)null)
{
Object.Destroy((Object)(object)rootObject);
rootObject = null;
}
shellWindow = null;
closeButtonGroup = null;
contentRoot = null;
bodyTextTemplate = null;
hotkeyText = null;
statusText = null;
walkSpeedToggle = null;
inputFields.Clear();
}
private bool TryEnsureCreated()
{
if ((Object)(object)rootObject != (Object)null)
{
return true;
}
UIRoot instance = UIRoot.instance;
if ((Object)(object)instance == (Object)null || (Object)(object)instance.uiGame == (Object)null || !((ManualBehaviour)instance.uiGame).inited)
{
return false;
}
UIGame uiGame = instance.uiGame;
if ((Object)(object)uiGame.windowGroup == (Object)null || (Object)(object)uiGame.inventoryWindow == (Object)null || (Object)(object)uiGame.minerWindow == (Object)null || (Object)(object)uiGame.blueprintCopyInspector == (Object)null)
{
return false;
}
if ((Object)(object)instance.optionWindow == (Object)null || (Object)(object)instance.optionWindow.applyButton == (Object)null || (Object)(object)instance.optionWindow.backgroundPause == (Object)null)
{
return false;
}
BuildWindow(uiGame, instance);
return (Object)(object)rootObject != (Object)null;
}
private void BuildWindow(UIGame uiGame, UIRoot uiRoot)
{
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
rootObject = Object.Instantiate<GameObject>(((Component)uiGame.inventoryWindow).gameObject, (Transform)(object)uiGame.windowGroup, false);
((Object)rootObject).name = "FactoryMultiplierWindow";
rootObject.SetActive(false);
shellWindow = rootObject.GetComponent<UIInventoryWindow>();
if ((Object)(object)shellWindow == (Object)null || (Object)(object)shellWindow.windowTrans == (Object)null || (Object)(object)shellWindow.titleText == (Object)null)
{
Dispose();
return;
}
Transform transform = rootObject.transform;
RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
if ((Object)(object)val != (Object)null)
{
val.anchorMin = new Vector2(0.5f, 0.5f);
val.anchorMax = new Vector2(0.5f, 0.5f);
val.pivot = new Vector2(0.5f, 0.5f);
val.anchoredPosition = Vector2.zero;
((Transform)val).localScale = Vector3.one;
}
shellWindow.windowTrans.sizeDelta = new Vector2(900f, 640f);
bodyTextTemplate = uiRoot.optionWindow.copyMsg;
if ((Object)(object)bodyTextTemplate == (Object)null)
{
bodyTextTemplate = ((Component)uiRoot.optionWindow.applyButton).GetComponentInChildren<Text>(true);
}
HideTemplateContent();
HideTemplateTextAndButtons();
CreateCloseButtonGroup(uiGame);
RewireCloseButton();
CreateContent(uiRoot);
}
private void HideTemplateContent()
{
if ((Object)(object)shellWindow.inventory != (Object)null)
{
((Component)shellWindow.inventory).gameObject.SetActive(false);
}
if ((Object)(object)shellWindow.deliveryPanel != (Object)null)
{
((Component)shellWindow.deliveryPanel).gameObject.SetActive(false);
}
}
private void HideTemplateTextAndButtons()
{
HashSet<GameObject> hashSet = new HashSet<GameObject>();
Text[] componentsInChildren = ((Component)shellWindow.windowTrans).GetComponentsInChildren<Text>(true);
Text[] array = componentsInChildren;
foreach (Text val in array)
{
if ((Object)(object)val != (Object)null && hashSet.Add(((Component)val).gameObject))
{
((Component)val).gameObject.SetActive(false);
}
}
UIButton[] componentsInChildren2 = ((Component)shellWindow.windowTrans).GetComponentsInChildren<UIButton>(true);
UIButton[] array2 = componentsInChildren2;
foreach (UIButton val2 in array2)
{
if ((Object)(object)val2 != (Object)null && hashSet.Add(((Component)val2).gameObject))
{
((Component)val2).gameObject.SetActive(false);
}
}
Button[] componentsInChildren3 = ((Component)shellWindow.windowTrans).GetComponentsInChildren<Button>(true);
Button[] array3 = componentsInChildren3;
foreach (Button val3 in array3)
{
if ((Object)(object)val3 != (Object)null && hashSet.Add(((Component)val3).gameObject))
{
((Component)val3).gameObject.SetActive(false);
}
}
}
private void CreateCloseButtonGroup(UIGame uiGame)
{
if (!((Object)(object)uiGame.minerWindow == (Object)null) && !((Object)(object)uiGame.minerWindow.closeButtonGroupGo == (Object)null))
{
closeButtonGroup = Object.Instantiate<GameObject>(uiGame.minerWindow.closeButtonGroupGo, (Transform)(object)shellWindow.windowTrans, false);
((Object)closeButtonGroup).name = "FactoryMultiplierCloseButton";
closeButtonGroup.SetActive(true);
closeButtonGroup.transform.SetAsLastSibling();
}
}
private void RewireCloseButton()
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
if ((Object)(object)closeButtonGroup == (Object)null)
{
return;
}
Button[] componentsInChildren = closeButtonGroup.GetComponentsInChildren<Button>(true);
Button[] array = componentsInChildren;
foreach (Button val in array)
{
((UnityEventBase)val.onClick).RemoveAllListeners();
((UnityEvent)val.onClick).AddListener(new UnityAction(OnCloseButtonClick));
}
UIButton[] componentsInChildren2 = closeButtonGroup.GetComponentsInChildren<UIButton>(true);
UIButton[] array2 = componentsInChildren2;
foreach (UIButton val2 in array2)
{
Button button = val2.button;
if (button != null)
{
((UnityEventBase)button.onClick).RemoveAllListeners();
}
ClearTips(val2);
val2.BindOnClickSafe((Action<int>)delegate
{
OnCloseButtonClick();
});
}
}
private void CreateContent(UIRoot uiRoot)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: 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_014d: 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_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: 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_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
contentRoot = CreateRect("FactoryMultiplierContent", (Transform)(object)shellWindow.windowTrans, new Vector2(0f, 0f), new Vector2(1f, 1f), new Vector2(0f, 1f));
contentRoot.offsetMin = new Vector2(28f, 18f);
contentRoot.offsetMax = new Vector2(-28f, -54f);
CreateText("WindowTitle", (Transform)(object)contentRoot, shellWindow.titleText, 20, 18f, 4f, 300f, 26f, (TextAnchor)3, ((Graphic)shellWindow.titleText).color).text = owner.GetWindowTitle();
RectTransform parent = contentRoot;
Text template = bodyTextTemplate;
Text componentInChildren = ((Component)uiRoot.optionWindow.applyButton).GetComponentInChildren<Text>(true);
hotkeyText = CreateText("HotkeyText", (Transform)(object)parent, template, 20, 0f, 0f, 828f, 24f, (TextAnchor)5, (componentInChildren != null) ? ((Graphic)componentInChildren).color : Color.white);
hotkeyText.text = owner.GetHotkeyHint();
RectTransform parent2 = CreateSectionPanel("LeftPanel", new Vector2(0f, -40f), new Vector2(404f, 430f), owner.GetSectionTitle(isLeftSection: true));
RectTransform parent3 = CreateSectionPanel("RightPanel", new Vector2(424f, -40f), new Vector2(404f, 430f), owner.GetSectionTitle(isLeftSection: false));
CreateFieldRow(parent2, FactoryMultiplier.MultiplierField.Smelt, 60f);
CreateFieldRow(parent2, FactoryMultiplier.MultiplierField.Chemical, 118f);
CreateFieldRow(parent2, FactoryMultiplier.MultiplierField.Refine, 176f);
CreateFieldRow(parent2, FactoryMultiplier.MultiplierField.Assemble, 234f);
CreateFieldRow(parent2, FactoryMultiplier.MultiplierField.Particle, 292f);
CreateFieldRow(parent2, FactoryMultiplier.MultiplierField.Lab, 350f);
CreateFieldRow(parent3, FactoryMultiplier.MultiplierField.Fractionator, 60f);
CreateFieldRow(parent3, FactoryMultiplier.MultiplierField.Ejector, 118f);
CreateFieldRow(parent3, FactoryMultiplier.MultiplierField.Silo, 176f);
CreateFieldRow(parent3, FactoryMultiplier.MultiplierField.Gamma, 234f);
CreateFieldRow(parent3, FactoryMultiplier.MultiplierField.Mining, 292f);
CreateFieldRow(parent3, FactoryMultiplier.MultiplierField.WalkSpeed, 350f);
CreateWalkSpeedToggle(parent3, 394f, uiRoot);
RectTransform val = CreateRect("StatusPanel", (Transform)(object)contentRoot, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, 1f));
val.anchoredPosition = new Vector2(0f, -486f);
val.sizeDelta = new Vector2(828f, 74f);
Image val2 = ((Component)val).gameObject.AddComponent<Image>();
((Graphic)val2).color = new Color(0.12f, 0.16f, 0.22f, 0.68f);
statusText = CreateText("StatusText", (Transform)(object)val, bodyTextTemplate, 16, 18f, 16f, 792f, 42f, (TextAnchor)0, ((Graphic)bodyTextTemplate).color);
statusText.horizontalOverflow = (HorizontalWrapMode)0;
statusText.verticalOverflow = (VerticalWrapMode)0;
statusText.text = owner.GetStatusText();
}
private RectTransform CreateSectionPanel(string name, Vector2 anchoredPosition, Vector2 size, string title)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: 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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: 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_00e1: 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_00ff: 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_0121: 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_0160: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = CreateRect(name, (Transform)(object)contentRoot, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, 1f));
val.anchoredPosition = anchoredPosition;
val.sizeDelta = size;
Image val2 = ((Component)val).gameObject.AddComponent<Image>();
((Graphic)val2).color = new Color(0.08f, 0.12f, 0.17f, 0.72f);
Text val3 = CreateText(name + "Title", (Transform)(object)val, shellWindow.titleText, 18, 18f, 16f, size.x - 36f, 24f, (TextAnchor)3, ((Graphic)shellWindow.titleText).color);
val3.text = title;
RectTransform val4 = CreateRect(name + "Divider", (Transform)(object)val, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, 1f));
val4.anchoredPosition = new Vector2(18f, -44f);
val4.sizeDelta = new Vector2(size.x - 36f, 1f);
Image val5 = ((Component)val4).gameObject.AddComponent<Image>();
((Graphic)val5).color = new Color(1f, 1f, 1f, 0.18f);
return val;
}
private void CreateFieldRow(RectTransform parent, FactoryMultiplier.MultiplierField field, float topOffset)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: 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_0161: 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_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
CreateText($"{field}Label", (Transform)(object)parent, shellWindow.titleText, 15, 18f, topOffset, 146f, 28f, (TextAnchor)3, ((Graphic)shellWindow.titleText).color).text = owner.GetFieldLabel(field);
UIInputField inputField = CloneInputField(parent, field);
Transform transform = ((Component)inputField).transform;
RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
val.anchorMin = new Vector2(0f, 1f);
val.anchorMax = new Vector2(0f, 1f);
val.pivot = new Vector2(0f, 1f);
val.anchoredPosition = new Vector2(162f, 0f - topOffset);
val.sizeDelta = new Vector2(96f, 28f);
inputFields[field] = inputField;
UIButton val2 = CloneButton(parent, owner.GetApplyButtonText());
Transform transform2 = ((Component)val2).transform;
RectTransform val3 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null);
val3.anchorMin = new Vector2(0f, 1f);
val3.anchorMax = new Vector2(0f, 1f);
val3.pivot = new Vector2(0f, 1f);
val3.anchoredPosition = new Vector2(274f, 0f - topOffset);
val3.sizeDelta = new Vector2(110f, 28f);
val2.BindOnClickSafe((Action<int>)delegate
{
owner.SetFieldValue(field, inputField.inputField.text);
owner.ApplyField(field);
RefreshField(field);
RefreshStatus();
RefreshWalkSpeedToggle();
});
}
private void CreateWalkSpeedToggle(RectTransform parent, float topOffset, UIRoot uiRoot)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: 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_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
walkSpeedToggle = CloneToggle(parent, uiRoot.optionWindow.backgroundPause);
RectTransform val = (RectTransform)(((object)walkSpeedToggle.rectTransform) ?? ((object)/*isinst with value type is only supported in some contexts*/));
val.anchorMin = new Vector2(0f, 1f);
val.anchorMax = new Vector2(0f, 1f);
val.pivot = new Vector2(0f, 1f);
val.anchoredPosition = new Vector2(162f, 0f - topOffset);
val.sizeDelta = new Vector2(22f, 22f);
((UnityEventBase)walkSpeedToggle.toggle.onValueChanged).RemoveAllListeners();
((UnityEvent<bool>)(object)walkSpeedToggle.toggle.onValueChanged).AddListener((UnityAction<bool>)OnWalkSpeedToggleChanged);
CreateText("WalkSpeedToggleLabel", (Transform)(object)parent, shellWindow.titleText, 14, 192f, topOffset - 4f, 190f, 28f, (TextAnchor)3, ((Graphic)shellWindow.titleText).color).text = owner.GetWalkSpeedModeText();
}
private UIInputField CloneInputField(RectTransform parent, FactoryMultiplier.MultiplierField field)
{
UIInputField shortUIInput = UIRoot.instance.uiGame.blueprintCopyInspector.shortUIInput;
UIInputField val = Object.Instantiate<UIInputField>(shortUIInput, (Transform)(object)parent, false);
((Object)val).name = $"{field}InputField";
((Component)val).gameObject.SetActive(true);
ClearTooltips(((Component)val).gameObject);
if ((Object)(object)val.iconSelectBtn != (Object)null)
{
Object.Destroy((Object)(object)((Component)val.iconSelectBtn).gameObject);
val.iconSelectBtn = null;
}
((UnityEventBase)val.inputField.onEndEdit).RemoveAllListeners();
((UnityEventBase)val.inputField.onValueChanged).RemoveAllListeners();
val.inputField.lineType = (LineType)0;
val.inputField.contentType = (ContentType)2;
val.inputField.characterLimit = owner.GetCharacterLimit(field);
val.inputField.text = owner.GetFieldValue(field);
val.inputField.textComponent.alignment = (TextAnchor)4;
val.overText.alignment = (TextAnchor)4;
val.inputField.ForceLabelUpdate();
return val;
}
private UIButton CloneButton(RectTransform parent, string text)
{
UIButton applyButton = UIRoot.instance.optionWindow.applyButton;
UIButton val = Object.Instantiate<UIButton>(applyButton, (Transform)(object)parent, false);
((Object)val).name = "ApplyButton";
((Component)val).gameObject.SetActive(true);
Button button = val.button;
if (button != null)
{
((UnityEventBase)button.onClick).RemoveAllListeners();
}
ClearTips(val);
Text[] componentsInChildren = ((Component)val).GetComponentsInChildren<Text>(true);
Text[] array = componentsInChildren;
foreach (Text val2 in array)
{
val2.text = text;
val2.alignment = (TextAnchor)4;
}
return val;
}
private UIToggle CloneToggle(RectTransform parent, UIToggle template)
{
UIToggle val = Object.Instantiate<UIToggle>(template, (Transform)(object)parent, false);
((Object)val).name = "WalkSpeedToggle";
((Component)val).gameObject.SetActive(true);
((UnityEventBase)val.toggle.onValueChanged).RemoveAllListeners();
return val;
}
private void Show()
{
RefreshAllFields();
RefreshWalkSpeedToggle();
RefreshStatus();
if ((Object)(object)hotkeyText != (Object)null)
{
hotkeyText.text = owner.GetHotkeyHint();
}
rootObject.SetActive(true);
rootObject.transform.SetAsLastSibling();
}
private void Hide()
{
if ((Object)(object)rootObject != (Object)null)
{
rootObject.SetActive(false);
}
}
private void OnCloseButtonClick()
{
owner.SetWindowVisible(visible: false);
Hide();
}
private void OnWalkSpeedToggleChanged(bool isOn)
{
owner.DirectWalkSpeedMode = isOn;
RefreshStatus();
}
private void RefreshAllFields()
{
foreach (KeyValuePair<FactoryMultiplier.MultiplierField, UIInputField> inputField in inputFields)
{
RefreshField(inputField.Key);
}
}
private void RefreshField(FactoryMultiplier.MultiplierField field)
{
if (inputFields.TryGetValue(field, out var value) && !((Object)(object)value == (Object)null))
{
string fieldValue = owner.GetFieldValue(field);
if (value.inputField.text != fieldValue)
{
value.inputField.text = fieldValue;
value.inputField.ForceLabelUpdate();
}
}
}
private void RefreshStatus()
{
if ((Object)(object)statusText != (Object)null)
{
statusText.text = owner.GetStatusText();
}
}
private void RefreshWalkSpeedToggle()
{
if ((Object)(object)walkSpeedToggle != (Object)null && walkSpeedToggle.toggle.isOn != owner.DirectWalkSpeedMode)
{
walkSpeedToggle.toggle.isOn = owner.DirectWalkSpeedMode;
}
}
private static RectTransform CreateRect(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
RectTransform component = val.GetComponent<RectTransform>();
((Transform)component).SetParent(parent, false);
component.anchorMin = anchorMin;
component.anchorMax = anchorMax;
component.pivot = pivot;
((Transform)component).localScale = Vector3.one;
return component;
}
private static Text CreateText(string name, Transform parent, Text template, int fontSize, float x, float y, float width, float height, TextAnchor alignment, Color color)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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_0087: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = CreateRect(name, parent, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, 1f));
val.anchoredPosition = new Vector2(x, 0f - y);
val.sizeDelta = new Vector2(width, height);
Text val2 = ((Component)val).gameObject.AddComponent<Text>();
val2.font = template.font;
val2.fontSize = fontSize;
((Graphic)val2).color = color;
val2.alignment = alignment;
val2.supportRichText = false;
val2.horizontalOverflow = (HorizontalWrapMode)1;
val2.verticalOverflow = (VerticalWrapMode)1;
return val2;
}
private static void SetInactive(Component component)
{
if ((Object)(object)component != (Object)null)
{
component.gameObject.SetActive(false);
}
}
private static void ClearTooltips(GameObject root)
{
if (!((Object)(object)root == (Object)null))
{
UIButton[] componentsInChildren = root.GetComponentsInChildren<UIButton>(true);
UIButton[] array = componentsInChildren;
foreach (UIButton button in array)
{
ClearTips(button);
}
}
}
private static void ClearTips(UIButton button)
{
if (!((Object)(object)button == (Object)null))
{
button.tips.tipTitle = string.Empty;
button.tips.tipText = string.Empty;
button.tips.corner = 0;
button.tipTitleFormatString = string.Empty;
button.tipTextFormatString = string.Empty;
button.CloseTip();
}
}
}
public static class Translate
{
private static Dictionary<string, string> TranslateDict = new Dictionary<string, string>();
public static string getTranslate(this string s)
{
if (Localization.isKMG && TranslateDict.ContainsKey(s))
{
return TranslateDict[s];
}
return s;
}
public static void regAllTranslate()
{
TranslateDict.Clear();
TranslateDict.Add("工厂倍率设置", "Factory Multiplier");
TranslateDict.Add("生产与科研", "Production & Research");
TranslateDict.Add("物流、能源与角色", "Logistics, Power & Player");
TranslateDict.Add("熔炉倍率", "Smelter Multiplier");
TranslateDict.Add("化工厂倍率", "Chemical Plant Multiplier");
TranslateDict.Add("精炼厂倍率", "Refinery Multiplier");
TranslateDict.Add("制造台倍率", "Assembler Multiplier");
TranslateDict.Add("对撞机倍率", "Collider Multiplier");
TranslateDict.Add("研究站倍率", "Lab Multiplier");
TranslateDict.Add("分馏器倍率", "Fractionator Multiplier");
TranslateDict.Add("弹射器倍率", "Ejector Multiplier");
TranslateDict.Add("发射井倍率", "Silo Multiplier");
TranslateDict.Add("射线站倍率", "Ray Receiver Multiplier");
TranslateDict.Add("行走倍率", "Walk Speed Multiplier");
TranslateDict.Add("采集速度倍率", "Mining Speed Multiplier");
TranslateDict.Add("应用", "Apply");
TranslateDict.Add("快捷键:{0}", "Hotkey: {0}");
TranslateDict.Add("直接设置行走速度(m/s)", "Set walk speed directly (m/s)");
TranslateDict.Add("在这里修改倍率并点击应用按钮。", "Adjust values here and click Apply.");
TranslateDict.Add("设置冶炼倍数", "Smelter Multiple");
TranslateDict.Add("冶炼倍数更改为", "Smelt Multipe Changed To ");
TranslateDict.Add("设置化工厂倍数", "Chemical Multiple");
TranslateDict.Add("化工厂倍数更改为", "Chemical Multipe Changed To ");
TranslateDict.Add("设置精炼厂倍数", "Refinery Multiple");
TranslateDict.Add("精炼厂倍数更改为", "Refinery Multipe Changed To ");
TranslateDict.Add("设置制造台倍数", "Assembler Multiple");
TranslateDict.Add("制造台倍数更改为", "Assembler Multipe Changed To ");
TranslateDict.Add("设置对撞机倍数", "Collider Multiple");
TranslateDict.Add("对撞机倍数更改为", "Collider Multipe Changed To ");
TranslateDict.Add("设置研究站倍数", "Lab Multiple");
TranslateDict.Add("研究站倍数更改为", "Lab Multipe Changed To ");
TranslateDict.Add("设置分馏器倍数", "Fractionator Multiple");
TranslateDict.Add("分馏器倍数更改为", "Fractionator Multipe Changed To ");
TranslateDict.Add("设置弹射器倍数", "Ejector Multiple");
TranslateDict.Add("弹射器倍数更改为", "Ejector Multipe Changed To ");
TranslateDict.Add("设置发射井倍数", "Silo Multiple");
TranslateDict.Add("发射井倍数更改为", "Silo Multipe Changed To ");
TranslateDict.Add("设置射线站倍数", "Gamma Multiple");
TranslateDict.Add("射线站倍数更改为", "Gamma Multipe Changed To ");
TranslateDict.Add("设置行走倍数", "WalkSpeed Multiple");
TranslateDict.Add("行走倍数更改为", "WalkSpeed Multipe Changed To ");
TranslateDict.Add("设置采集速度倍数", "MiningSpeed Multiple");
TranslateDict.Add("采集速度倍数更改为", "MiningSpeed Multipe Changed To ");
}
}
[BepInPlugin("waRNing.dsp.plugins.FactoryMultiplier", "FactoryMultiplier", "3.0.0")]
public class FactoryMultiplier : BaseUnityPlugin
{
internal enum MultiplierField
{
Smelt,
Chemical,
Refine,
Assemble,
Particle,
Lab,
Fractionator,
Ejector,
Silo,
Gamma,
WalkSpeed,
Mining
}
private static class harmony_Patch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(Player), "GameTick")]
private static void WalkSpeed_Tech()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
GameHistoryData history = GameMain.history;
for (int num = 8; num > 0; num--)
{
if (!history.techStates[2201].unlocked)
{
walkspeed_tech = 0;
break;
}
if (history.techStates[2200 + num].unlocked)
{
walkspeed_tech = num;
break;
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Mecha), "GameTick")]
private static void WalkSpeed_patch(ref Mecha __instance)
{
if (!Speed_set.Value)
{
if (walkspeed_tech == 0)
{
__instance.walkSpeed = Configs.freeMode.mechaWalkSpeed * (float)walkspeedMultiply.Value;
}
else if (walkspeed_tech >= 7)
{
__instance.walkSpeed = (Configs.freeMode.mechaWalkSpeed + (float)((walkspeed_tech - 6) * 2) + 6f) * (float)walkspeedMultiply.Value;
}
else if (walkspeed_tech < 7)
{
__instance.walkSpeed = (Configs.freeMode.mechaWalkSpeed + (float)walkspeed_tech) * (float)walkspeedMultiply.Value;
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(LabComponent), "InternalUpdateAssemble")]
private static void Lab_patch(ref LabComponent __instance)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Invalid comparison between Unknown and I4
ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2901);
if (!__instance.researchMode && __instance.recipeId > 0)
{
RecipeProto val2 = ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(__instance.recipeId);
if (val2 != null && (int)val2.Type == 15)
{
__instance.speed = val.prefabDesc.labAssembleSpeed * labMultiply.Value;
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(MechaLab), "GameTick")]
private static void Techspeed_patch(MechaLab __instance)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: 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_009b: Unknown result type (might be due to invalid IL or missing references)
GameHistoryData history = GameMain.history;
for (int num = 2; num > 0; num--)
{
if (history.techStates[3903].unlocked)
{
history.techSpeed = history.techStates[3904].curLevel * labMultiply.Value;
break;
}
if (!history.techStates[3901].unlocked)
{
history.techSpeed = Configs.freeMode.techSpeed * labMultiply.Value;
break;
}
if (history.techStates[3900 + num].unlocked)
{
history.techSpeed = (num + Configs.freeMode.techSpeed) * labMultiply.Value;
break;
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FractionatorComponent), "InternalUpdate")]
private static void Fractionate_patch(ref FractionatorComponent __instance)
{
__instance.produceProb = (float)fractionatorMultiply.Value * 0.01f;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(EjectorComponent), "InternalUpdate")]
private static void Ejector_patch(ref EjectorComponent __instance)
{
ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2311);
__instance.chargeSpend = val.prefabDesc.ejectorChargeFrame * 10000 / ejectorMultiply.Value;
__instance.coldSpend = val.prefabDesc.ejectorColdFrame * 10000 / ejectorMultiply.Value;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SiloComponent), "InternalUpdate")]
private static void Silo_patch(ref SiloComponent __instance)
{
ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2312);
__instance.chargeSpend = val.prefabDesc.siloChargeFrame * 10000 / siloMultiply.Value;
__instance.coldSpend = val.prefabDesc.siloColdFrame * 10000 / siloMultiply.Value;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PowerGeneratorComponent), "GameTick_Gamma")]
private static void Gamma_patch(ref PowerGeneratorComponent __instance)
{
ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(2208);
if (__instance.gamma)
{
__instance.genEnergyPerTick = gammaMultiply.Value * val.prefabDesc.genEnergyPerTick;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PowerSystem), "GameTick")]
private static void Power_patch(PowerSystem __instance)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: 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_007b: 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_0098: Expected I4, but got Unknown
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
float num = 0f;
for (int i = 1; i < __instance.consumerCursor; i++)
{
int entityId = __instance.consumerPool[i].entityId;
if (entityId <= 0)
{
continue;
}
ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select((int)__instance.factory.entityPool[entityId].protoId);
if (val.prefabDesc.isAssembler)
{
ERecipeType assemblerRecipeType = val.prefabDesc.assemblerRecipeType;
ERecipeType val2 = assemblerRecipeType;
ERecipeType val3 = val2;
switch (val3 - 1)
{
case 0:
num = smeltMultiply.Value;
break;
case 1:
num = chemicalMultiply.Value;
break;
case 2:
num = refineMultiply.Value;
break;
case 3:
num = assembleMultiply.Value;
break;
case 4:
num = particleMultiply.Value;
break;
default:
continue;
}
}
else if (val.prefabDesc.isLab)
{
num = labMultiply.Value;
}
else if (val.prefabDesc.isEjector)
{
num = ejectorMultiply.Value;
}
else if (val.prefabDesc.isSilo)
{
num = siloMultiply.Value;
}
else if (val.prefabDesc.isFractionator)
{
num = ((fractionatorMultiply.Value != 1) ? ((float)(Math.Pow(1.055, fractionatorMultiply.Value) * (double)fractionatorMultiply.Value)) : 1f);
}
else
{
if ((int)val.prefabDesc.minerType == 0 || val.prefabDesc.minerPeriod <= 0)
{
continue;
}
num = miningMultiply.Value;
}
__instance.consumerPool[i].workEnergyPerTick = (long)(num * (float)val.prefabDesc.workEnergyPerTick);
}
}
}
internal static ManualLogSource Log;
private static int walkspeed_tech;
private static ConfigEntry<int> walkspeedMultiply;
private static ConfigEntry<int> miningMultiply;
private static ConfigEntry<int> smeltMultiply;
private static ConfigEntry<int> chemicalMultiply;
private static ConfigEntry<int> refineMultiply;
private static ConfigEntry<int> assembleMultiply;
private static ConfigEntry<int> particleMultiply;
private static ConfigEntry<int> labMultiply;
private static ConfigEntry<int> fractionatorMultiply;
private static ConfigEntry<int> ejectorMultiply;
private static ConfigEntry<int> siloMultiply;
private static ConfigEntry<int> gammaMultiply;
private static ConfigEntry<KeyboardShortcut> mainWindowHotkey;
private static ConfigEntry<bool> Speed_set;
private string walkspeedmulti_str = "";
private string smeltmulti_str = "";
private string chemicalmulti_str = "";
private string refinemulti_str = "";
private string assemblemulti_str = "";
private string particlemulti_str = "";
private string labmulti_str = "";
private string fractionatormulti_str = "";
private string ejectormulti_str = "";
private string silomulti_str = "";
private string gammamulti_str = "";
private string miningmulti_str = "";
private string tempText = "";
private bool Showwindow = false;
private FactoryMultiplierWindow window;
internal bool DirectWalkSpeedMode
{
get
{
return Speed_set.Value;
}
set
{
Speed_set.Value = value;
}
}
internal bool IsWindowVisible => Showwindow;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
}
private void Start()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
Harmony.CreateAndPatchAll(typeof(harmony_Patch), (string)null);
Translate.regAllTranslate();
mainWindowHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keyboard Shortcuts", "mainWindowHotkey", KeyboardShortcut.Deserialize("R + LeftControl"), "开关窗口的热键");
walkspeedMultiply = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "walkspeedMultiply", 1, "行走速度倍率");
miningMultiply = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "miningMultiply", 1, "采集速度倍率");
smeltMultiply = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "smeltMultiply", 1, "熔炉速度倍率");
chemicalMultiply = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "chemicalMultiply", 1, "化工厂速度倍率");
refineMultiply = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "refineMultiply", 1, "精炼速度倍率");
assembleMultiply = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "assembleMultiply", 1, "制造台速度倍率");
particleMultiply = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "particleMultiply", 1, "对撞机速度倍率");
labMultiply = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "labMultiply", 1, "研究站速度倍率");
fractionatorMultiply = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "fractionatorMultiply", 1, "分馏塔生产概率倍率");
ejectorMultiply = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "ejectorMultiply", 1, "弹射器速度倍率");
siloMultiply = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "siloMultiply", 1, "发射井速度倍率");
gammaMultiply = ((BaseUnityPlugin)this).Config.Bind<int>("Config", "gammaMultiply", 1, "射线接受倍率");
Speed_set = ((BaseUnityPlugin)this).Config.Bind<bool>("Bool Config", "Speedsetting", false, "设置行走速度");
walkspeedmulti_str = walkspeedMultiply.Value.ToString();
smeltmulti_str = smeltMultiply.Value.ToString();
chemicalmulti_str = chemicalMultiply.Value.ToString();
refinemulti_str = refineMultiply.Value.ToString();
assemblemulti_str = assembleMultiply.Value.ToString();
particlemulti_str = particleMultiply.Value.ToString();
labmulti_str = labMultiply.Value.ToString();
fractionatormulti_str = fractionatorMultiply.Value.ToString();
ejectormulti_str = ejectorMultiply.Value.ToString();
silomulti_str = siloMultiply.Value.ToString();
gammamulti_str = gammaMultiply.Value.ToString();
miningmulti_str = miningMultiply.Value.ToString();
}
private void Update()
{
ToggleWindow();
if (window == null)
{
window = new FactoryMultiplierWindow(this);
}
window.Tick(Showwindow);
if (Showwindow && window != null && !window.IsVisible)
{
Showwindow = false;
}
if (GameMain.isRunning)
{
UpdateDirectWalkSpeed();
FactorySystemPatcher();
MiningSpeedScale_patch();
}
}
private void ToggleWindow()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if (!GameMain.isRunning || GameMain.isPaused || GameMain.instance.isMenuDemo)
{
Showwindow = false;
return;
}
KeyboardShortcut value = mainWindowHotkey.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
Showwindow = !Showwindow;
tempText = "";
}
if (Input.GetKeyDown("escape"))
{
Showwindow = false;
}
}
private static int ParsePositiveIntOrDefault(string input, int defaultValue)
{
string text = Regex.Replace(input ?? string.Empty, "[^0-9]", "");
if (string.IsNullOrEmpty(text))
{
return defaultValue;
}
if (int.TryParse(text, out var result))
{
return result;
}
return defaultValue;
}
private void UpdateDirectWalkSpeed()
{
if (Speed_set.Value)
{
int num = ParsePositiveIntOrDefault(walkspeedmulti_str, 1);
Player mainPlayer = GameMain.mainPlayer;
if (((mainPlayer != null) ? mainPlayer.mecha : null) != null)
{
GameMain.mainPlayer.mecha.walkSpeed = num;
}
walkspeedMultiply.Value = num;
}
}
private void ApplyConfigValue(ref string textValue, ConfigEntry<int> config, string changeText, int defaultValue = 1)
{
textValue = (config.Value = ParsePositiveIntOrDefault(textValue, defaultValue)).ToString();
tempText = changeText.getTranslate() + textValue + "X";
}
private void ApplyWalkSpeedValue()
{
Speed_set.Value = false;
int value = ParsePositiveIntOrDefault(walkspeedmulti_str, 1);
walkspeedMultiply.Value = value;
walkspeedmulti_str = value.ToString();
tempText = "行走倍数更改为".getTranslate() + walkspeedmulti_str + "X";
}
internal void SetWindowVisible(bool visible)
{
Showwindow = visible;
if (!visible)
{
tempText = "";
}
}
internal string GetWindowTitle()
{
return "工厂倍率设置".getTranslate();
}
internal string GetSectionTitle(bool isLeftSection)
{
return (isLeftSection ? "生产与科研" : "物流、能源与角色").getTranslate();
}
internal string GetStatusText()
{
if (!string.IsNullOrEmpty(tempText))
{
return tempText;
}
return "在这里修改倍率并点击应用按钮。".getTranslate();
}
internal string GetHotkeyHint()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
string translate = "快捷键:{0}".getTranslate();
ConfigEntry<KeyboardShortcut> obj = mainWindowHotkey;
object obj2;
if (obj == null)
{
obj2 = null;
}
else
{
KeyboardShortcut value = obj.Value;
obj2 = ((object)(KeyboardShortcut)(ref value)).ToString();
}
if (obj2 == null)
{
obj2 = "Ctrl + R";
}
return string.Format(translate, obj2);
}
internal string GetWalkSpeedModeText()
{
return "直接设置行走速度(m/s)".getTranslate();
}
internal string GetApplyButtonText()
{
return "应用".getTranslate();
}
internal int GetCharacterLimit(MultiplierField field)
{
if (field == MultiplierField.Fractionator || field == MultiplierField.WalkSpeed)
{
return 2;
}
return 1;
}
internal string GetFieldLabel(MultiplierField field)
{
return field switch
{
MultiplierField.Smelt => "熔炉倍率".getTranslate(),
MultiplierField.Chemical => "化工厂倍率".getTranslate(),
MultiplierField.Refine => "精炼厂倍率".getTranslate(),
MultiplierField.Assemble => "制造台倍率".getTranslate(),
MultiplierField.Particle => "对撞机倍率".getTranslate(),
MultiplierField.Lab => "研究站倍率".getTranslate(),
MultiplierField.Fractionator => "分馏器倍率".getTranslate(),
MultiplierField.Ejector => "弹射器倍率".getTranslate(),
MultiplierField.Silo => "发射井倍率".getTranslate(),
MultiplierField.Gamma => "射线站倍率".getTranslate(),
MultiplierField.WalkSpeed => "行走倍率".getTranslate(),
MultiplierField.Mining => "采集速度倍率".getTranslate(),
_ => string.Empty,
};
}
internal string GetFieldValue(MultiplierField field)
{
return field switch
{
MultiplierField.Smelt => smeltmulti_str,
MultiplierField.Chemical => chemicalmulti_str,
MultiplierField.Refine => refinemulti_str,
MultiplierField.Assemble => assemblemulti_str,
MultiplierField.Particle => particlemulti_str,
MultiplierField.Lab => labmulti_str,
MultiplierField.Fractionator => fractionatormulti_str,
MultiplierField.Ejector => ejectormulti_str,
MultiplierField.Silo => silomulti_str,
MultiplierField.Gamma => gammamulti_str,
MultiplierField.WalkSpeed => walkspeedmulti_str,
MultiplierField.Mining => miningmulti_str,
_ => string.Empty,
};
}
internal void SetFieldValue(MultiplierField field, string value)
{
string text = value ?? string.Empty;
switch (field)
{
case MultiplierField.Smelt:
smeltmulti_str = text;
break;
case MultiplierField.Chemical:
chemicalmulti_str = text;
break;
case MultiplierField.Refine:
refinemulti_str = text;
break;
case MultiplierField.Assemble:
assemblemulti_str = text;
break;
case MultiplierField.Particle:
particlemulti_str = text;
break;
case MultiplierField.Lab:
labmulti_str = text;
break;
case MultiplierField.Fractionator:
fractionatormulti_str = text;
break;
case MultiplierField.Ejector:
ejectormulti_str = text;
break;
case MultiplierField.Silo:
silomulti_str = text;
break;
case MultiplierField.Gamma:
gammamulti_str = text;
break;
case MultiplierField.WalkSpeed:
walkspeedmulti_str = text;
break;
case MultiplierField.Mining:
miningmulti_str = text;
break;
}
}
internal void ApplyField(MultiplierField field)
{
switch (field)
{
case MultiplierField.Smelt:
ApplyConfigValue(ref smeltmulti_str, smeltMultiply, "冶炼倍数更改为");
break;
case MultiplierField.Chemical:
ApplyConfigValue(ref chemicalmulti_str, chemicalMultiply, "化工厂倍数更改为");
break;
case MultiplierField.Refine:
ApplyConfigValue(ref refinemulti_str, refineMultiply, "精炼厂倍数更改为");
break;
case MultiplierField.Assemble:
ApplyConfigValue(ref assemblemulti_str, assembleMultiply, "制造台倍数更改为");
break;
case MultiplierField.Particle:
ApplyConfigValue(ref particlemulti_str, particleMultiply, "对撞机倍数更改为");
break;
case MultiplierField.Lab:
ApplyConfigValue(ref labmulti_str, labMultiply, "研究站倍数更改为");
break;
case MultiplierField.Fractionator:
ApplyConfigValue(ref fractionatormulti_str, fractionatorMultiply, "分馏器倍数更改为");
break;
case MultiplierField.Ejector:
ApplyConfigValue(ref ejectormulti_str, ejectorMultiply, "弹射器倍数更改为");
break;
case MultiplierField.Silo:
ApplyConfigValue(ref silomulti_str, siloMultiply, "发射井倍数更改为");
break;
case MultiplierField.Gamma:
ApplyConfigValue(ref gammamulti_str, gammaMultiply, "射线站倍数更改为");
break;
case MultiplierField.WalkSpeed:
ApplyWalkSpeedValue();
break;
case MultiplierField.Mining:
ApplyConfigValue(ref miningmulti_str, miningMultiply, "采集速度倍数更改为");
break;
}
}
private void OnDestroy()
{
window?.Dispose();
}
private static void FactorySystemPatcher()
{
PlanetFactory[] factories = GameMain.data.factories;
foreach (PlanetFactory val in factories)
{
if (val != null && val.factorySystem != null)
{
Assemblerpatch(val.factorySystem, val);
}
}
}
private static void Assemblerpatch(FactorySystem factorySystem, PlanetFactory factory)
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: 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_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Expected I4, but got Unknown
int num = 0;
for (int i = 1; i < factorySystem.assemblerCursor; i++)
{
if (factorySystem.assemblerPool[i].id != i)
{
continue;
}
int entityId = factorySystem.assemblerPool[i].entityId;
if (entityId > 0)
{
ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select((int)factory.entityPool[entityId].protoId);
ERecipeType recipeType = factorySystem.assemblerPool[i].recipeType;
ERecipeType val2 = recipeType;
ERecipeType val3 = val2;
switch (val3 - 1)
{
case 0:
num = smeltMultiply.Value;
break;
case 1:
num = chemicalMultiply.Value;
break;
case 2:
num = refineMultiply.Value;
break;
case 3:
num = assembleMultiply.Value;
break;
case 4:
num = particleMultiply.Value;
break;
default:
continue;
}
factorySystem.assemblerPool[i].speed = num * val.prefabDesc.assemblerSpeed;
}
}
}
private static void MiningSpeedScale_patch()
{
//IL_001a: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
GameHistoryData history = GameMain.history;
for (int num = 4; num > 0; num--)
{
if (history.techStates[3605].unlocked)
{
history.miningSpeedScale = ((float)(history.techStates[3606].curLevel - 1) / 10f + Configs.freeMode.miningSpeedScale) * (float)miningMultiply.Value;
break;
}
if (!history.techStates[3601].unlocked)
{
history.miningSpeedScale = Configs.freeMode.miningSpeedScale * (float)miningMultiply.Value;
break;
}
if (history.techStates[3600 + num].unlocked)
{
history.miningSpeedScale = ((float)num / 10f + Configs.freeMode.miningSpeedScale) * (float)miningMultiply.Value;
break;
}
}
}
}