Exemplo n.º 1
0
 public void GatherData(Func <IntVector3, ChunkGenData> GetChunk)
 {
     foreach (var chunkPos in CubeNeighbors6.NeighborsOfIncludingCenter(center))
     {
         neighbors.Set(chunkPos, GetChunk(chunkPos));
     }
 }
Exemplo n.º 2
0
 public async Task <NeighborChunkGenData> GatherDataAsync(Func <IntVector3, Task <ChunkGenData> > GetChunkAtAsync)
 {
     foreach (var chunkPos in CubeNeighbors6.NeighborsOfIncludingCenter(center))
     {
         neighbors.Set(chunkPos, await GetChunkAtAsync(chunkPos));
     }
     return(this);
 }
Exemplo n.º 3
0
 public T this[int i] {
     get {
         return(this[center + CubeNeighbors6.Relative(i)]);
     }
     set {
         this[center + CubeNeighbors6.Relative(i)] = value;
     }
 }
Exemplo n.º 4
0
 public T this[NeighborDirection nd] {
     get {
         return(this[center + CubeNeighbors6.Relative(nd)]);
     }
     set {
         this[center + CubeNeighbors6.Relative(nd)] = value;
     }
 }
Exemplo n.º 5
0
 public bool Get(IntVector3 candidate, out T item)
 {
     if (candidate.Equal(center) || CubeNeighbors6.IsNeighbor(center, candidate))
     {
         if (storage.ContainsKey(candidate))
         {
             item = storage[candidate];
             return(true);
         }
     }
     item = default(T);
     return(false);
 }
Exemplo n.º 6
0
            public void Execute(int index)
            {
                var  pos             = IntVector3.FromUint256(displayVoxels[index].voxel);
                bool hidden          = false;
                int  div             = (int)Mathf.Pow(2, lodIndex);
                var  touchDirections = CubeNeighbors6.TouchFaces(pos / div, chunkSize / div).ToList();

                foreach (var nd in touchDirections)
                {
                    hidden = true;
                    var  oppDir = CubeNeighbors6.Opposite(nd);
                    var  opp    = CubeNeighbors6.SnapToFace(pos / div, chunkSize / div, oppDir);
                    uint voxel  = GetVoxelFromGenDataArray(get(nd), opp);

                    if (voxel == EmptyVoxel)
                    {
                        hidden = false;
                        break;
                    }
                }
                if (hidden)
                {
                    foreach (var nd in CubeNeighbors6.Directions)
                    {
                        if (touchDirections.Contains(nd))
                        {
                            continue;
                        }

                        var  nudge = pos / div + CubeNeighbors6.Relative(nd);
                        uint voxel = GetVoxelFromGenDataArray(center, nudge);

                        if (voxel == EmptyVoxel)
                        {
                            hidden = false;
                            break;
                        }
                    }
                }

                if (hidden)
                {
                    var geomData = displayVoxels[index];
                    geomData.voxel       = EmptyVoxel;
                    displayVoxels[index] = geomData;
                }
            }
Exemplo n.º 7
0
 public bool Set(IntVector3 candidate, T item)
 {
     if (CubeNeighbors6.IsNeighbor(center, candidate) || candidate.Equal(center))
     {
         if (storage.ContainsKey(candidate))
         {
             storage[candidate] = item;
         }
         else
         {
             storage.Add(candidate, item);
         }
         return(true);
     }
     item = default(T);
     return(false);
 }
Exemplo n.º 8
0
 public T this[IntVector3 key] {
     get {
         if (storage.ContainsKey(key))
         {
             return(storage[key]);
         }
         return(default(T));
     }
     set {
         if (storage.ContainsKey(key))
         {
             storage[key] = value;
         }
         else if (center.Equal(key) || CubeNeighbors6.IsNeighbor(center, key))
         {
             storage.Add(key, value);
         }
     }
 }
Exemplo n.º 9
0
        static VoxelGeomDataMirror[] StairsVGeom(IntVector3 size, int verticalOffset = 0)
        {
            var result = new List <VoxelGeomDataMirror>(size.Area);

            foreach (var vi in size.IteratorXYZ)
            {
                if (vi.v.x + vi.v.y < size.x + verticalOffset)
                {
                    if (CubeNeighbors6.IsOnFace(vi.v, size) || vi.v.x + vi.v.y == size.x + verticalOffset - 1)
                    {
                        result.Add(new VoxelGeomDataMirror
                        {
                            voxel = vi.v.ToVoxel(2)
                        });
                    }
                }
            }

            return(result.ToArray());
        }
Exemplo n.º 10
0
 public bool Contains(NeighborDirection nd)
 {
     return(storage.ContainsKey(center + CubeNeighbors6.Relative(nd)));
 }