Returns a path between the given coordinates over the targetted BlockMap.
This is calculated using the A* algorithm, and only applies over a 2D slice of the BlockMap.
That is to say, it will not path between depths. Note: The GetPath function returns the collection of points from the target, to the target (if there is a path) excluding the ending point.
(Editor's Note: I'm sure there was a reason for this. But this, like a lot of things, has been lost to the ages)
The recommended style of pathing function is as follows (this is taken from the PathingEntity.cs template that comes with the tool).
public void PathTo(int x, int y, int z){ currentPath.Clear(); currentPath = BlockUtilities.GetPath(parentMap,this.x,this.y,(int)x,(int)y,z,false); if(currentPath == null || currentPath.Count <= 0){ currentPath = new List<Vector3>(); } else{ currentPath.Add(new Vector3(x,y,z)); } SetIsIdle(true); } So as you can see, we add the destination point to the path if the path returns and is not null. To decide if a node can be pathed through - the function checks the following (function IsWalkable in the BlockMap class): if(b != null && !b.isNullBlock && !b.actAsEmptyBlock && !pathOverAllBlocks) Is the Block a null block (i.e an empty block)? Is the Block acting as an Empty Block (i.e act empty is ticked)? Has the pathing funciton been asked to path over all Blocks? If any of these are true, the pathing function will path through this block. Definition:
List<Vector3> GetPath(BlockMap map, int from_x, int from_y, int to_x, int to_y, int depth, bool useDiagonals)
|