public void UpdateNonMutationAbilityDescription(string category, ActivatedAbilityEntry ability, bool bAddCooldownOnly = false) { if (!this.Categories.ContainsKey(category)) { Debug.Log("QudUX Mod: Couldn't find any data for activated ability category '" + category + "'. Activated ability description for " + this.SimplifiedAbilityName(ability.DisplayName) + " won't be updated."); return; } List <Egcb_AbilityDataEntry> abilityData = this.Categories[category]; string deleteLines = null; string deletePhrases = null; foreach (Egcb_AbilityDataEntry abilityDataEntry in abilityData) { if (abilityDataEntry.Name == this.SimplifiedAbilityName(ability.DisplayName)) { string description = string.Empty; deleteLines = abilityDataEntry.DeleteLines; deletePhrases = abilityDataEntry.DeletePhrases; if (!string.IsNullOrEmpty(abilityDataEntry.CustomDescription)) { description = abilityDataEntry.CustomDescription; } else if (bAddCooldownOnly) { description = this.VanillaDescriptionText.ContainsKey(ability.ID) ? this.VanillaDescriptionText[ability.ID] : ability.Description; } else if (!string.IsNullOrEmpty(abilityDataEntry.SkillName)) { if (SkillFactory.Factory.PowersByClass.ContainsKey(abilityDataEntry.SkillName)) { PowerEntry skill = SkillFactory.Factory.PowersByClass[abilityDataEntry.SkillName]; description = skill.Description; } } description = description.TrimEnd('\r', '\n', ' '); if (!string.IsNullOrEmpty(description)) { if (!string.IsNullOrEmpty(abilityDataEntry.BaseCooldown)) { string adjustedCooldownString = this.GetCooldownString(abilityDataEntry.BaseCooldown); if (!string.IsNullOrEmpty(adjustedCooldownString)) { description += "\n\n" + adjustedCooldownString; } } if (!this.VanillaDescriptionText.ContainsKey(ability.ID)) { this.VanillaDescriptionText.Add(ability.ID, ability.Description); } ability.Description = description; } break; } } if (!this.VanillaDescriptionText.ContainsKey(ability.ID)) { this.VanillaDescriptionText.Add(ability.ID, ability.Description); } ability.Description = Egcb_AbilityData.SpecialFormatDescription(ability.Description, deleteLines, deletePhrases); }
public void UpdateMutationAbilityDescription(string category, ActivatedAbilityEntry ability) { if (!this.Categories.ContainsKey(category)) { Debug.Log("QudUX Mod: Couldn't find any data for activated ability category '" + category + "'. Activated ability description for " + this.SimplifiedAbilityName(ability.DisplayName) + " won't be updated."); return; } List <Egcb_AbilityDataEntry> abilityData = this.Categories[category]; foreach (Egcb_AbilityDataEntry abilityDataEntry in abilityData) { if (abilityDataEntry.Name == this.SimplifiedAbilityName(ability.DisplayName)) { //match AbilityDataEntry to the Ability name BaseMutation abilitySourceMutation = null; BaseMutation secondaryMatch = null; foreach (BaseMutation playerMutation in this.PlayerMutations) { MutationEntry mutationEntry = playerMutation.GetMutationEntry(); if (mutationEntry != null && mutationEntry.DisplayName == abilityDataEntry.MutationName) { abilitySourceMutation = playerMutation; break; } if (playerMutation.DisplayName == abilityDataEntry.MutationName) { secondaryMatch = playerMutation; //less desirable match method, but necessary for some NPC mutations that don't have a MutationEntry } } if (abilitySourceMutation == null && secondaryMatch != null) { abilitySourceMutation = secondaryMatch; } if (abilitySourceMutation == null) { Debug.Log("QudUX Mod: Unexpectedly failed to load mutation description data for '" + this.SimplifiedAbilityName(ability.DisplayName) + "' activated ability."); continue; } if (!this.VanillaDescriptionText.ContainsKey(ability.ID)) { this.VanillaDescriptionText.Add(ability.ID, ability.Description); } ability.Description = abilitySourceMutation.GetDescription() + "\n\n" + abilitySourceMutation.GetLevelText(abilitySourceMutation.Level); ability.Description = ability.Description.TrimEnd('\r', '\n', ' '); //updated Cooldown based on wisdom: if (ability.Description.Contains("Cooldown:") || !string.IsNullOrEmpty(abilityDataEntry.BaseCooldown)) { string updatedDescription = string.Empty; string extractedCooldownString = !string.IsNullOrEmpty(abilityDataEntry.BaseCooldown) ? this.GetCooldownString(abilityDataEntry.BaseCooldown) : string.Empty; string[] descriptionParts = ability.Description.Split('\n'); foreach (string descriptionPart in descriptionParts) { if (descriptionPart.Contains("Cooldown:")) { string[] words = descriptionPart.Split(' '); foreach (string word in words) { int o; if (int.TryParse(word, out o)) { extractedCooldownString = this.GetCooldownString(word); break; } } if (string.IsNullOrEmpty(extractedCooldownString)) { updatedDescription += (updatedDescription != string.Empty ? "\n" : string.Empty) + descriptionPart; //restore line in case we didn't find the number (should never happen) } } else { updatedDescription += (updatedDescription != string.Empty ? "\n" : string.Empty) + descriptionPart; } } ability.Description = updatedDescription + (!string.IsNullOrEmpty(extractedCooldownString) ? "\n\n" + extractedCooldownString : string.Empty); } ability.Description = Egcb_AbilityData.SpecialFormatDescription(ability.Description, abilityDataEntry.DeleteLines, abilityDataEntry.DeletePhrases); break; } } }