public void GatherData(Func <IntVector3, ChunkGenData> GetChunk)
 {
     foreach (var chunkPos in CubeNeighbors6.NeighborsOfIncludingCenter(center))
     {
         neighbors.Set(chunkPos, GetChunk(chunkPos));
     }
 }
 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);
 }
 public T this[int i] {
     get {
         return(this[center + CubeNeighbors6.Relative(i)]);
     }
     set {
         this[center + CubeNeighbors6.Relative(i)] = value;
     }
 }
 public T this[NeighborDirection nd] {
     get {
         return(this[center + CubeNeighbors6.Relative(nd)]);
     }
     set {
         this[center + CubeNeighbors6.Relative(nd)] = value;
     }
 }
 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);
 }
Exemple #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;
                }
            }
 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);
 }
 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);
         }
     }
 }
Exemple #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());
        }
Exemple #10
0
 public bool Contains(NeighborDirection nd)
 {
     return(storage.ContainsKey(center + CubeNeighbors6.Relative(nd)));
 }