private static MutationCategory LoadCategoryNode(XmlTextReader stream)
        {
            MutationCategory mutationCategory = new MutationCategory
            {
                Name          = stream.GetAttribute("Name"),
                DisplayName   = stream.GetAttribute("DisplayName"),
                Help          = stream.GetAttribute("Help"),
                Stat          = stream.GetAttribute("Stat"),
                Property      = stream.GetAttribute("Property"),
                ForceProperty = stream.GetAttribute("ForceProperty")
            };

            while (stream.Read())
            {
                if (stream.Name == "mutation")
                {
                    MutationEntry mutationEntry = Egcb_MutableMutations.LoadMutationNode(stream);
                    mutationEntry.Category = mutationCategory;
                    if (!mutationEntry.Prerelease || Options.GetOption("OptionEnablePrereleaseContent", string.Empty) == "Yes")
                    {
                        mutationCategory.Entries.Add(mutationEntry);
                    }
                }
                if (stream.NodeType == XmlNodeType.EndElement && (stream.Name == string.Empty || stream.Name == "category"))
                {
                    return(mutationCategory);
                }
            }
            return(mutationCategory);
        }
        private static MutationEntry LoadMutationNode(XmlTextReader stream)
        {
            MutationEntry mutationEntry = new MutationEntry
            {
                DisplayName       = stream.GetAttribute("Name"),
                Class             = stream.GetAttribute("Class"),
                Constructor       = stream.GetAttribute("Constructor"),
                Cost              = (stream.GetAttribute("Cost") != null) ? Convert.ToInt32(stream.GetAttribute("Cost")) : -999,
                Stat              = stream.GetAttribute("Stat") ?? String.Empty,
                Property          = stream.GetAttribute("Property") ?? String.Empty,
                ForceProperty     = stream.GetAttribute("ForceProperty") ?? String.Empty,
                BearerDescription = stream.GetAttribute("BearerDescription") ?? String.Empty,
                Maximum           = (stream.GetAttribute("MaxSelected") != null) ? Convert.ToInt32(stream.GetAttribute("MaxSelected")) : -999,
                MaxLevel          = (stream.GetAttribute("MaxLevel") != null) ? Convert.ToInt32(stream.GetAttribute("MaxLevel")) : -999,
                Exclusions        = stream.GetAttribute("Exclusions"),
                MutationCode      = stream.GetAttribute("Code")
            };

            if (stream.GetAttribute("Prerelease") != null)
            {
                mutationEntry.Prerelease = (stream.GetAttribute("Prerelease").ToUpper() == "TRUE");
            }
            while (stream.Read())
            {
                if (stream.NodeType == XmlNodeType.EndElement && (stream.Name == string.Empty || stream.Name == "mutation"))
                {
                    return(mutationEntry);
                }
            }
            return(mutationEntry);
        }
        public static string GetMutationCostOptionDisplayText(MutationEntry me)
        {
            string part1 = me.DisplayName.Substring(0, Math.Min(me.DisplayName.Length, 28)).PadRight(29);
            string part2 = ConsoleLib.Console.ColorUtility.StripFormatting(me.Category.DisplayName).TrimEnd('s');

            return(part1 + "&K" + part2);
        }
        public static List <string> GetCostValueArrayForMutation(MutationEntry me)
        {
            if (me.Cost == 0)
            {
                return(new List <string> {
                    " 0", " 0", " 0", " 0", " 0", " 0"
                });
            }
            else if (me.Cost == 1)
            {
                return(new List <string> {
                    "         0", " 1", " 2", " 3"
                });
            }
            else if (me.Cost == 2)
            {
                return(new List <string> {
                    "     0", " 1", " 2", " 3", " 4"
                });
            }
            else if (me.Cost == -1)
            {
                return(new List <string> {
                    "-4", "-3", "-2", "-1", " 0    "
                });
            }

            //else if (me.Cost > 0 && me.Cost <= 3)
            //{
            //    return new List<string> { " 0", " 1", " 2", " 3", " 4", " 5" };
            //}
            //else if (me.Cost < 0 && me.Cost >= -2)
            //{
            //    return new List<string> { "-5", "-4", "-3", "-2", "-1", " 0" };
            //}
            else
            {
                List <string> retVals = new List <string>(6);
                for (int i = me.Cost - 3; i <= me.Cost + 2; i++)
                {
                    int j = (me.Cost > 0) ? (i < 0 ? 0 : i) : (i > 0 ? 0 : i);
                    retVals.Add(j.ToString().PadLeft(2, ' '));
                }
                return(retVals);
            }
        }
示例#5
0
        private IEnumerable <MutationEntry> GetEntriesFor(MorphDef morph)
        {
            if (_entryLookup.TryGetValue(morph, out List <MutationEntry> lst))
            {
                return(lst);
            }
            lst = new List <MutationEntry>();
            foreach (MutationDef morphMutation in morph.AllAssociatedMutations)
            {
                var entry = new MutationEntry
                {
                    mutation  = morphMutation,
                    addChance = 0.75f,
                    blocks    = false
                };
                lst.Add(entry);
            }

            _entryLookup[morph] = lst;
            return(lst);
        }
示例#6
0
            /// <summary>
            /// Creates an ability description for a mutation. The description is constructed from the
            /// mutation description and the GetLevelText() for the mutation at its current level.
            /// Cooldown information is also appended to the description.
            /// </summary>
            /// TODO: Determine if the Level logic has changed with the new chimera rapid advancements.
            ///       For example, will level return 6 if that's my actual level, or will it return
            ///       5 if my mutation level is restricted based on my character level?
            public List <string> MakeMutationAbilityDescription(string category, ActivatedAbilityEntry ability)
            {
                if (!this.Categories.ContainsKey(category))
                {
                    LogUnique($"(FYI) Activated ability description for '{SimplifiedAbilityName(ability?.DisplayName)}'"
                              + $" won't be updated because QudUX didn't recognize it's activated ability category, '{category}'");
                    return(SpecialFormatDescription(ability?.Description, SourceAbility: ability));
                }
                List <AbilityXmlInfo> abilityData = this.Categories[category];

                foreach (AbilityXmlInfo abilityDataEntry in abilityData)
                {
                    if (abilityDataEntry.Name == 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)
                        {
                            LogUnique($"(FYI) Mutation activated ability '{SimplifiedAbilityName(ability?.DisplayName)}'"
                                      + $" in category '{category}' has no description available in game and no backup description"
                                      + " provided by QudUX, so a description won't be shown on the Manage Abilities screen.");
                            break;
                        }

                        string abilityDescription = abilitySourceMutation.GetDescription() + "\n\n" + abilitySourceMutation.GetLevelText(abilitySourceMutation.Level);
                        abilityDescription = abilityDescription.TrimEnd('\r', '\n', ' ');
                        //updated Cooldown based on wisdom:
                        if (abilityDescription.Contains("Cooldown:") || !string.IsNullOrEmpty(abilityDataEntry.BaseCooldown))
                        {
                            if (string.IsNullOrEmpty(abilityDataEntry.NoCooldownReduction) || abilityDataEntry.NoCooldownReduction != "true")
                            {
                                string   updatedDescription      = string.Empty;
                                string   extractedCooldownString = GetAdjustedBaseCooldown(abilityDataEntry);
                                string[] descriptionParts        = abilityDescription.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;
                                    }
                                }
                                abilityDescription = updatedDescription + (!string.IsNullOrEmpty(extractedCooldownString) ? "\n\n" + extractedCooldownString : string.Empty);
                            }
                        }
                        return(SpecialFormatDescription(abilityDescription, abilityDataEntry.DeleteLines, abilityDataEntry.DeletePhrases, ability));
                    }
                }
                return(SpecialFormatDescription(ability?.Description, SourceAbility: ability));
            }
 public static string GetDefaultCostForMutationValueArray(MutationEntry me)
 {
     return(me.Cost.ToString().PadLeft(2, ' '));
 }
 public static string GetOptionNameForMutationCost(MutationEntry me)
 {
     return(Egcb_MutableMutations.ModOptionPrefix + me.DisplayName);
 }
示例#9
0
        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;
                }
            }
        }