/// <summary> /// Gets a list of all the product descriptors for a recipe. /// </summary> /// <param name="recipe">The recipe to describe.</param> /// <param name="result">The location where the products will be stored.</param> private static void GetResultDescriptions(ComplexRecipe recipe, IList <DescriptorWithSprite> result) { var results = recipe.results; int n = results.Length, nd; var text = CACHED_BUILDER; if (recipe.producedHEP > 0) { text.Clear().Append(HEP_TOOLTIP).Append(recipe.producedHEP.ToString()); string description = text.ToString(); result.Add(new DescriptorWithSprite(new Descriptor(description, description, Descriptor.DescriptorType.Requirement, false), RADBOLT_ICON)); } var desc = ListPool <Descriptor, SelectedRecipeQueueScreen> .Allocate(); for (int i = 0; i < n; i++) { var item = results[i]; var material = item.material; var prefab = Assets.GetPrefab(material); string amountText = GameUtil.GetFormattedByTag(material, item.amount), name = prefab.GetProperName(); var element = ElementLoader.GetElement(material); desc.Clear(); text.Clear().Append(RECIPE_PRODUCT).Replace("{0}", name).Replace("{1}", amountText); string description = text.ToString(); text.Clear().Append(RECIPE_TOOLTIP).Replace("{0}", name).Replace("{1}", amountText); result.Add(new DescriptorWithSprite(new Descriptor(description, text. ToString(), Descriptor.DescriptorType.Requirement), Def.GetUISprite( material, "ui"))); if (element != null) { DescriptorAllocPatches.GetMaterialDescriptors(element.attributeModifiers, desc); nd = desc.Count; for (int j = 0; j < nd; j++) { var descriptor = desc[j]; descriptor.IncreaseIndent(); result.Add(new DescriptorWithSprite(descriptor, null)); } } else { DescriptorAllocPatches.GetAllDescriptors(prefab, false, desc); nd = desc.Count; for (int j = 0; j < nd; j++) { var descriptor = desc[j]; if (descriptor.IsEffectDescriptor()) { descriptor.IncreaseIndent(); result.Add(new DescriptorWithSprite(descriptor, null)); } } } } desc.Recycle(); }
/// <summary> /// Shows or hides panels depending on the active object. /// </summary> /// <param name="target">The selected target object.</param> private void SetPanels(GameObject target) { var modifiers = lastSelection.modifiers; var descriptionContainer = sis.descriptionContainer; var id = lastSelection.identity; var attributeLabels = sis.attributeLabels; int n = attributeLabels.Count; string descText = "", flavorText = ""; var effects = DescriptorAllocPatches.GetGameObjectEffects(target, true); Klei.AI.Amounts amounts; bool hasAmounts = modifiers != null && (amounts = modifiers.amounts) != null && amounts.Count > 0, hasProcess = lastSelection.conditions != null, hasEffects = effects.Count > 0; for (int i = 0; i < n; i++) { Destroy(attributeLabels[i]); } attributeLabels.Clear(); if (hasAmounts) { sis.vitalsContainer.selectedEntity = target; if (target.TryGetComponent(out Uprootable plant) && !target.TryGetComponent( out WiltCondition _)) { hasAmounts = plant.GetPlanterStorage != null; } } vitalsActive = hasAmounts; sis.vitalsPanel.gameObject.SetActive(hasAmounts); sis.processConditionContainer.SetActive(hasProcess); if (hasProcess) { sis.RefreshProcessConditions(); } if (id != null) { descText = ""; } else if (target.TryGetComponent(out InfoDescription description)) { descText = description.description; } else if (target.TryGetComponent(out Building building)) { descText = building.Def.Effect; flavorText = building.Def.Desc; } else if (target.TryGetComponent(out Edible edible)) { descText = STRINGS.UI.GAMEOBJECTEFFECTS.CALORIES.Format(GameUtil. GetFormattedCalories(edible.FoodInfo.CaloriesPerUnit)); } else if (target.TryGetComponent(out CellSelectionObject cso)) { descText = cso.element.FullDescription(false); } else if (target.TryGetComponent(out PrimaryElement pe)) { var element = ElementLoader.FindElementByHash(pe.ElementID); descText = (element != null) ? element.FullDescription(false) : ""; } bool showInfo = id == null && (!descText.IsNullOrWhiteSpace() || !flavorText. IsNullOrWhiteSpace() || hasEffects); descriptionContainer.descriptors.gameObject.SetActive(hasEffects); if (hasEffects) { descriptionContainer.descriptors.SetDescriptors(effects); } descriptionContainer.gameObject.SetActive(showInfo); if (descText != null) { descriptionContainer.description.SetText(descText); } if (flavorText != null) { descriptionContainer.flavour.SetText(flavorText); } sis.infoPanel.gameObject.SetActive(showInfo); descriptionContainer.flavour.gameObject.SetActive(!string.IsNullOrWhiteSpace( flavorText)); storageParent.HeaderLabel.SetText((id != null) ? DETAILTABS.DETAILS. GROUPNAME_MINION_CONTENTS : DETAILTABS.DETAILS.GROUPNAME_CONTENTS); if (lastSelection.fertility == null) { sis.fertilityPanel.gameObject.SetActive(false); } sis.rocketStatusContainer.gameObject.SetActive(lastSelection. rocketInterface != null || lastSelection.rocketModule != null); }