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;
            }
        }
示例#2
0
        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;
            }
        }
        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;
            }
        }