public void SetNeighbors (bool force=false) { #if WDEBUG Profiler.BeginSample("Set Neighbors"); #endif ChunkGrid<Chunk> chunks = MapMagic.instance.chunks; if (terrain == null || terrain.terrainData == null || terrain.terrainData.heightmapResolution < 64) { #if WDEBUG Profiler.EndSample(); #endif return; } Chunk newNeig_x_chunk = chunks[coord.x-1, coord.z]; Terrain newNeig_x = (newNeig_x_chunk!= null && newNeig_x_chunk.worker.ready)? newNeig_x_chunk.terrain : null; Chunk newNeig_Z_chunk = chunks[coord.x, coord.z+1]; Terrain newNeig_Z = (newNeig_Z_chunk!= null && newNeig_Z_chunk.worker.ready)? newNeig_Z_chunk.terrain : null; Chunk newNeig_X_chunk = chunks[coord.x+1, coord.z]; Terrain newNeig_X = (newNeig_X_chunk!= null && newNeig_X_chunk.worker.ready)? newNeig_X_chunk.terrain : null; Chunk newNeig_z_chunk = chunks[coord.x, coord.z-1]; Terrain newNeig_z = (newNeig_z_chunk!= null && newNeig_z_chunk.worker.ready)? newNeig_z_chunk.terrain : null; if (oldNeig_x != newNeig_x || oldNeig_Z != newNeig_Z || oldNeig_X != newNeig_X || oldNeig_z != newNeig_z || force) { terrain.SetNeighbors( newNeig_x, newNeig_Z, newNeig_X, newNeig_z ); oldNeig_x = newNeig_x; oldNeig_Z = newNeig_Z; oldNeig_X = newNeig_X; oldNeig_z = newNeig_z; } #if WDEBUG Profiler.EndSample(); #endif }