예제 #1
0
        public static void InvSlot_SetColor(InvSlot __instance)
        {
            // set default color
            __instance.toolbarNumText.color = new Color32(255, 237, 0, 255);

            InvItem combiner = __instance.mainGUI.targetItem ?? __instance.database.invInterface.draggedInvItem;

            if (combiner is null)
            {
                return;
            }
            InvItem combinee = __instance.curItemList[__instance.slotNumber];

            CustomItem custom = combiner.GetHook <CustomItem>();

            if (!(custom is IItemCombinable combinable))
            {
                return;
            }

            if (__instance.slotType == "Player" || __instance.slotType == "Toolbar" || __instance.slotType == "Chest" || __instance.slotType == "NPCChest")
            {
                if (combinee.invItemName != null && combiner.itemType == ItemTypes.Combine)
                {
                    if (combiner.CombineItems(combinee, __instance.slotNumber, string.Empty, __instance.agent) && __instance.slotType != "NPCChest")
                    {
                        __instance.myImage.color   = new Color32(0, __instance.br, __instance.br, __instance.standardAlpha);
                        __instance.itemImage.color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
                        __instance.myImage.sprite  = __instance.invBoxCanUse;
                    }
                    else if ((__instance.slotType != "Toolbar" || __instance.mainGUI.openedInventory) && __instance.slotType != "NPCChest")
                    {
                        __instance.myImage.color   = new Color32(__instance.br, 0, __instance.br, __instance.standardAlpha);
                        __instance.itemImage.color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, __instance.fadedItemAlpha);
                        __instance.myImage.sprite  = __instance.invBoxNormal;
                        __instance.toolbarNumTextGo.SetActive(false);
                    }

                    if (__instance.slotType != "NPCChest" && __instance.slotType != "Chest")
                    {
                        CustomTooltip tooltip = combinable.CombineTooltip(combinee);
                        __instance.toolbarNumTextGo.SetActive(true);
                        __instance.toolbarNumText.text  = tooltip.Text ?? string.Empty;
                        __instance.toolbarNumText.color = tooltip.Color ?? new Color32(255, 237, 0, 255);
                    }
                }
                else if (__instance.slotType != "NPCChest" && (combinee.invItemName != null || combiner.itemType != ItemTypes.Combine))
                {
                    __instance.myImage.color = __instance.overSlot
                                                ? (Color) new Color32(0, __instance.br, __instance.br, __instance.standardAlpha)
                                                : (Color) new Color32(__instance.br, __instance.br, __instance.br, __instance.standardAlpha);

                    __instance.itemImage.color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
                    __instance.myImage.sprite  = __instance.invBoxNormal;
                    if (__instance.slotType == "Toolbar")
                    {
                        __instance.toolbarNumTextGo.SetActive(false);
                    }
                }
                if (__instance.mainGUI.curSelected == __instance.mySelectable && __instance.agent.controllerType != "Keyboard")
                {
                    __instance.invInterface.OnSelectionBox(__instance.slotType, __instance.tr.position);
                }
            }
        }
예제 #2
0
        protected static void InvSlot_SetColor(InvSlot __instance, Text ___itemText)
        {
            __instance.toolbarNumTextGo.SetActive(false);
            InvItem targetItem = __instance.mainGUI.targetItem ?? __instance.database.invInterface.draggedInvItem;

            if (targetItem == null)
            {
                return;
            }
            InvItem thisItem = __instance.curItemList[__instance.slotNumber];

            CustomItem cItem = RogueLibs.Instance.Items.Find(i => i.Id == targetItem.invItemName);

            if (cItem?.CombineTooltip == null)
            {
                return;
            }

            if (targetItem != null && (__instance.slotType == "Player" || __instance.slotType == "Toolbar" || __instance.slotType == "Chest" || __instance.slotType == "NPCChest"))
            {
                if (thisItem.invItemName != null && targetItem.itemType == "Combine")
                {
                    if (targetItem.CombineItems(thisItem, __instance.slotNumber, string.Empty, __instance.agent) && __instance.slotType != "NPCChest")
                    {
                        __instance.myImage.color   = new Color32(0, __instance.br, __instance.br, __instance.standardAlpha);
                        __instance.itemImage.color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
                        __instance.myImage.sprite  = __instance.invBoxCanUse;

                        if (__instance.slotType != "NPCChest" && __instance.slotType != "Chest")
                        {
                            string result = cItem.CombineTooltip(targetItem, targetItem.agent, thisItem) ?? string.Empty;
                            __instance.toolbarNumTextGo.SetActive(result != string.Empty);
                            __instance.toolbarNumText.text = result;
                        }
                    }
                    else if ((!(__instance.slotType == "Toolbar") || __instance.mainGUI.openedInventory) && __instance.slotType != "NPCChest")
                    {
                        __instance.myImage.color   = new Color32(__instance.br, 0, __instance.br, __instance.standardAlpha);
                        __instance.itemImage.color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, __instance.fadedItemAlpha);
                        __instance.myImage.sprite  = __instance.invBoxNormal;
                        ___itemText.color          = __instance.whiteTransparent;
                        __instance.toolbarNumTextGo.SetActive(false);
                    }
                }
                else if (__instance.slotType != "NPCChest" && (thisItem.invItemName != null || targetItem.itemType != "Combine"))
                {
                    __instance.myImage.color = __instance.overSlot
                                                ? (Color) new Color32(0, __instance.br, __instance.br, __instance.standardAlpha)
                                                : (Color) new Color32(__instance.br, __instance.br, __instance.br, __instance.standardAlpha);

                    __instance.itemImage.color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
                    __instance.myImage.sprite  = __instance.invBoxNormal;
                    if (__instance.slotType == "Toolbar")
                    {
                        __instance.toolbarNumTextGo.SetActive(false);
                    }
                }
                if (__instance.mainGUI.curSelected == __instance.mySelectable && __instance.agent.controllerType != "Keyboard")
                {
                    __instance.invInterface.OnSelectionBox(__instance.slotType, __instance.tr.position);
                }
            }
        }