public void SetupRequirementList(InventoryGui __instance, Player player, AugmentRecipe recipe, bool canCraft) { var requirementStates = new[] { Auga.RequirementWireState.Absent, Auga.RequirementWireState.Absent, Auga.RequirementWireState.Absent, Auga.RequirementWireState.Absent }; var index = 0; var cost = GetRecipeCost(recipe); foreach (var product in cost) { if (SetupRequirement(__instance, __instance.m_recipeRequirementList[index].transform, product.Key, product.Value, player, true, out var haveMaterials)) { requirementStates[index] = haveMaterials ? Auga.RequirementWireState.Have : Auga.RequirementWireState.DontHave; ++index; } } for (; index < __instance.m_recipeRequirementList.Length; ++index) { InventoryGui.HideRequirement(__instance.m_recipeRequirementList[index].transform); } if (EpicLoot.HasAuga) { Auga.API.RequirementsPanel_SetWires(AugaTabData.RequirementsPanelGO, requirementStates, canCraft); } }
public static Piece.Requirement[] GetRecipeRequirementArray(AugmentRecipe recipe) { var cost = GetRecipeCost(recipe); return(cost.Select(x => new Piece.Requirement() { m_amount = x.Value, m_resItem = x.Key }).ToArray()); }
private void GenerateAugmentRecipeForItem(ItemDrop.ItemData item) { if (item.CanBeAugmented()) { var recipe = new AugmentRecipe { FromItem = item }; Recipes.Add(recipe); } }
private void GenerateAugmentSelectors(AugmentRecipe recipe, InventoryGui inventoryGui) { const float spacing = 34; var checkboxPrefab = Menu.instance.m_settingsPrefab.GetComponent <Settings>().m_invertMouse; var magicItem = recipe.FromItem.GetMagicItem(); var rarity = recipe.FromItem.GetRarity(); var startOffset = new Vector2(-330, -165); var augmentableEffects = magicItem.Effects; var effectCount = augmentableEffects.Count; for (var i = 0; i < Mathf.Max(effectCount, EffectSelectors.Count); ++i) { if (i < effectCount && i >= EffectSelectors.Count) { // create new selector var selector = Object.Instantiate(checkboxPrefab, inventoryGui.m_variantButton.transform.parent, false); selector.gameObject.name = $"EffectSelector{i}"; var rt = selector.gameObject.RectTransform(); rt.anchoredPosition = startOffset + new Vector2(0, i * -spacing); var t = selector.GetComponentInChildren <Text>(); t.font = inventoryGui.m_recipeDecription.font; t.text = MagicItem.GetEffectText(augmentableEffects[i], rarity, true); t.color = magicItem.HasBeenAugmented() && recipe.EffectIndex != i ? Color.gray : EpicLoot.GetRarityColorARGB(rarity); t.resizeTextMaxSize = 18; t.resizeTextMinSize = 10; t.rectTransform.anchoredPosition += new Vector2(300, 0); t.alignment = TextAnchor.MiddleLeft; t.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 300); t.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, spacing); var index = i; selector.onValueChanged.AddListener((selected) => OnSelectorValueChanged(index, selected)); selector.isOn = recipe.EffectIndex == i; selector.gameObject.SetActive(true); selector.interactable = !magicItem.HasBeenAugmented() || recipe.EffectIndex == i; EffectSelectors.Add(selector); } else if (i >= effectCount && i < EffectSelectors.Count) { EffectSelectors[i].gameObject.SetActive(false); } else { var selector = EffectSelectors[i]; selector.gameObject.SetActive(true); selector.isOn = recipe.EffectIndex == i; selector.interactable = !magicItem.HasBeenAugmented() || recipe.EffectIndex == i; var t = selector.GetComponentInChildren <Text>(); t.text = MagicItem.GetEffectText(augmentableEffects[i], rarity, true); t.color = magicItem.HasBeenAugmented() && recipe.EffectIndex != i ? Color.gray : EpicLoot.GetRarityColorARGB(rarity); } } }
public static List <MagicItemEffectDefinition> GetAvailableAugments(AugmentRecipe recipe, ItemDrop.ItemData item, MagicItem magicItem, ItemRarity rarity) { var valuelessEffect = false; if (recipe.EffectIndex >= 0 && recipe.EffectIndex < magicItem.Effects.Count) { var currentEffectDef = MagicItemEffectDefinitions.Get(magicItem.Effects[recipe.EffectIndex].EffectType); valuelessEffect = currentEffectDef.GetValuesForRarity(rarity) == null; } return(MagicItemEffectDefinitions.GetAvailableEffects(item.Extended(), item.GetMagicItem(), valuelessEffect ? -1 : recipe.EffectIndex)); }
public void AddRecipeToList(InventoryGui __instance, AugmentRecipe 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 canCraft = Player.m_localPlayer.HaveRequirements(recipe.GetRequirementArray(), false, 1); var item = recipe.FromItem; var image = element.transform.Find("icon").GetComponent <Image>(); image.sprite = item.GetIcon(); image.color = Color.white; 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 = EpicLoot.GetRarityColorARGB(item.GetRarity()); var nameText = element.transform.Find("name").GetComponent <Text>(); nameText.text = Localization.instance.Localize(item.GetDecoratedName()); if (item.GetMagicItem() != null && item.GetMagicItem().HasBeenAugmented()) { nameText.text += " ◇"; } nameText.color = Color.white; 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(true); quality.text = item.m_quality.ToString(); element.GetComponent <Button>().onClick.AddListener(() => OnSelectedRecipe(__instance, index)); __instance.m_recipeList.Add(element); }
private void OnAugmentComplete(AugmentRecipe recipe, MagicItemEffect newEffect) { if (recipe != null) { var magicItem = recipe.FromItem.GetMagicItem(); if (magicItem.HasEffect(MagicEffectType.Indestructible)) { recipe.FromItem.m_shared.m_useDurability = recipe.FromItem.m_dropPrefab?.GetComponent <ItemDrop>().m_itemData.m_shared.m_useDurability ?? false; if (recipe.FromItem.m_shared.m_useDurability) { recipe.FromItem.m_durability = recipe.FromItem.GetMaxDurability(); } } magicItem.ReplaceEffect(recipe.EffectIndex, newEffect); if (magicItem.Rarity == ItemRarity.Rare) { magicItem.DisplayName = MagicItemNames.GetNameForItem(recipe.FromItem, magicItem); } // Note: I do not know why I have to do this, but this is the only thing that causes this item to save correctly recipe.FromItem.Extended().RemoveComponent <MagicItemComponent>(); recipe.FromItem.Extended().AddComponent <MagicItemComponent>().SetMagicItem(magicItem); InventoryGui.instance?.UpdateCraftingPanel(); var player = Player.m_localPlayer; if (player.GetCurrentCraftingStation() != null) { player.GetCurrentCraftingStation().m_craftItemDoneEffects.Create(player.transform.position, Quaternion.identity); } OnSelectorValueChanged(recipe.EffectIndex, true); MagicItemEffects.Indestructible.MakeItemIndestructible(recipe.FromItem); Game.instance.GetPlayerProfile().m_playerStats.m_crafts++; Gogan.LogEvent("Game", "Augmented", recipe.FromItem.m_shared.m_name, 1); EquipmentEffectCache.Reset(player); } }
public void SetupRequirementList(InventoryGui __instance, Player player, AugmentRecipe recipe) { var index = 0; var cost = GetRecipeCost(recipe); foreach (var product in cost) { if (SetupRequirement(__instance, __instance.m_recipeRequirementList[index].transform, product.Key, product.Value, player, true)) { ++index; } } for (; index < __instance.m_recipeRequirementList.Length; ++index) { InventoryGui.HideRequirement(__instance.m_recipeRequirementList[index].transform); } }
private void SetSelectorValues(AugmentRecipe recipe, int i, MagicItem magicItem, ItemRarity rarity) { var selector = EffectSelectors[i]; var augmentableEffects = magicItem.Effects; if (EpicLoot.HasAuga) { selector.transform.parent.gameObject.SetActive(true); } else { selector.gameObject.SetActive(true); } selector.isOn = recipe.EffectIndex == i; var t = selector.GetComponentInChildren <Text>(); t.text = GetAugmentSelectorText(magicItem, i, augmentableEffects, rarity); t.color = EpicLoot.GetRarityColorARGB(rarity); }
private void OnAugmentComplete(AugmentRecipe recipe, MagicItemEffect newEffect) { if (recipe != null) { var magicItem = recipe.FromItem.GetMagicItem(); if (magicItem.HasBeenAugmented()) { magicItem.ReplaceEffect(magicItem.AugmentedEffectIndex, newEffect); } else { magicItem.ReplaceEffect(recipe.EffectIndex, newEffect); } if (magicItem.Rarity == ItemRarity.Rare) { magicItem.DisplayName = MagicItemNames.GetNameForItem(recipe.FromItem, magicItem); } // Note: I do not know why I have to do this, but this is the only thing that causes this item to save correctly recipe.FromItem.Extended().RemoveComponent <MagicItemComponent>(); recipe.FromItem.Extended().AddComponent <MagicItemComponent>().SetMagicItem(magicItem); InventoryGui.instance?.UpdateCraftingPanel(); var player = Player.m_localPlayer; if (player.GetCurrentCraftingStation() != null) { player.GetCurrentCraftingStation().m_craftItemDoneEffects.Create(player.transform.position, Quaternion.identity); } OnSelectorValueChanged(recipe.EffectIndex, true); Game.instance.GetPlayerProfile().m_playerStats.m_crafts++; Gogan.LogEvent("Game", "Augmented", recipe.FromItem.m_shared.m_name, 1); } }
public static List <KeyValuePair <ItemDrop, int> > GetRecipeCost(AugmentRecipe recipe) { return(GetAugmentCosts(recipe.FromItem)); }
private void GenerateAugmentSelectors(AugmentRecipe recipe, InventoryGui inventoryGui) { const float spacing = 34; var checkboxPrefab = Menu.instance.m_settingsPrefab.GetComponent <Settings>().m_invertMouse; var magicItem = recipe.FromItem.GetMagicItem(); var rarity = recipe.FromItem.GetRarity(); var startOffset = new Vector2(-330, -165); var augmentableEffects = magicItem.Effects; var effectCount = augmentableEffects.Count; if (EffectSelectors.Count == 0 && EpicLoot.HasAuga) { Auga.API.ComplexTooltip_ClearTextBoxes(AugaTabData.ItemInfoGO); } for (var i = 0; i < Mathf.Max(effectCount, EffectSelectors.Count); ++i) { if (i < effectCount && i >= EffectSelectors.Count) { Toggle selector; if (EpicLoot.HasAuga) { var checkboxTextBox = Auga.API.ComplexTooltip_AddCheckBoxTextBox(AugaTabData.ItemInfoGO); selector = checkboxTextBox.GetComponentInChildren <Toggle>(true); } else { selector = Object.Instantiate(checkboxPrefab, inventoryGui.m_variantButton.transform.parent, false); selector.gameObject.name = $"EffectSelector{i}"; var rt = selector.gameObject.RectTransform(); rt.anchoredPosition = startOffset + new Vector2(0, i * -spacing); var t = selector.GetComponentInChildren <Text>(); t.font = inventoryGui.m_recipeDecription.font; t.resizeTextMaxSize = 18; t.resizeTextMinSize = 10; t.rectTransform.anchoredPosition += new Vector2(300, 0); t.alignment = TextAnchor.MiddleLeft; t.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 300); t.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, spacing); } var index = i; selector.onValueChanged.AddListener((selected) => OnSelectorValueChanged(index, selected)); EffectSelectors.Add(selector); SetSelectorValues(recipe, i, magicItem, rarity); } else if (i >= effectCount && i < EffectSelectors.Count) { if (EpicLoot.HasAuga) { EffectSelectors[i].transform.parent.gameObject.SetActive(false); } else { EffectSelectors[i].gameObject.SetActive(false); } } else { SetSelectorValues(recipe, i, magicItem, rarity); } } }