本文整理汇总了C#中Chunk.SetAllBlocks方法的典型用法代码示例。如果您正苦于以下问题:C# Chunk.SetAllBlocks方法的具体用法?C# Chunk.SetAllBlocks怎么用?C# Chunk.SetAllBlocks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chunk
的用法示例。
在下文中一共展示了Chunk.SetAllBlocks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProvideChunk
private Chunk ProvideChunk(int x, int z, Chunk chunk)
{
/*Stopwatch watch = new Stopwatch();
watch.Start();*/
InitGen();
byte[] data = new byte[32768];
double[, ,] density = new double[17, 129, 17];
for (int bx = 0; bx <= 16; bx += 4)
{
int worldX = bx + (x * 16);
for (int bz = 0; bz <= 16; bz += 4)
{
BIOME_TYPE type = CalcBiomeType((int)x, (int)z);
int worldZ = bz + (z * 16);
for (int by = 0; by <= 128; by += 8)
{
density[bx, by, bz] = CalcDensity(worldX, by, worldZ, type);
}
}
}
triLerpDensityMap(density);
for (int bx = 0; bx < 16; bx++)
{
int worldX = bx + (x * 16);
for (int bz = 0; bz < 16; bz++)
{
int worldZ = bz + (z * 16);
int firstBlockHeight = -1;
BIOME_TYPE type = CalcBiomeType(worldX, worldZ);
for (int by = 127; by >= 0; --by)
{
if (by <= 55)
data[bx << 11 | bz << 7 | by] = (byte)BlockData.Blocks.Stone;
else
{
if (by > 55 && by < 64)
{
data[bx << 11 | bz << 7 | by] = (byte)BlockData.Blocks.Still_Water;
if (by == 63 && type == BIOME_TYPE.SNOW)
{
data[bx << 11 | bz << 7 | by] = (byte)BlockData.Blocks.Ice;
}
}
double dens = density[bx, by, bz];
if (dens >= 0.009 && dens <= 0.02)
{
// Some block was set...
if (firstBlockHeight == -1)
firstBlockHeight = by;
GenerateOuterLayer(bx, by, bz, firstBlockHeight, type, data);
}
else if (dens > 0.02)
{
// Some block was set...
if (firstBlockHeight == -1)
firstBlockHeight = by;
GenerateInnerLayer(bx, by, bz, type, data);
}
}
}
}
}
//watch.Stop();
//Console.WriteLine(watch.ElapsedMilliseconds);
chunk.SetAllBlocks(data);
return chunk;
}