Ejemplo n.º 1
0
    private void AddChunk(Chunk chunk)
    {
        var at = chunk.Position();

        if (chunks.ContainsKey(at))
        {
            GD.PushError("Error! Can't add chunk at (" +
                         at.x + ", " + at.y + ", " + at.z +
                         ") since there is already a chunk with that position."
                         );
        }
        else
        {
            chunks.Add(at, chunk);

            for (int i = 0; i < 6; i++)
            {
                var direction = (Direction)i;
                var opposite  = (Direction)(i % 2 == 0 ? i + 1 : i - 1);
                WithChunk(at.Step(direction), other =>
                {
                    chunk.AddNeighbour(direction, other);
                    other.AddNeighbour(opposite, chunk);
                });
            }
        }
    }