public override void OnUpdate() { goo = InputPath.Value as FsmPath; if (goo.Value == null) { Finish(); return; } if (FsmConverter.GetPath(InputPath).vectorPath.Count == 0) { return; } // wait until path's ready var go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value; goo = InputPath.Value as FsmPath; var moo = (SimpleSmoothModifier)go.AddComponent(typeof(SimpleSmoothModifier)); goo.Value.vectorPath = moo.SmoothSimple(goo.Value.vectorPath); GameObject.Destroy(moo); Finish(); }
/// <summary> /// Toes the graph viz. /// </summary> /// <param name="filename">The filename.</param> public void ToGraphViz(string filename) { using (var writer = new StreamWriter(filename)) { FsmConverter.ToGraphViz(_finiteStateMachine, writer); } }
public override void OnEnter() { var mo = InputPath.Value as FsmPath; if ((mo == null) || (mo.Value == null) || !OutputPath.UseVariable) { Debug.Log("Input Incomplete"); Finish(); return; } // also abort the action if there is no variable to save to. var a = (InputPath.Value as FsmPath).Value as ABPath; var b = PathPool <ABPath> .GetPath(); // I can't instantiate so there's nothing but the manual way left b.duration = a.duration; b.heuristicScale = a.heuristicScale; b.enabledTags = a.enabledTags; b.radius = a.radius; b.searchedNodes = a.searchedNodes; b.searchIterations = a.searchIterations; b.speed = a.speed; b.turnRadius = a.turnRadius; b.recycled = a.recycled; b.nnConstraint = a.nnConstraint; b.path = a.path; b.vectorPath = a.vectorPath; OutputPath.Value = FsmConverter.SetPath(b); Finish(); }
/// <summary> /// Toes the graph ML. /// </summary> /// <param name="filename">The filename.</param> public void ToGraphML(string filename) { using (var writer = XmlWriter.Create(filename)) { FsmConverter.ToGraphML(_finiteStateMachine, writer); } }
public void DoStuff() { if (!astarPath.IsNone && astarPath.Value != null) { astarp = FsmConverter.GetAstarPath(astarPath); } else { astarp = AstarPath.active; } if (!isScanning.IsNone) { astarp.isScanning = isScanning.Value; } if (!showGraphs.IsNone) { astarp.showGraphs = showGraphs.Value; } if (!lastUniqueAreaIndex.IsNone) { astarp.lastUniqueAreaIndex = lastUniqueAreaIndex.Value; } if (!astarData.IsNone) { astarp.graphs = FsmConverter.GetNavGraphs(astarData.Value); } return; }
public void DoStuff() { var a = g.CreateNodes(number.Value); nodes.Value = new FsmNodes(); (nodes.Value as FsmNodes).Value = (List <Node>)FsmConverter.NodeListToArray(a); // g.nodes += a; // AstarPath.active.NodeCountChanged() ; AstarPathExtensions.ScanGraph(g); }
public void DoStuff() { var go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value; g.root = go.transform; // set the root so the scan will turn it into nodes g.maxDistance = maxDistance.Value; // set max distance for connection g.initialPenalty = (uint)cost.Value; g.name = name.Value; AstarPathExtensions.ScanGraph(g); // turn the gameObjects into ndoes. Nodes.Value = FsmConverter.SetNodes(FsmConverter.NodeListToArray(g.nodes)); AstarPath.active.FloodFill(); return; }
public override void OnEnter() { var mo = node.Value as FsmNode; var fo = node2.Value as FsmNode; if (mo == null || fo == null || (mo.Value == null) || (fo.Value == null)) { Debug.Log("Input incomplete, node not valid or does not exist. Make sure you assigned it properly."); Finish(); return; } var a = (node.Value as FsmNode).Value as Node; connected.Value = a.ContainsConnection(FsmConverter.GetAnythingShallow(node2) as Node); Finish(); }
public void DoStuff() { var doo = FsmConverter.GetPath(InputPath); doo.duration = duration.Value; doo.heuristicScale = heuristicScale.Value; doo.enabledTags = enabledTags.Value; doo.radius = radius.Value; doo.pathID = (ushort)pathID.Value; doo.searchedNodes = searchedNodes.Value; doo.searchIterations = searchIterations.Value; doo.speed = speed.Value; doo.turnRadius = turnRadius.Value; doo.recycled = recycled.Value; nnConstraint.Value = FsmConverter.SetNNConstraint(doo.nnConstraint); nodes.Value = FsmConverter.SetNodes(doo.path); runData.Value = FsmConverter.SetNodeRunData(doo.runData); }
public override void OnEnter() { var mo = graph.Value as FsmNavGraph; if (mo.Value == null) { Finish(); return; } // it would continue for a frame without return g = FsmConverter.GetNavGraph(graph); DoStuff(); if (!everyFrame.Value) { Finish(); } }
public override void OnEnter() { mo = graph.Value as FsmNavGraph; if ((mo == null) || (mo.Value == null) || alwaysNew.Value) { AstarPath.active.astarData.AddGraph(mo.Value); g = FsmConverter.GetNavGraph(graph) as PointGraph; Debug.Log("Creating New Point Graph"); graph.Value = FsmConverter.SetNavGraph(g as NavGraph); } else { g = FsmConverter.GetNavGraph(graph) as PointGraph; } DoStuff(); Finish(); }
public void DoStuff() { var go = graph.Value as FsmNavGraph; if (go.Value == null) { Finish(); return; } g = FsmConverter.GetNavGraph(graph); guid.Value = g.guid.ToString(); drawGizmos.Value = g.drawGizmos; infoScreenOpen.Value = g.infoScreenOpen; initialPenalty.Value = (int)g.initialPenalty; name.Value = g.name; nodes.Value = FsmConverter.SetNodes(FsmConverter.NodeListToArray(g.nodes)) as FsmNodes; // everywhere else it's saved as a generic list, only here it is an array, so it needs extra conversion open.Value = g.open; if (graphType == GraphType.pointGraph && g as PointGraph != null) { autoLinkNodes.Value = (g as PointGraph).autoLinkNodes; limits.Value = (g as PointGraph).limits; mask.Value = (g as PointGraph).mask; maxDistance.Value = (g as PointGraph).maxDistance; raycast.Value = (g as PointGraph).raycast; recursive.Value = (g as PointGraph).recursive; root.Value = (g as PointGraph).root.gameObject; searchTag.Value = (g as PointGraph).searchTag; thickRaycast.Value = (g as PointGraph).thickRaycast; thickRaycastRadius.Value = (g as PointGraph).thickRaycastRadius; } if (graphType == GraphType.gridGraph && g as GridGraph != null) { getNearestForceOverlap.Value = (g as GridGraph).getNearestForceOverlap; scans.Value = (g as GridGraph).scans; size.Value = (g as GridGraph).size; } }
public override void OnEnter() { mo = graph.Value as FsmPointGraph; //Debug.Log(typeof(mo)); if ((mo == null) || (mo.Value == null) || alwaysNew.Value) { AstarPath.active.astarData.AddGraph(mo.Value); g = FsmConverter.GetPointGraph(graph) as PointGraph; Debug.Log("Creating New Point Graph"); graph.Value = FsmConverter.SetPointGraph(g); } // create a PointGraph if the variable does not contain a valid one already. else { g = FsmConverter.GetPointGraph(graph) as PointGraph; } DoStuff(); Finish(); }
public override void OnEnter() { var mo = nodes.Value as FsmNodes; if (mo == null || (mo.Value == null) || !node.UseVariable) { Debug.Log("No Input"); Finish(); return; } if ((mo.Value as List <Node>).Count <= index.Value) { Debug.Log("index is higher than the number of nodes in the nodes list/variable"); Finish(); return; } node.Value = FsmConverter.SetNode((nodes.Value as FsmNodes).Value[index.Value]); Finish(); }
public override void OnEnter() { var go = graphs.Value as FsmNavGraphs; if ((go.Value == null) || !graph.UseVariable) { Finish(); return; } // it would continue for a frame without return var goo = FsmConverter.GetNavGraphs(graphs); var coo = new FsmNavGraph(); if (index.Value >= goo.Length) //check if the index exists { Finish(); } coo.Value = goo[index.Value]; graph.Value = coo; Finish(); }
public void DoStuff() { var doo = ((node as FsmObject).Value as FsmNode).Value as Node; nodeIndex.Value = doo.GetNodeIndex(); penalty.Value = (int)doo.penalty; area.Value = doo.area; tags.Value = doo.tags; walkable.Value = doo.walkable; graphIndex.Value = doo.graphIndex; position.Value = new Vector3(doo.position.x, doo.position.y, doo.position.z); position.Value *= Int3.PrecisionFactor; if (!connectedNodes.IsNone) { (connectedNodes.Value as FsmNodes).Value = (List <Node>)FsmConverter.NodeListToArray(doo.connections); } var loo = new FsmNavGraph(); loo.Value = AstarPath.active.graphs[doo.graphIndex]; graph.Value = loo; }
public override void OnUpdate() { if (updatePath && moveMode == MoveMode.followPath) { path = FsmConverter.GetPath(inputPath); } if (path == null || path.vectorPath.Count == 0) // only continue if path is valid { return; } if (!pathLoading && ((moveMode == MoveMode.follow || moveMode == MoveMode.followTo || moveMode == MoveMode.fleeContinuously) && frame >= Math.Max(1, updateInterval.Value))) { CalculatePath(); pathLoading = true; frame = 0; } else { frame += 1; } if (moveMode == MoveMode.shadow || moveMode == MoveMode.shadowTo) { ShadowExtendPath(); } if (auto.Value) { Auto(); if (endOfPathEvent != null) { Fsm.Event(endOfPathEvent); } Finish(); } if (currentWaypoint >= (path.vectorPath).Count) { currentWaypoint = path.vectorPath.Count - 1; } if ((finishDistanceMode == FinishDistance.absolute && ( (target.Value != null && (target.Value.transform.position - go.transform.position).sqrMagnitude <= finishDistance.Value * finishDistance.Value) || (ignoreY.Value && target.Value != null && (new Vector3(target.Value.transform.position.x, go.transform.position.y, target.Value.transform.position.z) - go.transform.position).sqrMagnitude <= finishDistance.Value * finishDistance.Value) || (target.Value == null && Vector3.Distance(go.transform.position, targetPosition.Value) <= finishDistance.Value)) ) || (finishDistanceMode == FinishDistance.absoluteEndnode && ( (!ignoreY.Value && Vector3.Distance(go.transform.position, path.vectorPath[path.vectorPath.Count - 1]) <= finishDistance.Value) || (ignoreY.Value && Vector3.Distance(new Vector3(go.transform.position.x, path.vectorPath[path.vectorPath.Count - 1].y, go.transform.position.z), path.vectorPath[path.vectorPath.Count - 1]) <= finishDistance.Value))) ) { Debug.Log("Finish"); if (moveMode != MoveMode.follow && moveMode != MoveMode.shadow && moveMode != MoveMode.fleeContinuously) { if (LogEvents.Value) { Debug.Log("End Of path reached."); } if (controller2 != null && controllerType == ControllerType.rvoController) //RVO controller needs to be set to 0/0/0 , else it continues running. { controller2.Move(new Vector3(0, 0, 0)); } if (rigidbody != null && (controllerType == ControllerType.rigidbody || controllerType == ControllerType.rigidbodyVelocity)) { rigidbody.velocity = new Vector3(0, rigidbody.velocity.y, 0); } if (endOfPathEvent != null) { Fsm.Event(endOfPathEvent); } Finish(); return; } else { return; } } else if (finishDistanceMode == FinishDistance.relative) { var i = currentWaypoint; var leng = 0.0f; while (i < path.vectorPath.Count - 1) { leng += Vector3.Distance(path.vectorPath[currentWaypoint], path.vectorPath[currentWaypoint + 1]); if (leng > finishDistance.Value) // if the distance is still too far to finish, break to save performance { break; } } if (leng <= finishDistance.Value) { if (moveMode != MoveMode.follow && moveMode != MoveMode.shadow && moveMode != MoveMode.fleeContinuously) { if (LogEvents.Value) { Debug.Log("End Of path reached."); } if (controller2 != null && controllerType == ControllerType.rvoController) //RVO controller needs to be set to 0/0/0 , else it continues running. { controller2.Move(new Vector3(0, 0, 0)); } if (rigidbody != null && (controllerType == ControllerType.rigidbody || controllerType == ControllerType.rigidbodyVelocity)) { rigidbody.velocity = new Vector3(0, rigidbody.velocity.y, 0); } Fsm.Event(endOfPathEvent); Finish(); return; } else { return; } } } // Check if we are close enough to the next waypoint. if (ignoreY.Value) { var distVec = nextPos - go.transform.position; distVec.y = 0; dist = distVec.magnitude; } else { dist = Vector3.Distance(go.transform.position, nextPos); } if (dist < nextWaypointDistance.Value && !smoothTurns.Value) { if (finishDistanceMode == FinishDistance.last && currentWaypoint >= (path.vectorPath).Count - 1) { if (moveMode != MoveMode.follow && moveMode != MoveMode.shadow && moveMode != MoveMode.fleeContinuously) { if (LogEvents.Value) { Debug.Log("End Of path reached."); } if (controller2 != null && controllerType == ControllerType.rvoController) //RVO controller needs to be set to 0/0/0 , else it continues running. { controller2.Move(new Vector3(0, 0, 0)); } if (rigidbody != null && (controllerType == ControllerType.rigidbody || controllerType == ControllerType.rigidbodyVelocity)) { rigidbody.velocity = new Vector3(0, rigidbody.velocity.y, 0); } Fsm.Event(endOfPathEvent); Finish(); return; } } // Proceed to follow the next waypoint. currentWaypoint++; currentWaypoint = Math.Min(currentWaypoint, path.vectorPath.Count - 1); } nextPos = path.vectorPath[currentWaypoint]; // Direction to the next waypoint. if (!smoothTurns.Value) { direction = (nextPos - go.transform.position).normalized; } //test else { var turnDistance = 0.0f; var targetPos = prevTarget; if (frame == 1) { if (firstFrame) { targetPos = go.transform.position; } // keep targetPos on update currentWaypoint = 1; path.vectorPath[0] = targetPos; } currentWaypoint = Math.Min(currentWaypoint, path.vectorPath.Count - 2); var deltaPos = 0.0f; if (frame == 1) { deltaPos = turnRadius.Value - (targetPos - go.transform.position).magnitude; } else { deltaPos = (go.transform.position - prevPosition).magnitude; } if (deltaPos * deltaPos > (path.vectorPath[currentWaypoint + 1] - targetPos).sqrMagnitude) { while (deltaPos * deltaPos > (path.vectorPath[currentWaypoint + 1] - targetPos).sqrMagnitude) { currentWaypoint++; currentWaypoint = Math.Min(currentWaypoint, path.vectorPath.Count - 2); targetPos = path.vectorPath[currentWaypoint]; deltaPos -= (path.vectorPath[currentWaypoint] - targetPos).magnitude; } } if ((targetPos - go.transform.position).sqrMagnitude < turnRadius.Value * turnRadius.Value) { targetPos += ((path.vectorPath[currentWaypoint + 1] - targetPos).normalized) * deltaPos * 1.5f; } // targetObjectHelper.transform.position = targetPos; prevPosition = go.transform.position; prevTarget = targetPos; direction = (targetPos - go.transform.position).normalized; } directionOut.Value = direction; if (ignoreY.Value) { direction.y = 0; directionOut.Value = new Vector3(directionOut.Value.x, 0, directionOut.Value.z); directionOut.Value = directionOut.Value.normalized; direction = direction.normalized; } outputSpeed.Value = (float)((1 / Math.Exp(costDependendSpeed.Value * path.path[Math.Min(currentWaypoint, path.path.Count - 1)].penalty)) * speed.Value); direction *= outputSpeed.Value; // 1/e^x for exponentially slower speed, but never 0 or negative or more than 1. Math classes were good for something afterall :D Move(); firstFrame = false; if (drawGizmos && path != null && path.path != null && path.vectorPath != null) { for (var i = 0; i < path.vectorPath.Count - 1; i++) { Debug.DrawLine(path.vectorPath[i], path.vectorPath[i + 1], gizmosColor.Value); } } return; }
public override void OnEnter() { if (moveMode == MoveMode.followPath) { path = FsmConverter.GetPath(inputPath); if (path == null) { if (LogEvents.Value) { Debug.Log("Astar Follow Path failed. The path is null"); } Fsm.Event(failedEvent); Finish(); return; } else if (path.vectorPath.Count == 0) { if (LogEvents.Value) { Debug.Log("Astar Follow Path failed. The path contains no nodes"); } Fsm.Event(failedEvent); Finish(); return; } } currentWaypoint = 0; go = actor.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : actor.GameObject.Value; if (go == null) { if (LogEvents.Value) { Debug.Log("Astar Move To failed. The actor is null"); } Fsm.Event(failedEvent); Finish(); return; } //finish the action if any of the requirements are not met controller = go.GetComponent <CharacterController>(); controller2 = go.GetComponent <RVOController>(); rigidbody = go.GetComponent <Rigidbody>(); if (controllerType == ControllerType.characterController && controller == null) { controller = go.AddComponent <CharacterController>(); } else if (controllerType == ControllerType.rvoController && controller2 == null) { if (AstarPath.HasPro) { controller2 = go.AddComponent <RVOController>(); controller2.Move(new Vector3(0, 0, 0)); } else { controllerType = ControllerType.characterController; //free version can't use RVOControllers if (controller == null) { controller = go.AddComponent <CharacterController>(); } } } else if (controllerType == ControllerType.rigidbody && rigidbody == null) { rigidbody = go.AddComponent <Rigidbody>(); rigidbody.drag = 0.5f; rigidbody.freezeRotation = true; } else if (controllerType == ControllerType.rigidbodyVelocity && rigidbody == null) { rigidbody = go.AddComponent <Rigidbody>(); rigidbody.freezeRotation = true; } if (moveMode != MoveMode.followPath) { CalculatePath(); } if (moveMode == MoveMode.followPath && !startAtStart.Value) { currentWaypoint = getClosest(); } if (moveMode == MoveMode.followPath && connectPath.Value) { done = false; ConnectPathX(); } }
public void DoStuff() { var go = graph.Value as FsmNavGraph; if (go.Value == null) { Finish(); return; } g = FsmConverter.GetNavGraph(graph); if (!drawGizmos.IsNone) { g.drawGizmos = drawGizmos.Value; } if (!infoScreenOpen.IsNone) { g.infoScreenOpen = infoScreenOpen.Value; } if (!initialPenalty.IsNone) { g.initialPenalty = (uint)initialPenalty.Value; } if (!name.IsNone) { g.name = name.Value; } if (!nodes.IsNone) { g.nodes = FsmConverter.NodeArrayFromList((nodes.Value as FsmNodes).Value); } if (!open.IsNone) { g.open = open.Value; } if (graphType == GraphType.pointGraph && g as PointGraph != null) { if (!autoLinkNodes.IsNone) { (g as PointGraph).autoLinkNodes = autoLinkNodes.Value; } if (!limits.IsNone) { (g as PointGraph).limits = limits.Value; } if (!mask.IsNone) { (g as PointGraph).mask = mask.Value; } if (!maxDistance.IsNone) { (g as PointGraph).maxDistance = maxDistance.Value; } if (!raycast.IsNone) { (g as PointGraph).raycast = raycast.Value; } if (!recursive.IsNone) { (g as PointGraph).recursive = recursive.Value; } if (!searchTag.IsNone) { (g as PointGraph).searchTag = searchTag.Value; } if (!thickRaycast.IsNone) { (g as PointGraph).thickRaycast = thickRaycast.Value; } if (!thickRaycastRadius.IsNone) { (g as PointGraph).thickRaycastRadius = thickRaycastRadius.Value; } } if (graphType == GraphType.gridGraph && g as GridGraph != null) { if (!getNearestForceOverlap.IsNone) { (g as GridGraph).getNearestForceOverlap = getNearestForceOverlap.Value; } if (!scans.IsNone) { (g as GridGraph).scans = scans.Value; } if (!size.IsNone) { (g as GridGraph).size = size.Value; } } }
public void mohogony() { node.Value = FsmConverter.SetNode(AstarPath.active.GetNearest(Position.Value).node as Node); return; }
public void DoStuff() { if (!astarPath.IsNone && astarPath.Value != null) { astarp = FsmConverter.GetAstarPath(astarPath); } else { astarp = AstarPath.active; } if (!isScanning.IsNone) { isScanning.Value = astarp.isScanning; } if (!showGraphs.IsNone) { showGraphs.Value = astarp.showGraphs; } if (!IsUsingMultithreading.IsNone) { IsUsingMultithreading.Value = AstarPath.IsUsingMultithreading; } if (!IsAnyGraphUpdatesQueued.IsNone) { IsAnyGraphUpdatesQueued.Value = astarp.IsAnyGraphUpdatesQueued; } if (!lastUniqueAreaIndex.IsNone) { lastUniqueAreaIndex.Value = astarp.lastUniqueAreaIndex; } if (!ActiveThreadsCount.IsNone) { ActiveThreadsCount.Value = AstarPath.ActiveThreadsCount; } if (!NumParallelThreads.IsNone) { NumParallelThreads.Value = AstarPath.NumParallelThreads; } if (!Version.IsNone) { Version.Value = AstarPath.Version.ToString(); } if (!graphs.IsNone) { graphs.Value = FsmConverter.SetNavGraphs(astarp.graphs); } if (!activeAstarPath.IsNone) { activeAstarPath.Value = FsmConverter.SetAstarPath(AstarPath.active); } if (!astarData.IsNone) { astarData.Value = FsmConverter.SetNavGraphs(astarp.graphs); } return; }
public void DoStuff() { var go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value; g.root = go.transform; // set the root so the scan will turn it into nodes g.maxDistance = -1; // no autoconnect g.initialPenalty = (uint)cost.Value; g.name = name.Value; AstarPathExtensions.ScanGraph(g); // turn the gameObjects into ndoes. if (width.Value <= 1) { for (var i = 1; i < g.nodes.Length; i++) { // connect the node with the previously created node g.nodes[i].AddConnection(g.nodes[i - 1], cost.Value); g.nodes[i - 1].AddConnection(g.nodes[i], cost.Value); } if (connectStart.Value || connectEnd.Value) { // You would want to use an NNConstraint to ignore this graph when searching (graphMask) // Since it currently will find g.nodes[0] when searching nnc = NNConstraint.Default; var nncSave = nnc.graphMask; var index = AstarPath.active.astarData.GetGraphIndex(g); nnc.graphMask = ~(1 << index); if (connectStart.Value) { connectEm(0); } if (connectEnd.Value) { connectEm(g.nodes.Length - 1); } nnc.graphMask = nncSave; } } else { for (var i = 0; i < g.nodes.Length; i++) { // connect the node with the previously created node //g.nodes[i].AddConnection(g.nodes[i-1], cost.Value); //g.nodes[i-1].AddConnection(g.nodes[i], cost.Value); //if(i + width.Value <= g.nodes.Length) //{ //connect the node with the next node in line //g.nodes[i-1].AddConnection(g.nodes[i-1+width.Value], cost.Value); //g.nodes[i-1+width.Value].AddConnection(g.nodes[i-1], cost.Value); //} // there are 3 scenarios: Either a node is in the middle or at either of the ends of the row. if (i % width.Value == width.Value - 1) //2 { if (i + width.Value < g.nodes.Length) { g.nodes[i].AddConnection(g.nodes[i + width.Value], cost.Value); g.nodes[i + width.Value].AddConnection(g.nodes[i], cost.Value); } if (i + width.Value - 1 < g.nodes.Length) { g.nodes[i].AddConnection(g.nodes[i + width.Value - 1], cost.Value); g.nodes[i + width.Value - 1].AddConnection(g.nodes[i], cost.Value); } } else if (i == 0 || 0 == i % width.Value) //1 // if i is 0 or a multiple of width { if (i + width.Value < g.nodes.Length) { g.nodes[i].AddConnection(g.nodes[i + width.Value], cost.Value); g.nodes[i + width.Value].AddConnection(g.nodes[i], cost.Value); } if (i + 1 < g.nodes.Length) { g.nodes[i].AddConnection(g.nodes[i + 1], cost.Value); g.nodes[i + 1].AddConnection(g.nodes[i], cost.Value); } if (i + width.Value + 1 < g.nodes.Length) { g.nodes[i].AddConnection(g.nodes[i + width.Value + 1], cost.Value); g.nodes[i + width.Value + 1].AddConnection(g.nodes[i], cost.Value); } } else //3 { if (i + width.Value < g.nodes.Length) { g.nodes[i].AddConnection(g.nodes[i + width.Value], cost.Value); g.nodes[i + width.Value].AddConnection(g.nodes[i], cost.Value); } if (i + 1 < g.nodes.Length) { g.nodes[i].AddConnection(g.nodes[i + 1], cost.Value); g.nodes[i + 1].AddConnection(g.nodes[i], cost.Value); } if (i + width.Value + 1 < g.nodes.Length) { g.nodes[i].AddConnection(g.nodes[i + width.Value + 1], cost.Value); g.nodes[i + width.Value + 1].AddConnection(g.nodes[i], cost.Value); } if (i + width.Value - 1 < g.nodes.Length) { g.nodes[i].AddConnection(g.nodes[i + width.Value - 1], cost.Value); g.nodes[i + width.Value - 1].AddConnection(g.nodes[i], cost.Value); } } } if (connectStart.Value || connectEnd.Value) { // You would want to use an NNConstraint to ignore this graph when searching (graphMask) // Since it currently will find g.nodes[0] when searching nnc = NNConstraint.Default; var nncSave = nnc.graphMask; var index = AstarPath.active.astarData.GetGraphIndex(g); nnc.graphMask = ~(1 << index); if (connectStart.Value) { connectEm(0); } if (connectEnd.Value) { connectEm(g.nodes.Length - width.Value); } nnc.graphMask = nncSave; } } Nodes.Value = FsmConverter.SetNodes(FsmConverter.NodeListToArray(g.nodes)); //Required since the graph connections have been updated AstarPath.active.FloodFill(); //g.AddChildren(Count, go.transform); return; }
/// <summary> /// Toes the graph viz. /// </summary> /// <param name="writer">The writer.</param> public void ToGraphViz(TextWriter writer) { FsmConverter.ToGraphViz(_finiteStateMachine, writer); }
/// <summary> /// Toes the graph ML. /// </summary> /// <param name="writer">The writer.</param> public void ToGraphML(XmlWriter writer) { FsmConverter.ToGraphML(_finiteStateMachine, writer); }