public void Initialize( WorldBuilder worldBuilder, WorldChunk parent, EDirection parentDirection) { _worldBuilder = worldBuilder; Vector3 newChunkPosition = Vector3.zero; if (parent != null) { _neighbors[parentDirection] = parent; EDirection newChunkDirection = worldBuilder.GetInverseDirection(parentDirection); newChunkPosition = parent.transform.position; newChunkPosition += worldBuilder.ChunkStep * worldBuilder.DirectionToVector(newChunkDirection); parent.SetNeighbor(this, newChunkDirection); var surroundingNeihbors = worldBuilder.CheckSurroundingNeighbors(newChunkPosition, parentDirection); foreach (var chunkPair in surroundingNeihbors) { SetNeighbor(chunkPair.Value, chunkPair.Key); chunkPair.Value.SetNeighbor(this, worldBuilder.GetInverseDirection(chunkPair.Key)); //Debug.Log($"Added neighbor to the {chunkPair.Key} => {chunkPair.Value.name}"); } } gameObject.name = $"({newChunkPosition.x}, {newChunkPosition.z})"; transform.position = newChunkPosition; GenerateResources(); // Don't generate enemies for the first chunk if (parent != null) { GenerateEnemies(); } GenerateEnvironment(); //_navMeshSurface.BuildNavMesh(); }