/// <summary> /// Add the item, its previous levels and its prerequisites to the given set and list. /// </summary> /// <param name="list">The list.</param> /// <param name="set">The set.</param> /// <param name="item">The item.</param> /// <param name="includeRoots">if set to <c>true</c> [include roots].</param> internal static void FillDependencies(this IList<StaticSkillLevel> list, SkillLevelSet<StaticSkillLevel> set, StaticSkillLevel item, bool includeRoots) { StaticSkill skill = item.Skill; // Add first level and prerequisites if (!set.Contains(skill, 1)) { // Prerequisites foreach (StaticSkillLevel prereq in skill.Prerequisites.Where(prereq => skill != prereq.Skill)) { list.FillDependencies(set, prereq, true); } // Include the first level StaticSkillLevel newItem = new StaticSkillLevel(skill, 1); list.Add(newItem); set.Set(newItem); } // Add greater levels Int64 max = includeRoots ? item.Level : item.Level - 1; for (int i = 2; i <= max; i++) { if (set.Contains(skill, i)) continue; StaticSkillLevel newItem = new StaticSkillLevel(skill, i); list.Add(newItem); set.Set(newItem); } }
/// <summary> /// Add the item, its previous levels and its prerequisites to the given set and list. /// </summary> /// <param name="set"></param> /// <param name="list"></param> /// <param name="item"></param> /// <param name="includeRoots"></param> internal static void FillDependencies(SkillLevelSet<StaticSkillLevel> set, List<StaticSkillLevel> list, StaticSkillLevel item, bool includeRoots) { var skill = item.Skill; // Add first level and prerequisites if (!set.Contains(skill, 1)) { // Prerequisites foreach (var prereq in skill.Prerequisites) { // Deal with recursive skills such as Polaris if (skill != prereq.Skill) { FillDependencies(set, list, prereq, true); } } // Include the first level var newItem = new StaticSkillLevel(skill, 1); list.Add(newItem); set.Set(newItem); } // Add greater levels int max = (includeRoots ? item.Level : item.Level - 1); for (int i = 2; i <= max; i++) { if (!set.Contains(skill, i)) { var newItem = new StaticSkillLevel(skill, i); list.Add(newItem); set.Set(newItem); } } }
/// <summary> /// Fills the given levels array with the prerequisites and when <c>includeRoots</c> is true, the item level itself. /// </summary> /// <param name="highestLevels"></param> /// <param name="list"></param> /// <param name="item"></param> /// <param name="includeRoots"></param> internal static void FillPrerequisites(Int64[] highestLevels, List<StaticSkillLevel> list, StaticSkillLevel item, bool includeRoots) { // Prerequisites if (highestLevels[item.Skill.ArrayIndex] == 0) { foreach (StaticSkillLevel prereq in item.Skill.Prerequisites.Where(prereq => prereq.Skill != item.Skill)) { FillPrerequisites(highestLevels, list, prereq, true); } } // The very level if (!includeRoots || highestLevels[item.Skill.ArrayIndex] >= item.Level) return; highestLevels[item.Skill.ArrayIndex] = item.Level; list.Add(item); }
/// <summary> /// Fills the given levels array with the prerequisites and, when <c>includeRoots</c> is true, the item level itself /// </summary> /// <param name="highestLevels"></param> /// <param name="list"></param> /// <param name="item"></param> /// <param name="includeRoots"></param> internal static void FillPrerequisites(int[] highestLevels, List<StaticSkillLevel> list, StaticSkillLevel item, bool includeRoots) { // Prerequisites if (highestLevels[item.Skill.ArrayIndex] == 0) { foreach (var prereq in item.Skill.Prerequisites) { // Deal with recursive skills such as Polaris if (prereq.Skill != item.Skill) { FillPrerequisites(highestLevels, list, prereq, true); } } } // The very level if (includeRoots && highestLevels[item.Skill.ArrayIndex] < item.Level) { highestLevels[item.Skill.ArrayIndex] = item.Level; list.Add(item); } }
/// <summary> /// Add the item, its previous levels and its prerequisites to the given set and list. /// </summary> /// <param name="set"></param> /// <param name="list"></param> /// <param name="item"></param> /// <param name="includeRoots"></param> internal static void FillDependencies(SkillLevelSet <StaticSkillLevel> set, List <StaticSkillLevel> list, StaticSkillLevel item, bool includeRoots) { var skill = item.Skill; // Add first level and prerequisites if (!set.Contains(skill, 1)) { // Prerequisites foreach (var prereq in skill.Prerequisites) { // Deal with recursive skills such as Polaris if (skill != prereq.Skill) { FillDependencies(set, list, prereq, true); } } // Include the first level var newItem = new StaticSkillLevel(skill, 1); list.Add(newItem); set.Set(newItem); } // Add greater levels int max = (includeRoots ? item.Level : item.Level - 1); for (int i = 2; i <= max; i++) { if (!set.Contains(skill, i)) { var newItem = new StaticSkillLevel(skill, i); list.Add(newItem); set.Set(newItem); } } }
/// <summary> /// Recursive method to generate treenodes for tvCertList. /// </summary> /// <param name="requiredSkill">An EntityRequiredSkill object</param> /// <returns></returns> private TreeNode GetSkillNode(StaticSkillLevel prereq) { var character = (Character)m_plan.Character; Skill skill = character.Skills[prereq.Skill]; TreeNode node = new TreeNode(prereq.ToString()); node.Tag = new SkillLevel(skill, prereq.Level); // Generate child prerequisite skill nodes if required foreach (StaticSkillLevel childPrereq in skill.StaticData.Prerequisites) { node.Nodes.Add(GetSkillNode(childPrereq)); } return node; }
/// <summary> /// Recursive method to generate treenodes for tvSkillList /// </summary> /// <param name="requiredSkill">An EntityRequiredSkill object</param> /// <returns></returns> private TreeNode GetSkillNode(StaticSkillLevel prereq, ref bool allSkillsKnown, ref bool skillsUnplanned) { var character = (Character)m_plan.Character; Skill skill = character.Skills[prereq.Skill]; TreeNode node = new TreeNode(prereq.ToString()); node.Tag = new SkillLevel(skill, prereq.Level); // Skill requirement met if (skill.Level >= prereq.Level) { node.ImageIndex = 1; node.SelectedImageIndex = 1; } // Requirement not met, but planned else if (m_plan.IsPlanned(skill, prereq.Level)) { node.ImageIndex = 2; node.SelectedImageIndex = 2; allSkillsKnown = false; } // Requirement not met, but trainable else if (skill.Level < prereq.Level && skill.IsKnown) { node.ImageIndex = 3; node.SelectedImageIndex = 3; allSkillsKnown = false; skillsUnplanned = true; } // Requirement not met else { node.ImageIndex = 0; node.SelectedImageIndex = 0; allSkillsKnown = false; skillsUnplanned = true; } // Generate child nodes if required foreach (StaticSkillLevel childPrereq in skill.StaticData.Prerequisites) { node.Nodes.Add(GetSkillNode(childPrereq, ref allSkillsKnown, ref skillsUnplanned)); } return node; }
/// <summary> /// Fills the given levels array with the prerequisites and, when <c>includeRoots</c> is true, the item level itself /// </summary> /// <param name="highestLevels"></param> /// <param name="list"></param> /// <param name="item"></param> /// <param name="includeRoots"></param> internal static void FillPrerequisites(int[] highestLevels, List <StaticSkillLevel> list, StaticSkillLevel item, bool includeRoots) { // Prerequisites if (highestLevels[item.Skill.ArrayIndex] == 0) { foreach (var prereq in item.Skill.Prerequisites) { // Deal with recursive skills such as Polaris if (prereq.Skill != item.Skill) { FillPrerequisites(highestLevels, list, prereq, true); } } } // The very level if (includeRoots && highestLevels[item.Skill.ArrayIndex] < item.Level) { highestLevels[item.Skill.ArrayIndex] = item.Level; list.Add(item); } }