Decompiled source of SmarterHauling v1.0.4
plugins/SmarterHauling/SmarterHauling.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LitJson; using Ostranauts.Bit.Interactions; using Ostranauts.Bit.Items; using Ostranauts.Bit.Items.Categories; using Ostranauts.Bit.MegaTooltip; using Ostranauts.Bit.PersistentData; using Ostranauts.Bit.SmarterHauling.Data; using Ostranauts.Bit.SmarterHauling.Effects; using Ostranauts.Bit.SmarterHauling.Extensions; using Ostranauts.Bit.SmarterHauling.Pledges; using Ostranauts.Bit.SmarterHauling.UI; using Ostranauts.Bit.SmarterHauling.Utilities; using Ostranauts.UI.MegaToolTip; using Ostranauts.UI.MegaToolTip.DataModules; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("SmarterHauling")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+f70bee004304fd527076446390adf512027de96f")] [assembly: AssemblyProduct("SmarterHauling")] [assembly: AssemblyTitle("SmarterHauling")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)] internal sealed class ExtensionAttribute : Attribute { } } namespace Ostranauts.Bit.SmarterHauling { [BepInPlugin("com.ostranauts.smarterhauling", "Smarter Hauling", "2.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class SmarterHaulingPlugin : BaseUnityPlugin { internal static ManualLogSource Logger; internal static bool EnableDebugLogging; private Harmony _harmony; private ConfigEntry<bool> _configDebugLogging; private void Awake() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; SetupConfiguration(); Logger.LogInfo((object)"Plugin com.ostranauts.smarterhauling v2.0.0 is loading..."); InitializePreferenceSystem(); RegisterPersistentDataHandler(); RegisterMegaTooltipModules(); RegisterInteractionEffects(); RegisterCommands(); RegisterPledgeTypes(); LaunchControl.OnGameReady += OnGameReady; _harmony = new Harmony("com.ostranauts.smarterhauling"); _harmony.PatchAll(typeof(SmarterHaulingPlugin).Assembly); Logger.LogInfo((object)"SmarterHauling patches applied successfully!"); } private void OnGameReady() { try { Logger.LogInfo((object)"Game ready - checking EVA maintenance pledges on all characters"); JsonPledge pledge = DataHandler.GetPledge("PledgeEVABatteryMaintenance"); JsonPledge pledge2 = DataHandler.GetPledge("PledgeEVAO2Maintenance"); if (pledge == null) { Logger.LogError((object)"PledgeEVABatteryMaintenance not found in game data!"); } if (pledge2 == null) { Logger.LogError((object)"PledgeEVAO2Maintenance not found in game data!"); } if (pledge == null && pledge2 == null) { Logger.LogError((object)"Neither EVA maintenance pledge found, aborting!"); return; } int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; foreach (KeyValuePair<string, CondOwner> mapCO in DataHandler.mapCOs) { CondOwner value = mapCO.Value; if ((Object)(object)value == (Object)null || !value.HasCond("IsHuman")) { continue; } if (pledge != null) { if (!value.HasPledge(pledge, (string)null)) { Pledge2 val = PledgeFactory.Factory(value, pledge, (CondOwner)null); if (val != null) { value.AddPledge(val); num++; Logger.LogDebug((object)("Added EVA battery maintenance pledge to " + value.strNameFriendly)); } } else { num2++; } } if (pledge2 == null) { continue; } if (!value.HasPledge(pledge2, (string)null)) { Pledge2 val2 = PledgeFactory.Factory(value, pledge2, (CondOwner)null); if (val2 != null) { value.AddPledge(val2); num3++; Logger.LogDebug((object)("Added EVA O2 maintenance pledge to " + value.strNameFriendly)); } } else { num4++; } } Logger.LogInfo((object)"EVA maintenance pledge check complete:"); Logger.LogInfo((object)$" Battery: {num} added, {num2} already had it"); Logger.LogInfo((object)$" O2: {num3} added, {num4} already had it"); } catch (Exception ex) { Logger.LogError((object)("Error adding EVA maintenance pledges on game load: " + ex.Message)); Logger.LogError((object)ex.StackTrace); } } private void SetupConfiguration() { _configDebugLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableDebugLogging", false, "Enable verbose debug logging for troubleshooting"); EnableDebugLogging = _configDebugLogging.Value; if (EnableDebugLogging) { Logger.LogInfo((object)"Debug logging is ENABLED"); } } private void InitializePreferenceSystem() { try { LaunchControl instance = LaunchControl.Instance; object obj; if (instance == null) { obj = null; } else { ItemManager items = instance.Items; obj = ((items != null) ? items.Categories : null); } if (obj != null) { IEnumerable<ItemCategory> allCategories = LaunchControl.Instance.Items.Categories.GetAllCategories(); int num = 0; foreach (ItemCategory item in allCategories) { num++; if (EnableDebugLogging) { Logger.LogDebug((object)$" - {item.DisplayName} ({item.Id}): {item.Description}"); } } Logger.LogInfo((object)$"Preference system initialized with {num} categories from bitlib"); } else { Logger.LogWarning((object)"BitLib item categories not yet available during initialization"); } } catch (Exception ex) { Logger.LogError((object)("Error initializing preference system: " + ex.Message)); } } private void RegisterPersistentDataHandler() { try { if ((Object)(object)LaunchControl.Instance == (Object)null) { Logger.LogError((object)"LaunchControl.Instance is null, cannot register persistent data handler"); return; } if (LaunchControl.Instance.PersistentData == null) { Logger.LogError((object)"LaunchControl.Instance.PersistentData is null, cannot register handler"); return; } SmarterHaulingDataHandler smarterHaulingDataHandler = new SmarterHaulingDataHandler(); ((PersistentDataHandler)smarterHaulingDataHandler).Logger = Logger; SmarterHaulingDataHandler smarterHaulingDataHandler2 = smarterHaulingDataHandler; LaunchControl.Instance.PersistentData.RegisterHandler("smarterhauling", (PersistentDataHandler)(object)smarterHaulingDataHandler2); Logger.LogInfo((object)"Registered persistent data handler for container preferences"); } catch (Exception ex) { Logger.LogError((object)("Error registering persistent data handler: " + ex.Message)); Logger.LogError((object)ex.StackTrace); } } private void RegisterMegaTooltipModules() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown try { LaunchControl.RegisterItemModule(typeof(StorageSettingsModule), new UISetupCallback(StorageSettingsModule.SetupUI)).OnlyShowIf(new VisibilityPredicate(StorageModuleHelper.ShouldShowStorageModule)).InsertAfter("ValueModule"); Logger.LogInfo((object)"Registered StorageSettingsModule with BitLib MegaTooltip system"); } catch (Exception ex) { Logger.LogError((object)("Error registering MegaTooltip modules: " + ex.Message)); Logger.LogError((object)ex.StackTrace); } } private void RegisterInteractionEffects() { try { if ((Object)(object)LaunchControl.Instance == (Object)null || LaunchControl.Instance.Interactions == null) { Logger.LogError((object)"BitLib interactions not available, cannot register effects"); return; } LaunchControl.Instance.Interactions.RegisterEffect((IEffect)(object)new ContainerDropEffect()); LaunchControl.Instance.Interactions.RegisterEffect((IEffect)(object)new EVABatteryChargerSwapEffect()); LaunchControl.Instance.Interactions.RegisterEffect((IEffect)(object)new EVAO2BottleSwapEffect()); Logger.LogInfo((object)"Registered interaction effects with BitLib Interactions system"); } catch (Exception ex) { Logger.LogError((object)("Error registering interaction effects: " + ex.Message)); Logger.LogError((object)ex.StackTrace); } } private void RegisterCommands() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown try { if ((Object)(object)LaunchControl.Instance == (Object)null || LaunchControl.Instance.Commands == null) { Logger.LogError((object)"BitLib commands not available, cannot register commands"); return; } Object.DontDestroyOnLoad((Object)new GameObject("SmarterHaulingCommands")); Logger.LogInfo((object)"Registered SmarterHauling commands"); } catch (Exception ex) { Logger.LogError((object)("Error registering commands: " + ex.Message)); Logger.LogError((object)ex.StackTrace); } } private void RegisterPledgeTypes() { try { if ((Object)(object)LaunchControl.Instance == (Object)null || LaunchControl.Instance.Pledges == null) { Logger.LogError((object)"LaunchControl pledge system not available"); return; } bool flag = LaunchControl.RegisterPledgeType("evabatterymaintenance", typeof(PledgeEVAMaintenance)); bool flag2 = LaunchControl.RegisterPledgeType("evao2maintenance", typeof(PledgeEVAMaintenance)); if (flag && flag2) { Logger.LogInfo((object)"Registered custom pledge types: EVA Battery Maintenance, EVA O2 Maintenance"); return; } if (!flag) { Logger.LogError((object)"Failed to register EVA Battery Maintenance pledge type"); } if (!flag2) { Logger.LogError((object)"Failed to register EVA O2 Maintenance pledge type"); } } catch (Exception ex) { Logger.LogError((object)("Error registering pledge types: " + ex.Message)); Logger.LogError((object)ex.StackTrace); } } private void OnDestroy() { LaunchControl.OnGameReady -= OnGameReady; Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogInfo((object)"SmarterHauling unloaded"); } } public static class PluginInfo { public const string PLUGIN_GUID = "com.ostranauts.smarterhauling"; public const string PLUGIN_NAME = "Smarter Hauling"; public const string PLUGIN_VERSION = "2.0.0"; } } namespace Ostranauts.Bit.SmarterHauling.Utilities { public static class EVAUtils { private static CondTrigger _ctEVAOn; private static CondTrigger CtEVAOn { get { if (_ctEVAOn == null) { _ctEVAOn = DataHandler.GetCondTrigger("TIsEVAOn"); } return _ctEVAOn; } } public static bool IsInPlayerCompany(CondOwner actor) { if ((Object)(object)actor == (Object)null) { return false; } if ((Object)(object)CrewSim.coPlayer == (Object)null) { return false; } if (actor.Company == null) { return false; } return actor.Company == CrewSim.coPlayer.Company; } public static bool IsWearingEVASuit(CondOwner actor) { if ((Object)(object)((actor != null) ? actor.compSlots : null) == (Object)null) { return false; } List<CondOwner> cOs = actor.compSlots.GetCOs("shirt_out", false, CtEVAOn); if (cOs != null) { return cOs.Count > 0; } return false; } public static CondOwner FindEVASuit(CondOwner actor) { if ((Object)(object)((actor != null) ? actor.compSlots : null) == (Object)null) { return null; } return actor.compSlots.GetCOs("shirt_out", false, CtEVAOn)?.FirstOrDefault(); } } } namespace Ostranauts.Bit.SmarterHauling.UI { public class StoragePrefListItem : MonoBehaviour { public enum StoragePrefStatus { All, Some, None } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__26_0; public static UnityAction <>9__29_0; internal void <CreateExpansionButton>b__26_0() { SmarterHaulingPlugin.Logger.LogInfo((object)"[CategoryWidget] CategoryExpansionButton clicked"); } internal void <CreateActionButton>b__29_0() { SmarterHaulingPlugin.Logger.LogInfo((object)"[CategoryWidget] CategoryActionButton clicked"); } } private static readonly string[] DisplayNamePrefixes = new string[5] { "Shoe: ", "Street Food: ", "Food: ", "Pill: ", "Battery: " }; private GameObject categoryExpansionButton; private GameObject categoryArrow; private GameObject categoryText; private GameObject categoryActionButton; private GameObject categoryActionIcon; private TextMeshProUGUI textComponent; private Image arrowImage; private Image actionIconImage; private Button expansionButtonComponent; private Button actionButtonComponent; private StoragePrefStatus _toggleStatus = StoragePrefStatus.None; private List<GameObject> childWidgets = new List<GameObject>(); private bool isExpanded; private bool isUsingItemIcon; public string[] CategoryIds { get; set; } public StoragePrefStatus ToggleStatus => _toggleStatus; public static string StripDisplayNamePrefix(string displayName) { if (string.IsNullOrEmpty(displayName)) { return displayName; } string[] displayNamePrefixes = DisplayNamePrefixes; foreach (string text in displayNamePrefixes) { if (displayName.StartsWith(text, StringComparison.OrdinalIgnoreCase)) { return displayName.Substring(text.Length); } } return displayName; } public static StoragePrefListItem Create(Transform parent, string categoryName, float margin = 4f, bool hasChildren = true, Sprite itemIcon = null) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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) GameObject val = new GameObject("Category", new Type[4] { typeof(CanvasRenderer), typeof(RectTransform), typeof(LayoutElement), typeof(CanvasGroup) }); val.transform.SetParent(parent, false); val.GetComponent<RectTransform>().anchoredPosition = Vector2.zero; val.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 14f); val.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f); val.GetComponent<RectTransform>().anchorMin = Vector2.zero; val.GetComponent<RectTransform>().anchorMax = Vector2.zero; val.GetComponent<LayoutElement>().preferredHeight = 14f; val.GetComponent<CanvasGroup>().alpha = 1f; val.GetComponent<CanvasGroup>().interactable = true; val.GetComponent<CanvasGroup>().blocksRaycasts = true; StoragePrefListItem storagePrefListItem = val.AddComponent<StoragePrefListItem>(); storagePrefListItem.SetToggleStatus(StoragePrefStatus.None); storagePrefListItem.Initialize(val, categoryName, margin, hasChildren, itemIcon); return storagePrefListItem; } public void SetToggleStatus(StoragePrefStatus status) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) _toggleStatus = status; if ((Object)(object)actionIconImage != (Object)null) { switch (status) { case StoragePrefStatus.All: actionIconImage.sprite = SpriteUtility.FindSpriteByKeywords(new string[1] { "GUICheckmarkBox" }, true); ((Graphic)actionIconImage).color = new Color(0.2f, 0.8f, 0.2f, 1f); break; case StoragePrefStatus.Some: actionIconImage.sprite = SpriteUtility.FindSpriteByKeywords(new string[1] { "100xSquare" }, true); ((Graphic)actionIconImage).color = new Color(0.8f, 0.8f, 0.2f, 1f); break; case StoragePrefStatus.None: actionIconImage.sprite = SpriteUtility.FindSpriteByKeywords(new string[1] { "100xSquare" }, true); ((Graphic)actionIconImage).color = new Color(0.8f, 0.2f, 0.2f, 1f); break; } } } private void Initialize(GameObject categoryGo, string categoryName, float margin, bool hasChildren, Sprite itemIcon) { CreateExpansionButton(categoryGo, margin); CreateArrow(hasChildren, itemIcon); CreateText(categoryName); CreateActionButton(categoryGo); } private void CreateExpansionButton(GameObject categoryGo, float margin) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0065: 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_00a3: 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_00e1: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown categoryExpansionButton = new GameObject("CategoryExpansionButton", new Type[3] { typeof(CanvasRenderer), typeof(RectTransform), typeof(Button) }); categoryExpansionButton.transform.SetParent(categoryGo.transform, false); categoryExpansionButton.GetComponent<RectTransform>().anchoredPosition = new Vector2(margin, 0f); categoryExpansionButton.GetComponent<RectTransform>().sizeDelta = new Vector2(100f, 14f); categoryExpansionButton.GetComponent<RectTransform>().pivot = new Vector2(0f, 0.5f); categoryExpansionButton.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 0.5f); categoryExpansionButton.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 0.5f); expansionButtonComponent = categoryExpansionButton.GetComponent<Button>(); ButtonClickedEvent onClick = expansionButtonComponent.onClick; object obj = <>c.<>9__26_0; if (obj == null) { UnityAction val = delegate { SmarterHaulingPlugin.Logger.LogInfo((object)"[CategoryWidget] CategoryExpansionButton clicked"); }; <>c.<>9__26_0 = val; obj = (object)val; } ((UnityEvent)onClick).AddListener((UnityAction)obj); ((Selectable)expansionButtonComponent).interactable = true; } private void CreateArrow(bool hasChildren, Sprite itemIcon) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_006e: 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_00cb: 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_0120: 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) categoryArrow = new GameObject("CategoryArrow", new Type[3] { typeof(CanvasRenderer), typeof(RectTransform), typeof(Image) }); categoryArrow.transform.SetParent(categoryExpansionButton.transform, false); categoryArrow.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 0f); categoryArrow.GetComponent<RectTransform>().sizeDelta = new Vector2(10f, 10f); categoryArrow.GetComponent<RectTransform>().pivot = new Vector2(0f, 0.5f); categoryArrow.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 0.5f); categoryArrow.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 0.5f); arrowImage = categoryArrow.GetComponent<Image>(); if ((Object)(object)itemIcon != (Object)null) { arrowImage.sprite = itemIcon; ((Graphic)arrowImage).color = Color.white; arrowImage.preserveAspect = true; isUsingItemIcon = true; } else if (hasChildren) { arrowImage.sprite = SpriteUtility.FindSpriteByKeywords(new string[1] { "GUIArrowR" }, true); ((Graphic)arrowImage).color = Color.white; isUsingItemIcon = false; } else { ((Behaviour)arrowImage).enabled = false; isUsingItemIcon = false; } } private void CreateText(string categoryName) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_006e: 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_00cb: 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_014d: Unknown result type (might be due to invalid IL or missing references) categoryText = new GameObject("CategoryText", new Type[3] { typeof(CanvasRenderer), typeof(RectTransform), typeof(TextMeshProUGUI) }); categoryText.transform.SetParent(categoryExpansionButton.transform, false); categoryText.GetComponent<RectTransform>().anchoredPosition = new Vector2(18f, 0f); categoryText.GetComponent<RectTransform>().sizeDelta = new Vector2(80f, 14f); categoryText.GetComponent<RectTransform>().pivot = new Vector2(0f, 0.5f); categoryText.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 0.5f); categoryText.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 0.5f); textComponent = categoryText.GetComponent<TextMeshProUGUI>(); string text = StripDisplayNamePrefix(categoryName); ((TMP_Text)textComponent).text = ((text.Length > 24) ? (text.Substring(0, 24) + "...") : text); ((TMP_Text)textComponent).fontSize = 10f; ((Graphic)textComponent).color = Color.white; ((TMP_Text)textComponent).alignment = (TextAlignmentOptions)513; ((TMP_Text)textComponent).enableWordWrapping = false; } private void CreateActionButton(GameObject categoryGo) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown categoryActionButton = new GameObject("CategoryActionButton", new Type[3] { typeof(CanvasRenderer), typeof(RectTransform), typeof(Button) }); categoryActionButton.transform.SetParent(categoryGo.transform, false); categoryActionButton.GetComponent<RectTransform>().anchoredPosition = new Vector2(166f, 0f); categoryActionButton.GetComponent<RectTransform>().sizeDelta = new Vector2(14f, 14f); categoryActionButton.GetComponent<RectTransform>().pivot = new Vector2(0f, 0.5f); categoryActionButton.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 0.5f); categoryActionButton.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 0.5f); actionButtonComponent = categoryActionButton.GetComponent<Button>(); ButtonClickedEvent onClick = actionButtonComponent.onClick; object obj = <>c.<>9__29_0; if (obj == null) { UnityAction val = delegate { SmarterHaulingPlugin.Logger.LogInfo((object)"[CategoryWidget] CategoryActionButton clicked"); }; <>c.<>9__29_0 = val; obj = (object)val; } ((UnityEvent)onClick).AddListener((UnityAction)obj); ((Selectable)actionButtonComponent).interactable = true; categoryActionIcon = new GameObject("CategoryActionIcon", new Type[3] { typeof(CanvasRenderer), typeof(RectTransform), typeof(Image) }); categoryActionIcon.transform.SetParent(categoryActionButton.transform, false); categoryActionIcon.GetComponent<RectTransform>().anchoredPosition = Vector2.zero; categoryActionIcon.GetComponent<RectTransform>().sizeDelta = new Vector2(14f, 14f); categoryActionIcon.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f); categoryActionIcon.GetComponent<RectTransform>().anchorMin = new Vector2(0.5f, 0.5f); categoryActionIcon.GetComponent<RectTransform>().anchorMax = new Vector2(0.5f, 0.5f); actionIconImage = categoryActionIcon.GetComponent<Image>(); actionIconImage.sprite = SpriteUtility.FindSpriteByKeywords(new string[1] { "100xSquare" }, true); ((Graphic)actionIconImage).color = Color.white; } public void SetCategoryName(string name) { if ((Object)(object)textComponent != (Object)null) { string text = StripDisplayNamePrefix(name); ((TMP_Text)textComponent).text = ((text.Length > 24) ? (text.Substring(0, 24) + "...") : text); } } public void SetExpanded(bool expanded) { isExpanded = expanded; if (!isUsingItemIcon && (Object)(object)arrowImage != (Object)null && ((Behaviour)arrowImage).enabled) { if (expanded) { arrowImage.sprite = SpriteUtility.FindSpriteByKeywords(new string[1] { "GUIArrowD" }, true); } else { arrowImage.sprite = SpriteUtility.FindSpriteByKeywords(new string[1] { "GUIArrowR" }, true); } } } public bool IsExpanded() { return isExpanded; } public void AddChildWidget(GameObject childWidget) { if ((Object)(object)childWidget != (Object)null) { childWidgets.Add(childWidget); } } public List<GameObject> GetChildWidgets() { return childWidgets; } public void ClearChildren() { foreach (GameObject childWidget in childWidgets) { if ((Object)(object)childWidget != (Object)null) { Object.Destroy((Object)(object)childWidget); } } childWidgets.Clear(); } public void SetExpansionClickHandler(UnityAction callback) { if ((Object)(object)expansionButtonComponent != (Object)null) { ((UnityEventBase)expansionButtonComponent.onClick).RemoveAllListeners(); ((UnityEvent)expansionButtonComponent.onClick).AddListener(callback); } } public void SetActionClickHandler(UnityAction callback) { if ((Object)(object)actionButtonComponent != (Object)null) { ((UnityEventBase)actionButtonComponent.onClick).RemoveAllListeners(); ((UnityEvent)actionButtonComponent.onClick).AddListener(callback); } } public void SetArrowVisible(bool visible) { if ((Object)(object)arrowImage != (Object)null) { ((Behaviour)arrowImage).enabled = visible; } if (!visible && (Object)(object)expansionButtonComponent != (Object)null) { ((Selectable)expansionButtonComponent).interactable = false; } } public void SetActionIcon(Sprite sprite) { if ((Object)(object)actionIconImage != (Object)null) { actionIconImage.sprite = sprite; } } public void SetActionIconColor(Color color) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)actionIconImage != (Object)null) { ((Graphic)actionIconImage).color = color; } } } public static class StorageModuleHelper { private static readonly string[] AllowedPortableContainers = new string[6] { "ItmCrate01", "ItmCrate01Lock", "ItmToolBox01", "ItmToolBox02", "ItmBackpack02", "ItmBackpack03" }; private static bool IsAllowedPortableContainer(CondOwner co) { if ((Object)(object)co == (Object)null || string.IsNullOrEmpty(co.strCODef)) { return false; } string strCODef = co.strCODef; string[] allowedPortableContainers = AllowedPortableContainers; foreach (string text in allowedPortableContainers) { if (strCODef == text) { return true; } } return false; } public static bool ShouldShowStorageModule(CondOwner co) { if ((Object)(object)co == (Object)null) { return false; } if ((Object)(object)co.GetContainer() == (Object)null) { return false; } if (co.HasCond("IsCarried")) { if (SmarterHaulingPlugin.EnableDebugLogging) { SmarterHaulingPlugin.Logger.LogDebug((object)("[StorageModule] Hiding module for " + co.strNameFriendly + " - item is carried")); } return false; } if (co.slotNow != null && co.slotNow.strName == "drag") { if (SmarterHaulingPlugin.EnableDebugLogging) { SmarterHaulingPlugin.Logger.LogDebug((object)("[StorageModule] Hiding module for " + co.strNameFriendly + " - item is being dragged")); } return false; } if (co.HasCond("IsDamaged")) { if (SmarterHaulingPlugin.EnableDebugLogging) { SmarterHaulingPlugin.Logger.LogDebug((object)("[StorageModule] Hiding module for " + co.strNameFriendly + " - item is damaged")); } return false; } CondTrigger condTrigger = DataHandler.GetCondTrigger("TIsLoose"); if (condTrigger != null && condTrigger.Triggered(co, (string)null, false)) { if (!IsAllowedPortableContainer(co)) { if (SmarterHaulingPlugin.EnableDebugLogging) { SmarterHaulingPlugin.Logger.LogDebug((object)("[StorageModule] Hiding module for " + co.strNameFriendly + " - item is loose")); } return false; } if (SmarterHaulingPlugin.EnableDebugLogging) { SmarterHaulingPlugin.Logger.LogDebug((object)("[StorageModule] Allowing module for portable container " + co.strNameFriendly + " (def:" + co.strCODef + ") even though it's loose")); } } if (co.HasCond("Locked")) { if (SmarterHaulingPlugin.EnableDebugLogging) { SmarterHaulingPlugin.Logger.LogDebug((object)("[StorageModule] Hiding module for " + co.strNameFriendly + " - item is locked")); } return false; } if (co.HasCond("IsTraderNPC")) { if (SmarterHaulingPlugin.EnableDebugLogging) { SmarterHaulingPlugin.Logger.LogDebug((object)("[StorageModule] Hiding module for " + co.strNameFriendly + " - is trader NPC")); } return false; } return true; } } public class StorageSettingsModule : ModuleBase, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { private GameObject _chipContainer; private Image _chipBackground; private TMP_Text _chipText; private Button _settingsButton; private Container _container; private CondOwner _condOwner; private string _containerId; private void Awake() { ((ModuleBase)this).Awake(); StorageSettingWidget.OnPreferencesChanged = (Action<string>)Delegate.Combine(StorageSettingWidget.OnPreferencesChanged, new Action<string>(OnPreferencesChanged)); } private void OnDestroy() { StorageSettingWidget.OnPreferencesChanged = (Action<string>)Delegate.Remove(StorageSettingWidget.OnPreferencesChanged, new Action<string>(OnPreferencesChanged)); } private void OnPreferencesChanged(string containerId) { if (!string.IsNullOrEmpty(containerId) && containerId == _containerId) { UpdateChipText(); } } public override void SetData(CondOwner co) { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown if ((Object)(object)co == (Object)null) { base._IsMarkedForDestroy = true; return; } _condOwner = co; _container = co.GetContainer(); if ((Object)(object)_container == (Object)null) { base._IsMarkedForDestroy = true; return; } _containerId = co.strID; if ((Object)(object)_chipContainer == (Object)null) { Transform obj = ((Component)this).transform.Find("StorageChip"); _chipContainer = ((obj != null) ? ((Component)obj).gameObject : null); GameObject chipContainer = _chipContainer; _chipBackground = ((chipContainer != null) ? chipContainer.GetComponent<Image>() : null); GameObject chipContainer2 = _chipContainer; _chipText = (TMP_Text)(object)((chipContainer2 != null) ? chipContainer2.GetComponentInChildren<TextMeshProUGUI>() : null); Transform obj2 = ((Component)this).transform.Find("SettingsButton"); _settingsButton = ((obj2 != null) ? ((Component)obj2).GetComponent<Button>() : null); } UpdateChipText(); if ((Object)(object)_settingsButton != (Object)null) { ((UnityEventBase)_settingsButton.onClick).RemoveAllListeners(); ((UnityEvent)_settingsButton.onClick).AddListener((UnityAction)delegate { StorageSettingWidget.Show(_condOwner); }); } LayoutRebuilder.ForceRebuildLayoutImmediate(((Component)this).GetComponent<RectTransform>()); } public static void SetupUI(GameObject go) { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_0200: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0240: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Expected O, but got Unknown //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Expected O, but got Unknown //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) Sprite val = SpriteUtility.FindSpriteByKeywords(new string[2] { "gradient", "bordered" }, true); if ((Object)(object)val == (Object)null) { SmarterHaulingPlugin.Logger.LogWarning((object)"[StorageSettings] Failed to load chip sprite with keywords: gradient, bordered"); } Sprite val2 = SpriteUtility.FindSpriteByKeywords(new string[2] { "crewbar", "circbutton" }, true); if ((Object)(object)val2 == (Object)null) { SmarterHaulingPlugin.Logger.LogWarning((object)"[StorageSettings] Failed to load button background sprite (GUICrewBarCircButtonMid)"); } Sprite val3 = SpriteUtility.FindSpriteByKeywords(new string[1] { "screw" }, true); if ((Object)(object)val3 == (Object)null) { SmarterHaulingPlugin.Logger.LogWarning((object)"[StorageSettings] Failed to load settings icon sprite (GUIScrew01)"); } ((Graphic)go.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.278f); HorizontalLayoutGroup obj = go.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f; ((LayoutGroup)obj).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; ((LayoutGroup)obj).padding = new RectOffset(5, 5, 5, 5); RectTransform val4 = go.GetComponent<RectTransform>(); if ((Object)(object)val4 == (Object)null) { val4 = go.AddComponent<RectTransform>(); } val4.anchorMin = new Vector2(0f, 1f); val4.anchorMax = new Vector2(1f, 1f); val4.pivot = new Vector2(0.5f, 1f); val4.sizeDelta = new Vector2(0f, 32f); GameObject val5 = new GameObject("StorageChip"); val5.transform.SetParent(go.transform, false); RectTransform obj2 = val5.AddComponent<RectTransform>(); obj2.sizeDelta = new Vector2(120f, 24f); obj2.pivot = new Vector2(0f, 0.5f); obj2.anchorMin = new Vector2(0f, 0.5f); obj2.anchorMax = new Vector2(0f, 0.5f); Image val6 = val5.AddComponent<Image>(); ((Graphic)val6).color = new Color(0.5f, 0.7f, 1f, 1f); val6.type = (Type)1; if ((Object)(object)val != (Object)null) { val6.sprite = val; } GameObject val7 = new GameObject("Text"); val7.transform.SetParent(val5.transform, false); RectTransform obj3 = val7.AddComponent<RectTransform>(); obj3.anchorMin = Vector2.zero; obj3.anchorMax = Vector2.one; obj3.offsetMin = new Vector2(6f, 2f); obj3.offsetMax = new Vector2(-6f, -2f); TextMeshProUGUI obj4 = val7.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj4).text = "None"; ((TMP_Text)obj4).fontSize = 12f; ((Graphic)obj4).color = Color.white; ((TMP_Text)obj4).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj4).enableWordWrapping = false; GameObject val8 = new GameObject("SettingsButton"); val8.transform.SetParent(go.transform, false); RectTransform obj5 = val8.AddComponent<RectTransform>(); obj5.anchorMin = new Vector2(1f, 0.5f); obj5.anchorMax = new Vector2(1f, 0.5f); obj5.pivot = new Vector2(1f, 0.5f); obj5.sizeDelta = new Vector2(100f, 22f); obj5.anchoredPosition = new Vector2(-5f, 0f); Image val9 = val8.AddComponent<Image>(); val9.type = (Type)1; ((Graphic)val9).color = new Color(0.15f, 0.15f, 0.15f, 1f); if ((Object)(object)val2 != (Object)null) { val9.sprite = val2; } Button obj6 = val8.AddComponent<Button>(); ColorBlock colors = ((Selectable)obj6).colors; ((ColorBlock)(ref colors)).normalColor = Color.white; ((ColorBlock)(ref colors)).highlightedColor = new Color(1.2f, 1.2f, 1.2f, 1f); ((ColorBlock)(ref colors)).pressedColor = new Color(0.8f, 0.8f, 0.8f, 1f); ((Selectable)obj6).colors = colors; GameObject val10 = new GameObject("Content"); val10.transform.SetParent(val8.transform, false); RectTransform obj7 = val10.AddComponent<RectTransform>(); obj7.anchorMin = Vector2.zero; obj7.anchorMax = Vector2.one; obj7.offsetMin = new Vector2(4f, 0f); obj7.offsetMax = new Vector2(-4f, 0f); HorizontalLayoutGroup obj8 = val10.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj8).spacing = 4f; ((LayoutGroup)obj8).childAlignment = (TextAnchor)4; ((HorizontalOrVerticalLayoutGroup)obj8).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)obj8).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)obj8).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj8).childForceExpandHeight = false; if ((Object)(object)val3 != (Object)null) { GameObject val11 = new GameObject("Icon"); val11.transform.SetParent(val10.transform, false); Image obj9 = val11.AddComponent<Image>(); obj9.sprite = val3; ((Graphic)obj9).color = Color.white; val11.GetComponent<RectTransform>().sizeDelta = new Vector2(12f, 12f); } GameObject val12 = new GameObject("Text"); val12.transform.SetParent(val10.transform, false); TextMeshProUGUI obj10 = val12.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj10).text = "SETTINGS"; ((TMP_Text)obj10).fontSize = 10f; ((Graphic)obj10).color = Color.white; ((TMP_Text)obj10).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj10).enableWordWrapping = false; ((TMP_Text)obj10).fontStyle = (FontStyles)1; val12.GetComponent<RectTransform>().sizeDelta = new Vector2(70f, 20f); } private void UpdateChipText() { if ((Object)(object)_chipText == (Object)null || (Object)(object)_container == (Object)null) { return; } ContainerStoragePrefs prefs = _container.GetPrefs(); if (prefs == null || prefs.AllowedCategories == null || prefs.AllowedCategories.Count == 0) { _chipText.text = "None"; } else if (prefs.AllowedCategories.Count == 1) { string text = ItemHintId.op_Implicit(prefs.AllowedCategories[0]); LaunchControl instance = LaunchControl.Instance; object obj; if (instance == null) { obj = null; } else { ItemManager items = instance.Items; if (items == null) { obj = null; } else { ItemCategoryManager categories = items.Categories; obj = ((categories != null) ? categories.GetCategory(text) : null); } } ItemCategory val = (ItemCategory)obj; if (val != null) { _chipText.text = val.DisplayName; return; } string cOFriendlyName = DataHandler.GetCOFriendlyName(text); if (!string.IsNullOrEmpty(cOFriendlyName)) { _chipText.text = cOFriendlyName; } else { _chipText.text = text; } } else { _chipText.text = "Multiple"; } } public void OnPointerEnter(PointerEventData eventData) { if (!((Object)(object)_condOwner == (Object)null)) { string text = BuildTooltipText(); GUITooltip2.SetToolTip("Storage Settings", text, true); } } public void OnPointerExit(PointerEventData eventData) { GUITooltip2.SetToolTip(string.Empty, string.Empty, false); } private string BuildTooltipText() { if ((Object)(object)_condOwner == (Object)null) { return string.Empty; } Container container = _condOwner.GetContainer(); if ((Object)(object)container == (Object)null) { return string.Empty; } ContainerStoragePrefs prefs = container.GetPrefs(); string strName = _condOwner.strName; if (prefs == null || prefs.AllowedCategories == null || prefs.AllowedCategories.Count == 0) { return $"The {strName} isn't configured to store anything in particular."; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("The {0} is set to store:\n\n", strName); LaunchControl instance = LaunchControl.Instance; object obj; if (instance == null) { obj = null; } else { ItemManager items = instance.Items; obj = ((items != null) ? items.Categories : null); } ItemCategoryManager val = (ItemCategoryManager)obj; int num = Math.Min(10, prefs.AllowedCategories.Count); for (int i = 0; i < num; i++) { string text = ItemHintId.op_Implicit(prefs.AllowedCategories[i]); ItemCategory obj2 = ((val != null) ? val.GetCategory(text) : null); string text2 = ((obj2 != null) ? obj2.DisplayName : null) ?? text; stringBuilder.AppendLine("• " + text2); } if (prefs.AllowedCategories.Count > 10) { int num2 = prefs.AllowedCategories.Count - 10; stringBuilder.AppendFormat("\n...and {0} more", num2); if (num2 > 1) { stringBuilder.Append(" categories"); } else { stringBuilder.Append(" category"); } } return stringBuilder.ToString(); } } public class StorageSettingWidget : MonoBehaviour, IEventSystemHandler { private CondOwner _coTarget; private CanvasGroup cg; private static StorageSettingWidget _instance; private static GameObject _goInstance; private RectTransform _megaTooltipRect; private RectTransform _megaTooltipContentRect; private RectTransform _rectTransform; private bool _megaTooltipSearched; private static CondOwner _lastShownCondOwner; private Vector3 _lastMegaTooltipPosition = Vector3.zero; private Vector2 _lastMegaTooltipSize = Vector2.zero; private Vector3 _lastWidgetPosition = Vector3.zero; private const float POSITION_CHANGE_THRESHOLD = 1f; private List<StoragePrefListItem> _storagePrefListItems = new List<StoragePrefListItem>(); public static Action<string> OnPreferencesChanged; public CondOwner COTarget { get { return _coTarget; } set { _coTarget = value; } } public static void Show(CondOwner condOwner) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown if ((Object)(object)_goInstance == (Object)null) { _goInstance = new GameObject("StorageSettingWidget", new Type[4] { typeof(CanvasRenderer), typeof(CanvasGroup), typeof(StorageSettingWidget), typeof(RectTransform) }); _goInstance.transform.SetParent(CanvasManager.instance.goCanvasCrewBar.transform, false); _goInstance.layer = LayerMask.NameToLayer("UI"); _instance = _goInstance.GetComponent<StorageSettingWidget>(); _instance.cg = _goInstance.GetComponent<CanvasGroup>(); _instance.cg.alpha = 0f; _instance.cg.interactable = false; _instance.cg.blocksRaycasts = false; try { _instance.SetupUI(); } catch (Exception ex) { SmarterHaulingPlugin.Logger.LogError((object)("[StorageSettingWidget] SetupUI failed: " + ex.Message)); SmarterHaulingPlugin.Logger.LogError((object)("[StorageSettingWidget] Stack trace: " + ex.StackTrace)); } SmarterHaulingPlugin.Logger.LogInfo((object)"[StorageSettingWidget] Widget created and SetupUI called"); } _instance.COTarget = condOwner; _lastShownCondOwner = condOwner; _instance.cg.alpha = 1f; _instance.cg.interactable = true; _instance.cg.blocksRaycasts = true; _instance.RefreshAllToggleStatuses(); SmarterHaulingPlugin.Logger.LogInfo((object)"[StorageSettingWidget] Widget shown"); } public static void Hide() { if (!((Object)(object)_instance == (Object)null) && !((Object)(object)_instance.cg == (Object)null)) { _instance.cg.alpha = 0f; _instance.cg.interactable = false; _instance.cg.blocksRaycasts = false; } } public void SetupUI() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_0154: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Expected O, but got Unknown //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Expected O, but got Unknown //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Expected O, but got Unknown //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Expected O, but got Unknown //IL_05d9: Unknown result type (might be due to invalid IL or missing references) //IL_05f4: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Unknown result type (might be due to invalid IL or missing references) //IL_0645: Unknown result type (might be due to invalid IL or missing references) //IL_06bb: Unknown result type (might be due to invalid IL or missing references) //IL_06c2: Expected O, but got Unknown //IL_06e7: Unknown result type (might be due to invalid IL or missing references) //IL_06f8: Unknown result type (might be due to invalid IL or missing references) //IL_0713: Unknown result type (might be due to invalid IL or missing references) //IL_072e: Unknown result type (might be due to invalid IL or missing references) //IL_0795: Unknown result type (might be due to invalid IL or missing references) //IL_079f: Expected O, but got Unknown //IL_07de: Unknown result type (might be due to invalid IL or missing references) //IL_07e5: Expected O, but got Unknown //IL_0819: Unknown result type (might be due to invalid IL or missing references) //IL_0834: Unknown result type (might be due to invalid IL or missing references) //IL_0845: Unknown result type (might be due to invalid IL or missing references) //IL_0860: Unknown result type (might be due to invalid IL or missing references) //IL_0871: Unknown result type (might be due to invalid IL or missing references) //IL_08de: Unknown result type (might be due to invalid IL or missing references) //IL_090d: Unknown result type (might be due to invalid IL or missing references) //IL_0914: Expected O, but got Unknown //IL_0940: Unknown result type (might be due to invalid IL or missing references) //IL_095b: Unknown result type (might be due to invalid IL or missing references) //IL_0976: Unknown result type (might be due to invalid IL or missing references) //IL_0987: Unknown result type (might be due to invalid IL or missing references) //IL_0998: Unknown result type (might be due to invalid IL or missing references) //IL_09d4: Unknown result type (might be due to invalid IL or missing references) //IL_09db: Expected O, but got Unknown //IL_0a19: Unknown result type (might be due to invalid IL or missing references) //IL_0a34: Unknown result type (might be due to invalid IL or missing references) //IL_0a4f: Unknown result type (might be due to invalid IL or missing references) //IL_0a60: Unknown result type (might be due to invalid IL or missing references) //IL_0a71: Unknown result type (might be due to invalid IL or missing references) //IL_0ab6: Unknown result type (might be due to invalid IL or missing references) SmarterHaulingPlugin.Logger.LogInfo((object)"[StorageSettingWidget] SetupUI started"); RectTransform component = ((Component)this).GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = new Vector2(200f, 400f); component.anchoredPosition = Vector2.zero; _rectTransform = component; GameObject val = new GameObject("TopBar", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(((Component)this).transform, false); val.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f); val.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f); val.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 18f); GameObject val2 = new GameObject("TopBarBg", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val2.transform.SetParent(val.transform, false); val2.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 0f); val2.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f); val2.GetComponent<RectTransform>().sizeDelta = Vector2.zero; val2.GetComponent<Image>().sprite = SpriteUtility.FindSpriteByKeywords(new string[3] { "background", "panel", "desaturated" }, true); ((Graphic)val2.GetComponent<Image>()).color = new Color(0.424f, 0.459f, 0.49f, 1f); GameObject val3 = new GameObject("TopBarBgImage", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val3.transform.SetParent(val2.transform, false); val3.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 0f); val3.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f); val3.GetComponent<RectTransform>().sizeDelta = new Vector2(-2f, -2f); val3.GetComponent<Image>().sprite = SpriteUtility.FindSpriteByKeywords(new string[1] { "GUIMenuBackgroundSpriteE" }, true); ((Graphic)val3.GetComponent<Image>()).color = new Color(0.231f, 0.227f, 0.239f, 1f); GameObject val4 = new GameObject("TopBarText", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(TextMeshProUGUI) }); val4.transform.SetParent(val.transform, false); val4.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 0f); val4.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f); val4.GetComponent<RectTransform>().sizeDelta = Vector2.zero; ((TMP_Text)val4.GetComponent<TextMeshProUGUI>()).text = "Storage Settings"; ((TMP_Text)val4.GetComponent<TextMeshProUGUI>()).fontSize = 10f; ((Graphic)val4.GetComponent<TextMeshProUGUI>()).color = Color.white; ((TMP_Text)val4.GetComponent<TextMeshProUGUI>()).alignment = (TextAlignmentOptions)513; ((TMP_Text)val4.GetComponent<TextMeshProUGUI>()).enableWordWrapping = false; GameObject val5 = new GameObject("CenterPanel", new Type[3] { typeof(CanvasRenderer), typeof(RectTransform), typeof(Image) }); val5.layer = LayerMask.NameToLayer("UI"); val5.transform.SetParent(((Component)this).transform, false); RectTransform component2 = val5.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0f, 0f); component2.anchorMax = new Vector2(1f, 1f); component2.pivot = new Vector2(0.5f, 0.5f); component2.anchoredPosition = new Vector2(0f, 1f); component2.sizeDelta = new Vector2(0f, -29f); GameObject val6 = new GameObject("ScrollList", new Type[4] { typeof(CanvasRenderer), typeof(RectTransform), typeof(ScrollRect), typeof(Image) }); val6.transform.SetParent(val5.transform, false); val6.GetComponent<RectTransform>().anchoredPosition = Vector2.zero; val6.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 0f); val6.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f); val6.GetComponent<RectTransform>().sizeDelta = Vector2.zero; val6.GetComponent<Image>().sprite = SpriteUtility.FindSpriteByKeywords(new string[3] { "background", "panel", "desaturated" }, true); ((Graphic)val6.GetComponent<Image>()).color = new Color(0.231f, 0.227f, 0.239f, 1f); val6.GetComponent<Image>().type = (Type)2; GameObject val7 = new GameObject("ScrollMask", new Type[4] { typeof(CanvasRenderer), typeof(RectTransform), typeof(Image), typeof(Mask) }); val7.transform.SetParent(val6.transform, false); val7.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 0f); val7.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f); val7.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f); val7.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 0f); val7.GetComponent<RectTransform>().sizeDelta = new Vector2(-8f, 0f); val7.GetComponent<Mask>().showMaskGraphic = false; val7.GetComponent<Image>().sprite = SpriteUtility.FindSpriteByKeywords(new string[1] { "100xSquare" }, true); GameObject val8 = new GameObject("Content", new Type[4] { typeof(CanvasRenderer), typeof(RectTransform), typeof(VerticalLayoutGroup), typeof(ContentSizeFitter) }); val8.transform.SetParent(val7.transform, false); val8.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f); val8.GetComponent<RectTransform>().anchoredPosition = Vector2.zero; val8.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f); val8.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f); val8.GetComponent<ContentSizeFitter>().horizontalFit = (FitMode)0; val8.GetComponent<ContentSizeFitter>().verticalFit = (FitMode)2; ((HorizontalOrVerticalLayoutGroup)val8.GetComponent<VerticalLayoutGroup>()).spacing = 2f; ((LayoutGroup)val8.GetComponent<VerticalLayoutGroup>()).childAlignment = (TextAnchor)0; ((HorizontalOrVerticalLayoutGroup)val8.GetComponent<VerticalLayoutGroup>()).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val8.GetComponent<VerticalLayoutGroup>()).childControlHeight = false; ((LayoutGroup)val8.GetComponent<VerticalLayoutGroup>()).padding = new RectOffset(4, 4, 0, 0); GameObject val9 = new GameObject("Scrollbar Vertical", new Type[4] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image), typeof(Scrollbar) }); val9.layer = LayerMask.NameToLayer("UI"); val9.SetActive(true); val9.transform.SetParent(val6.transform, false); val9.GetComponent<RectTransform>().anchoredPosition = Vector2.zero; val9.GetComponent<RectTransform>().sizeDelta = new Vector2(8f, 0f); val9.GetComponent<RectTransform>().pivot = Vector2.one; val9.GetComponent<RectTransform>().anchorMin = new Vector2(1f, 0f); val9.GetComponent<RectTransform>().anchorMax = Vector2.one; val9.GetComponent<Scrollbar>().size = 1f; val9.GetComponent<Scrollbar>().value = 1f; val9.GetComponent<Scrollbar>().numberOfSteps = 0; val9.GetComponent<Scrollbar>().direction = (Direction)2; val9.GetComponent<Image>().sprite = SpriteUtility.FindSpriteByKeywords(new string[1] { "Background" }, true); ((Graphic)val9.GetComponent<Image>()).color = Color.black; val9.GetComponent<Image>().type = (Type)1; GameObject val10 = new GameObject("Sliding Area", new Type[1] { typeof(RectTransform) }); val10.layer = LayerMask.NameToLayer("UI"); val10.transform.SetParent(val9.transform, false); val10.GetComponent<RectTransform>().anchoredPosition = Vector2.zero; val10.GetComponent<RectTransform>().sizeDelta = new Vector2(-2f, -20f); val10.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f); val10.GetComponent<RectTransform>().anchorMin = Vector2.zero; val10.GetComponent<RectTransform>().anchorMax = Vector2.one; GameObject val11 = new GameObject("Handle", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val11.layer = LayerMask.NameToLayer("UI"); val11.SetActive(true); val11.transform.SetParent(val10.transform, false); val11.GetComponent<RectTransform>().anchoredPosition = new Vector2(-0.5f, 0f); val11.GetComponent<RectTransform>().sizeDelta = new Vector2(3f, 20f); val11.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f); val11.GetComponent<RectTransform>().anchorMin = Vector2.zero; val11.GetComponent<RectTransform>().anchorMax = Vector2.one; val11.GetComponent<Image>().sprite = SpriteUtility.FindSpriteByKeywords(new string[1] { "UISprite" }, true); ((Graphic)val11.GetComponent<Image>()).color = new Color(0.212f, 0.212f, 0.212f, 1f); val11.GetComponent<Image>().type = (Type)1; val9.GetComponent<Scrollbar>().handleRect = val11.GetComponent<RectTransform>(); val6.GetComponent<ScrollRect>().content = val8.GetComponent<RectTransform>(); val6.GetComponent<ScrollRect>().viewport = val7.GetComponent<RectTransform>(); val6.GetComponent<ScrollRect>().horizontal = false; val6.GetComponent<ScrollRect>().vertical = true; val6.GetComponent<ScrollRect>().movementType = (MovementType)2; val6.GetComponent<ScrollRect>().verticalScrollbar = val9.GetComponent<Scrollbar>(); val6.GetComponent<ScrollRect>().verticalScrollbarVisibility = (ScrollbarVisibility)1; val6.GetComponent<ScrollRect>().verticalScrollbarSpacing = -3f; val6.GetComponent<ScrollRect>().scrollSensitivity = 2.4f; foreach (ItemCategory rootCategory in LaunchControl.Instance.Items.Categories.GetRootCategories()) { if (!HasAnyItems(rootCategory)) { SmarterHaulingPlugin.Logger.LogDebug((object)("Skipping empty root category: " + rootCategory.DisplayName)); continue; } SmarterHaulingPlugin.Logger.LogInfo((object)("Showing category " + rootCategory.DisplayName)); CreateStoragePrefListItem(val8.transform, rootCategory, 4f); } Canvas.ForceUpdateCanvases(); LayoutRebuilder.ForceRebuildLayoutImmediate(val8.GetComponent<RectTransform>()); LayoutRebuilder.ForceRebuildLayoutImmediate(val5.GetComponent<RectTransform>()); SmarterHaulingPlugin.Logger.LogInfo((object)"[StorageSettingWidget] SetupUI completed"); } private void FindMegaTooltip() { //IL_00cf: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) if (_megaTooltipSearched) { return; } _megaTooltipSearched = true; try { GameObject val = CanvasManager.instance?.goCanvasCrewBar; if ((Object)(object)val != (Object)null) { Transform val2 = val.transform.Find("pnlMegaTooltip"); if ((Object)(object)val2 != (Object)null) { _megaTooltipRect = ((Component)val2).GetComponent<RectTransform>(); SmarterHaulingPlugin.Logger.LogInfo((object)"[StorageSettingWidget] Found MegaTooltip via CanvasManager.goCanvasCrewBar"); } } if ((Object)(object)_megaTooltipRect == (Object)null) { GameObject val3 = GameObject.Find("pnlMegaTooltip"); if ((Object)(object)val3 != (Object)null) { _megaTooltipRect = val3.GetComponent<RectTransform>(); SmarterHaulingPlugin.Logger.LogInfo((object)"[StorageSettingWidget] Found MegaTooltip via GameObject.Find"); } } if ((Object)(object)_megaTooltipRect == (Object)null) { SmarterHaulingPlugin.Logger.LogWarning((object)"[StorageSettingWidget] Could not find pnlMegaTooltip!"); return; } SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] MegaTooltip cached. AnchoredPos: {_megaTooltipRect.anchoredPosition}, Size: {_megaTooltipRect.sizeDelta}"); Transform val4 = ((Transform)_megaTooltipRect).Find("TooltipSelectionStack"); if ((Object)(object)val4 != (Object)null) { _megaTooltipContentRect = ((Component)val4).GetComponent<RectTransform>(); SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] Found TooltipSelectionStack content. Size: {_megaTooltipContentRect.sizeDelta}, Rect: {_megaTooltipContentRect.rect}"); } else { SmarterHaulingPlugin.Logger.LogWarning((object)"[StorageSettingWidget] Could not find TooltipSelectionStack child!"); } } catch (Exception ex) { SmarterHaulingPlugin.Logger.LogError((object)("[StorageSettingWidget] FindMegaTooltip failed: " + ex.Message)); } } private void UpdatePosition() { //IL_0031: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0229: 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_0245: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_rectTransform == (Object)null) && !((Object)(object)_megaTooltipRect == (Object)null) && !((Object)(object)_megaTooltipContentRect == (Object)null)) { Vector3 localPosition = ((Transform)_megaTooltipRect).localPosition; Rect rect = _megaTooltipContentRect.rect; Vector2 size = ((Rect)(ref rect)).size; bool flag = Vector3.Distance(localPosition, _lastMegaTooltipPosition) > 1f; bool flag2 = Vector2.Distance(size, _lastMegaTooltipSize) > 1f; bool flag3 = flag || flag2 || _lastMegaTooltipPosition == Vector3.zero; if (flag3) { _lastMegaTooltipPosition = localPosition; _lastMegaTooltipSize = size; } if (flag3) { SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] === Position Update (pos changed: {flag}, size changed: {flag2}) ==="); SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] MegaTooltip LocalPos: {localPosition}"); SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] MegaTooltip Parent Rect: {_megaTooltipRect.rect}"); SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] MegaTooltip Content Size: {size}"); SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] MegaTooltip Content Rect: {_megaTooltipContentRect.rect}"); SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] MegaTooltip Content LocalPos: {((Transform)_megaTooltipContentRect).localPosition}"); } Vector3 localPosition2 = ((Transform)_megaTooltipContentRect).localPosition; float x = localPosition.x; float num = localPosition.y + localPosition2.y; rect = _rectTransform.rect; float width = ((Rect)(ref rect)).width; rect = _rectTransform.rect; float height = ((Rect)(ref rect)).height; float num2 = width / 2f; float num3 = height / 2f; rect = _megaTooltipRect.rect; float width2 = ((Rect)(ref rect)).width; float num4 = Mathf.Abs(size.y); float num5 = width2 / 2f; float num6 = num4 / 2f; float num7 = x - num5 - num2; float num8 = num - num3; if (flag3) { SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] Parent X: {localPosition.x}, Parent Y + Content Offset: {localPosition.y} + {localPosition2.y} = {num}"); SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] Using content center: ({x}, {num})"); SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] Widget size: {width}x{height}, half: ({num2}, {num3})"); ManualLogSource logger = SmarterHaulingPlugin.Logger; rect = _megaTooltipRect.rect; logger.LogInfo((object)$"[StorageSettingWidget] Using parent WIDTH ({((Rect)(ref rect)).width}) x content HEIGHT ({size.y} -> {num4})"); SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] MegaTooltip half: ({num5}, {num6})"); SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] Target X (widget center): {x} - {num5} - {num2} = {num7}"); SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] Target Y (widget center): {num} - {num3} = {num8}"); SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] Widget top edge: {num8 + num3} (should equal content center {num})"); SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] Content spans: top={num + num6}, center={num}, bottom={num - num6}"); } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(num7, num8, 0f); bool flag4 = Vector3.Distance(val, _lastWidgetPosition) > 1f; if (flag3 || flag4) { SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] Widget current local position: {((Transform)_rectTransform).localPosition}"); SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] Widget new calculated position: {val}"); SmarterHaulingPlugin.Logger.LogInfo((object)$"[StorageSettingWidget] Position changed: {flag4}"); _lastWidgetPosition = val; } ((Transform)_rectTransform).localPosition = val; } } private void Update() { if (!_megaTooltipSearched) { FindMegaTooltip(); } if (!ModuleHost.Opened) { if ((Object)(object)cg != (Object)null && cg.alpha > 0f) { SmarterHaulingPlugin.Logger.LogInfo((object)"[StorageSettingWidget] Hiding widget because ModuleHost.Opened = false"); Hide(); } return; } CondOwner selected = GUIMegaToolTip.Selected; if ((Object)(object)selected != (Object)(object)_lastShownCondOwner) { if ((Object)(object)cg != (Object)null && cg.alpha > 0f) { SmarterHaulingPlugin.Logger.LogInfo((object)("[StorageSettingWidget] Hiding widget because selection changed from " + _lastShownCondOwner?.strName + " to " + selected?.strName)); Hide(); } } else if (!((Object)(object)cg == (Object)null) && !(cg.alpha <= 0f)) { UpdatePosition(); } } private Sprite GetItemIconSprite(string itemId) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(itemId)) { return null; } try { string text = null; if (DataHandler.dictCOOverlays.TryGetValue(itemId, out var value) && !string.IsNullOrEmpty(value.strPortraitImg)) { text = value.strPortraitImg; } else { JsonCondOwner condOwnerDef = DataHandler.GetCondOwnerDef(itemId); if (condOwnerDef != null && !string.IsNullOrEmpty(condOwnerDef.strPortraitImg)) { text = condOwnerDef.strPortraitImg; } } if (string.IsNullOrEmpty(text)) { return null; } Texture2D val = DataHandler.LoadPNG(text + ".png", false, false); if ((Object)(object)val == (Object)null) { return null; } return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } catch (Exception ex) { SmarterHaulingPlugin.Logger.LogWarning((object)("[GetItemIconSprite] Failed to get icon for item '" + itemId + "': " + ex.Message)); return null; } } private StoragePrefListItem CreateStoragePrefListItem(Transform parent, ItemCategory category, float margin) { //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown bool flag = HasAnyItems(category); SmarterHaulingPlugin.Logger.LogDebug((object)$"[CreateCategoryWidget] Category '{category.DisplayName}' has children: {flag} (subcats: {category.Subcategories?.Count ?? 0}, items: {category.Items?.Count ?? 0})"); StoragePrefListItem widget = StoragePrefListItem.Create(parent, category.DisplayName, margin, flag); _storagePrefListItems.Add(widget); widget.CategoryIds = new string[1] { ItemHintId.op_Implicit(category.Id) }; if ((Object)(object)_coTarget != (Object)null) { ContainerStoragePrefs prefsById = ContainerExtensions.GetPrefsById(_coTarget.strID); StoragePrefListItem.StoragePrefStatus toggleStatus = CalculateToggleStatus(prefsById, widget.CategoryIds); widget.SetToggleStatus(toggleStatus); } if (flag) { widget.SetExpansionClickHandler((UnityAction)delegate { ToggleCategoryExpansion(widget, category, margin); }); } widget.SetActionClickHandler((UnityAction)delegate { SmarterHaulingPlugin.Logger.LogInfo((object)("[CreateStoragePrefListItem] Action clicked for category: " + category.DisplayName + ", CategoryIds: [" + string.Join(", ", widget.CategoryIds) + "]")); HandleCategoryToggle(widget); }); return widget; } private bool HasAnyItems(ItemCategory category) { if (category.Items != null && category.Items.Count > 0) { return true; } if (category.Predicates != null && category.Predicates.Count > 0) { return true; } if (category.Subcategories != null) { foreach (ItemCategory subcategory in category.Subcategories) { if (HasAnyItems(subcategory)) { return true; } } } return false; } private void CollapseChildrenRecursive(StoragePrefListItem widget) { if ((Object)(object)widget == (Object)null) { return; } List<GameObject> list = new List<GameObject>(); foreach (GameObject childWidget in widget.GetChildWidgets()) { list.Add(childWidget); } foreach (GameObject item in list) { if (!((Object)(object)item == (Object)null)) { StoragePrefListItem component = item.GetComponent<StoragePrefListItem>(); if ((Object)(object)component != (Object)null && component.IsExpanded()) { CollapseChildrenRecursive(component); component.SetExpanded(expanded: false); } } } widget.ClearChildren(); } private void ToggleCategoryExpansion(StoragePrefListItem widget, ItemCategory category, float margin) { if (widget.IsExpanded()) { CollapseChildrenRecursive(widget); widget.SetExpanded(expanded: false); return; } float margin2 = margin + 8f; int num = ((Component)widget).transform.GetSiblingIndex() + 1; if (category.Subcategories != null) { foreach (ItemCategory subcategory in category.Subcategories) { if (!HasAnyItems(subcategory)) { SmarterHaulingPlugin.Logger.LogDebug((object)("[ToggleCategoryExpansion] Skipping empty subcategory '" + subcategory.DisplayName + "'")); continue; } StoragePrefListItem storagePrefListItem = CreateStoragePrefListItem(((Component)widget).transform.parent, subcategory, margin2); ((Component)storagePrefListItem).transform.SetSiblingIndex(num); num++; widget.AddChildWidget(((Component)storagePrefListItem).gameObject); } } if (category.Items != null) { foreach (ItemHintId item in category.Items) { string itemDisplayName = GetItemDisplayName(item.Id); string[] alternativeIds = item.AlternativeIds; int num2 = 1 + ((alternativeIds != null) ? alternativeIds.Length : 0); SmarterHaulingPlugin.Logger.LogDebug((object)$"[ToggleCategoryExpansion] Displaying '{itemDisplayName}' (represents {num2} item variant(s))"); GameObject val = CreateItemWidget(((Component)widget).transform.parent, itemDisplayName, item, margin2); val.transform.SetSiblingIndex(num); num++; widget.AddChildWidget(val); } } widget.SetExpanded(expanded: true); } private GameObject CreateItemWidget(Transform parent, string displayName, ItemHintId itemHintId, float margin) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown Sprite itemIconSprite = GetItemIconSprite(itemHintId.Id); StoragePrefListItem widget = StoragePrefListItem.Create(parent, displayName, margin, hasChildren: false, itemIconSprite); _storagePrefListItems.Add(widget); widget.CategoryIds = new string[1] { itemHintId.Id }; if ((Object)(object)_coTarget != (Object)null) { ContainerStoragePrefs prefsById = ContainerExtensions.GetPrefsById(_coTarget.strID); StoragePrefListItem.StoragePrefStatus toggleStatus = CalculateToggleStatus(prefsById, widget.CategoryIds); widget.SetToggleStatus(toggleStatus); } widget.SetActionClickHandler((UnityAction)delegate { SmarterHaulingPlugin.Logger.LogInfo((object)("[CreateItemWidget] Action clicked for item: " + displayName + ", CategoryIds: [" + string.Join(", ", widget.CategoryIds) + "]")); HandleCategoryToggle(widget); }); return ((Component)widget).gameObject; } private string GetItemDisplayName(string itemId) { string cOFriendlyName = DataHandler.GetCOFriendlyName(itemId); if (!string.IsNullOrEmpty(cOFriendlyName) && cOFriendlyName != itemId) { return cOFriendlyName; } string cOShortName = DataHandler.GetCOShortName(itemId); if (!string.IsNullOrEmpty(cOShortName) && cOShortName != itemId) { return cOShortName; } if (DataHandler.dictCOs != null && DataHandler.dictCOs.ContainsKey(itemId)) { JsonCondOwner val = DataHandler.dictCOs[itemId]; if (!string.IsNullOrEmpty(val.strNameFriendly)) { return val.strNameFriendly; } if (!string.IsNullOrEmpty(val.strName)) { return val.strName; } } return itemId; } private string[] GetCategoryIdsArray(List<ItemHintId> categories) { if (categories == null || categories.Count == 0) { return new string[0]; } string[] array = new string[categories.Count]; for (int i = 0; i < categories.Count; i++) { array[i] = categories[i].Id; } return array; } private bool IsIdInAllowedCategories(List<ItemHintId> categories, string id) { if (categories == null || string.IsNullOrEmpty(id)) { return false; } for (int i = 0; i < categories.Count; i++) { if (categories[i].Id == id) { return true; } } return false; } private void HandleCategoryToggle(StoragePrefListItem widget) { if ((Object)(object)widget == (Object)null || widget.CategoryIds == null || widget.CategoryIds.Length == 0) { return; } if ((Object)(object)_coTarget == (Object)null) { SmarterHaulingPlugin.Logger.LogWarning((object)"[HandleCategoryToggle] No target CondOwner"); return; } ContainerStoragePrefs orCreatePrefs = ContainerExtensions.GetOrCreatePrefs(_coTarget.strID); if (orCreatePrefs == null) { SmarterHaulingPlugin.Logger.LogWarning((object)"[HandleCategoryToggle] Failed to get or create preferences"); return; } SmarterHaulingPlugin.Logger.LogInfo((object)"[HandleCategoryToggle] ===== Category Toggle Started ====="); SmarterHaulingPlugin.Logger.LogInfo((object)("[HandleCategoryToggle] Container: " + _coTarget.strID)); SmarterHaulingPlugin.Logger.LogInfo((object)("[HandleCategoryToggle] Widget CategoryIds: [" + string.Join(", ", widget.CategoryIds) + "]")); SmarterHaulingPlugin.Logger.LogInfo((object)$"[HandleCategoryToggle] Current Status: {widget.ToggleStatus}"); SmarterHaulingPlugin.Logger.LogInfo((object)string.Format("[HandleCategoryToggle] Prefs BEFORE: [{0}] (Count: {1})", string.Join(", ", GetCategoryIdsArray(orCreatePrefs.AllowedCategories)), orCreatePrefs.AllowedCategories.Count)); string text = widget.CategoryIds[0]; LaunchControl instance = LaunchControl.Instance; object obj; if (instance == null) { obj = null; } else { ItemManager items = instance.Items; if (items == null) { obj = null; } else { ItemCategoryManager categories = items.Categories; obj = ((categories != null) ? categories.GetCategory(text) : null); } } bool flag = obj != null; SmarterHaulingPlugin.Logger.LogInfo((object)("[HandleCategoryToggle] Widget type: " + (flag ? "Category" : "Item"))); switch (widget.ToggleStatus) { case StoragePrefListItem.StoragePrefStatus.All: { SmarterHaulingPlugin.Logger.LogInfo((object)("[HandleCategoryToggle] Action: REMOVING " + (flag ? "category and children" : "item"))); if (flag) { RemoveCategoriesRecursive(orCreatePrefs, widget.CategoryIds); break; } string[] categoryIds = widget.CategoryIds; foreach (string itemId2 in categoryIds) { orCreatePrefs.RemoveItem(itemId2); } break; } case StoragePrefListItem.StoragePrefStatus.Some: case StoragePrefListItem.StoragePrefStatus.None: { SmarterHaulingPlugin.Logger.LogInfo((object)string.Format("[HandleCategoryToggle] Action: ADDING {0} (was {1})", flag ? "category and children" : "item", widget.ToggleStatus)); if (flag) { AddCategoriesRecursive(orCreatePrefs, widget.CategoryIds); break; } string[] categoryIds = widget.CategoryIds; foreach (string itemId in categoryIds) { orCreatePrefs.AddItem(itemId); } break; } } SmarterHaulingPlugin.Logger.LogInfo((object)string.Format("[HandleCategoryToggle] Prefs AFTER: [{0}] (Count: {1})", string.Join(", ", GetCategoryIdsArray(orCreatePrefs.AllowedCategories)), orCreatePrefs.AllowedCategories.Count)); SmarterHaulingPlugin.Logger.LogInfo((object)"[HandleCategoryToggle] ===== Category Toggle Complete ====="); RefreshAllToggleStatuses(); if (OnPreferencesChanged != null) { OnPreferencesChanged(_coTarget.strID); } } private void AddCategoriesRecursive(ContainerStoragePrefs prefs, string[] categoryIds) { if (prefs == null || categoryIds == null) { return; } foreach (string text in categoryIds) { SmarterHaulingPlugin.Logger.LogDebug((object)("[AddCategoriesRecursive] Adding category: " + text)); prefs.AddCategory(text); LaunchControl instance = LaunchControl.Instance; object obj; if (instance == null) { obj = null; } else { ItemManager items = instance.Items; if (items == null) { obj = null; } else { ItemCategoryManager categories = items.Categories; obj = ((categories != null) ? categories.GetCategory(text) : null); } } ItemCategory val = (ItemCategory)obj; if (val == null) { continue; } if (val.Items != null && val.Items.Count > 0) { SmarterHaulingPlugin.Logger.LogDebug((object)$"[AddCategoriesRecursive] Category {text} has {val.Items.Count} items"); foreach (ItemHintId item in val.Items) { SmarterHaulingPlugin.Logger.LogDebug((object)("[AddCategoriesRecursive] Adding item: " + item.Id)); prefs.AddItem(item); } } if (val.Subcategories == null || val.Subcategories.Count <= 0) { continue; } SmarterHaulingPlugin.Logger.LogDebug((object)$"[AddCategoriesRecursive] Category {text} has {val.Subcategories.Count} subcategories"); foreach (ItemCategory subcategory in val.Subcategories) { AddCategoriesRecursive(prefs, new string[1] { ItemHintId.op_Implicit(subcategory.Id) }); } } } private void RemoveCategoriesRecursive(ContainerStoragePrefs prefs, string[] categoryIds) { if (prefs == null || categoryIds == null) { return; } foreach (string text in categoryIds) { SmarterHaulingPlugin.Logger.LogDebug((object)("[RemoveCategoriesRecursive] Removing category: " + text)); prefs.RemoveCategory(text); LaunchControl instance = LaunchControl.Instance; object obj; if (instance == null) { obj = null; } else { ItemManager items = instance.Items; if (items == null) { obj = null; } else { ItemCategoryManager categories = items.Categories; obj = ((categories != null) ? categories.GetCategory(text) : null); } } ItemCategory val = (ItemCategory)obj; if (val == null) { continue; } if (val.Items != null && val.Items.Count > 0) { SmarterHaulingPlugin.Logger.LogDebug((object)$"[RemoveCategoriesRecursive] Category {text} has {val.Items.Count} items"); foreach (ItemHintId item in val.Items) { SmarterHaulingPlugin.Logger.LogDebug((object)("[RemoveCategoriesRecursive] Removing item: " + item.Id)); prefs.RemoveItem(item.Id); } } if (val.Subcategories == null || val.Subcategories.Count <= 0) { continue; } SmarterHaulingPlugin.Logger.LogDebug((object)$"[RemoveCategoriesRecursive] Category {text} has {val.Subcategories.Count} subcategories"); foreach (ItemCategory subcategory in val.Subcategories) { RemoveCategoriesRecursive(prefs, new string[1] { ItemHintId.op_Implicit(subcategory.Id) }); } } } private void RefreshAllToggleStatuses() { if ((Object)(object)_coTarget == (Object)null) { return; } SmarterHaulingPlugin.Logger.LogInfo((object)"[RefreshAllToggleStatuses] ===== Refresh Started ====="); SmarterHaulingPlugin.Logger.LogInfo((object)("[RefreshAllToggleStatuses] Container: " + _coTarget.strID)); SmarterHaulingPlugin.Logger.LogInfo((object)$"[RefreshAllToggleStatuses] Total widgets: {_storagePrefListItems.Count}"); ContainerStoragePrefs prefsById = ContainerExtensions.GetPrefsById(_coTarget.strID); if (prefsById != null) { SmarterHaulingPlugin.Logger.LogInfo((object)string.Format("[RefreshAllToggleStatuses] Current Prefs: [{0}] (Count: {1})", string.Join(", ", GetCategoryIdsArray(prefsById.AllowedCategories)), prefsById.AllowedCategories.Count)); } else { SmarterHaulingPlugin.Logger.LogInfo((object)"[RefreshAllToggleStatuses] No prefs found (whitelist is empty)"); } int num = 0; foreach (StoragePrefListItem storagePrefListItem in _storagePrefListItems) { if (!((Object)(object)storagePrefListItem == (Object)null) && storagePrefListItem.CategoryIds != null && storagePrefListItem.CategoryIds.Length != 0) { StoragePrefListItem.StoragePrefStatus toggleStatus = storagePrefListItem.ToggleStatus; StoragePrefListItem.StoragePrefStatus storagePrefStatus = CalculateToggleStatus(prefsById, storagePrefListItem.CategoryIds); storagePrefListItem.SetToggleStatus(storagePrefStatus); num++; if (toggleStatus != storagePrefStatus) { SmarterHaulingPlugin.Logger.LogDebug((object)string.Format("[RefreshAllToggleStatuses] Widget [{0}]: {1} -> {2}", string.Join(", ", storagePrefListItem.CategoryIds), toggleStatus, storagePrefStatus)); } } } SmarterHaulingPlugin.Logger.LogInfo((object)$"[RefreshAllToggleStatuses] Updated {num} widgets"); SmarterHaulingPlugin.Logger.LogInfo((object)"[RefreshAllToggleStatuses] ===== Refresh Complete ====="); } private StoragePrefListItem.StoragePrefStatus CalculateToggleStatus(ContainerStoragePrefs prefs, string[] categoryIds) { if (prefs == null || categoryIds == null || categoryIds.Length == 0) { return StoragePrefListItem.StoragePrefStatus.None; } HashSet<string> hashSet = new HashSet<string>(); GetAllCategoryIdsRecursive(categoryIds, hashSet); if (hashSet.Count == 0) { return StoragePrefListItem.StoragePrefStatus.None; } int num = 0; foreach (string item in hashSet) { if (IsIdInAllowedCategories(prefs.AllowedCategories, item)) { num++; } } StoragePrefListItem.StoragePrefStatus storagePrefStatus = ((num == 0) ? StoragePrefListItem.StoragePrefStatus.None : ((num != hashSet.Count) ? StoragePrefListItem.StoragePrefStatus.Some : StoragePrefListItem.StoragePrefStatus.All)); SmarterHaulingPlugin.Logger.LogDebug((object)string.Format("[CalculateToggleStatus] Categories: [{0}] -> AllCategories: {1}, Enabled: {2}, Status: {3}", string.Join(", ", categoryIds), hashSet.Count, num, storagePrefStatus)); return storagePrefStatus; } private void GetAllCategoryIdsRecursive(string[] categoryIds, HashSet<string> result) { if (categoryIds == null || result == null) { return; } foreach (string text in categoryIds) { result.Add(text); LaunchControl instance = LaunchControl.Instance; object obj; if (instance == null) { obj = null; } else { ItemManager items = instance.Items; if (items == null) { obj = null; } else { ItemCategoryManager categories = items.Categories; obj = ((categories != null) ? categories.GetCategory(text) : null); } } ItemCategory val = (ItemCategory)obj; if (val == null) { continue; } if (val.Items != null) { foreach (ItemHintId item2 in val.Items) { result.Add(item2.Id); if (item2.AlternativeIds != null) { string[] alternativeIds = item2.AlternativeIds; foreach (string item in alternativeIds) { result.Add(item); } } } } if (val.Subcategories == null) { continue; } foreach (ItemCategory subcategory in val.Subcategories) { GetAllCategoryIdsRecursive(new string[1] { ItemHintId.op_Implicit(subcategory.Id) }, result); } } } } } namespace Ostranauts.Bit.SmarterHauling.Pledges { public class PledgeEVAMaintenance : Pledge2 { private sealed class BatteryCandidate { public CondOwner Charger { get; } public CondOwner Battery { get; } public BatteryCandidate(CondOwner charger, CondOwner battery) { Charger = charger; Battery = battery; } } private const double NORMAL_THRESHOLD = 0.25; private const double EMERGENCY_THRESHOLD = 0.05; private const double REPLACEMENT_MIN_THRESHOLD = 0.5; private const double COOLDOWN_TIME = 30.0; private CondTrigger _ctEVAOn; private CondTrigger _ctEVABattery; private CondTrigger _ctEVABottle; private bool _batteryEmergency; private bool _o2Emergency; private double _lastCheckTime = -1000.0; private CondTrigger CtEVAOn { get { if (_ctEVAOn == null) { _ctEVAOn = DataHandler.GetCondTrigger("TIsEVAOn"); } return _ctEVAOn; } } private CondTrigger CtEVABattery { get { if (_ctEVABattery == null) { _ctEVABattery = DataHandler.GetCondTrigger("TIsFitContainerEVABattery"); } return _ctEVABattery; } } private CondTrigger CtEVABottle { get { if (_ctEVABottle == null) { _ctEVABottle = DataHandler.GetCondTrigger("TIsFitContainerEVABottle"); } return _ctEVABottle; } } public override bool IsEmergency() { if ((Object)(object)((Pledge2)this).Us == (Object)null || ((Pledge2)this).Us.HasCond("IsAIManual")) { return false; } CheckEVALevels(out var batteryPercent, out var o2Percent); _batteryEmergency = batteryPercent > 0.0 && batteryPercent < 0.05; _o2Emergency = o2Percent > 0.0 && o2Percent < 0.05; if (!_batteryEmergency) { return _o2Emergency; } return true; } public override bool Do() { if ((Object)(object)((Pledge2)this).Us == (Object)null || ((Pledge2)this).Us.HasCond("IsAIManual")) { return false; } if (((Pledge2)this).Finished()) { return true; } if (((Pledge2)this).Us.ship == null) { return false; } if (((Pledge2)this).Us.HasCond("IsInCombat") || ((Pledge2)this).Us.GetInteractionCurrent() != null) { return false; } if (!EVAUtils.IsWearingEVASuit(((Pledge2)this).Us)) { return false; } double fEpoch = StarSystem.fEpoch; if (fEpoch - _lastCheckTime < 30.0) { return false; } _lastCheckTime = fEpoch; Debug.Log((object)("[EVAMaintenance] " + ((Pledge2)this).Us?.strNameFriendly + " - Starting EVA maintenance check")); CheckEVALevels(out var batteryPercent, out var o2Percent); Debug.Log((object)("[EVAMaintenance] " + ((Pledge2)this).Us?.strNameFriendly + " - Battery: " + ((batteryPercent >= 0.0) ? $"{batteryPercent * 100.0:F1}%" : "N/A") + ", O2: " + ((o2Percent >= 0.0) ? $"{o2Percent * 100.0:F1}%" : "N/A"))); bool num = batteryPercent > 0.0 && batteryPercent < 0.05; bool flag = o2Percent > 0.0 && o2Percent < 0.05; if (num) { if (!EVAUtils.IsInPlayerCompany(((Pledge2)this).Us)) { CheatBatteryCharge(); return true; } Debug.Log((object)("[EVAMaintenance] " + ((Pledge2)this).Us?.strNameFriendly + " - BATTERY EMERGENCY! Searching for replacement...")); BatteryCandidate batteryCandidate = FindReplacementBattery(); if (batteryCandidate != null) { Debug.Log((object)("[EVAMaintenance] " + ((Pledge2)this).Us?.strNameFriendly + " - Found replacement battery: " + batteryCandidate.Battery.strNameFriendly)); QueueBatterySwap(batteryCandidate); return true; } if (IsAtmosphereBreathable()) { Debug.Log((object)("[EVAMaintenance] " + ((Pledge2)this).Us?.strNameFriendly + " - No battery found, atmosphere breathable, removing helmet")); RemoveHelmet(); return true; } Debug.Log((object)("[EVAMaintenance] " + ((Pledge2)this).Us?.strNameFriendly + " - No battery found and atmosphere NOT breathable!")); } if (f