}
}
// progress zlevels
// up is only available if we are the center of our chunk
if (selfPointNodeRef.pointNodeCoord.equals(Vector2.Zero)) {
let upZLevel = worldGen.zLevels[selfPointNodeRef.z + 1];
if (upZLevel) {
// use our chunkcoord and divide by CHUNK_DIM
let chunkCoord = selfPointNodeRef.chunkCoord;
let upChunkCoordX = Math.round(chunkCoord.x / ChunkGenConstants.CHUNK_DIM)
let upNodeX = chunkCoord.x - ChunkGenConstants.CHUNK_DIM * upChunkCoordX // should be between - CHUNK_HALF_DIM and CHUNK_HALF_DIM
let upChunkCoordY = Math.round(chunkCoord.y / ChunkGenConstants.CHUNK_DIM)
let upNodeY = chunkCoord.y - ChunkGenConstants.CHUNK_DIM * upChunkCoordX // should be between - CHUNK_HALF_DIM and CHUNK_HALF_DIM
let upChunkCoord = new Vector2(upChunkCoordX, upChunkCoordY);
let upChunk = upZLevel.chunks.get(upChunkCoord);
if (upChunk) {
let upNode = new Vector2(upNodeX, upNodeY);
let nbor = upChunk.pointNodes.get(upNode)
if (nbor) {
neighbors.UP = new PointNodeRef({
z: selfPointNodeRef.z + 1,
chunkCoord: upChunkCoord,
pointNodeCoord: upNode,
pointNodeId: nbor.id
});
}
}
}
}
// down
let downZLevel = worldGen.zLevels[selfPointNodeRef.z - 1];
if (downZLevel) {
let chunkCoord = selfPointNodeRef.chunkCoord.multiply(9).add(selfPointNodeRef.pointNodeCoord);
let downChunk = downZLevel.chunks.get(chunkCoord);
if (downChunk) {
let nbor = downChunk.pointNodes.get(Vector2.Zero);
if (nbor) {
neighbors.DOWN = new PointNodeRef({
z: selfPointNodeRef.z - 1,
chunkCoord,
pointNodeCoord: Vector2.Zero,
pointNodeId: nbor.id
});
}