private static NodeBlueprint?FindNextUnfinishedNode(GraphBlueprint g, INodeBlueprint snode, FractionDifficulty d) { Stack <INodeBlueprint> mem = new Stack <INodeBlueprint>(); mem.Push(snode); while (mem.Any()) { var node = mem.Pop(); foreach (var pipe in node.Pipes.OrderBy(p => p.Priority)) { var lnode = Get(g, pipe.Target); if (!(lnode is NodeBlueprint)) { continue; } if (!MainGame.Inst.Profile.GetLevelData(lnode.ConnectionID).HasCompletedOrBetter(d)) { return((NodeBlueprint?)lnode); } mem.Push(lnode); } } return(null); }
public static NodeBlueprint?FindNextNode(GraphBlueprint g, INodeBlueprint snode, FractionDifficulty d) { snode = Get(g, snode.ConnectionID); if (snode == null) { return(null); } // unfinished descendants var descendant = FindNextUnfinishedNode(g, snode, d); if (descendant != null) { return(descendant.Value); } // all unfinished var unfin = FindNextUnfinishedNode(g, g.RootNode, d); if (unfin != null) { return(unfin.Value); } // none return(null); }
private void AddWarpNode(List <string> methodParameter) { var pos = ExtractVec2fParameter(methodParameter, 0); var target = ExtractGuidParameter(methodParameter, 1); var px = pos.Item1 * _scaleFactor; var py = pos.Item2 * _scaleFactor; var node = new WarpNodeBlueprint(px, py, target); _currentNode = node; _result.WarpNodes.Add(node); }
public GraphBlueprint Parse(string fileName = "__root__") { _result = new GraphBlueprint(); _scaleFactor = 1f; _currentNode = null; StartParse(fileName, content); _result.ValidOrThrow(); return(_result); }
private void AddRootNode(List <string> methodParameter) { var pos = ExtractVec2fParameter(methodParameter, 0); var worldid = ExtractGuidParameter(methodParameter, 1); var px = pos.Item1 * _scaleFactor; var py = pos.Item2 * _scaleFactor; var node = new RootNodeBlueprint(px, py, worldid); _currentNode = node; _result.RootNode = node; }
private void WalkGraphAndFindLoops(INodeBlueprint me, List <INodeBlueprint> history) { if (history.Contains(me)) { throw new Exception("Graph has a directed cycle"); } foreach (var p in me.Pipes) { WalkGraphAndFindLoops(AllNodes.Single(n => n.ConnectionID == p.Target), history.Concat(new List <INodeBlueprint> { me }).ToList()); } }
public IWorldNode FindNode(INodeBlueprint bp) { return(Nodes.FirstOrDefault(n => n.ConnectionID == bp.ConnectionID)); }