private void DoMove(ResearchNode node, int from, int to) { List <ResearchNode> movingNodes = new List <ResearchNode>(); to = Math.Max(0, Math.Min(Count(), to)); if (to > from) { movingNodes.Add(node); int dest = --to; for (int i = from + 1; i <= to; ++i) { if (_queue[i].MissingPrerequisites().Contains(node)) { movingNodes.Add(_queue[i]); --dest; } } movingNodes.ForEach(n => _queue.Remove(n)); _queue.InsertRange(dest, movingNodes); } else if (to < from) { var prerequisites = node.MissingPrerequisites().ToList(); for (int i = to; i < from; ++i) { if (prerequisites.Contains(_queue[i])) { movingNodes.Add(_queue[i]); } } movingNodes.Add(node); UnsafeInsert(movingNodes, to); } }
public static bool BuildingPresent(ResearchNode node) { var research = node.Research; if (DebugSettings.godMode && Prefs.DevMode) { return(true); } // try get from cache bool result; if (_buildingPresentCache.TryGetValue(research, out result)) { return(result); } // do the work manually if (research.requiredResearchBuilding == null) { result = true; } else { result = Find.Maps.SelectMany(map => map.listerBuildings.allBuildingsColonist) .OfType <Building_ResearchBench>() .Any(b => research.CanBeResearchedAt(b, true)); } if (result) { result = node.MissingPrerequisites().All(BuildingPresent); } // update cache _buildingPresentCache.Add(research, result); return(result); }
static List <ResearchNode> FindHighlightsFrom(ResearchNode node) { return(node.MissingPrerequisites() .Concat(node.Children.Where(c => !c.Completed())) .ToList()); }