Class PlatformerGraphBuilder
Utility to construct a platformer graph by connecting vertices by Id instead of index, which is far more convenient when building a custom editor. As an example use case, this class is used to construct the Platformer Graph by the PlatformerSceneGraph.
Namespace: AnyPath.Graphs.PlatformerGraph
Assembly: AnyPath.dll
Syntax
public class PlatformerGraphBuilder
Remarks
Also have a look at PlatformerGraphDrawer which is simpler to use
Constructors
PlatformerGraphBuilder()
Declaration
public PlatformerGraphBuilder()
Methods
Clear()
Clear the builder.
Declaration
public void Clear()
ContainsVertex(int)
Check if a vertex has been added
Declaration
public bool ContainsVertex(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id |
Returns
| Type | Description |
|---|---|
| bool |
GetData(out List<float2>, out List<Edge>, out List<Edge>)
Convert this representation to a representation suitable to construct the platformer graph.
Declaration
public void GetData(out List<float2> verts, out List<PlatformerGraph.Edge> undirectedIndices, out List<PlatformerGraph.Edge> directedIndices)
Parameters
| Type | Name | Description |
|---|---|---|
| List<float2> | verts | |
| List<PlatformerGraph.Edge> | undirectedIndices | |
| List<PlatformerGraph.Edge> | directedIndices |
GetVertex(int)
Returns the position of the vertex with a given Id
Declaration
public float2 GetVertex(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id |
Returns
| Type | Description |
|---|---|
| float2 |
LinkDirected(int, int)
Links two vertices together creating a traversable edge only from a to b
Declaration
public void LinkDirected(int a, int b)
Parameters
| Type | Name | Description |
|---|---|---|
| int | a | |
| int | b |
LinkDirected(int, int, float, int, int)
Links two vertices together creating a traversable edge only from a to b
Declaration
public void LinkDirected(int a, int b, float enterCost, int flags, int id = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | a | Id of vertex A |
| int | b | Id of vertex B |
| float | enterCost | Additional cost associated with entering this edge in a path |
| int | flags | Flags that can be used to filter the edge being traversable |
| int | id | Optional user defined Id that is given to the edge. This Id can be used for obtaining the edge from the PlatformerGraph that is constructed |
LinkUndirected(int, int)
Links two vertices together creating a traversable edge in both directions
Declaration
public int LinkUndirected(int a, int b)
Parameters
| Type | Name | Description |
|---|---|---|
| int | a | |
| int | b |
Returns
| Type | Description |
|---|---|
| int | The index of the edge in the internal list of edges |
LinkUndirected(int, int, float, int, int)
Links two vertices together creating a traversable edge in both directions
Declaration
public int LinkUndirected(int a, int b, float enterCost, int flags, int id = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | a | Id of vertex A |
| int | b | Id of vertex B |
| float | enterCost | Additional cost associated with entering this edge in a path |
| int | flags | Flags that can be used to filter the edge being traversable |
| int | id | Optional user defined Id that is given to the edge. This Id can be used for obtaining the edge from the PlatformerGraph that is constructed |
Returns
| Type | Description |
|---|---|
| int | The index of the edge in the internal list of edges |
SetVertex(int, float2)
Assigns a position to a vertex Id. If the vertex Id doesn't exist yet, it will be created. Otherwise it will be overwritten.
Declaration
public void SetVertex(int id, float2 pos)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | |
| float2 | pos |