public static bool SetupRequirement( InventoryGui __instance, Transform elementRoot, ItemDrop item, int amount, Player player) { var icon = elementRoot.transform.Find("res_icon").GetComponent <Image>(); var nameText = elementRoot.transform.Find("res_name").GetComponent <Text>(); var amountText = elementRoot.transform.Find("res_amount").GetComponent <Text>(); var tooltip = elementRoot.GetComponent <UITooltip>(); if (item != null) { icon.gameObject.SetActive(true); nameText.gameObject.SetActive(true); amountText.gameObject.SetActive(true); if (item.m_itemData.IsMagicCraftingMaterial()) { var rarity = item.m_itemData.GetCraftingMaterialRarity(); icon.sprite = item.m_itemData.m_shared.m_icons[EpicLoot.GetRarityIconIndex(rarity)]; } else { icon.sprite = item.m_itemData.GetIcon(); } icon.color = Color.white; var bgIconTransform = icon.transform.parent.Find("bgIcon"); if (item.m_itemData.UseMagicBackground()) { if (bgIconTransform == null) { bgIconTransform = Object.Instantiate(icon, icon.transform.parent, true).transform; bgIconTransform.name = "bgIcon"; bgIconTransform.SetSiblingIndex(icon.transform.GetSiblingIndex()); } bgIconTransform.gameObject.SetActive(true); var bgIcon = bgIconTransform.GetComponent <Image>(); bgIcon.sprite = EpicLoot.GetMagicItemBgSprite(); bgIcon.color = item.m_itemData.GetRarityColor(); } else if (bgIconTransform != null) { bgIconTransform.gameObject.SetActive(false); } tooltip.m_text = Localization.instance.Localize(item.m_itemData.m_shared.m_name); nameText.text = Localization.instance.Localize(item.m_itemData.m_shared.m_name); if (amount <= 0) { InventoryGui.HideRequirement(elementRoot); return(false); } amountText.text = amount.ToString(); amountText.color = Color.white; } return(true); }
public static bool Prefix(ItemDrop.ItemData item) { if (item.IsMagicCraftingMaterial()) { var variant = EpicLoot.GetRarityIconIndex(item.GetCraftingMaterialRarity()); item.m_variant = variant; } return(true); }
public static void Postfix(Inventory __instance) { foreach (var item in __instance.m_inventory) { if (item.IsMagicCraftingMaterial()) { var rarity = item.GetCraftingMaterialRarity(); var variant = EpicLoot.GetRarityIconIndex(rarity); item.m_variant = variant; } } }
public override void DoCrafting(InventoryGui __instance, Player player) { if (SelectedRecipe >= 0 && SelectedRecipe < Recipes.Count) { var recipe = Recipes[SelectedRecipe]; var inventory = player.GetInventory(); var disenchantCount = _disenchantAllFlag ? recipe.FromItem.m_stack : 1; inventory.RemoveItem(recipe.FromItem, disenchantCount); var didntAdd = new List <KeyValuePair <ItemDrop.ItemData, int> >(); foreach (var product in recipe.Products) { var amountToAdd = product.Value * disenchantCount; var addSuccess = false; var canAdd = player.GetInventory().CanAddItem(product.Key.m_itemData, amountToAdd); if (canAdd) { var itemData = player.GetInventory().AddItem(product.Key.name, amountToAdd, 1, 0, 0, ""); addSuccess = itemData != null; if (itemData != null && itemData.IsMagicCraftingMaterial()) { itemData.m_variant = EpicLoot.GetRarityIconIndex(itemData.GetRarity()); } } if (!addSuccess) { var newItem = product.Key.m_itemData.Clone(); newItem.m_dropPrefab = ObjectDB.instance.GetItemPrefab(product.Key.GetPrefabName(product.Key.gameObject.name)); didntAdd.Add(new KeyValuePair <ItemDrop.ItemData, int>(newItem, amountToAdd)); } } __instance.UpdateCraftingPanel(); foreach (var itemNotAdded in didntAdd) { var itemDrop = ItemDrop.DropItem(itemNotAdded.Key, itemNotAdded.Value, player.transform.position + player.transform.forward + player.transform.up, player.transform.rotation); itemDrop.GetComponent <Rigidbody>().velocity = (player.transform.forward + Vector3.up) * 5f; player.Message(MessageHud.MessageType.TopLeft, $"$msg_dropped {itemDrop.m_itemData.m_shared.m_name} $mod_epicloot_sacrifice_inventoryfullexplanation", itemDrop.m_itemData.m_stack, itemDrop.m_itemData.GetIcon()); } if (player.GetCurrentCraftingStation() != null) { player.GetCurrentCraftingStation().m_craftItemDoneEffects.Create(player.transform.position, Quaternion.identity); } Game.instance.GetPlayerProfile().m_playerStats.m_crafts++; Gogan.LogEvent("Game", "Disenchanted", recipe.FromItem.m_shared.m_name, 1); } _disenchantAllFlag = false; }
public static void Postfix(ItemDrop __instance) { if (__instance.m_itemData.IsMagicCraftingMaterial()) { var particleContainer = __instance.transform.Find("Particles"); if (particleContainer != null) { particleContainer.gameObject.AddComponent <AlwaysPointUp>(); } var rarity = __instance.m_itemData.GetCraftingMaterialRarity(); var magicColor = EpicLoot.GetRarityColor(rarity); var variant = EpicLoot.GetRarityIconIndex(rarity); if (ColorUtility.TryParseHtmlString(magicColor, out var rgbaColor)) { __instance.gameObject.AddComponent <BeamColorSetter>().SetColor(rgbaColor); } __instance.m_itemData.m_variant = variant; } else if (__instance.m_itemData.IsRunestone()) { var particleContainer = __instance.transform.Find("Particles"); if (particleContainer != null) { particleContainer.gameObject.AddComponent <AlwaysPointUp>(); } var rarity = __instance.m_itemData.GetRunestoneRarity(); var magicColor = EpicLoot.GetRarityColor(rarity); if (ColorUtility.TryParseHtmlString(magicColor, out var rgbaColor)) { __instance.gameObject.AddComponent <BeamColorSetter>().SetColor(rgbaColor); } __instance.m_itemData.m_variant = 0; } }
public static bool SetupRequirement( InventoryGui __instance, Transform elementRoot, ItemDrop item, int amount, Player player, bool showOutOfMaterials, out bool haveMaterials) { haveMaterials = false; var icon = elementRoot.transform.Find("res_icon").GetComponent <Image>(); var nameText = elementRoot.transform.Find("res_name").GetComponent <Text>(); var amountText = elementRoot.transform.Find("res_amount").GetComponent <Text>(); var tooltip = elementRoot.GetComponent <UITooltip>(); if (item != null) { icon.gameObject.SetActive(true); nameText.gameObject.SetActive(true); amountText.gameObject.SetActive(true); if (item.m_itemData.IsMagicCraftingMaterial()) { var rarity = item.m_itemData.GetCraftingMaterialRarity(); icon.sprite = item.m_itemData.m_shared.m_icons[EpicLoot.GetRarityIconIndex(rarity)]; } else { icon.sprite = item.m_itemData.GetIcon(); } icon.color = Color.white; var bgIconTransform = (RectTransform)icon.transform.parent.Find("bgIcon"); if (item.m_itemData.UseMagicBackground()) { if (bgIconTransform == null) { bgIconTransform = (RectTransform)Object.Instantiate(icon, icon.transform.parent, true).transform; bgIconTransform.name = "bgIcon"; bgIconTransform.SetSiblingIndex(icon.transform.GetSiblingIndex()); bgIconTransform.anchorMin = Vector2.zero; bgIconTransform.anchorMax = new Vector2(1, 1); bgIconTransform.sizeDelta = Vector2.zero; bgIconTransform.pivot = new Vector2(0.5f, 0.5f); bgIconTransform.anchoredPosition = Vector2.zero; } bgIconTransform.gameObject.SetActive(true); var bgIcon = bgIconTransform.GetComponent <Image>(); bgIcon.sprite = EpicLoot.GetMagicItemBgSprite(); bgIcon.color = item.m_itemData.GetRarityColor(); } else if (bgIconTransform != null) { bgIconTransform.gameObject.SetActive(false); } tooltip.m_text = Localization.instance.Localize(item.m_itemData.m_shared.m_name); nameText.text = Localization.instance.Localize(item.m_itemData.m_shared.m_name); if (amount <= 0) { InventoryGui.HideRequirement(elementRoot); return(false); } amountText.text = amount.ToString(); haveMaterials = player.HaveRequirements(new [] { new Piece.Requirement() { m_resItem = item, m_amount = amount } }, false, 1); if (showOutOfMaterials && !haveMaterials) { amountText.color = Mathf.Sin(Time.time * 10.0f) > 0.0f ? Color.red : Color.white; } else { amountText.color = Color.white; } } else { var bgIconTransform = icon.transform.parent.Find("bgIcon"); if (bgIconTransform != null) { bgIconTransform.gameObject.SetActive(false); } } return(true); }