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 AnyPath.Graphs.PlatformerSceneGraph
Inheritance
System.Object
PlatformerGraphBuilder
Implements
System.IDisposable
Assembly: Assembly-CSharp.dll
public class PlatformerGraphBuilder : IDisposable
Constructors
|
Improve this Doc
View Source
Constructs a builder. Note that the builder must be disposed after usage because it uses internal Native allocations.
Declaration
public PlatformerGraphBuilder()
Methods
|
Improve this Doc
View Source
Declaration
public void AddEdge(PlatformerGraphBuilder.ProtoEdge protoEdge)
Parameters
|
Improve this Doc
View Source
Calculates the current bounds of the (proto) graph.
Declaration
public AABB2D CalculateBounds()
Returns
|
Improve this Doc
View Source
Declaration
|
Improve this Doc
View Source
Check if a vertex has been added
Declaration
public bool ContainsVertex(int id)
Parameters
Type |
Name |
Description |
System.Int32 |
id |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Dispose this builder. This is neccessary because internal native allocations are made.
Declaration
|
Improve this Doc
View Source
Declaration
public bool GetClosestVertex(float2 position, float maxRadius, out int id)
Parameters
Type |
Name |
Description |
Unity.Mathematics.float2 |
position |
|
System.Single |
maxRadius |
|
System.Int32 |
id |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
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 |
System.Collections.Generic.List<Unity.Mathematics.float2> |
verts |
|
System.Collections.Generic.List<AnyPath.Graphs.PlatformerGraph.Edge> |
undirectedIndices |
|
System.Collections.Generic.List<AnyPath.Graphs.PlatformerGraph.Edge> |
directedIndices |
|
|
Improve this Doc
View Source
Declaration
public PlatformerGraphBuilder.ProtoEdge GetEdge(int index)
Parameters
Type |
Name |
Description |
System.Int32 |
index |
|
Returns
|
Improve this Doc
View Source
Returns the position of the vertex with a given Id
Declaration
public float2 GetVertex(int id)
Parameters
Type |
Name |
Description |
System.Int32 |
id |
|
Returns
Type |
Description |
Unity.Mathematics.float2 |
|
|
Improve this Doc
View Source
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 |
System.Int32 |
a |
|
System.Int32 |
b |
|
|
Improve this Doc
View Source
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)
Parameters
Type |
Name |
Description |
System.Int32 |
a |
|
System.Int32 |
b |
|
System.Single |
enterCost |
Additional cost associated with entering this edge in a path
|
System.Int32 |
flags |
Flags that can be used to filter the edge being traversable
|
|
Improve this Doc
View Source
Links two vertices together creating a traversable edge in both directions
Declaration
public void LinkUndirected(int a, int b)
Parameters
Type |
Name |
Description |
System.Int32 |
a |
|
System.Int32 |
b |
|
|
Improve this Doc
View Source
Links two vertices together creating a traversable edge in both directions
Declaration
public void LinkUndirected(int a, int b, float enterCost, int flags)
Parameters
Type |
Name |
Description |
System.Int32 |
a |
|
System.Int32 |
b |
|
System.Single |
enterCost |
Additional cost associated with entering this edge in a path
|
System.Int32 |
flags |
Flags that can be used to filter the edge being traversable
|
|
Improve this Doc
View Source
Moves a set of vertices to their new positions
Declaration
public void MoveVertices(IEnumerable<int> ids, Func<int, Vector2> positionPerId)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<System.Int32> |
ids |
|
System.Func<System.Int32, UnityEngine.Vector2> |
positionPerId |
|
|
Improve this Doc
View Source
Declaration
public void OverlapEdges(AABB2D aabb, List<int> edgeIndices)
Parameters
Type |
Name |
Description |
AABB2D |
aabb |
|
System.Collections.Generic.List<System.Int32> |
edgeIndices |
|
|
Improve this Doc
View Source
Clears and fills overlappedIds with the Id's of vertices that overlap with the given rectangle
Declaration
public void OverlapVertices(AABB2D aabb, List<int> overlappedIds)
Parameters
Type |
Name |
Description |
AABB2D |
aabb |
|
System.Collections.Generic.List<System.Int32> |
overlappedIds |
|
|
Improve this Doc
View Source
Declaration
public bool RaycastEdge(Ray2D ray, out int edgeIndex, out Vector2 hitPoint)
Parameters
Type |
Name |
Description |
UnityEngine.Ray2D |
ray |
|
System.Int32 |
edgeIndex |
|
UnityEngine.Vector2 |
hitPoint |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Declaration
public void RemoveEdge(int edgeIndex)
Parameters
Type |
Name |
Description |
System.Int32 |
edgeIndex |
|
|
Improve this Doc
View Source
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 |
System.Int32 |
id |
|
Unity.Mathematics.float2 |
pos |
|
Implements
System.IDisposable
Extension Methods