Class PlatformerGraphDrawer
Makes it extremely easy to 'draw' a platformer graph. Just add lines/edges and close enough vertices will automatically be joined together.
Namespace: AnyPath.Graphs.PlatformerGraph
Assembly: AnyPath.dll
Syntax
public class PlatformerGraphDrawer
Examples
void Example()
{
// create a drawer which merges vertices that are closer than .1f
var drawer = new PlatformerGraphDrawer(.1f);
// draw a square
drawer.AddUndirected(new float2(0, 0), new float2(1, 0));
drawer.AddUndirected(new float2(1, 0), new float2(1, 1));
drawer.AddUndirected(new float2(1, 1), new float2(0, 1));
drawer.AddUndirected(new float2(0, 1), new float2(0, 0));
// create our graph
var graph = new PlatformerGraph(Allocator.Persistent);
// populate it with our square
graph.Populate(drawer.Vertices, drawer.UndirectedEdges);
}
Constructors
PlatformerGraphDrawer(float)
Construct a platformer graph drawer
Declaration
public PlatformerGraphDrawer(float weldThreshold)
Parameters
| Type | Name | Description |
|---|---|---|
| float | weldThreshold | Approx maximum distance vertices can have in order to be joined/welded together |
Properties
DirectedEdges
All edges that have been added as directed edges, use to populate the graph
Declaration
public IReadOnlyList<PlatformerGraph.Edge> DirectedEdges { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<PlatformerGraph.Edge> |
UndirectedEdges
All edges that have been added as undirected, use to populate the graph
Declaration
public IReadOnlyList<PlatformerGraph.Edge> UndirectedEdges { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<PlatformerGraph.Edge> |
Vertices
The welded vertices, use to populate the graph
Declaration
public IReadOnlyList<float2> Vertices { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<float2> |
Methods
AddDirected(float2, float2)
Draw a directed edge
Declaration
public void AddDirected(float2 from, float2 to)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | from | |
| float2 | to |
AddDirected(float2, float2, float, int)
Draw a directed edge with some additional traversal cost and flags associated with it
Declaration
public void AddDirected(float2 from, float2 to, float enterCost, int flags = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | from | |
| float2 | to | |
| float | enterCost | |
| int | flags |
AddUndirected(float2, float2)
Draw an undirected edge
Declaration
public void AddUndirected(float2 from, float2 to)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | from | |
| float2 | to |
AddUndirected(float2, float2, float, int)
Draw an undirected edge with some additional traversal cost and flags associated with it
Declaration
public void AddUndirected(float2 from, float2 to, float enterCost, int flags = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | from | |
| float2 | to | |
| float | enterCost | |
| int | flags |