public NodeState GetNode(string cacheName,int x, int y,int z,Block associatedBlock,IPathfindingAgent agent) { var cache = nodes [cacheName]; if (cache [x, y, z] == null) { cache [x, y, z] = new NodeState (this, x, y, z, cacheName, associatedBlock); var connected = associatedBlock.getConnected (); for (int i = 0; i < connected.Length; i++) { int xPos = (int)connected [i].block.intPosition.x; int yPos = (int)connected [i].block.intPosition.y; int zPos = (int)connected [i].block.intPosition.z; if (cache [xPos, yPos, zPos] != null) { UpdateBlock (cacheName, xPos, yPos, zPos, cache [xPos, yPos, zPos].AssocaitedBlock.getConnected (), agent); } } UpdateBlock (cacheName, x, y, z, connected, agent); } return cache [x, y, z]; }