当前位置: 首页>>代码示例>>C#>>正文


C# Chunk.BlockIndex方法代码示例

本文整理汇总了C#中Chunk.BlockIndex方法的典型用法代码示例。如果您正苦于以下问题:C# Chunk.BlockIndex方法的具体用法?C# Chunk.BlockIndex怎么用?C# Chunk.BlockIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chunk的用法示例。


在下文中一共展示了Chunk.BlockIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SpecialSetBlockAt

 void SpecialSetBlockAt(Chunk chunk, int X, int Y, int Z, BlockInternal bi)
 {
     if (X < 0 || Y < 0 || Z < 0 || X >= Chunk.CHUNK_SIZE || Y >= Chunk.CHUNK_SIZE || Z >= Chunk.CHUNK_SIZE)
     {
         Vector3i chloc = chunk.OwningRegion.ChunkLocFor(new Location(X, Y, Z));
         Chunk ch = chunk.OwningRegion.LoadChunkNoPopulate(chunk.WorldPosition + chloc);
         int x = (int)(X - chloc.X * Chunk.CHUNK_SIZE);
         int y = (int)(Y - chloc.Y * Chunk.CHUNK_SIZE);
         int z = (int)(Z - chloc.Z * Chunk.CHUNK_SIZE);
         BlockInternal orig = ch.GetBlockAt(x, y, z);
         BlockFlags flags = ((BlockFlags)orig.BlockLocalData);
         if (!flags.HasFlag(BlockFlags.EDITED) && !flags.HasFlag(BlockFlags.PROTECTED))
         {
             // TODO: lock?
             ch.BlocksInternal[chunk.BlockIndex(x, y, z)] = bi;
         }
     }
     else
     {
         BlockInternal orig = chunk.GetBlockAt(X, Y, Z);
         BlockFlags flags = ((BlockFlags)orig.BlockLocalData);
         if (!flags.HasFlag(BlockFlags.EDITED) && !flags.HasFlag(BlockFlags.PROTECTED))
         {
             chunk.BlocksInternal[chunk.BlockIndex(X, Y, Z)] = bi;
         }
     }
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:27,代码来源:SimpleGeneratorCore.cs

示例2: PopulateInternal

 private void PopulateInternal(int Seed, int seed2, int seed3, int seed4, int seed5, Chunk chunk)
 {
     #endif
     if (chunk.OwningRegion.TheWorld.Flat)
     {
         if (chunk.WorldPosition.Z == 0)
         {
             for (int i = 0; i < chunk.BlocksInternal.Length; i++)
             {
                 chunk.BlocksInternal[i] = new BlockInternal((ushort)Material.STONE, 0, 0, 0);
             }
             for (int x = 0; x < Chunk.CHUNK_SIZE; x++)
             {
                 for (int y = 0; y < Chunk.CHUNK_SIZE; y++)
                 {
                     chunk.BlocksInternal[chunk.BlockIndex(x, y, Chunk.CHUNK_SIZE - 1)] = new BlockInternal((ushort)Material.GRASS_PLAINS, 0, 0, 0);
                     chunk.BlocksInternal[chunk.BlockIndex(x, y, Chunk.CHUNK_SIZE - 2)] = new BlockInternal((ushort)Material.DIRT, 0, 0, 0);
                     chunk.BlocksInternal[chunk.BlockIndex(x, y, Chunk.CHUNK_SIZE - 3)] = new BlockInternal((ushort)Material.DIRT, 0, 0, 0);
                 }
             }
         }
         else if (chunk.WorldPosition.Z < 0)
         {
             for (int i = 0; i < chunk.BlocksInternal.Length; i++)
             {
                 chunk.BlocksInternal[i] = new BlockInternal((ushort)Material.STONE, 0, 0, 0);
             }
         }
         else
         {
             for (int i = 0; i < chunk.BlocksInternal.Length; i++)
             {
                 chunk.BlocksInternal[i] = BlockInternal.AIR;
             }
         }
         return;
     }
     if (chunk.WorldPosition.Z > MaxNonAirHeight)
     {
         for (int i = 0; i < chunk.BlocksInternal.Length; i++)
         {
             chunk.BlocksInternal[i] = BlockInternal.AIR;
         }
         return;
     }
     // TODO: Special case for too far down as well.
     for (int x = 0; x < Chunk.CHUNK_SIZE; x++)
     {
         for (int y = 0; y < Chunk.CHUNK_SIZE; y++)
         {
             Location cpos = chunk.WorldPosition.ToLocation() * Chunk.CHUNK_SIZE;
             // Prepare basics
             int cx = (int)cpos.X + x;
             int cy = (int)cpos.Y + y;
             Biome biomeOrig;
             double hheight = GetHeight(Seed, seed2, seed3, seed4, seed5, cx, cy, (double)cpos.Z, out biomeOrig);
             SimpleBiome biome = (SimpleBiome)biomeOrig;
             //Biome biomeOrig2;
             /*double hheight2 = */
             /*GetHeight(Seed, seed2, seed3, seed4, seed5, cx + 7, cy + 7, (double)cpos.Z + 7, out biomeOrig2);
             SimpleBiome biome2 = (SimpleBiome)biomeOrig2;*/
             Material surf = biome.SurfaceBlock();
             Material seco = biome.SecondLayerBlock();
             Material basb = biome.BaseBlock();
             Material water = biome.WaterMaterial();
             /*Material surf2 = biome2.SurfaceBlock();
             Material seco2 = biome2.SecondLayerBlock();
             Material basb2 = biome2.BaseBlock();*/
             // TODO: Make this possible?: hheight = (hheight + hheight2) / 2f;
             int hheightint = (int)Math.Round(hheight);
             double topf = hheight - (double)(chunk.WorldPosition.Z * Chunk.CHUNK_SIZE);
             int top = (int)Math.Round(topf);
             // General natural ground
             for (int z = 0; z < Math.Min(top - 5, Chunk.CHUNK_SIZE); z++)
             {
                 if (CanBeSolid(seed3, seed4, seed5, cx, cy, (int)cpos.Z + z, biome))
                 {
                     Material typex = GetMatType(seed2, seed3, seed4, seed5, cx, cy, (int)cpos.Z + z);
                     byte shape = 0;
                     if (typex != Material.AIR)
                     {
                         shape = OreShapes[new Random((int)((hheight + cx + cy + cpos.Z + z) * 5)).Next(OreShapes.Length)];
                     }
                     //bool choice = SimplexNoise.Generate(cx / 10f, cy / 10f, ((double)cpos.Z + z) / 10f) >= 0.5f;
                     chunk.BlocksInternal[chunk.BlockIndex(x, y, z)] = new BlockInternal((ushort)(typex == Material.AIR ? (/*choice ? basb2 : */basb) : typex), shape, 0, 0);
                 }
                 else if ((CanBeSolid(seed3, seed4, seed5, cx, cy, (int)cpos.Z + z - 1, biome) || (CanBeSolid(seed3, seed4, seed5, cx, cy, (int)cpos.Z + z + 1, biome))) &&
                     (CanBeSolid(seed3, seed4, seed5, cx + 1, cy, (int)cpos.Z + z, biome) || CanBeSolid(seed3, seed4, seed5, cx, cy + 1, (int)cpos.Z + z, biome)
                         || CanBeSolid(seed3, seed4, seed5, cx - 1, cy, (int)cpos.Z + z, biome) || CanBeSolid(seed3, seed4, seed5, cx, cy - 1, (int)cpos.Z + z, biome)))
                 {
                     //bool choice = SimplexNoise.Generate(cx / 10f, cy / 10f, ((double)cpos.Z + z) / 10f) >= 0.5f;
                     chunk.BlocksInternal[chunk.BlockIndex(x, y, z)] = new BlockInternal((ushort)(/*choice ? basb2 : */basb), 3, 0, 0);
                 }
             }
             for (int z = Math.Max(top - 5, 0); z < Math.Min(top - 1, Chunk.CHUNK_SIZE); z++)
             {
                 if (CanBeSolid(seed3, seed4, seed5, cx, cy, (int)cpos.Z + z, biome))
                 {
                     //bool choice = SimplexNoise.Generate(cx / 10f, cy / 10f, ((double)cpos.Z + z) / 10f) >= 0.5f;
                     chunk.BlocksInternal[chunk.BlockIndex(x, y, z)] = new BlockInternal((ushort)(/*choice ? seco2 :*/ seco), 0, 0, 0);
//.........这里部分代码省略.........
开发者ID:Morphan1,项目名称:Voxalia,代码行数:101,代码来源:SimpleGeneratorCore.cs


注:本文中的Chunk.BlockIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。