using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Mirror; using OrderAndOrganize.Configuration; using OrderAndOrganize.Diagnostics; using OrderAndOrganize.Game; using OrderAndOrganize.Models; using OrderAndOrganize.Patches; using OrderAndOrganize.Services; using OrderAndOrganize.UI; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("OrderAndOrganize")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a0eb83a8da5c37e61bc0621f5b234821dacba945")] [assembly: AssemblyProduct("OrderAndOrganize")] [assembly: AssemblyTitle("OrderAndOrganize")] [assembly: AssemblyVersion("1.0.0.0")] [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 OrderAndOrganize { [BepInPlugin("com.ddqminik.supermarkettogether.orderandorganize", "Order & Organize", "0.5.0")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.ddqminik.supermarkettogether.orderandorganize"; public const string PluginName = "Order & Organize"; public const string PluginVersion = "0.5.0"; internal static ManualLogSource Log; internal static Plugin Instance; private ModConfiguration _config; private Harmony _harmony; private GameInventoryAdapter _inventoryAdapter; private GameProductCatalogAdapter _catalogAdapter; private GameShoppingListAdapter _shoppingListAdapter; private GamePurchaseAdapter _purchaseAdapter; private GameMoneyAdapter _moneyAdapter; private GameNotificationAdapter _notificationAdapter; private GameAuthorityAdapter _authorityAdapter; private GameUiAdapter _uiAdapter; private PendingOrderTracker _pendingTracker; private AutomationController _automationController; private OrderButtonController _buttonController; private GameApiDiagnostics _diagnostics; private ConfigWindow _configWindow; private CategoryMapper _categoryMapper; private CategoryShelfManager _categoryShelfManager; private CategoryPickerUI _categoryPickerUI; private bool _hasLoggedApiOnce; private float _storeLoadedTime; private const float DiagnosticsDelaySeconds = 5f; private bool _categoryMapperRebuilt; private float _lastStalePurgeTime; private float _sceneLoadedTime; private const float PurgeGracePeriodSeconds = 120f; private void Awake() { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"Order & Organize v0.5.0 loading..."); MigrateFromOldVersion(); _config = new ModConfiguration(); _config.Bind(((BaseUnityPlugin)this).Config); if (!_config.Enabled.Value) { Log.LogInfo((object)"Plugin is disabled via configuration."); return; } InitializeAdapters(); InitializeServices(); InitializeCategoryShelves(); CoroutineRunner.Initialize(); _harmony = new Harmony("com.ddqminik.supermarkettogether.orderandorganize"); _harmony.PatchAll(); SceneManager.sceneUnloaded += OnSceneUnloaded; Log.LogInfo((object)"Order & Organize v0.5.0 loaded successfully."); } private void InitializeAdapters() { _inventoryAdapter = new GameInventoryAdapter(Log); _catalogAdapter = new GameProductCatalogAdapter(Log); _shoppingListAdapter = new GameShoppingListAdapter(Log); _moneyAdapter = new GameMoneyAdapter(Log); _notificationAdapter = new GameNotificationAdapter(Log); _authorityAdapter = new GameAuthorityAdapter(Log); _uiAdapter = new GameUiAdapter(Log); _purchaseAdapter = new GamePurchaseAdapter(Log, _shoppingListAdapter, _moneyAdapter); } private void InitializeServices() { _pendingTracker = new PendingOrderTracker(Log); _automationController = new AutomationController(Log, _config, _authorityAdapter, _moneyAdapter, _purchaseAdapter, _catalogAdapter, _inventoryAdapter, _shoppingListAdapter, _notificationAdapter, _pendingTracker); _buttonController = new OrderButtonController(Log, _config, _catalogAdapter, _inventoryAdapter, _shoppingListAdapter, _notificationAdapter, _pendingTracker, () => _automationController.IsEnabled); _diagnostics = new GameApiDiagnostics(Log, _inventoryAdapter, _catalogAdapter, _shoppingListAdapter); _configWindow = new ConfigWindow(_config, () => _automationController.IsEnabled, delegate { _automationController.Toggle((MonoBehaviour)(object)this); _buttonController.UpdateAutoLabel(); }); } private void InitializeCategoryShelves() { _categoryMapper = new CategoryMapper(Log); string savePath = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Config.ConfigFilePath), "OrderAndOrganize_CategoryShelves.json"); _categoryShelfManager = new CategoryShelfManager(Log, _categoryMapper, savePath); _categoryPickerUI = new CategoryPickerUI(Log, _categoryShelfManager, _categoryMapper); _categoryPickerUI.LabelsVisible = _config.CategoryLabelsVisible.Value; CategoryStoragePatches.ShelfManager = _categoryShelfManager; CategoryStoragePatches.CategoryMapper = _categoryMapper; CategoryStoragePatches.Enabled = _config.CategoryShelvesEnabled.Value; _config.CategoryShelvesEnabled.SettingChanged += delegate { CategoryStoragePatches.Enabled = _config.CategoryShelvesEnabled.Value; Log.LogInfo((object)("Category shelves " + (_config.CategoryShelvesEnabled.Value ? "enabled" : "disabled") + ".")); }; _config.CategoryLabelsVisible.SettingChanged += delegate { _categoryPickerUI.LabelsVisible = _config.CategoryLabelsVisible.Value; }; Log.LogInfo((object)"Category storage shelves initialized."); } private void Update() { //IL_003f: 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_00a7: 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) if (!_config.Enabled.Value) { return; } if (_categoryPickerUI != null && _categoryPickerUI.IsPickerVisible) { _categoryPickerUI.UpdateInput(); return; } if (Input.GetKeyDown(_config.ToggleHotkey.Value)) { _automationController.Toggle((MonoBehaviour)(object)this); _buttonController.UpdateAutoLabel(); } if (Input.GetKeyDown(_config.ConfigWindowHotkey.Value)) { _configWindow?.Toggle(); } if (_config.CategoryShelvesEnabled.Value && Input.GetKeyDown(_config.CategoryHotkey.Value)) { _categoryPickerUI?.OnHotkeyPressed(); } if (_config.CategoryShelvesEnabled.Value && Input.GetKeyDown(_config.CategoryLabelsToggleHotkey.Value) && _categoryPickerUI != null) { _categoryPickerUI.ToggleLabels(); _config.CategoryLabelsVisible.Value = _categoryPickerUI.LabelsVisible; } if (!_categoryMapperRebuilt && (Object)(object)ProductListing.Instance != (Object)null && ProductListing.Instance.tiers != null && ProductListing.Instance.tiers.Length != 0) { _categoryMapperRebuilt = true; _categoryMapper.Rebuild(); } if (_categoryShelfManager != null && _categoryShelfManager.AssignmentCount > 0 && (Object)(object)GameData.Instance != (Object)null && _sceneLoadedTime > 0f && Time.time - _sceneLoadedTime > 120f && Time.time - _lastStalePurgeTime > 60f) { _lastStalePurgeTime = Time.time; try { _categoryShelfManager.PurgeStaleAssignments(); } catch (Exception ex) { Log.LogWarning((object)("Stale purge failed: " + ex.Message)); } } HandleDiagnostics(); } private void HandleDiagnostics() { if (_hasLoggedApiOnce || !_authorityAdapter.IsStoreLoaded()) { return; } if (_storeLoadedTime <= 0f) { _storeLoadedTime = Time.time; _sceneLoadedTime = Time.time; } else if (!(Time.time - _storeLoadedTime < 5f)) { _hasLoggedApiOnce = true; try { _diagnostics.LogResolvedApi(); } catch (Exception ex) { Log.LogWarning((object)("API diagnostics failed: " + ex.Message)); } } } private void OnGUI() { _configWindow?.Draw(); if (_config.CategoryShelvesEnabled.Value) { _categoryPickerUI?.Draw(); } } private void OnSceneUnloaded(Scene scene) { Log.LogInfo((object)("Scene unloaded: " + ((Scene)(ref scene)).name)); _automationController.OnSceneUnload(); _hasLoggedApiOnce = false; _storeLoadedTime = 0f; _sceneLoadedTime = 0f; _lastStalePurgeTime = 0f; _categoryMapperRebuilt = false; } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } SceneManager.sceneUnloaded -= OnSceneUnloaded; _pendingTracker?.ClearAll(); Log.LogInfo((object)"Order & Organize unloaded."); } private void MigrateFromOldVersion() { try { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Config.ConfigFilePath); if (!string.IsNullOrEmpty(directoryName)) { string text = Path.Combine(directoryName, "com.dominik.supermarkettogether.smartrestock.cfg"); string configFilePath = ((BaseUnityPlugin)this).Config.ConfigFilePath; if (File.Exists(text) && !File.Exists(configFilePath)) { File.Copy(text, configFilePath); Log.LogInfo((object)("Migrated config from " + Path.GetFileName(text))); } string text2 = Path.Combine(directoryName, "SmartRestock_CategoryShelves.json"); string text3 = Path.Combine(directoryName, "OrderAndOrganize_CategoryShelves.json"); if (File.Exists(text2) && !File.Exists(text3)) { File.Copy(text2, text3); Log.LogInfo((object)("Migrated category data from " + Path.GetFileName(text2))); } string text4 = text2 + ".backup"; string text5 = text3 + ".backup"; if (File.Exists(text4) && !File.Exists(text5)) { File.Copy(text4, text5); } } } catch (Exception ex) { Log.LogWarning((object)("Migration from old version failed: " + ex.Message)); } } internal void OnOrderingUIInitialized() { _buttonController?.TryCreateButton(); } internal void OnAutoStartup() { if (_config.AutoOrderAtStartup.Value) { _automationController.SetEnabled(enabled: true, (MonoBehaviour)(object)this); Log.LogInfo((object)"Automation auto-started per configuration."); } } } [HarmonyPatch] internal static class GamePatches { [HarmonyPatch(typeof(ProductListing), "OnStartClient")] [HarmonyPostfix] private static void OnProductListingStartClient() { try { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"ProductListing.OnStartClient fired - initializing Order & Organize UI."); } Plugin.Instance?.OnOrderingUIInitialized(); Plugin.Instance?.OnAutoStartup(); } catch (Exception arg) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogError((object)$"Error in OnStartClient patch: {arg}"); } } } [HarmonyPatch(typeof(ManagerBlackboard), "UpdateUnlockedFranchises")] [HarmonyPostfix] private static void OnUpdateUnlockedFranchises() { try { Plugin.Instance?.OnOrderingUIInitialized(); } catch (Exception arg) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)$"Error in UpdateUnlockedFranchises patch: {arg}"); } } } [HarmonyPatch(typeof(LocalizationManager), "GetLocalizationString")] [HarmonyPrefix] private static bool OnGetLocalizationString(ref string key, ref string __result) { if (key != null && key.Length > 0 && key[0] == '`') { __result = key.Substring(1); return false; } return true; } } } namespace OrderAndOrganize.UI { public class CategoryPickerUI { private readonly ManualLogSource _log; private readonly CategoryShelfManager _shelfManager; private readonly CategoryMapper _categoryMapper; private bool _pickerVisible; private Data_Container _targetContainer; private List> _sortedGroups; private int _selectedIndex; private CursorLockMode _savedLockState; private bool _savedCursorVisible; private MonoBehaviour _frozenController; private static Type _fpcType; private static bool _fpcTypeResolved; private static MonoBehaviour _cachedFpc; private bool _labelsVisible = true; private bool _skipNextFrame; private GUIStyle _panelBgStyle; private GUIStyle _titleStyle; private GUIStyle _itemStyle; private GUIStyle _selectedItemStyle; private GUIStyle _footerStyle; private bool _stylesInitialized; private const float PanelWidth = 320f; private const float PanelHeight = 360f; private const float ItemHeight = 30f; private const int VisibleItemCount = 7; private const float LabelMaxDistance = 20f; private static Dictionary _texCache = new Dictionary(); public bool IsPickerVisible => _pickerVisible; public bool LabelsVisible { get { return _labelsVisible; } set { _labelsVisible = value; } } public CategoryPickerUI(ManualLogSource log, CategoryShelfManager shelfManager, CategoryMapper categoryMapper) { _log = log; _shelfManager = shelfManager; _categoryMapper = categoryMapper; } public void UpdateInput() { if (!_pickerVisible) { return; } if (_skipNextFrame) { _skipNextFrame = false; Input.ResetInputAxes(); return; } if (Input.GetKeyDown((KeyCode)103)) { ClosePicker(apply: false); Input.ResetInputAxes(); return; } if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)) { ClosePicker(apply: true); Input.ResetInputAxes(); return; } if (Input.GetKeyDown((KeyCode)8) || Input.GetKeyDown((KeyCode)127)) { ClearAndClose(); Input.ResetInputAxes(); return; } if (_sortedGroups != null) { float axis = Input.GetAxis("Mouse ScrollWheel"); if (axis > 0.01f) { _selectedIndex = (_selectedIndex - 1 + _sortedGroups.Count) % _sortedGroups.Count; } else if (axis < -0.01f) { _selectedIndex = (_selectedIndex + 1) % _sortedGroups.Count; } if (Input.GetKeyDown((KeyCode)273)) { _selectedIndex = (_selectedIndex - 1 + _sortedGroups.Count) % _sortedGroups.Count; } if (Input.GetKeyDown((KeyCode)274)) { _selectedIndex = (_selectedIndex + 1) % _sortedGroups.Count; } } Input.ResetInputAxes(); } public void OnHotkeyPressed() { if (_pickerVisible) { ClosePicker(apply: false); return; } Data_Container val = RaycastForStorageShelf(); if ((Object)(object)val == (Object)null) { ManualLogSource log = _log; if (log != null) { log.LogDebug((object)"CategoryPicker: No storage shelf found in crosshair."); } } else { OpenPicker(val); } } public void ToggleLabels() { _labelsVisible = !_labelsVisible; try { string text = (_labelsVisible ? "ON" : "OFF"); GameCanvas instance = GameCanvas.Instance; if (instance != null) { instance.CreateCanvasNotification("`Category labels: " + text); } } catch { } } private void OpenPicker(Data_Container container) { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) _targetContainer = container; _sortedGroups = new List>(_categoryMapper.GetAllGroups()); _sortedGroups.Sort((KeyValuePair a, KeyValuePair b) => a.Key.CompareTo(b.Key)); if (_sortedGroups.Count == 0) { ManualLogSource log = _log; if (log != null) { log.LogWarning((object)"CategoryPicker: No category groups available."); } return; } int? category = _shelfManager.GetCategory(container); _selectedIndex = 0; if (category.HasValue) { for (int num = 0; num < _sortedGroups.Count; num++) { if (_sortedGroups[num].Key == category.Value) { _selectedIndex = num; break; } } } _pickerVisible = true; _skipNextFrame = true; _savedLockState = Cursor.lockState; _savedCursorVisible = Cursor.visible; Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; FreezePlayerController(); ManualLogSource log2 = _log; if (log2 != null) { log2.LogDebug((object)$"CategoryPicker: Opened for shelf at {((Component)container).transform.position}"); } } private void ClosePicker(bool apply) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if (apply && (Object)(object)_targetContainer != (Object)null && _sortedGroups != null && _selectedIndex >= 0 && _selectedIndex < _sortedGroups.Count) { KeyValuePair keyValuePair = _sortedGroups[_selectedIndex]; _shelfManager.SetCategory(_targetContainer, keyValuePair.Key); try { GameCanvas instance = GameCanvas.Instance; if (instance != null) { instance.CreateCanvasNotification("`Shelf tagged: " + keyValuePair.Value); } } catch { } } _pickerVisible = false; _targetContainer = null; _sortedGroups = null; UnfreezePlayerController(); Cursor.lockState = _savedLockState; Cursor.visible = _savedCursorVisible; } private void ClearAndClose() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_targetContainer != (Object)null) { _shelfManager.ClearCategory(_targetContainer); try { GameCanvas instance = GameCanvas.Instance; if (instance != null) { instance.CreateCanvasNotification("`Shelf category cleared"); } } catch { } } _pickerVisible = false; _targetContainer = null; _sortedGroups = null; UnfreezePlayerController(); Cursor.lockState = _savedLockState; Cursor.visible = _savedCursorVisible; } public void Draw() { InitStyles(); if (_labelsVisible) { DrawFloatingLabels(); } if (_pickerVisible && _sortedGroups != null && _sortedGroups.Count != 0) { DrawPickerOverlay(); } } private void DrawPickerOverlay() { //IL_0032: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_0104: 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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Expected O, but got Unknown //IL_0273: 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_0287: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Expected O, but got Unknown //IL_0209: Unknown result type (might be due to invalid IL or missing references) float num = ((float)Screen.width - 320f) / 2f; float num2 = ((float)Screen.height - 360f) / 2f; GUI.Box(new Rect(num, num2, 320f, 360f), "", _panelBgStyle); GUILayout.BeginArea(new Rect(num + 12f, num2 + 10f, 296f, 340f)); GUILayout.Label("Assign Category", _titleStyle, Array.Empty()); GUILayout.Space(4f); int? category = _shelfManager.GetCategory(_targetContainer); string text = (category.HasValue ? _categoryMapper.GetGroupName(category.Value) : "None"); GUIStyle val = new GUIStyle(_footerStyle) { alignment = (TextAnchor)4 }; val.normal.textColor = (Color)(category.HasValue ? _categoryMapper.GetGroupColor(category.Value) : new Color(0.6f, 0.6f, 0.6f)); GUILayout.Label("Current: " + text, val, Array.Empty()); GUILayout.Space(6f); DrawSeparator(296f); GUILayout.Space(6f); int num3 = 3; int num4 = _selectedIndex - num3; for (int i = 0; i < 7; i++) { int num5 = num4 + i; num5 = (num5 % _sortedGroups.Count + _sortedGroups.Count) % _sortedGroups.Count; KeyValuePair keyValuePair = _sortedGroups[num5]; bool num6 = num5 == _selectedIndex; Color val2 = EnsureReadable(_categoryMapper.GetGroupColor(keyValuePair.Key)); if (num6) { Rect rect = GUILayoutUtility.GetRect(296f, 30f); Color col = val2 * 0.4f; col.a = 0.9f; GUI.DrawTexture(rect, (Texture)(object)MakeTex(1, 1, col)); GUIStyle val3 = new GUIStyle(_selectedItemStyle); val3.normal.textColor = Color.white; GUI.Label(rect, " > " + keyValuePair.Value, val3); } else { Rect rect2 = GUILayoutUtility.GetRect(296f, 30f); float num7 = Mathf.Abs(i - num3); float a = Mathf.Lerp(1f, 0.45f, num7 / ((float)num3 + 1f)); GUIStyle val4 = new GUIStyle(_itemStyle); Color textColor = val2; textColor.a = a; val4.normal.textColor = textColor; GUI.Label(rect2, " " + keyValuePair.Value, val4); } } GUILayout.Space(6f); DrawSeparator(296f); GUILayout.Space(8f); GUILayout.Label("[Scroll/Arrows] Browse [Enter] Apply", _footerStyle, Array.Empty()); GUILayout.Label("[G] Cancel [Backspace] Clear", _footerStyle, Array.Empty()); GUILayout.EndArea(); } private void DrawFloatingLabels() { //IL_002b: 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_004c: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_007a: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return; } IReadOnlyDictionary allAssignments = _shelfManager.GetAllAssignments(); if (allAssignments.Count == 0) { return; } Vector3 position = ((Component)main).transform.position; foreach (KeyValuePair item in allAssignments) { Vector3 val = CategoryShelfManager.ParsePositionKey(item.Key); float num = Vector3.Distance(position, val); if (!(num > 20f)) { Vector3 val2 = val + Vector3.up * 2.2f; Vector3 val3 = main.WorldToScreenPoint(val2); if (!(val3.z <= 0f)) { float num2 = (float)Screen.height - val3.y; string groupName = _categoryMapper.GetGroupName(item.Value); Color groupColor = _categoryMapper.GetGroupColor(item.Value); float num3 = Mathf.Clamp01(1f - num / 20f); int fontSize = Mathf.RoundToInt(Mathf.Lerp(10f, 16f, num3)); GUIStyle val4 = new GUIStyle(GUI.skin.label) { fontSize = fontSize, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; groupColor.a = 0.7f + 0.3f * num3; val4.normal.textColor = groupColor; Vector2 val5 = val4.CalcSize(new GUIContent(groupName)); Rect val6 = new Rect(val3.x - val5.x / 2f, num2 - val5.y / 2f, val5.x + 8f, val5.y + 2f); GUI.DrawTexture(val6, (Texture)(object)MakeTex(1, 1, new Color(0f, 0f, 0f, 0.4f * num3))); GUI.Label(val6, groupName, val4); } } } } private Data_Container RaycastForStorageShelf() { //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) Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return null; } RaycastHit val = default(RaycastHit); if (!Physics.Raycast(main.ScreenPointToRay(new Vector3((float)Screen.width / 2f, (float)Screen.height / 2f, 0f)), ref val, 8f)) { return null; } Transform val2 = ((RaycastHit)(ref val)).transform; int num = 6; while ((Object)(object)val2 != (Object)null && num-- > 0) { Data_Container component = ((Component)val2).GetComponent(); if ((Object)(object)component != (Object)null) { if (component.containerClass == 69) { return component; } ManualLogSource log = _log; if (log != null) { log.LogDebug((object)$"CategoryPicker: Found Data_Container but containerClass={component.containerClass} (not storage)"); } return null; } InteractableContainer component2 = ((Component)val2).GetComponent(); if ((Object)(object)component2 != (Object)null && component2.isStorageShelf) { Transform parent = val2.parent; object obj; if (parent == null) { obj = null; } else { Transform parent2 = parent.parent; obj = ((parent2 != null) ? ((Component)parent2).GetComponent() : null); } Data_Container val3 = (Data_Container)obj; if ((Object)(object)val3 != (Object)null && val3.containerClass == 69) { return val3; } } val2 = val2.parent; } return null; } private void FreezePlayerController() { try { MonoBehaviour val = FindFirstPersonController(); if ((Object)(object)val != (Object)null && ((Behaviour)val).enabled) { ((Behaviour)val).enabled = false; _frozenController = val; ManualLogSource log = _log; if (log != null) { log.LogDebug((object)"CategoryPicker: Disabled FirstPersonController."); } } } catch (Exception ex) { ManualLogSource log2 = _log; if (log2 != null) { log2.LogWarning((object)("CategoryPicker: Failed to freeze player controller: " + ex.Message)); } } } private void UnfreezePlayerController() { try { if ((Object)(object)_frozenController != (Object)null) { ((Behaviour)_frozenController).enabled = true; _frozenController = null; ManualLogSource log = _log; if (log != null) { log.LogDebug((object)"CategoryPicker: Re-enabled FirstPersonController."); } } } catch (Exception ex) { ManualLogSource log2 = _log; if (log2 != null) { log2.LogWarning((object)("CategoryPicker: Failed to unfreeze player controller: " + ex.Message)); } } } internal static MonoBehaviour FindFirstPersonController() { if ((Object)(object)_cachedFpc != (Object)null) { return _cachedFpc; } if (!_fpcTypeResolved) { _fpcTypeResolved = true; _fpcType = AccessTools.TypeByName("StarterAssets.FirstPersonController") ?? AccessTools.TypeByName("FirstPersonController"); } if (_fpcType == null) { return null; } Object obj = Object.FindFirstObjectByType(_fpcType); _cachedFpc = (MonoBehaviour)(object)((obj is MonoBehaviour) ? obj : null); return _cachedFpc; } private void InitStyles() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_006d: 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_0080: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) if (!_stylesInitialized) { _stylesInitialized = true; _panelBgStyle = new GUIStyle(GUI.skin.box); _panelBgStyle.normal.background = MakeTex(2, 2, new Color(0.08f, 0.08f, 0.12f, 0.95f)); _titleStyle = new GUIStyle(GUI.skin.label) { fontSize = 18, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; _titleStyle.normal.textColor = new Color(0.92f, 0.92f, 0.92f); _itemStyle = new GUIStyle(GUI.skin.label) { fontSize = 14, alignment = (TextAnchor)3 }; _selectedItemStyle = new GUIStyle(GUI.skin.label) { fontSize = 15, fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; _footerStyle = new GUIStyle(GUI.skin.label) { fontSize = 11, alignment = (TextAnchor)4 }; _footerStyle.normal.textColor = new Color(0.55f, 0.55f, 0.55f); } } private void DrawSeparator(float width) { //IL_0006: 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) GUI.DrawTexture(GUILayoutUtility.GetRect(width, 1f), (Texture)(object)MakeTex(1, 1, new Color(0.4f, 0.4f, 0.4f, 0.6f))); } private static Color EnsureReadable(Color c) { //IL_0005: 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_001e: 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_0043: 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_006b: Unknown result type (might be due to invalid IL or missing references) float num = 0.299f * c.r + 0.587f * c.g + 0.114f * c.b; if (num < 0.35f) { float num2 = 0.35f / Mathf.Max(num, 0.01f); c.r = Mathf.Clamp01(c.r * num2); c.g = Mathf.Clamp01(c.g * num2); c.b = Mathf.Clamp01(c.b * num2); } return c; } private static Texture2D MakeTex(int width, int height, Color col) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (_texCache.TryGetValue(col, out var value) && (Object)(object)value != (Object)null) { return value; } Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < array.Length; i++) { array[i] = col; } Texture2D val = new Texture2D(width, height); val.SetPixels(array); val.Apply(); _texCache[col] = val; return val; } } public class ConfigWindow { private readonly ModConfiguration _config; private readonly Func _getAutoEnabled; private readonly Action _toggleAuto; private bool _visible; private Rect _windowRect = new Rect(20f, 20f, 420f, 620f); private int _windowId; private int _thresholdInput; private float _cashReserveInput; private int _scanIntervalInput; private int _pendingTimeoutInput; private string _buttonTextInput; private Vector2 _scrollPos; private GUIStyle _headerStyle; private GUIStyle _sectionStyle; private GUIStyle _labelStyle; private GUIStyle _valueStyle; private GUIStyle _toggleStyle; private GUIStyle _windowStyle; private bool _stylesInitialized; private static Texture2D _lineTex; public bool IsVisible => _visible; public ConfigWindow(ModConfiguration config, Func getAutoEnabled, Action toggleAuto) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) _config = config; _getAutoEnabled = getAutoEnabled; _toggleAuto = toggleAuto; _windowId = "OAOConfig".GetHashCode(); SyncFromConfig(); } public void Toggle() { _visible = !_visible; if (_visible) { SyncFromConfig(); } } private void SyncFromConfig() { _thresholdInput = _config.ThresholdUnits.Value; _cashReserveInput = _config.CashReserve.Value; _scanIntervalInput = _config.ScanIntervalSeconds.Value; _pendingTimeoutInput = _config.PendingOrderTimeoutSeconds.Value; _buttonTextInput = _config.ButtonText.Value; } public void Draw() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (_visible) { InitStyles(); _windowRect = GUI.Window(_windowId, _windowRect, new WindowFunction(DrawWindowContents), "", _windowStyle); } } private void InitStyles() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0046: 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) //IL_008b: Expected O, but got Unknown //IL_0096: 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) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_01da: 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) if (!_stylesInitialized) { _stylesInitialized = true; _windowStyle = new GUIStyle(GUI.skin.window); _windowStyle.normal.background = MakeTex(2, 2, new Color(0.1f, 0.1f, 0.12f, 0.95f)); _windowStyle.onNormal.background = _windowStyle.normal.background; _windowStyle.padding = new RectOffset(12, 12, 8, 8); _headerStyle = new GUIStyle(GUI.skin.label) { fontSize = 18, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; _headerStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f); _sectionStyle = new GUIStyle(GUI.skin.label) { fontSize = 14, fontStyle = (FontStyle)1 }; _sectionStyle.normal.textColor = new Color(0.7f, 0.85f, 1f); _labelStyle = new GUIStyle(GUI.skin.label) { fontSize = 13 }; _labelStyle.normal.textColor = new Color(0.85f, 0.85f, 0.85f); _valueStyle = new GUIStyle(GUI.skin.label) { fontSize = 13, fontStyle = (FontStyle)1, alignment = (TextAnchor)5 }; _valueStyle.normal.textColor = Color.white; _toggleStyle = new GUIStyle(GUI.skin.toggle) { fontSize = 13 }; _toggleStyle.normal.textColor = new Color(0.85f, 0.85f, 0.85f); _toggleStyle.onNormal.textColor = Color.white; } } private void DrawWindowContents(int id) { //IL_003d: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0680: Unknown result type (might be due to invalid IL or missing references) //IL_0687: Expected O, but got Unknown //IL_06a8: Unknown result type (might be due to invalid IL or missing references) //IL_06a1: Unknown result type (might be due to invalid IL or missing references) //IL_07e0: Unknown result type (might be due to invalid IL or missing references) //IL_07e5: Unknown result type (might be due to invalid IL or missing references) //IL_08a2: Unknown result type (might be due to invalid IL or missing references) //IL_08a7: Unknown result type (might be due to invalid IL or missing references) GUILayout.Space(4f); GUILayout.Label("Order & Organize Settings", _headerStyle, Array.Empty()); GUILayout.Space(4f); float num = ((Rect)(ref _windowRect)).height - 70f; _scrollPos = GUILayout.BeginScrollView(_scrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) }); DrawLine(); GUILayout.Space(4f); GUILayout.Label("General", _sectionStyle, Array.Empty()); GUILayout.Space(4f); bool flag = GUILayout.Toggle(_config.Enabled.Value, " Mod Enabled", _toggleStyle, Array.Empty()); if (flag != _config.Enabled.Value) { _config.Enabled.Value = flag; } GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Threshold:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); GUILayout.Label(_thresholdInput.ToString(), _valueStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); GUILayout.EndHorizontal(); float num2 = GUILayout.HorizontalSlider((float)_thresholdInput, 0f, 500f, Array.Empty()); _thresholdInput = Mathf.RoundToInt(num2); if (_thresholdInput != _config.ThresholdUnits.Value) { _config.ThresholdUnits.Value = _thresholdInput; } GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Button Text:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); _buttonTextInput = GUILayout.TextField(_buttonTextInput, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(180f) }); GUILayout.EndHorizontal(); if (_buttonTextInput != _config.ButtonText.Value) { _config.ButtonText.Value = _buttonTextInput; } GUILayout.Space(2f); bool flag2 = GUILayout.Toggle(_config.ShowNotifications.Value, " Show Notifications", _toggleStyle, Array.Empty()); if (flag2 != _config.ShowNotifications.Value) { _config.ShowNotifications.Value = flag2; } bool flag3 = GUILayout.Toggle(_config.VerboseLogging.Value, " Verbose Logging", _toggleStyle, Array.Empty()); if (flag3 != _config.VerboseLogging.Value) { _config.VerboseLogging.Value = flag3; } GUILayout.Space(8f); DrawLine(); GUILayout.Space(4f); GUILayout.Label("Automation", _sectionStyle, Array.Empty()); GUILayout.Space(4f); bool flag4 = GUILayout.Toggle(_config.AutoOrderAtStartup.Value, " Auto Order at Startup", _toggleStyle, Array.Empty()); if (flag4 != _config.AutoOrderAtStartup.Value) { _config.AutoOrderAtStartup.Value = flag4; } GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Toggle Hotkey:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); GUILayout.Label(((object)_config.ToggleHotkey.Value/*cast due to .constrained prefix*/).ToString(), _valueStyle, Array.Empty()); GUILayout.EndHorizontal(); GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Scan Interval:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); GUILayout.Label($"{_scanIntervalInput}s", _valueStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); GUILayout.EndHorizontal(); float num3 = GUILayout.HorizontalSlider((float)_scanIntervalInput, 2f, 300f, Array.Empty()); _scanIntervalInput = Mathf.RoundToInt(num3); if (_scanIntervalInput != _config.ScanIntervalSeconds.Value) { _config.ScanIntervalSeconds.Value = _scanIntervalInput; } GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Cash Reserve:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); GUILayout.Label($"${_cashReserveInput:F0}", _valueStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }); GUILayout.EndHorizontal(); float num4 = GUILayout.HorizontalSlider(_cashReserveInput, 0f, 100000f, Array.Empty()); _cashReserveInput = Mathf.Round(num4 / 100f) * 100f; if (Mathf.Abs(_cashReserveInput - _config.CashReserve.Value) > 1f) { _config.CashReserve.Value = _cashReserveInput; } GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Pending Timeout:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); GUILayout.Label($"{_pendingTimeoutInput}s", _valueStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); GUILayout.EndHorizontal(); float num5 = GUILayout.HorizontalSlider((float)_pendingTimeoutInput, 10f, 600f, Array.Empty()); _pendingTimeoutInput = Mathf.RoundToInt(num5); if (_pendingTimeoutInput != _config.PendingOrderTimeoutSeconds.Value) { _config.PendingOrderTimeoutSeconds.Value = _pendingTimeoutInput; } GUILayout.Space(8f); DrawLine(); GUILayout.Space(4f); bool flag5 = _getAutoEnabled?.Invoke() ?? false; GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Auto Order:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); GUIStyle val = new GUIStyle(_valueStyle); val.normal.textColor = (Color)(flag5 ? Color.green : new Color(1f, 0.4f, 0.4f)); GUILayout.Label(flag5 ? "ACTIVE" : "OFF", val, Array.Empty()); GUILayout.EndHorizontal(); GUILayout.Space(4f); if (GUILayout.Button(flag5 ? "Disable Auto Order" : "Enable Auto Order", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { _toggleAuto?.Invoke(); } GUILayout.Space(8f); DrawLine(); GUILayout.Space(4f); GUILayout.Label("Category Shelves", _sectionStyle, Array.Empty()); GUILayout.Space(4f); bool flag6 = GUILayout.Toggle(_config.CategoryShelvesEnabled.Value, " Category Shelves Enabled", _toggleStyle, Array.Empty()); if (flag6 != _config.CategoryShelvesEnabled.Value) { _config.CategoryShelvesEnabled.Value = flag6; } GUILayout.Space(2f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Category Hotkey:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); GUILayout.Label(((object)_config.CategoryHotkey.Value/*cast due to .constrained prefix*/).ToString(), _valueStyle, Array.Empty()); GUILayout.EndHorizontal(); GUILayout.Space(2f); bool flag7 = GUILayout.Toggle(_config.CategoryLabelsVisible.Value, " Show Floating Labels", _toggleStyle, Array.Empty()); if (flag7 != _config.CategoryLabelsVisible.Value) { _config.CategoryLabelsVisible.Value = flag7; } GUILayout.Space(2f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Labels Hotkey:", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); GUILayout.Label(((object)_config.CategoryLabelsToggleHotkey.Value/*cast due to .constrained prefix*/).ToString(), _valueStyle, Array.Empty()); GUILayout.EndHorizontal(); GUILayout.Space(4f); GUILayout.EndScrollView(); GUILayout.Space(4f); if (GUILayout.Button("Close", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(25f) })) { _visible = false; } GUI.DragWindow(); } private void DrawLine() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) GUI.DrawTexture(GUILayoutUtility.GetRect(1f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }), (Texture)(object)MakeLineTex(), (ScaleMode)0); } private static Texture2D MakeLineTex() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_lineTex == (Object)null) { _lineTex = MakeTex(1, 1, new Color(0.4f, 0.4f, 0.4f, 0.8f)); } return _lineTex; } private static Texture2D MakeTex(int width, int height, Color col) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < array.Length; i++) { array[i] = col; } Texture2D val = new Texture2D(width, height); val.SetPixels(array); val.Apply(); return val; } } public class OrderButtonController { private const string ButtonObjectName = "OAO_AddLowStockButton"; private const string AutoLabelObjectName = "OAO_AutoLabel"; private readonly ManualLogSource _log; private readonly ModConfiguration _config; private readonly GameProductCatalogAdapter _catalog; private readonly GameInventoryAdapter _inventory; private readonly GameShoppingListAdapter _shoppingList; private readonly GameNotificationAdapter _notification; private readonly PendingOrderTracker _pendingTracker; private readonly Func _isAutoEnabled; private GameObject _buttonObj; private GameObject _autoLabelObj; private bool _isRunning; private bool _hasLoggedHierarchy; public OrderButtonController(ManualLogSource log, ModConfiguration config, GameProductCatalogAdapter catalog, GameInventoryAdapter inventory, GameShoppingListAdapter shoppingList, GameNotificationAdapter notification, PendingOrderTracker pendingTracker, Func isAutoEnabled) { _log = log; _config = config; _catalog = catalog; _inventory = inventory; _shoppingList = shoppingList; _notification = notification; _pendingTracker = pendingTracker; _isAutoEnabled = isAutoEnabled; } public void TryCreateButton() { try { ManagerBlackboard managerBlackboard = _catalog.GetManagerBlackboard(); if ((Object)(object)managerBlackboard == (Object)null) { return; } if (!_hasLoggedHierarchy) { _hasLoggedHierarchy = true; LogUiHierarchy(managerBlackboard); } Transform val = FindButtonParent(managerBlackboard); if ((Object)(object)val == (Object)null) { _log.LogWarning((object)"Could not find a suitable parent for button placement."); return; } if ((Object)(object)val.Find("OAO_AddLowStockButton") != (Object)null) { _log.LogDebug((object)"Button already exists; skipping creation."); UpdateAutoLabel(); return; } CreateButtonByCloning(managerBlackboard, val); if ((Object)(object)_buttonObj == (Object)null) { CreateButtonFallback(val); } CreateAutoLabel(val); _log.LogInfo((object)("Order & Organize button created. Parent: " + ((Object)val).name)); } catch (Exception arg) { _log.LogError((object)$"Failed to create button: {arg}"); } } private Transform FindButtonParent(ManagerBlackboard blackboard) { if ((Object)(object)blackboard.shoppingListParent != (Object)null) { Transform parent = blackboard.shoppingListParent.transform.parent; if ((Object)(object)parent != (Object)null) { _log.LogDebug((object)("Using shopping list grandparent: " + ((Object)parent).name)); return parent; } } if ((Object)(object)blackboard.tabsOBJ != (Object)null) { return blackboard.tabsOBJ.transform.parent ?? blackboard.tabsOBJ.transform; } return ((Component)blackboard).transform; } private void CreateButtonByCloning(ManagerBlackboard blackboard, Transform parent) { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) GameObject val = FindReferenceButton(((Component)blackboard).transform); if ((Object)(object)val == (Object)null) { _log.LogDebug((object)"No reference button found to clone; will use fallback."); return; } _log.LogDebug((object)("Cloning reference button: " + ((Object)val).name)); _buttonObj = Object.Instantiate(val, parent); ((Object)_buttonObj).name = "OAO_AddLowStockButton"; PlayMakerFSM[] components = _buttonObj.GetComponents(); for (int i = 0; i < components.Length; i++) { Object.Destroy((Object)(object)components[i]); } components = _buttonObj.GetComponentsInChildren(); for (int i = 0; i < components.Length; i++) { Object.Destroy((Object)(object)components[i]); } Button val2 = _buttonObj.GetComponent