private static void AddDisenchantProducts(ItemDrop.ItemData item, DisenchantRecipe recipe, ItemRarity rarity)
        {
            var dustPrefab    = ObjectDB.instance.GetItemPrefab($"Dust{rarity}").GetComponent <ItemDrop>();
            var essencePrefab = ObjectDB.instance.GetItemPrefab($"Essence{rarity}").GetComponent <ItemDrop>();
            var reagentPrefab = ObjectDB.instance.GetItemPrefab($"Reagent{rarity}").GetComponent <ItemDrop>();
            var shardPrefab   = ObjectDB.instance.GetItemPrefab($"Shard{rarity}").GetComponent <ItemDrop>();

            switch (item.m_shared.m_itemType)
            {
            case ItemDrop.ItemData.ItemType.Trophie:
                recipe.Products.Add(new KeyValuePair <ItemDrop, int>(shardPrefab, 1));
                break;

            case ItemDrop.ItemData.ItemType.OneHandedWeapon:
            case ItemDrop.ItemData.ItemType.Bow:
            case ItemDrop.ItemData.ItemType.TwoHandedWeapon:
            case ItemDrop.ItemData.ItemType.Torch:
            case ItemDrop.ItemData.ItemType.Tool:
                recipe.Products.Add(new KeyValuePair <ItemDrop, int>(dustPrefab, 1));
                recipe.Products.Add(new KeyValuePair <ItemDrop, int>(essencePrefab, 1));
                break;

            case ItemDrop.ItemData.ItemType.Shield:
            case ItemDrop.ItemData.ItemType.Helmet:
            case ItemDrop.ItemData.ItemType.Chest:
            case ItemDrop.ItemData.ItemType.Legs:
            case ItemDrop.ItemData.ItemType.Shoulder:
            case ItemDrop.ItemData.ItemType.Utility:
                recipe.Products.Add(new KeyValuePair <ItemDrop, int>(dustPrefab, 1));
                recipe.Products.Add(new KeyValuePair <ItemDrop, int>(reagentPrefab, 1));
                break;
            }
        }
Exemple #2
0
        public void AddRecipeToList(InventoryGui __instance, DisenchantRecipe recipe, int index)
        {
            var count   = __instance.m_recipeList.Count;
            var element = Object.Instantiate(__instance.m_recipeElementPrefab, __instance.m_recipeListRoot);

            element.SetActive(true);
            element.RectTransform().anchoredPosition = new Vector2(0.0f, count * -__instance.m_recipeListSpace);

            var item = recipe.FromItem;

            var image = element.transform.Find("icon").GetComponent <Image>();

            image.sprite = item.GetIcon();
            image.color  = Color.white;

            if (item.UseMagicBackground())
            {
                var bgImage = Object.Instantiate(image, image.transform.parent, true);
                bgImage.name = "MagicItemBG";
                bgImage.transform.SetSiblingIndex(image.transform.GetSiblingIndex());
                bgImage.sprite = EpicLoot.Assets.GenericItemBgSprite;
                bgImage.color  = item.GetRarityColor();
            }

            var nameText = element.transform.Find("name").GetComponent <Text>();

            nameText.text = Localization.instance.Localize(item.GetDecoratedName());
            if (item.m_shared.m_maxStackSize > 1 && item.m_stack > 1)
            {
                nameText.text += $" x{item.m_stack}";
            }

            var durability = element.transform.Find("Durability").GetComponent <GuiBar>();

            if (item.m_shared.m_useDurability && item.m_durability < item.GetMaxDurability())
            {
                durability.gameObject.SetActive(true);
                durability.SetValue(item.GetDurabilityPercentage());
            }
            else
            {
                durability.gameObject.SetActive(false);
            }

            var quality = element.transform.Find("QualityLevel").GetComponent <Text>();

            quality.gameObject.SetActive(item.m_shared.m_maxQuality > 1);
            quality.text = item.m_quality.ToString();

            element.GetComponent <Button>().onClick.AddListener(() => OnSelectedRecipe(__instance, index));
            __instance.m_recipeList.Add(element);
        }
        private static DisenchantRecipe GenerateDisenchantRecipe(ItemDrop.ItemData item)
        {
            if (item.IsMagic())
            {
                var recipe = new DisenchantRecipe {
                    FromItem = item.Extended()
                };
                AddDisenchantProducts(item, recipe, item.GetMagicItem().Rarity);
                return(recipe);
            }

            return(null);
        }
Exemple #4
0
        public static DisenchantRecipe GenerateDisenchantRecipe(ItemDrop.ItemData item)
        {
            if (item.IsMagic())
            {
                var recipe = new DisenchantRecipe {
                    FromItem = item.Extended()
                };
                recipe.Products = GetDisenchantProducts(item, item.GetRarity());
                return(recipe);
            }

            return(null);
        }
Exemple #5
0
        public static int GetRecipeSortOrderValue(DisenchantRecipe recipe)
        {
            if (recipe.FromItem.IsMagic())
            {
                return(3);
            }

            if (recipe.FromItem.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Trophie)
            {
                return(recipe.Products.Exists(x => x.Key.m_itemData.IsRunestone()) ? 1 : 0);
            }

            return(2);
        }
Exemple #6
0
        public static DisenchantRecipe GenerateDisenchantRecipe(ItemDrop.ItemData item)
        {
            var products = GetDisenchantProducts(item);

            if (products == null)
            {
                return(null);
            }

            var recipe = new DisenchantRecipe {
                FromItem = item,
                Products = products
            };

            return(recipe);
        }
 private static DisenchantRecipe GenerateSpecialRecipe(ItemDrop.ItemData item)
 {
     if (SpecialDisenchants.TryGetValue(item.m_shared.m_name, out var entry))
     {
         var recipe = new DisenchantRecipe {
             FromItem = item
         };
         foreach (var productEntry in entry)
         {
             var prefab = ObjectDB.instance.GetItemPrefab(productEntry.Key).GetComponent <ItemDrop>();
             recipe.Products.Add(new KeyValuePair <ItemDrop, int>(prefab, productEntry.Value));
         }
         return(recipe);
     }
     return(null);
 }
 private static DisenchantRecipe GenerateBossTrophyRecipe(ItemDrop.ItemData item)
 {
     if (item.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Trophie)
     {
         if (BossTrophies.TryGetValue(item.m_shared.m_name, out var entry))
         {
             var recipe = new DisenchantRecipe {
                 FromItem = item
             };
             var prefab = ObjectDB.instance.GetItemPrefab(entry.Key).GetComponent <ItemDrop>();
             recipe.Products.Add(new KeyValuePair <ItemDrop, int>(prefab, entry.Value));
             return(recipe);
         }
     }
     return(null);
 }
        private static DisenchantRecipe GenerateTrophyRecipe(ItemDrop.ItemData item)
        {
            if (item.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Trophie)
            {
                foreach (var entry in TrophyShards)
                {
                    var rarity = entry.Key;
                    if (entry.Value.Contains(item.m_shared.m_name))
                    {
                        var recipe = new DisenchantRecipe {
                            FromItem = item.Extended()
                        };
                        AddDisenchantProducts(item, recipe, rarity);
                        return(recipe);
                    }
                }
            }

            return(null);
        }
Exemple #10
0
        public static void SetupRequirementList(InventoryGui __instance, Player player, DisenchantRecipe recipe)
        {
            var index = 0;

            foreach (var product in recipe.Products)
            {
                if (SetupRequirement(__instance, __instance.m_recipeRequirementList[index].transform, product.Key, product.Value, player, false))
                {
                    ++index;
                }
            }

            for (; index < __instance.m_recipeRequirementList.Length; ++index)
            {
                InventoryGui.HideRequirement(__instance.m_recipeRequirementList[index].transform);
            }
        }