public override void ErodeWalkableArea (int xmin, int zmin, int xmax, int zmax) {
//Clamp values to grid
xmin = xmin < 0 ? 0 : (xmin > width ? width : xmin);
xmax = xmax < 0 ? 0 : (xmax > width ? width : xmax);
zmin = zmin < 0 ? 0 : (zmin > depth ? depth : zmin);
zmax = zmax < 0 ? 0 : (zmax > depth ? depth : zmax);
if (erosionUseTags) {
Debug.LogError ("Erosion Uses Tags is not supported for LayerGridGraphs yet");
}
for (int it=0;it < erodeIterations;it++) {
for (int l=0;l<layerCount;l++) {
for (int z = zmin; z < zmax; z ++) {
for (int x = xmin; x < xmax; x++) {
LevelGridNode node = nodes[z*width+x + width*depth*l] as LevelGridNode;
if (node == null) continue;
if (!node.Walkable) {
/*int index = node.GetIndex ();
for (int i=0;i<4;i++) {
int conn = node.GetConnectionValue (i);
/** \todo Add constant for 0xF - InvalidConnection *
if (conn != 0xF) {
nodes[index+neighbourOffsets[i] + width*depth*conn].walkable = false;
}
}*/
} else {
bool anyFalseConnections = false;
for (int i=0;i<4;i++) {
if (!node.GetConnection (i)) {
anyFalseConnections = true;
break;
}
}
if (anyFalseConnections) {
node.Walkable = false;
}
}
}
}
}
//Recalculate connections
for (int l=0;l<layerCount;l++) {
for (int z = zmin; z < zmax; z ++) {
for (int x = xmin; x < xmax; x++) {
LevelGridNode node = nodes[z*width+x + width*depth*l];
if (node == null) continue;
CalculateConnections (nodes,node,x,z,l);
}
}
}
}
}