/// <summary> /// Determines what kind of ability this is and whether it needs to be handed off to another /// method in order to generate a better ability description. /// </summary> public List <string> MakeDescription(AbilityNode abilityNode) { string category = abilityNode?.Ability?.Class; ActivatedAbilityEntry ability = abilityNode?.Ability; if (ability != null && !string.IsNullOrEmpty(category)) { try { if (category == "Mental Mutation" || category == "Mutation" || category == "Physical Mutation") { return(this.MakeMutationAbilityDescription(category, ability)); } //handle other ability descriptions else { bool hasMeaningfulDescription; if (AbilityNarrator.AbilitiesWithoutRealDescriptions.Contains(ability.ID)) { hasMeaningfulDescription = false; } else { string vanillaDescription = ability.Description; string simplifiedName = SimplifiedAbilityName(ability.DisplayName); hasMeaningfulDescription = !string.IsNullOrEmpty(vanillaDescription) && ability.DisplayName != vanillaDescription && simplifiedName != vanillaDescription && !simplifiedName.StartsWith(vanillaDescription); } if (!hasMeaningfulDescription) { AbilityNarrator.AbilitiesWithoutRealDescriptions.Add(ability.ID); return(this.MakeNonMutationAbilityDescription(category, ability)); } else //already has a meaningful description. Append cooldown info to the existing description. { return(this.AddCooldownToPrexistingAbilityDescription(category, ability)); } } } catch (Exception ex) { LogUnique("(Error) Unable to update ability description for " + $"ability '{ability?.DisplayName}' [{ability?.Command}].\n Exception: {ex}"); } } try { return(SpecialFormatDescription(ability?.Description, SourceAbility: ability)); } catch (Exception ex) { LogUnique($"(Warning) Couldn't recognize ability '{ability?.DisplayName}' " + $"[{ability?.Command}], so it's description was not updated.\n Exception: {ex}"); } return(new List <string>()); }
/// <summary> /// Called from our Harmony patch. Uses the UI's AbilityNode to form a better description /// if possible, then adds that description to the TextBlock that the AbilityManager will /// write to the screen. /// </summary> public static void UpdateAbilityText(AbilityNode node, TextBlock textBlock) { if (Options.UI.ShowAbilityDescriptions) { AbilityNarrator abilityHandler = new AbilityNarrator(); List <string> computedAbilityDescription = abilityHandler.MakeDescription(node); if (computedAbilityDescription.Count > 0) { textBlock.Lines = computedAbilityDescription; textBlock._Width = -1; } } }