Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of AutoRepairBuilding v1.2.9
AutoRepairBuilding.dll
Decompiled 3 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.EventSystems; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BuildingRepair")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BuildingRepair")] [assembly: AssemblyTitle("BuildingRepair")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.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 AutoBuildingRepair { public static class LocalizationHelper { public static string GetLanguage() { return PlayerPrefs.GetString("language", "English"); } public static bool IsRussian() { return GetLanguage().Equals("Russian", StringComparison.OrdinalIgnoreCase); } public static bool IsUkrainian() { return GetLanguage().Equals("Ukrainian", StringComparison.OrdinalIgnoreCase); } public static bool IsSpanish() { return GetLanguage().Equals("Spanish", StringComparison.OrdinalIgnoreCase); } public static string T(string english, string russian, string ukrainian, string spanish) { string language = GetLanguage(); if (language.Equals("Russian", StringComparison.OrdinalIgnoreCase)) { return russian; } if (language.Equals("Ukrainian", StringComparison.OrdinalIgnoreCase)) { return ukrainian; } if (language.Equals("Spanish", StringComparison.OrdinalIgnoreCase)) { return spanish; } return english; } } public class RepairTooltipTrigger : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { public string Description = ""; public void OnPointerEnter(PointerEventData eventData) { if (!string.IsNullOrEmpty(Description)) { AutoRepairSettingsMenu.ShowTooltip(Description); } } public void OnPointerExit(PointerEventData eventData) { AutoRepairSettingsMenu.HideTooltip(); } } public class RepairTooltipFollower : MonoBehaviour { private RectTransform _rt; private RectTransform _canvasRt; private void Awake() { _rt = ((Component)this).GetComponent<RectTransform>(); } private void Update() { //IL_0052: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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) if ((Object)(object)_canvasRt == (Object)null && (Object)(object)((Component)this).transform.parent != (Object)null) { _canvasRt = ((Component)((Component)this).transform.parent).GetComponent<RectTransform>(); } if ((Object)(object)_canvasRt == (Object)null) { return; } Vector2 val = Vector2.op_Implicit(Input.mousePosition); Vector2 val2 = default(Vector2); if (RectTransformUtility.ScreenPointToLocalPointInRectangle(_canvasRt, val, (Camera)null, ref val2)) { float num = 15f; float num2 = -15f; Rect rect = _rt.rect; float num3; if (!(((Rect)(ref rect)).width > 0f)) { num3 = 360f; } else { rect = _rt.rect; num3 = ((Rect)(ref rect)).width; } float num4 = num3; rect = _rt.rect; float num5; if (!(((Rect)(ref rect)).height > 0f)) { num5 = 75f; } else { rect = _rt.rect; num5 = ((Rect)(ref rect)).height; } float num6 = num5; rect = _canvasRt.rect; float num7 = ((Rect)(ref rect)).width / 2f; rect = _canvasRt.rect; float num8 = ((Rect)(ref rect)).height / 2f; float num9 = Mathf.Clamp(val2.x + num, 0f - num7, num7 - num4); float num10 = Mathf.Clamp(val2.y + num2, 0f - num8 + num6, num8); _rt.anchoredPosition = new Vector2(num9, num10); } } } public class RepairKeyBindListener : MonoBehaviour { private ConfigEntryBase _entry; private Text _text; private Image _btnImage; private Action _onFinished; private bool _isListening = false; private float _startTime; public static RepairKeyBindListener ActiveListener { get; private set; } public void StartListening(ConfigEntryBase entry, Text buttonText, Image btnImage, Action onFinished) { //IL_009b: 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) if ((Object)(object)ActiveListener != (Object)null && (Object)(object)ActiveListener != (Object)(object)this) { ActiveListener.CancelListening(); } _entry = entry; _text = buttonText; _btnImage = btnImage; _onFinished = onFinished; _isListening = true; _startTime = Time.unscaledTime; ActiveListener = this; _text.text = LocalizationHelper.T("[ PRESS ANY KEY ]", "[ НАЖМИТЕ КЛАВИШУ ]", "[ НАТИСНІТЬ КЛАВІШУ ]", "[ PULSA UNA TECLA ]"); ((Graphic)_text).color = new Color(1f, 0.85f, 0.2f); if ((Object)(object)_btnImage != (Object)null) { ((Graphic)_btnImage).color = new Color(0.32f, 0.38f, 0.52f, 1f); } } public void CancelListening() { //IL_00aa: 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) _isListening = false; if ((Object)(object)ActiveListener == (Object)(object)this) { ActiveListener = null; } if ((Object)(object)_text != (Object)null && _entry != null) { _text.text = _entry.BoxedValue?.ToString().ToUpper() ?? "NONE"; ((Graphic)_text).color = Color.white; } if ((Object)(object)_btnImage != (Object)null) { ((Graphic)_btnImage).color = new Color(0.2f, 0.25f, 0.35f, 1f); } } private void Update() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Invalid comparison between Unknown and I4 //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (!_isListening || Time.unscaledTime - _startTime < 0.08f) { return; } if (Input.GetKeyDown((KeyCode)27)) { CancelListening(); } else { if (!Input.anyKeyDown) { return; } foreach (KeyCode value in Enum.GetValues(typeof(KeyCode))) { if ((int)value == 0 || (int)value == 323 || !Input.GetKeyDown(value)) { continue; } ApplyKey(value); break; } } } private void OnGUI() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Invalid comparison between Unknown and I4 //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (!_isListening) { return; } Event current = Event.current; if (current != null && current.isKey && (int)current.type == 4) { if ((int)current.keyCode == 27) { CancelListening(); } else if ((int)current.keyCode > 0) { ApplyKey(current.keyCode); } } } private unsafe void ApplyKey(KeyCode key) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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) _entry.BoxedValue = key; _isListening = false; if ((Object)(object)ActiveListener == (Object)(object)this) { ActiveListener = null; } if ((Object)(object)_text != (Object)null) { _text.text = ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString().ToUpper(); ((Graphic)_text).color = Color.white; } if ((Object)(object)_btnImage != (Object)null) { ((Graphic)_btnImage).color = new Color(0.2f, 0.25f, 0.35f, 1f); } try { ConfigFile configInstance = AutoRepairSettingsMenu.ConfigInstance; if (configInstance != null) { configInstance.Save(); } } catch { } _onFinished?.Invoke(); } private void OnDisable() { if (_isListening) { CancelListening(); } } } public static class AutoRepairSettingsMenu { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__8_0; internal void <OpenMenu>b__8_0() { ConfigFile configInstance = ConfigInstance; if (configInstance != null) { configInstance.Save(); } CloseMenu(); } } public static ConfigFile ConfigInstance; private static GameObject _settingsCanvas; private static GameObject _tooltipGO; private static Text _tooltipText; private static readonly List<Action> _uiRefreshCallbacks = new List<Action>(); public static bool IsOpen => (Object)(object)_settingsCanvas != (Object)null; public static void ToggleSettingsMenu() { if ((Object)(object)_settingsCanvas == (Object)null) { OpenMenu(); } else { CloseMenu(); } } public static void OpenMenu() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: 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_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: 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_0247: 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_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Expected O, but got Unknown //IL_037a: 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_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Expected O, but got Unknown if ((Object)(object)_settingsCanvas != (Object)null) { return; } _uiRefreshCallbacks.Clear(); _settingsCanvas = new GameObject("AutoRepairSettingsCanvas"); _settingsCanvas.layer = 5; Object.DontDestroyOnLoad((Object)(object)_settingsCanvas); Canvas val = _settingsCanvas.AddComponent<Canvas>(); val.renderMode = (RenderMode)0; val.sortingOrder = 10000; _settingsCanvas.AddComponent<CanvasScaler>(); _settingsCanvas.AddComponent<GraphicRaycaster>(); GameObject val2 = MakeRect("Background", _settingsCanvas.transform, new Color(0.06f, 0.06f, 0.07f, 0.98f)); SetRect(val2, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(680f, 430f), Vector2.zero); Outline val3 = val2.AddComponent<Outline>(); ((Shadow)val3).effectColor = new Color(0.3f, 0.3f, 0.3f, 1f); ((Shadow)val3).effectDistance = new Vector2(2f, -2f); string text = LocalizationHelper.T("AUTO REPAIR CONFIGURATION", "НАСТРОЙКИ АВТОПОЧИНКИ", "НАЛАШТУВАННЯ АВТОПОЧИНКИ", "CONFIGURACIÓN DE AUTORREPARACIÓN"); Text val4 = MakeText("Header", val2.transform, text, 20, new Color(1f, 0.72f, 0.15f), (FontStyle)1); SetRect(((Component)val4).gameObject, new Vector2(0f, 0.88f), new Vector2(1f, 1f), Vector2.zero, new Vector2(0f, -4f)); GameObject val5 = MakeRect("ScrollArea", val2.transform, new Color(0f, 0f, 0f, 0.5f)); SetRect(val5, new Vector2(0.03f, 0.16f), new Vector2(0.97f, 0.88f), Vector2.zero, Vector2.zero); GameObject val6 = MakeRect("Viewport", val5.transform, Color.clear); SetRect(val6, Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero); val6.AddComponent<RectMask2D>(); GameObject val7 = MakeRect("Content", val6.transform, Color.clear); RectTransform component = val7.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(0.5f, 1f); component.sizeDelta = Vector2.zero; VerticalLayoutGroup val8 = val7.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val8).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val8).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val8).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val8).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)val8).spacing = 5f; ((LayoutGroup)val8).padding = new RectOffset(10, 10, 6, 6); ContentSizeFitter val9 = val7.AddComponent<ContentSizeFitter>(); val9.verticalFit = (FitMode)2; ScrollRect val10 = val5.AddComponent<ScrollRect>(); val10.content = component; val10.viewport = val6.GetComponent<RectTransform>(); val10.horizontal = false; val10.vertical = true; val10.scrollSensitivity = 40f; GenerateConfigRows(val7.transform); GameObject val11 = MakeRect("CloseBtn", val2.transform, new Color(0.75f, 0.2f, 0.2f, 1f)); SetRect(val11, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(280f, 40f), new Vector2(0f, 32f)); string text2 = LocalizationHelper.T("CLOSE & SAVE", "ЗАКРЫТЬ И СОХРАНИТЬ", "ЗАКРИТИ ТА ЗБЕРЕГТИ", "CERRAR Y GUARDAR"); MakeText("CloseTxt", val11.transform, text2, 15, Color.white, (FontStyle)1); Button val12 = val11.AddComponent<Button>(); ButtonClickedEvent onClick = val12.onClick; object obj = <>c.<>9__8_0; if (obj == null) { UnityAction val13 = delegate { ConfigFile configInstance = ConfigInstance; if (configInstance != null) { configInstance.Save(); } CloseMenu(); }; <>c.<>9__8_0 = val13; obj = (object)val13; } ((UnityEvent)onClick).AddListener((UnityAction)obj); CreateTooltipUI(_settingsCanvas.transform); } public static void CloseMenu() { HideTooltip(); if ((Object)(object)_settingsCanvas != (Object)null) { Object.Destroy((Object)(object)_settingsCanvas); _settingsCanvas = null; } } private static void GenerateConfigRows(Transform parent) { AddConfigRow(parent, (ConfigEntryBase)(object)Plugin.ModEnabled, LocalizationHelper.T("Mod Enabled", "Включение мода", "Увімкнення моду", "Mod Habilitado"), LocalizationHelper.T("Enable or disable auto repair mod globally.", "Глобальное включение или выключение мода автопочинки.", "Глобальне увімкнення або вимкнення моду автопочинки.", "Habilita o deshabilita el mod de autorreparación globalmente.")); AddConfigRow(parent, (ConfigEntryBase)(object)Plugin.RepairRadius, LocalizationHelper.T("Repair Radius (m)", "Радиус починки (м)", "Радіус починки (м)", "Radio de Reparación (m)"), LocalizationHelper.T("Radius around crafting station to search and repair pieces.", "Радиус вокруг верстака для поиска и починки построек.", "Радіус навколо верстака для пошуку та лагодження споруд.", "Radio alrededor del banco de trabajo para buscar y reparar piezas.")); AddConfigRow(parent, (ConfigEntryBase)(object)Plugin.RepairInterval, LocalizationHelper.T("Repair Interval (0 = Morning)", "Интервал починки (0 = Утром)", "Інтервал починки (0 = Вранці)", "Intervalo (0 = Mañana)"), LocalizationHelper.T("Interval in seconds between repairs. Set to 0 to repair only in the morning (after sleep).", "Интервал в секундах между циклами автопочинки. Установите 0 для починки только утром при пробуждении ото сна.", "Інтервал у секундах між циклами автопочинки. Встановіть 0 для лагодження лише вранці після сну.", "Intervalo en segundos. Establece en 0 para reparar solo por la mañana al despertar.")); AddConfigRow(parent, (ConfigEntryBase)(object)Plugin.AllowRepairOther, LocalizationHelper.T("Repair Other Players' Pieces", "Чинить чужие постройки", "Лагодити чужі споруди", "Reparar Piezas Ajenas"), LocalizationHelper.T("Allow repairing pieces built by other players.", "Разрешить верстаку чинить постройки других игроков.", "Дозволити верстаку лагодити споруди інших гравців.", "Permitir reparar piezas construidas por otros jugadores.")); AddConfigRow(parent, (ConfigEntryBase)(object)Plugin.ShowRepairMessage, LocalizationHelper.T("HUD Notifications", "Уведомления на экране", "Сповіщення на екрані", "Notificaciones en Pantalla"), LocalizationHelper.T("Show top-left HUD message when pieces are repaired.", "Показывать уведомление в углу экрана при починке построек.", "Показувати сповіщення в кутку екрана під час лагодження споруд.", "Mostrar mensaje en la interfaz когда se reparen piezas.")); AddConfigRow(parent, (ConfigEntryBase)(object)Plugin.MenuHotkey, LocalizationHelper.T("Settings Menu Hotkey", "Горячая клавиша меню", "Гаряча клавіша меню", "Tecla de Menú de Ajustes"), LocalizationHelper.T("Hotkey to open this settings menu. Click to rebind.", "Горячая клавиша для открытия данного меню настроек. Нажмите для смены.", "Гаряча клавіша для відкриття цього меню налаштувань. Натисніть для зміни.", "Tecla rápida para abrir este menú de configuración. Haz clic para reasignar.")); } private static void AddConfigRow(Transform parent, ConfigEntryBase entry, string localizedLabel, string localizedTooltip) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) GameObject val = MakeRect("Row_" + entry.Definition.Key, parent, new Color(1f, 1f, 1f, 0.06f)); LayoutElement val2 = val.AddComponent<LayoutElement>(); val2.minHeight = 44f; val2.preferredHeight = 44f; if (!string.IsNullOrEmpty(localizedTooltip)) { RepairTooltipTrigger repairTooltipTrigger = val.AddComponent<RepairTooltipTrigger>(); repairTooltipTrigger.Description = localizedTooltip; } HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = true; ((HorizontalOrVerticalLayoutGroup)val3).spacing = 10f; ((LayoutGroup)val3).padding = new RectOffset(15, 15, 5, 5); Text val4 = MakeText("Label", val.transform, localizedLabel, 15, Color.white, (FontStyle)0); val4.alignment = (TextAnchor)3; LayoutElement val5 = ((Component)val4).gameObject.AddComponent<LayoutElement>(); val5.flexibleWidth = 1f; Action action = null; if (entry.SettingType == typeof(bool)) { action = CreateBoolToggle(val.transform, (ConfigEntry<bool>)(object)entry); } else if (entry.SettingType == typeof(KeyCode)) { action = CreateKeybindButton(val.transform, entry); } else if (entry.SettingType == typeof(float) || entry.SettingType == typeof(int)) { action = CreateInputField(val.transform, entry); } if (action != null) { _uiRefreshCallbacks.Add(action); } CreateResetButton(val.transform, entry, action); } private static Action CreateBoolToggle(Transform parent, ConfigEntry<bool> entry) { //IL_0051: 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_00fc: 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_0141: Expected O, but got Unknown GameObject btnGo = MakeRect("ToggleBtn", parent, entry.Value ? new Color(0.2f, 0.6f, 0.2f, 1f) : new Color(0.6f, 0.2f, 0.2f, 1f)); LayoutElement val = btnGo.AddComponent<LayoutElement>(); val.minWidth = 180f; val.preferredWidth = 180f; val.flexibleWidth = 0f; string onStr = LocalizationHelper.T("ENABLED", "ВКЛЮЧЕНО", "УВІМКНЕНО", "HABILITADO"); string offStr = LocalizationHelper.T("DISABLED", "ВЫКЛЮЧЕНО", "ВИМКНЕНО", "DESACTIVADO"); Text txt = MakeText("Txt", btnGo.transform, entry.Value ? onStr : offStr, 14, Color.white, (FontStyle)1); Button val2 = btnGo.AddComponent<Button>(); Action updateUI = delegate { //IL_0048: 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) ((Graphic)btnGo.GetComponent<Image>()).color = (entry.Value ? new Color(0.2f, 0.6f, 0.2f, 1f) : new Color(0.6f, 0.2f, 0.2f, 1f)); txt.text = (entry.Value ? onStr : offStr); }; ((UnityEvent)val2.onClick).AddListener((UnityAction)delegate { entry.Value = !entry.Value; updateUI(); }); return updateUI; } private static Action CreateKeybindButton(Transform parent, ConfigEntryBase entry) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown GameObject val = MakeRect("KeybindBtn", parent, new Color(0.2f, 0.25f, 0.35f, 1f)); LayoutElement val2 = val.AddComponent<LayoutElement>(); val2.minWidth = 180f; val2.preferredWidth = 180f; val2.flexibleWidth = 0f; Image img = val.GetComponent<Image>(); Text txt = MakeText("Txt", val.transform, entry.BoxedValue?.ToString().ToUpper() ?? "NONE", 14, Color.white, (FontStyle)1); Button val3 = val.AddComponent<Button>(); RepairKeyBindListener listener = val.AddComponent<RepairKeyBindListener>(); Action updateUI = delegate { //IL_0038: 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) txt.text = entry.BoxedValue?.ToString().ToUpper() ?? "NONE"; ((Graphic)txt).color = Color.white; ((Graphic)img).color = new Color(0.2f, 0.25f, 0.35f, 1f); }; ((UnityEvent)val3.onClick).AddListener((UnityAction)delegate { listener.StartListening(entry, txt, img, updateUI); }); return updateUI; } private static Action CreateInputField(Transform parent, ConfigEntryBase entry) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0198: 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_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Expected O, but got Unknown //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Expected O, but got Unknown GameObject val = MakeRect("InputContainer", parent, Color.clear); LayoutElement val2 = val.AddComponent<LayoutElement>(); val2.minWidth = 180f; val2.preferredWidth = 180f; val2.flexibleWidth = 0f; HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = true; ((HorizontalOrVerticalLayoutGroup)val3).spacing = 3f; GameObject val4 = MakeRect("InputBg", val.transform, new Color(0.12f, 0.12f, 0.14f, 1f)); Outline val5 = val4.AddComponent<Outline>(); ((Shadow)val5).effectColor = new Color(0.25f, 0.25f, 0.25f, 0.8f); ((Shadow)val5).effectDistance = new Vector2(1f, -1f); LayoutElement val6 = val4.AddComponent<LayoutElement>(); val6.flexibleWidth = 1f; string text = entry.BoxedValue?.ToString() ?? ""; Text val7 = MakeText("Text", val4.transform, text, 14, Color.white, (FontStyle)0); val7.alignment = (TextAnchor)4; InputField inputField = val4.AddComponent<InputField>(); inputField.textComponent = val7; inputField.text = text; ((UnityEvent<string>)(object)inputField.onEndEdit).AddListener((UnityAction<string>)delegate(string s) { float result2; if (entry.SettingType == typeof(int) && int.TryParse(s, out var result)) { entry.BoxedValue = Mathf.Max(0, result); } else if (entry.SettingType == typeof(float) && float.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out result2)) { entry.BoxedValue = Mathf.Max(0f, result2); } else { inputField.text = entry.BoxedValue?.ToString() ?? ""; } }); GameObject val8 = MakeRect("StepperCol", val.transform, Color.clear); LayoutElement val9 = val8.AddComponent<LayoutElement>(); val9.minWidth = 24f; val9.preferredWidth = 24f; val9.flexibleWidth = 0f; VerticalLayoutGroup val10 = val8.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val10).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val10).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val10).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)val10).childForceExpandHeight = true; ((HorizontalOrVerticalLayoutGroup)val10).spacing = 2f; GameObject val11 = MakeRect("UpBtn", val8.transform, new Color(0.22f, 0.22f, 0.22f, 0.95f)); Text val12 = MakeText("UpTxt", val11.transform, "▲", 8, Color.white, (FontStyle)0); val12.alignment = (TextAnchor)4; ((UnityEvent)val11.AddComponent<Button>().onClick).AddListener((UnityAction)delegate { StepValue(entry, inputField, 1f); }); GameObject val13 = MakeRect("DownBtn", val8.transform, new Color(0.22f, 0.22f, 0.22f, 0.95f)); Text val14 = MakeText("DownTxt", val13.transform, "▼", 8, Color.white, (FontStyle)0); val14.alignment = (TextAnchor)4; ((UnityEvent)val13.AddComponent<Button>().onClick).AddListener((UnityAction)delegate { StepValue(entry, inputField, -1f); }); return delegate { inputField.text = entry.BoxedValue?.ToString() ?? ""; }; } private static void StepValue(ConfigEntryBase entry, InputField inputField, float dir) { if (entry.SettingType == typeof(float)) { float num = (float)entry.BoxedValue; float num2 = 1f; float num3 = Mathf.Max(0f, (float)Math.Round(num + dir * num2, 1)); entry.BoxedValue = num3; inputField.text = num3.ToString(CultureInfo.InvariantCulture); } else if (entry.SettingType == typeof(int)) { int num4 = (int)entry.BoxedValue; int num5 = Mathf.Max(0, num4 + (int)dir); entry.BoxedValue = num5; inputField.text = num5.ToString(); } } private static void CreateResetButton(Transform parent, ConfigEntryBase entry, Action refreshAction) { //IL_002f: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown GameObject val = MakeRect("ResetBtn", parent, new Color(0.18f, 0.45f, 0.85f, 1f)); LayoutElement val2 = val.AddComponent<LayoutElement>(); val2.minWidth = 34f; val2.preferredWidth = 34f; val2.minHeight = 34f; val2.preferredHeight = 34f; val2.flexibleWidth = 0f; Text val3 = MakeText("ArrowTxt", val.transform, "↺", 16, Color.white, (FontStyle)1); val3.alignment = (TextAnchor)4; RepairTooltipTrigger repairTooltipTrigger = val.AddComponent<RepairTooltipTrigger>(); repairTooltipTrigger.Description = LocalizationHelper.T($"Reset to default: {entry.DefaultValue}", $"Сбросить на значение по умолчанию: {entry.DefaultValue}", $"Скинути на стандартне значення: {entry.DefaultValue}", $"Restablecer al valor predeterminado: {entry.DefaultValue}"); ((UnityEvent)val.AddComponent<Button>().onClick).AddListener((UnityAction)delegate { entry.BoxedValue = entry.DefaultValue; refreshAction?.Invoke(); }); } private static void CreateTooltipUI(Transform parent) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) _tooltipGO = MakeRect("TooltipPanel", parent, new Color(0.08f, 0.08f, 0.08f, 0.95f)); _tooltipGO.SetActive(false); RectTransform component = _tooltipGO.GetComponent<RectTransform>(); component.pivot = new Vector2(0f, 1f); Outline val = _tooltipGO.AddComponent<Outline>(); ((Shadow)val).effectColor = new Color(0.4f, 0.4f, 0.4f, 0.9f); ((Shadow)val).effectDistance = new Vector2(1f, -1f); VerticalLayoutGroup val2 = _tooltipGO.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)val2).padding = new RectOffset(12, 12, 10, 10); ContentSizeFitter val3 = _tooltipGO.AddComponent<ContentSizeFitter>(); val3.horizontalFit = (FitMode)2; val3.verticalFit = (FitMode)2; LayoutElement val4 = _tooltipGO.AddComponent<LayoutElement>(); val4.preferredWidth = 360f; _tooltipText = MakeText("TooltipText", _tooltipGO.transform, "", 14, new Color(0.9f, 0.9f, 0.9f, 1f), (FontStyle)0); _tooltipText.alignment = (TextAnchor)3; _tooltipText.horizontalOverflow = (HorizontalWrapMode)0; _tooltipGO.AddComponent<RepairTooltipFollower>(); } public static void ShowTooltip(string text) { if (!((Object)(object)_tooltipGO == (Object)null) && !((Object)(object)_tooltipText == (Object)null)) { _tooltipText.text = text; _tooltipGO.SetActive(true); _tooltipGO.transform.SetAsLastSibling(); } } public static void HideTooltip() { if ((Object)(object)_tooltipGO != (Object)null) { _tooltipGO.SetActive(false); } } public static GameObject MakeRect(string name, Transform parent, Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.layer = 5; val.transform.SetParent(parent, false); ((Graphic)val.AddComponent<Image>()).color = color; return val; } public static Text MakeText(string name, Transform parent, string text, int size, Color color, FontStyle style = (FontStyle)0) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0042: 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_0063: 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_0087: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.layer = 5; val.transform.SetParent(parent, false); Text val2 = val.AddComponent<Text>(); val2.text = text; val2.font = GetValheimFont(); val2.fontSize = size; ((Graphic)val2).color = color; val2.fontStyle = style; val2.alignment = (TextAnchor)4; RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.sizeDelta = Vector2.zero; component.anchoredPosition = Vector2.zero; return val2; } public static void SetRect(GameObject go, Vector2 min, Vector2 max, Vector2 size, Vector2 pos) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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) RectTransform component = go.GetComponent<RectTransform>(); component.anchorMin = min; component.anchorMax = max; component.sizeDelta = size; component.anchoredPosition = pos; } public static Font GetValheimFont() { Font[] array = Object.FindObjectsByType<Font>((FindObjectsSortMode)0); Font[] array2 = array; foreach (Font val in array2) { if ((Object)(object)val != (Object)null && ((Object)val).name.Contains("Averia")) { return val; } } return Resources.GetBuiltinResource<Font>("Arial.ttf"); } } public static class CraftingStationAutoRepair { [HarmonyPatch(typeof(CraftingStation), "GetHoverText")] public static class CraftingStation_GetHoverText_Patch { public static void Postfix(CraftingStation __instance, ref string __result) { if (Plugin.ModEnabled.Value && IsWorkbench(__instance)) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { string arg = (component.GetZDO().GetBool("VPO_AutoRepair_State", false) ? LocalizationHelper.T("<color=#55FF55>ON</color>", "<color=#55FF55>ВКЛ</color>", "<color=#55FF55>УВІМК</color>", "<color=#55FF55>ACT</color>") : LocalizationHelper.T("<color=#FF5555>OFF</color>", "<color=#FF5555>ВЫКЛ</color>", "<color=#FF5555>ВИМК</color>", "<color=#FF5555>DESACT</color>")); string format = LocalizationHelper.T("\n[<color=yellow><b>Hold $KEY_Use</b></color>] Auto-Repair: {0}", "\n[<color=yellow><b>Зажать $KEY_Use</b></color>] Автопочинка: {0}", "\n[<color=yellow><b>Затиснути $KEY_Use</b></color>] Автопочинка: {0}", "\n[<color=yellow><b>Mantener $KEY_Use</b></color>] Autorreparación: {0}"); __result += Localization.instance.Localize(string.Format(format, arg)); } } } } [HarmonyPatch(typeof(Player), "Update")] public static class Player_HoldE_Interaction_Patch { public static void Postfix(Player __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !Plugin.ModEnabled.Value) { return; } if (!ZInput.GetButton("Use")) { _holdTimer = 0f; _holdExecuted = false; return; } GameObject hoverObject = ((Humanoid)__instance).GetHoverObject(); if ((Object)(object)hoverObject == (Object)null) { return; } CraftingStation componentInParent = hoverObject.GetComponentInParent<CraftingStation>(); if ((Object)(object)componentInParent == (Object)null || !IsWorkbench(componentInParent)) { return; } ZNetView component = ((Component)componentInParent).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { _holdTimer += Time.deltaTime; if (_holdTimer >= 0.6f && !_holdExecuted) { _holdExecuted = true; ToggleStationAutoRepair(componentInParent, component); } } } private static void ToggleStationAutoRepair(CraftingStation station, ZNetView nview) { bool flag = nview.GetZDO().GetBool("VPO_AutoRepair_State", false); bool flag2 = !flag; nview.ClaimOwnership(); nview.GetZDO().Set("VPO_AutoRepair_State", flag2); string message = (flag2 ? LocalizationHelper.T("Workbench Auto-Repair: ENABLED", "Автопочинка верстака: ВКЛЮЧЕНА", "Автопочинка верстака: УВІМКНЕНА", "Autorreparación del banco: ACTIVADA") : LocalizationHelper.T("Workbench Auto-Repair: DISABLED", "Автопочинка верстака: ВЫКЛЮЧЕНА", "Автопочинка верстака: ВИМКНЕНА", "Autorreparación del banco: DESACTIVADA")); ShowPlayerMessage((MessageType)2, message); } } [HarmonyPatch(typeof(Player), "SetSleeping")] public static class Player_SetSleeping_Patch { public static void Postfix(Player __instance, bool sleep) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && !sleep) { TriggerMorningRepair(); } } } public const string ZDO_AUTO_REPAIR_KEY = "VPO_AutoRepair_State"; private static readonly FieldInfo _allStationsField = AccessTools.Field(typeof(CraftingStation), "m_allStations"); private static readonly Collider[] _overlapBuffer = (Collider[])(object)new Collider[512]; private static readonly HashSet<Piece> _processedPieces = new HashSet<Piece>(256); private static readonly Dictionary<CraftingStation, float> _stationTimers = new Dictionary<CraftingStation, float>(32); private static float _nextLoopCheckTime = 0f; private static float _holdTimer = 0f; private const float HOLD_REQUIRED_TIME = 0.6f; private static bool _holdExecuted = false; public static bool IsWorkbench(CraftingStation station) { if ((Object)(object)station == (Object)null) { return false; } if (station.m_name == "$piece_workbench") { return true; } string prefabName = Utils.GetPrefabName(((Component)station).gameObject); return prefabName.Equals("piece_workbench", StringComparison.OrdinalIgnoreCase); } private static List<CraftingStation> GetStationList() { if (_allStationsField != null) { return _allStationsField.GetValue(null) as List<CraftingStation>; } return null; } public static void ShowPlayerMessage(MessageType type, string message) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message(type, message, 0, (Sprite)null, false); } else { if (!((Object)(object)MessageHud.instance != (Object)null)) { return; } MethodInfo methodInfo = AccessTools.Method(typeof(MessageHud), "ShowMessage", (Type[])null, (Type[])null); if (methodInfo != null) { ParameterInfo[] parameters = methodInfo.GetParameters(); object[] array = new object[parameters.Length]; if (parameters.Length != 0) { array[0] = type; } if (parameters.Length > 1) { array[1] = message; } for (int i = 2; i < parameters.Length; i++) { array[i] = (parameters[i].HasDefaultValue ? parameters[i].DefaultValue : null); } methodInfo.Invoke(MessageHud.instance, array); } } } public static void UpdateAutoRepairLoop() { //IL_009f: 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_0101: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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) if (!Plugin.ModEnabled.Value) { return; } float value = Plugin.RepairInterval.Value; if (value <= 0f || Time.time < _nextLoopCheckTime) { return; } _nextLoopCheckTime = Time.time + 0.25f; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } List<CraftingStation> stationList = GetStationList(); if (stationList == null || stationList.Count == 0) { return; } Vector3 position = ((Component)localPlayer).transform.position; float num = Plugin.RepairRadius.Value + 35f; float num2 = num * num; float time = Time.time; for (int i = 0; i < stationList.Count; i++) { CraftingStation val = stationList[i]; if ((Object)(object)val == (Object)null || !IsWorkbench(val)) { continue; } Vector3 position2 = ((Component)val).transform.position; Vector3 val2 = position2 - position; if (((Vector3)(ref val2)).sqrMagnitude > num2) { continue; } ZNetView component = ((Component)val).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner() && component.GetZDO().GetBool("VPO_AutoRepair_State", false)) { if (!_stationTimers.TryGetValue(val, out var value2)) { value2 = 0f; } if (time - value2 >= value) { _stationTimers[val] = time; PerformStationRepair(val, suppressMessage: false); } } } } public static void TriggerMorningRepair() { //IL_006a: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00d0: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.ModEnabled.Value || Plugin.RepairInterval.Value > 0f) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } List<CraftingStation> stationList = GetStationList(); if (stationList == null || stationList.Count == 0) { return; } Vector3 position = ((Component)localPlayer).transform.position; float num = Plugin.RepairRadius.Value + 50f; float num2 = num * num; int num3 = 0; for (int i = 0; i < stationList.Count; i++) { CraftingStation val = stationList[i]; if ((Object)(object)val == (Object)null || !IsWorkbench(val)) { continue; } Vector3 val2 = ((Component)val).transform.position - position; if (!(((Vector3)(ref val2)).sqrMagnitude > num2)) { ZNetView component = ((Component)val).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner() && component.GetZDO().GetBool("VPO_AutoRepair_State", false)) { num3 += PerformStationRepair(val, suppressMessage: true); } } } if (num3 > 0 && Plugin.ShowRepairMessage.Value) { string message = string.Format(LocalizationHelper.T("[AutoRepair] Good morning! Repaired {0} pieces.", "[Автопочинка] Доброе утро! Починено {0} деталей.", "[Автопочинка] Доброго ранку! Полагоджено {0} деталей.", "[Autorreparación] ¡Buenos días! Reparadas {0} piezas."), num3); ShowPlayerMessage((MessageType)1, message); } } private static int PerformStationRepair(CraftingStation station, bool suppressMessage) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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) float value = Plugin.RepairRadius.Value; int num = Physics.OverlapSphereNonAlloc(((Component)station).transform.position, value, _overlapBuffer, Plugin.DestroyMask); if (num == 0) { return 0; } int num2 = 0; _processedPieces.Clear(); bool value2 = Plugin.AllowRepairOther.Value; for (int i = 0; i < num; i++) { Collider val = _overlapBuffer[i]; if ((Object)(object)val == (Object)null) { continue; } Piece componentInParent = ((Component)val).GetComponentInParent<Piece>(); if (!((Object)(object)componentInParent == (Object)null) && _processedPieces.Add(componentInParent) && (value2 || componentInParent.IsCreator())) { WearNTear component = ((Component)componentInParent).GetComponent<WearNTear>(); if (!((Object)(object)component == (Object)null) && component.GetHealthPercentage() < 1f && component.Repair()) { num2++; } } } if (!suppressMessage && num2 > 0 && Plugin.ShowRepairMessage.Value && (Object)(object)Player.m_localPlayer != (Object)null) { float num3 = Vector3.Distance(((Component)station).transform.position, ((Component)Player.m_localPlayer).transform.position); if (num3 <= value) { string message = string.Format(LocalizationHelper.T("[AutoRepair] Repaired {0} pieces.", "[Автопочинка] Верстак починил {0} деталей.", "[Автопочинка] Верстак полагодив {0} деталей.", "[Autorreparación] Banco reparó {0} piezas."), num2); ShowPlayerMessage((MessageType)1, message); } } return num2; } } [BepInPlugin("aedenthorn.AutoBuildingRepair", "Auto Building Repair", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string ModGUID = "aedenthorn.AutoBuildingRepair"; public const string ModName = "Auto Building Repair"; public const string ModVersion = "1.0.0"; private Harmony _harmony; public static ConfigEntry<bool> ModEnabled; public static ConfigEntry<float> RepairRadius; public static ConfigEntry<float> RepairInterval; public static ConfigEntry<bool> AllowRepairOther; public static ConfigEntry<bool> ShowRepairMessage; public static ConfigEntry<KeyCode> MenuHotkey; public static int DestroyMask; public static Plugin Instance { get; private set; } private void Awake() { //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) Instance = this; DestroyMask = LayerMask.GetMask(new string[4] { "piece", "piece_nonsolid", "Default", "static_solid" }); ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1. General", "Mod Enabled", true, "Enable or disable auto repair mod globally."); RepairRadius = ((BaseUnityPlugin)this).Config.Bind<float>("2. Repair", "Repair Radius", 20f, "Radius around crafting station to search and repair pieces."); RepairInterval = ((BaseUnityPlugin)this).Config.Bind<float>("2. Repair", "Repair Interval (s)", 0f, "Interval in seconds between repairs (0 = morning wake up)."); AllowRepairOther = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Repair", "Allow Repair Other", true, "Allow repairing pieces built by other players."); ShowRepairMessage = ((BaseUnityPlugin)this).Config.Bind<bool>("3. UI", "Show Notification", false, "Show top-left HUD message when pieces are repaired."); MenuHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("3. UI", "Settings Menu Hotkey", (KeyCode)289, "Hotkey to open the in-game settings menu."); AutoRepairSettingsMenu.ConfigInstance = ((BaseUnityPlugin)this).Config; _harmony = new Harmony("aedenthorn.AutoBuildingRepair"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("[{0}] Loaded successfully. Press {1} to configure.", "Auto Building Repair", MenuHotkey.Value)); } private void Update() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (AutoRepairSettingsMenu.IsOpen && Input.GetKeyDown((KeyCode)27) && (Object)(object)RepairKeyBindListener.ActiveListener == (Object)null) { AutoRepairSettingsMenu.CloseMenu(); return; } if ((Object)(object)RepairKeyBindListener.ActiveListener == (Object)null && Input.GetKeyDown(MenuHotkey.Value)) { AutoRepairSettingsMenu.ToggleSettingsMenu(); } CraftingStationAutoRepair.UpdateAutoRepairLoop(); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } }