Extending Node class to store extra metadata

Hey there, I’m using a grid graph in my game. I would really like to somehow extend the GridNode class to store more meta-data about the node to support systems within my game. Is there any way to do this? I have currently created a new class that keeps a 1:1 map of node meta-data that corresponds to the GridGraph list of nodes; but using it this way has become cumbersome and error prone. Thoughts?

Hey,

You could just make a class CustomGridNode. And modify the gridgenerator to fit your needs.

By using source control like git, you can save your changes as a patch. To be used in case you update to a newer version of A*

Something like this?

public class GridNodeExtended: GraphNode {
         private metaData;

         public GridObject(String metaData, AstarPath astar) : base(astar) {
            this.metaData = metaData;
    }

   
       public override void GetConnections(Action<GraphNode> action) {
        throw new NotImplementedException();
    }

    public override void AddConnection(GraphNode node, uint cost) {
        throw new NotImplementedException();
    }

    public override void RemoveConnection(GraphNode node) {
        throw new NotImplementedException();
    }

    public override void ClearConnections(bool alsoReverse) {
        throw new NotImplementedException();
    }

    public override void Open(Path path, PathNode pathNode, PathHandler handler) {
        throw new NotImplementedException();
    }

    public override Vector3 ClosestPointOnNode(Vector3 p) {
        throw new NotImplementedException();
    }
}