internal static void FinishingConnectingToPda(uGUI_Equipment uGUI_Equipment) { equipmentUI = uGUI_Equipment; if (upgradeModules != null && equipmentUI != null && upgradeModules == uGUI_Equipment.equipment) { QuickLogger.Debug("PdaOverlayManager continued connecting upgrade console to PDA overlay"); ConnectToInventory(uGUI_Equipment); ActiveOverlays.UpdateText(); } else { QuickLogger.Debug("PdaOverlayManager failed to connect upgrade console to PDA overlay"); if (upgradeModules == null) { QuickLogger.Debug("upgradeModules null"); } if (uGUI_Equipment == null) { QuickLogger.Debug("uGUI_Equipment null"); } DisconnectFromPda(); } }
internal static void DisconnectFromPda() { QuickLogger.Debug("PdaOverlayManager disconnecting from PDA overlay"); ActiveOverlays.Deactivate(); upgradeModules = null; equipmentUI = null; }
public void Awake() { Instance = this; ALLSLOTS_Text.Clear(); uGUI_Equipment uGUIequipment = gameObject.GetComponent <uGUI_Equipment>(); Dictionary <string, uGUI_EquipmentSlot> ALLSLOTS = (Dictionary <string, uGUI_EquipmentSlot>)uGUIequipment.GetPrivateField("allSlots"); BZLogger.Debug("uGUI_SlotTextHandler processing ALLSLOTS..."); foreach (KeyValuePair <string, uGUI_EquipmentSlot> item in ALLSLOTS) { BZLogger.Debug($"slot name: {item.Key}"); if (SlotHelper.ALLSLOTS.TryGetValue(item.Key, out SlotData slotData)) { TextMeshProUGUI TMProText = AddTextToSlot(item.Value.transform, slotData); ALLSLOTS_Text.Add(slotData.SlotID, TMProText); } } BZLogger.Log("uGUI_SlotTextHandler added."); }
public static void Postfix(ref uGUI_Equipment __instance) { if (Main.uGUI_PostfixComplete) { return; } __instance.gameObject.EnsureComponent <uGUI_SlotTextHandler>(); Main.uGUI_PostfixComplete = true; }
internal static bool PreCanSwitchOrSwap(uGUI_Equipment __instance, ref ItemAction __result, string slotB) { //Log.LogDebug($"uGUI_EquipmentPatches.PreCanSwitchOrSwap(): __result = {__result.ToString()}, slotB = {slotB}"); if (!ItemDragManager.isDragging) { return(true); } InventoryItem draggedItem = ItemDragManager.draggedItem; if (draggedItem == null) { return(true); } Pickupable item = draggedItem.item; if (item == null) { return(true); } TechType techType = item.GetTechType(); if (InventoryPatches.IsChip(techType)) { if (Equipment.GetSlotType(slotB) == EquipmentType.BatteryCharger) { Equipment equipmentValue = __instance.equipment; InventoryItem itemInSlot = equipmentValue.GetItemInSlot(slotB); if (itemInSlot == null) { #if DEBUG Logger.Log("DEBUG: CanSwitchOrSwap returns SWITCH battery for " + techType.AsString(false)); #endif __result = ItemAction.Switch; return(false); } if (Inventory.CanSwap(draggedItem, itemInSlot)) { #if DEBUG Logger.Log("DEBUG: CanSwitchOrSwap returns SWAP battery for " + techType.AsString(false)); #endif __result = ItemAction.Swap; return(false); } #if DEBUG Logger.Log("DEBUG: CanSwitchOrSwap returns NONE battery for " + techType.AsString(false)); #endif __result = ItemAction.None; return(false); } } return(true); }
private static void ConnectToInventory(uGUI_Equipment equipmentUI) { foreach (KeyValuePair <InventoryItem, uGUI_EquipmentSlot> pair in equipmentUI.items) { InventoryItem item = pair.Key; if (OverlayCreators.TryGetValue(item.item.GetTechType(), out CreateIconOverlay creator)) { uGUI_ItemIcon icon = pair.Value.icon; ActiveOverlays.Add(creator.Invoke(icon, item)); } } }
internal void Add_uGUIslots(uGUI_Equipment instance, Dictionary <string, uGUI_EquipmentSlot> allSlots) { if (!_isPatched) { foreach (uGUI_EquipmentSlot slot in instance.GetComponentsInChildren <uGUI_EquipmentSlot>(true)) { if (slot.name == "PowerCellCharger1") { foreach (string slotID in Configuration.Configuration.SlotIDs) { _tempSlot = Instantiate(slot, slot.transform.parent); _tempSlot.name = slotID; _tempSlot.slot = slotID; allSlots.Add(slotID, _tempSlot); } break; } } foreach (KeyValuePair <string, uGUI_EquipmentSlot> item in allSlots) { try { if (item.Value.name.StartsWith("SC")) { int.TryParse(item.Key.Substring(9), out int slotNum); switch (slotNum) { case 1: item.Value.rectTransform.anchoredPosition = slotPos[5]; break; } } } catch { QuickLogger.Error($"Add text to slot error!"); } } QuickLogger.Debug("uGUI_EquipmentSlots Patched!"); _isPatched = true; } }
public static void Prefix(uGUI_Equipment __instance) { int num = 0; foreach (var slot in __instance.GetComponentsInChildren <uGUI_EquipmentSlot>()) { if (SeaMoth._slotIDs.IndexOf(slot.slot) != -1) { var slotClone = UnityEngine.Object.Instantiate(slot.gameObject, slot.transform.parent).GetComponent <uGUI_EquipmentSlot>(); slotClone.transform.localPosition = slot.transform.localPosition; slotClone.transform.localRotation = slot.transform.localRotation; slotClone.slot = "SharkSlot" + (num + 1); num++; } } }
public void Awake() { Instance = this; uGUI_Equipment uGUIequipment = gameObject.GetComponent <uGUI_Equipment>(); Dictionary <string, uGUI_EquipmentSlot> ALLSLOTS = (Dictionary <string, uGUI_EquipmentSlot>)uGUIequipment.GetPrivateField("allSlots"); foreach (KeyValuePair <string, uGUI_EquipmentSlot> item in ALLSLOTS) { if (SlotHelper.ALLSLOTS.TryGetValue(item.Key, out SlotData slotData)) { Text text = AddTextToSlot(item.Value.transform, slotData); ALLSLOTS_Text.Add(slotData.SlotID, text); } } }
internal void Add_uGUIslots(uGUI_Equipment instance, Dictionary <string, uGUI_EquipmentSlot> allSlots) { if (!isPatched) { foreach (uGUI_EquipmentSlot slot in instance.GetComponentsInChildren <uGUI_EquipmentSlot>(true)) { // reposition the background image if (slot.name == "SeamothModule1") { slot.transform.Find("Seamoth").transform.localPosition = new Vector3(RightColumn, FourthRow); } // slot1 always includes the background image, therefore instantiate the slot2 to avoid duplicate background images if (slot.name == "SeamothModule2") { foreach (string slotID in SlotHelper.NewSeamothSlotIDs) { temp_slot = Instantiate(slot, slot.transform.parent); temp_slot.name = slotID; temp_slot.slot = slotID; allSlots.Add(slotID, temp_slot); } } else if (slot.name == "ExosuitModule2") { foreach (string slotID in SlotHelper.NewExosuitSlotIDs) { temp_slot = Instantiate(slot, slot.transform.parent); temp_slot.name = slotID; temp_slot.slot = slotID; allSlots.Add(slotID, temp_slot); } } } foreach (KeyValuePair <string, uGUI_EquipmentSlot> item in allSlots) { if (item.Value.name.StartsWith("SeamothModule")) { int.TryParse(item.Key.Substring(13), out int slotNum); item.Value.rectTransform.anchoredPosition = slotPos[slotNum - 1]; AddSlotNumbers(item.Value.transform, slotNum.ToString()); } if (item.Value.name.StartsWith("ExosuitModule")) { int.TryParse(item.Key.Substring(13), out int slotNum); item.Value.rectTransform.anchoredPosition = slotPos[slotNum - 1]; AddSlotNumbers(item.Value.transform, slotNum.ToString()); } if (item.Value.name == "ExosuitArmLeft") { item.Value.rectTransform.anchoredPosition = new Vector3(LeftColumn, FifthRow); } if (item.Value.name == "ExosuitArmRight") { item.Value.rectTransform.anchoredPosition = new Vector3(RightColumn, FifthRow); } } Debug.Log("[SlotExtender] uGUI_EquipmentSlots Patched!"); isPatched = true; } }
internal static void Postfix(ref uGUI_Equipment __instance) { var allSlots = (Dictionary <string, uGUI_EquipmentSlot>)__instance.GetPrivateField("allSlots", BindingFlags.SetField); Initialize_uGUI.Instance.Add_uGUIslots(__instance, allSlots); }
internal static void Prefix(uGUI_Equipment __instance) { __instance.gameObject.EnsureComponent <Initialize_uGUI>(); }
internal static void Prefix(uGUI_Equipment __instance) { if (Main.uGUI_PrefixComplete) { return; } Transform transform = __instance.gameObject.transform; void _setSlotPos(GameObject slot, Vector2 pos) { slot.GetComponent <uGUI_EquipmentSlot>().rectTransform.anchoredPosition = pos; } void _processSlot(SlotData slotData, GameObject normal, GameObject ArmLeft, GameObject ArmRight) { switch (slotData.SlotType) { case SlotType.CloneChip: _processCloneSlot(slotData, normal); break; case SlotType.OriginalNormal: case SlotType.OriginalArmLeft: case SlotType.OriginalArmRight: _processOriginalSlot(slotData); break; case SlotType.CloneNormal: _processCloneSlot(slotData, normal); break; case SlotType.CloneArmLeft: _processCloneSlot(slotData, ArmLeft); break; case SlotType.CloneArmRight: _processCloneSlot(slotData, ArmRight); break; } } void _processOriginalSlot(SlotData slotData) { GameObject originalSlot = transform.Find(slotData.SlotID).gameObject; _setSlotPos(originalSlot, slotData.SlotPos); } void _processCloneSlot(SlotData slotData, GameObject prefab) { GameObject temp_slot = Object.Instantiate(prefab, transform, false); temp_slot.name = slotData.SlotID; _setSlotPos(temp_slot, slotData.SlotPos); temp_slot.GetComponent <uGUI_EquipmentSlot>().slot = slotData.SlotID; } // initializing GameObject variables for cloning GameObject NormalModuleSlot = transform.Find("SeaTruckModule2").gameObject; GameObject ArmLeftSlot = transform.Find("ExosuitArmLeft").gameObject; GameObject ArmRightSlot = transform.Find("ExosuitArmRight").gameObject; GameObject ChipSlot = transform.Find("Chip1").gameObject; // processing player chip slots SlotHelper.NewChipSlots.ForEach(slotData => _processSlot(slotData, ChipSlot, null, null)); // processing Hoverbike slots SlotHelper.NewHoverbikeSlots.ForEach(slotData => _processSlot(slotData, NormalModuleSlot, null, null)); // repositioning Hoverbike background picture transform.Find("HoverbikeModule1/Hoverbike").localPosition = SlotHelper.HoverbikeSlotPosLayout.VehicleImgPos; // processing Exosuit slots SlotHelper.SessionExosuitSlots.ForEach(slotData => _processSlot(slotData, NormalModuleSlot, ArmLeftSlot, ArmRightSlot)); // repositioning Exosuit background picture transform.Find("ExosuitModule1/Exosuit").localPosition = SlotHelper.VehicleImgPos; // processing Seatruck slots SlotHelper.SessionSeatruckSlots.ForEach(slotData => _processSlot(slotData, NormalModuleSlot, ArmLeftSlot, ArmRightSlot)); // repositioning Seatruck background picture transform.Find("SeaTruckModule1/SeaTruck").localPosition = SlotHelper.VehicleImgPos; if (SEzConfig.isSeatruckScannerModuleExists) { GameObject original = null; for (int i = 1; i < 5; i++) { original = transform.Find($"BatteryCharger{i}").gameObject; GameObject clone = Object.Instantiate(original, transform, false); clone.name = $"ScannerModuleBattery{i}"; clone.GetComponent <uGUI_EquipmentSlot>().slot = clone.name; } } Main.uGUI_PrefixComplete = true; BZLogger.Log("uGUI_Equipment Slots Patched."); }
public static bool CanSwitchOrSwap_Prefix(uGUI_Equipment __instance, ref ItemAction __result, string slotB) { if (!ItemDragManager.isDragging) { return(true); } InventoryItem draggedItem = ItemDragManager.draggedItem; if (draggedItem == null) { return(true); } Pickupable item = draggedItem.item; if (item == null) { return(true); } TechType techType = item.GetTechType(); if (ModdedBatteriesFixer.BatteriesTechTypes().Contains(techType)) { if (Equipment.GetSlotType(slotB) == EquipmentType.BatteryCharger) { Equipment equipmentValue = equipmentField.GetValue(__instance) as Equipment; InventoryItem itemInSlot = equipmentValue.GetItemInSlot(slotB); if (itemInSlot == null) { #if DEBUG_PLACE_TOOL Logger.Log("DEBUG: CanSwitchOrSwap returns SWITCH battery for " + techType.AsString(false)); #endif __result = ItemAction.Switch; return(false); } if (Inventory.CanSwap(draggedItem, itemInSlot)) { #if DEBUG_PLACE_TOOL Logger.Log("DEBUG: CanSwitchOrSwap returns SWAP battery for " + techType.AsString(false)); #endif __result = ItemAction.Swap; return(false); } #if DEBUG_PLACE_TOOL Logger.Log("DEBUG: CanSwitchOrSwap returns NONE battery for " + techType.AsString(false)); #endif __result = ItemAction.None; return(false); } } else if (ModdedBatteriesFixer.PowercellsTechTypes().Contains(techType)) { if (Equipment.GetSlotType(slotB) == EquipmentType.PowerCellCharger) { Equipment equipmentValue = equipmentField.GetValue(__instance) as Equipment; InventoryItem itemInSlot = equipmentValue.GetItemInSlot(slotB); if (itemInSlot == null) { #if DEBUG_PLACE_TOOL Logger.Log("DEBUG: CanSwitchOrSwap returns SWITCH powercell for " + techType.AsString(false)); #endif __result = ItemAction.Switch; return(false); } if (Inventory.CanSwap(draggedItem, itemInSlot)) { #if DEBUG_PLACE_TOOL Logger.Log("DEBUG: CanSwitchOrSwap returns SWAP powercell for " + techType.AsString(false)); #endif __result = ItemAction.Swap; return(false); } #if DEBUG_PLACE_TOOL Logger.Log("DEBUG: CanSwitchOrSwap returns NONE powercell for " + techType.AsString(false)); #endif __result = ItemAction.None; return(false); } } #if DEBUG_PLACE_TOOL Logger.Log("DEBUG: CanSwitchOrSwap returns NONE for " + techType.AsString(false) + " and origin function will get called."); #endif __result = ItemAction.None; return(true); }
internal void Add_uGUIslots(uGUI_Equipment instance, Dictionary <string, uGUI_EquipmentSlot> allSlots) { if (!isPatched) { foreach (uGUI_EquipmentSlot slot in instance.GetComponentsInChildren <uGUI_EquipmentSlot>(true)) { // reposition the background image if (slot.name == "SeamothModule1") { slot.transform.Find("Seamoth").transform.localPosition = new Vector3(RightColumn, FourthRow); } // slot1 always includes the background image, therefore instantiate the slot2 to avoid duplicate background images if (slot.name == "SeamothModule2") { seamothSlotTransform = slot.transform; foreach (string slotID in SlotHelper.NewSeamothSlotIDs) { if (slotID.StartsWith("SeamothArm")) { break; } temp_slot = Instantiate(slot, slot.transform.parent); temp_slot.name = slotID; temp_slot.slot = slotID; allSlots.Add(slotID, temp_slot); } } else if (slot.name == "ExosuitModule2") { foreach (string slotID in SlotHelper.NewExosuitSlotIDs) { temp_slot = Instantiate(slot, slot.transform.parent); temp_slot.name = slotID; temp_slot.slot = slotID; allSlots.Add(slotID, temp_slot); } } else if (slot.name == "ExosuitArmLeft") { temp_slot = Instantiate(slot, seamothSlotTransform.parent); temp_slot.name = "SeamothArmLeft"; temp_slot.slot = "SeamothArmLeft"; allSlots.Add("SeamothArmLeft", temp_slot); } else if (slot.name == "ExosuitArmRight") { temp_slot = Instantiate(slot, seamothSlotTransform.parent); temp_slot.name = "SeamothArmRight"; temp_slot.slot = "SeamothArmRight"; allSlots.Add("SeamothArmRight", temp_slot); } } foreach (KeyValuePair <string, uGUI_EquipmentSlot> item in allSlots) { try { if (item.Value.name.StartsWith("SeamothModule")) { int.TryParse(item.Key.Substring(13), out int slotNum); item.Value.rectTransform.anchoredPosition = slotPos[slotNum - 1]; Text text = AddTextToSlotIcon(item.Value.transform, SEConfig.SLOTKEYS[$"Slot{slotNum}"], slotNum); Seamoth_SlotText.Add(text.gameObject.name, text); } } catch { SNLogger.Log($"[{SEConfig.PROGRAM_NAME}] Seamoth: Add text to slot error!"); } try { if (item.Value.name.StartsWith("ExosuitModule")) { int.TryParse(item.Key.Substring(13), out int slotNum); item.Value.rectTransform.anchoredPosition = slotPos[slotNum - 1]; Text text = AddTextToSlotIcon(item.Value.transform, SEConfig.SLOTKEYS[$"Slot{slotNum}"], slotNum); Exosuit_SlotText.Add(text.gameObject.name, text); } } catch { SNLogger.Log($"[{SEConfig.PROGRAM_NAME}] Exosuit: Add text to slot error!"); } if (item.Value.name == "ExosuitArmLeft") { item.Value.rectTransform.anchoredPosition = new Vector3(LeftColumn, FifthRow); } if (item.Value.name == "ExosuitArmRight") { item.Value.rectTransform.anchoredPosition = new Vector3(RightColumn, FifthRow); } if (item.Value.name == "SeamothArmLeft") { item.Value.rectTransform.anchoredPosition = new Vector3(LeftColumn, FifthRow); } if (item.Value.name == "SeamothArmRight") { item.Value.rectTransform.anchoredPosition = new Vector3(RightColumn, FifthRow); } } SNLogger.Log($"[{SEConfig.PROGRAM_NAME}] uGUI_EquipmentSlots Patched!"); isPatched = true; } }
public static bool CanSwitchOrSwap_Prefix(uGUI_Equipment __instance, ref ItemAction __result, string slotB) { if (!ItemDragManager.isDragging) { return(true); } InventoryItem draggedItem = ItemDragManager.draggedItem; if (draggedItem == null) { return(true); } Pickupable item = draggedItem.item; if (item == null) { return(true); } TechType techType = item.GetTechType(); if (techType == TechType.Battery || techType == TechType.PrecursorIonBattery) { if (Equipment.GetSlotType(slotB) == EquipmentType.BatteryCharger) { Equipment equipmentValue = equipmentField.GetValue(__instance) as Equipment; InventoryItem itemInSlot = equipmentValue.GetItemInSlot(slotB); if (itemInSlot == null) { __result = ItemAction.Switch; return(false); } if (Inventory.CanSwap(draggedItem, itemInSlot)) { __result = ItemAction.Swap; return(false); } __result = ItemAction.None; return(false); } } else if (techType == TechType.PowerCell || techType == TechType.PrecursorIonPowerCell) { if (Equipment.GetSlotType(slotB) == EquipmentType.PowerCellCharger) { Equipment equipmentValue = equipmentField.GetValue(__instance) as Equipment; InventoryItem itemInSlot = equipmentValue.GetItemInSlot(slotB); if (itemInSlot == null) { __result = ItemAction.Switch; return(false); } if (Inventory.CanSwap(draggedItem, itemInSlot)) { __result = ItemAction.Swap; return(false); } __result = ItemAction.None; return(false); } } return(true); }
public static void Prefix(uGUI_Equipment __instance) { if (Main.uGUI_PrefixComplete) { return; } Transform transform = __instance.gameObject.transform; void _setSlotPos(GameObject slot, Vector2 pos) { slot.GetComponent <uGUI_EquipmentSlot>().rectTransform.anchoredPosition = pos; } void _processSlot(SlotData slotData, GameObject normal, GameObject ArmLeft, GameObject ArmRight) { switch (slotData.SlotType) { case SlotType.CloneChip: _processCloneSlot(slotData, normal); break; case SlotType.OriginalNormal: case SlotType.OriginalArmLeft: case SlotType.OriginalArmRight: _processOriginalSlot(slotData); break; case SlotType.CloneNormal: _processCloneSlot(slotData, normal); break; case SlotType.CloneArmLeft: _processCloneSlot(slotData, ArmLeft); break; case SlotType.CloneArmRight: _processCloneSlot(slotData, ArmRight); break; } } void _processOriginalSlot(SlotData slotData) { GameObject originalSlot = transform.Find(slotData.SlotID).gameObject; _setSlotPos(originalSlot, slotData.SlotPos); } void _processCloneSlot(SlotData slotData, GameObject prefab) { GameObject temp_slot = Object.Instantiate(prefab, transform, false); temp_slot.name = slotData.SlotID; _setSlotPos(temp_slot, slotData.SlotPos); temp_slot.GetComponent <uGUI_EquipmentSlot>().slot = slotData.SlotID; } // initializing GameObject variables for cloning GameObject NormalModuleSlot = transform.Find("SeamothModule2").gameObject; GameObject ArmLeftSlot = transform.Find("ExosuitArmLeft").gameObject; GameObject ArmRightSlot = transform.Find("ExosuitArmRight").gameObject; GameObject ChipSlot = transform.Find("Chip1").gameObject; // processing player chip slots SlotHelper.NewChipSlots.ForEach(slotData => _processSlot(slotData, ChipSlot, null, null)); // processing seamoth slots SlotHelper.SessionSeamothSlots.ForEach(slotData => _processSlot(slotData, NormalModuleSlot, ArmLeftSlot, ArmRightSlot)); // repositioning Seamoth background picture transform.Find("SeamothModule1/Seamoth").localPosition = SlotHelper.VehicleImgPos; // processing exosuit slots SlotHelper.SessionExosuitSlots.ForEach(slotData => _processSlot(slotData, NormalModuleSlot, ArmLeftSlot, ArmRightSlot)); // repositioning Exosuit background picture transform.Find("ExosuitModule1/Exosuit").localPosition = SlotHelper.VehicleImgPos; Main.uGUI_PrefixComplete = true; SNLogger.Log("uGUI_Equipment Slots Patched!"); }