本文整理汇总了C#中BlockPos.Add方法的典型用法代码示例。如果您正苦于以下问题:C# BlockPos.Add方法的具体用法?C# BlockPos.Add怎么用?C# BlockPos.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlockPos
的用法示例。
在下文中一共展示了BlockPos.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OldBuild
public void OldBuild(World world, BlockPos chunkPos, BlockPos pos, OldTerrainGen gen)
{
int leaves = gen.GetNoise(pos.x, 0, pos.z, 1f, 2, 1) + 1;
pos = pos.Add(chunkPos);
for (int x = -leaves; x <= leaves; x++)
{
for (int y = 3; y <= 6; y++)
{
for (int z = -leaves; z <= leaves; z++)
{
if (Chunk.InRange(pos.x + x - chunkPos.x) && Chunk.InRange(pos.z + z - chunkPos.z))
{
Block block = "leaves";
block.modified = false;
world.SetBlock(pos.Add(x, y, z), block, false);
}
}
}
}
for (int y = 0; y <= 5; y++)
{
if (y < Config.Env.WorldMaxY)
{
Block block = "log";
block.modified = false;
world.SetBlock(pos.Add(0, y, 0), block, false);
}
}
}
示例2: RandomUpdate
//On random update spread grass to any nearby dirt blocks on the surface
public override void RandomUpdate(Chunk chunk, BlockPos pos, Block block)
{
for (int x = -1; x <= 1; x++)
{
for (int y = -1; y <= 1; y++)
{
for (int z = -1; z <= 1; z++)
{
if (chunk.GetBlock(pos.Add(x, y, z) - chunk.pos) == dirt
&& chunk.GetBlock(pos.Add(x, y + 1, z) - chunk.pos) == air)
{
chunk.SetBlock(pos.Add(x, y, z) - chunk.pos, "grass", false);
chunk.SetFlag(Chunk.Flag.updateSoon, true);
}
}
}
}
}
示例3: Build
public static void Build(Chunk chunk, BlockPos pos, TerrainGen terrainGen)
{
int leaves = terrainGen.GetNoise(pos.x + chunk.pos.x, 0, pos.z + chunk.pos.z, 1f, 2, 1) +1;
for (int x = -leaves; x <= leaves; x++)
{
for (int y = 3; y <= 6; y++)
{
for (int z = -leaves; z <= leaves; z++)
{
TerrainGen.SetBlock(chunk, "leaves", pos.Add(x,y,z), true);
}
}
}
for (int y = 0; y <= 5; y++)
{
TerrainGen.SetBlock(chunk, "log", pos.Add(0, y, 0), true);
}
}
示例4: IsWalkable
public static bool IsWalkable(World world, BlockPos pos)
{
if(!world.GetBlock(pos).controller.IsSolid(Direction.up))
return false;
for(int y = 1; y< characterHeight+1; y++){
if (world.GetBlock(pos.Add(0,y,0)).GetType() != typeof(BlockAir))
return false;
}
return true;
}
示例5: IsWalkable
public bool IsWalkable(World world, BlockPos pos)
{
Block block = world.GetBlock(pos);
if (!block.controller.CanBeWalkedOn(block))
return false;
for (int y = 1; y < entityHeight + 1; y++) {
block = world.GetBlock(pos.Add(0, y, 0));
if (!block.controller.CanBeWalkedThrough(block)) {
return false;
}
}
return true;
}
示例6: GenerateTerrainForChunkColumn
public void GenerateTerrainForChunkColumn(BlockPos pos)
{
if (Config.Toggle.UseOldTerrainGen)
{
if (oldTerrainGen == null)
oldTerrainGen = new OldTerrainGen(noiseGen);
for (int y = Config.Env.WorldMinY; y < Config.Env.WorldMaxY; y += Config.Env.ChunkSize)
{
Chunk chunk = world.GetChunk(pos.Add(0, y, 0));
if(chunk != null)
oldTerrainGen.ChunkGen(chunk);
for (int x = 0; x < Config.Env.ChunkSize; x++)
{
for (int z = 0; z < Config.Env.ChunkSize; z++)
{
}
}
}
}
else
{
for (int x = pos.x; x < pos.x + Config.Env.ChunkSize; x++)
{
for (int z = pos.z; z < pos.z + Config.Env.ChunkSize; z++)
{
GenerateTerrainForBlockColumn(x, z);
}
}
GenerateStructuresForChunk(pos);
}
}
示例7: AddBlockData
public override void AddBlockData(Chunk chunk, BlockPos pos, MeshData meshData, Block block)
{
if (!chunk.GetBlock(pos.Add(0, 1, 0)).controller.IsSolid(BlockDirection.down))
BuildFace(chunk, pos, meshData, BlockDirection.up, block);
if (!chunk.GetBlock(pos.Add(0, -1, 0)).controller.IsSolid(BlockDirection.up))
BuildFace(chunk, pos, meshData, BlockDirection.down, block);
if (!chunk.GetBlock(pos.Add(0, 0, 1)).controller.IsSolid(BlockDirection.south))
BuildFace(chunk, pos, meshData, BlockDirection.north, block);
if (!chunk.GetBlock(pos.Add(0, 0, -1)).controller.IsSolid(BlockDirection.north))
BuildFace(chunk, pos, meshData, BlockDirection.south, block);
if (!chunk.GetBlock(pos.Add(1, 0, 0)).controller.IsSolid(BlockDirection.west))
BuildFace(chunk, pos, meshData, BlockDirection.east, block);
if (!chunk.GetBlock(pos.Add(-1, 0, 0)).controller.IsSolid(BlockDirection.east))
BuildFace(chunk, pos, meshData, BlockDirection.west, block);
}
示例8: AddBlockData
public override void AddBlockData(Chunk chunk, BlockPos pos, MeshData meshData, Block block)
{
if ((isSolid || !solidTowardsSameType || chunk.GetBlock(pos.Add(0, 1, 0)) != block))
BuildFace(chunk, pos, meshData, Direction.up, block);
if ((isSolid || !solidTowardsSameType || chunk.GetBlock(pos.Add(0, -1, 0)) != block))
BuildFace(chunk, pos, meshData, Direction.down, block);
if ((isSolid || !solidTowardsSameType || chunk.GetBlock(pos.Add(0, 0, 1)) != block))
BuildFace(chunk, pos, meshData, Direction.north, block);
if ((isSolid || !solidTowardsSameType || chunk.GetBlock(pos.Add(0, 0, -1)) != block))
BuildFace(chunk, pos, meshData, Direction.south, block);
if ((isSolid || !solidTowardsSameType || chunk.GetBlock(pos.Add(1, 0, 0)) != block))
BuildFace(chunk, pos, meshData, Direction.east, block);
if ((isSolid || !solidTowardsSameType || chunk.GetBlock(pos.Add(-1, 0, 0)) != block))
BuildFace(chunk, pos, meshData, Direction.west, block);
}
示例9: RelativePos
public static BlockPos RelativePos(BlockPos pos, int h, int v, Direction forwards)
{
switch (forwards)
{
case Direction.up:
return pos.Add(v, 0, h);
case Direction.down:
return pos.Add(v, 0, -h);
case Direction.north:
return pos.Add(h, v, 0);
case Direction.south:
return pos.Add(-h, v, 0);
case Direction.east:
return pos.Add(0, v, -h);
case Direction.west:
return pos.Add(0, v, h);
default:
return pos;
}
}
示例10: BuildColors
public static void BuildColors(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction)
{
bool nSolid = false;
bool eSolid = false;
bool sSolid = false;
bool wSolid = false;
bool wnSolid = false;
bool neSolid = false;
bool esSolid = false;
bool swSolid = false;
float light = 0;
switch (direction)
{
case Direction.up:
nSolid = chunk.GetBlock(pos.Add(0, 1, 1)).controller.IsSolid(Direction.south);
eSolid = chunk.GetBlock(pos.Add(1, 1, 0)).controller.IsSolid(Direction.west);
sSolid = chunk.GetBlock(pos.Add(0, 1, -1)).controller.IsSolid(Direction.north);
wSolid = chunk.GetBlock(pos.Add(-1, 1, 0)).controller.IsSolid(Direction.east);
wnSolid = chunk.GetBlock(pos.Add(-1, 1, 1)).controller.IsSolid(Direction.east) && chunk.GetBlock(pos.Add(-1, 1, 1)).controller.IsSolid(Direction.south);
neSolid = chunk.GetBlock(pos.Add(1, 1, 1)).controller.IsSolid(Direction.south) && chunk.GetBlock(pos.Add(1, 1, 1)).controller.IsSolid(Direction.west);
esSolid = chunk.GetBlock(pos.Add(1, 1, -1)).controller.IsSolid(Direction.west) && chunk.GetBlock(pos.Add(1, 1, -1)).controller.IsSolid(Direction.north);
swSolid = chunk.GetBlock(pos.Add(-1, 1, -1)).controller.IsSolid(Direction.north) && chunk.GetBlock(pos.Add(-1, 1, -1)).controller.IsSolid(Direction.east);
light = chunk.GetBlock(pos.Add(0, 1, 0)).data1 / 255f;
break;
case Direction.down:
nSolid = chunk.GetBlock(pos.Add(0, -1, -1)).controller.IsSolid(Direction.south);
eSolid = chunk.GetBlock(pos.Add(1, -1, 0)).controller.IsSolid(Direction.west);
sSolid = chunk.GetBlock(pos.Add(0, -1, 1)).controller.IsSolid(Direction.north);
wSolid = chunk.GetBlock(pos.Add(-1, -1, 0)).controller.IsSolid(Direction.east);
wnSolid = chunk.GetBlock(pos.Add(-1, -1, -1)).controller.IsSolid(Direction.east) && chunk.GetBlock(pos.Add(-1, -1, -1)).controller.IsSolid(Direction.south);
neSolid = chunk.GetBlock(pos.Add(1, -1, -1)).controller.IsSolid(Direction.south) && chunk.GetBlock(pos.Add(1, -1, -1)).controller.IsSolid(Direction.west);
esSolid = chunk.GetBlock(pos.Add(1, -1, 1)).controller.IsSolid(Direction.west) && chunk.GetBlock(pos.Add(1, -1, 1)).controller.IsSolid(Direction.north);
swSolid = chunk.GetBlock(pos.Add(-1, -1, 1)).controller.IsSolid(Direction.north) && chunk.GetBlock(pos.Add(-1, -1, 1)).controller.IsSolid(Direction.east);
light = chunk.GetBlock(pos.Add(0, -1, 0)).data1 / 255f;
break;
case Direction.north:
nSolid = chunk.GetBlock(pos.Add(1, 0, 1)).controller.IsSolid(Direction.west);
eSolid = chunk.GetBlock(pos.Add(0, 1, 1)).controller.IsSolid(Direction.down);
sSolid = chunk.GetBlock(pos.Add(-1, 0, 1)).controller.IsSolid(Direction.east);
wSolid = chunk.GetBlock(pos.Add(0, -1, 1)).controller.IsSolid(Direction.up);
esSolid = chunk.GetBlock(pos.Add(-1, 1, 1)).controller.IsSolid(Direction.east) && chunk.GetBlock(pos.Add(-1, 1, 1)).controller.IsSolid(Direction.south);
neSolid = chunk.GetBlock(pos.Add(1, 1, 1)).controller.IsSolid(Direction.south) && chunk.GetBlock(pos.Add(1, 1, 1)).controller.IsSolid(Direction.west);
wnSolid = chunk.GetBlock(pos.Add(1, -1, 1)).controller.IsSolid(Direction.west) && chunk.GetBlock(pos.Add(1, -1, 1)).controller.IsSolid(Direction.north);
swSolid = chunk.GetBlock(pos.Add(-1, -1, 1)).controller.IsSolid(Direction.north) && chunk.GetBlock(pos.Add(-1, -1, 1)).controller.IsSolid(Direction.east);
light = chunk.GetBlock(pos.Add(0, 0, 1)).data1 / 255f;
break;
case Direction.east:
nSolid = chunk.GetBlock(pos.Add(1, 0, -1)).controller.IsSolid(Direction.up);
eSolid = chunk.GetBlock(pos.Add(1, 1, 0)).controller.IsSolid(Direction.west);
sSolid = chunk.GetBlock(pos.Add(1, 0, 1)).controller.IsSolid(Direction.down);
wSolid = chunk.GetBlock(pos.Add(1, -1, 0)).controller.IsSolid(Direction.east);
esSolid = chunk.GetBlock(pos.Add(1, 1, 1)).controller.IsSolid(Direction.west) && chunk.GetBlock(pos.Add(1, 1, 1)).controller.IsSolid(Direction.north);
neSolid = chunk.GetBlock(pos.Add(1, 1, -1)).controller.IsSolid(Direction.south) && chunk.GetBlock(pos.Add(1, 1, -1)).controller.IsSolid(Direction.west);
wnSolid = chunk.GetBlock(pos.Add(1, -1, -1)).controller.IsSolid(Direction.east) && chunk.GetBlock(pos.Add(1, -1, -1)).controller.IsSolid(Direction.north);
swSolid = chunk.GetBlock(pos.Add(1, -1, 1)).controller.IsSolid(Direction.north) && chunk.GetBlock(pos.Add(1, -1, 1)).controller.IsSolid(Direction.east);
light = chunk.GetBlock(pos.Add(1, 0, 0)).data1 / 255f;
break;
case Direction.south:
nSolid = chunk.GetBlock(pos.Add(-1, 0, -1)).controller.IsSolid(Direction.down);
eSolid = chunk.GetBlock(pos.Add(0, 1, -1)).controller.IsSolid(Direction.west);
sSolid = chunk.GetBlock(pos.Add(1, 0, -1)).controller.IsSolid(Direction.up);
wSolid = chunk.GetBlock(pos.Add(0, -1, -1)).controller.IsSolid(Direction.south);
esSolid = chunk.GetBlock(pos.Add(1, 1, -1)).controller.IsSolid(Direction.west) && chunk.GetBlock(pos.Add(1, 1, -1)).controller.IsSolid(Direction.north);
neSolid = chunk.GetBlock(pos.Add(-1, 1, -1)).controller.IsSolid(Direction.south) && chunk.GetBlock(pos.Add(-1, 1, -1)).controller.IsSolid(Direction.west);
wnSolid = chunk.GetBlock(pos.Add(-1, -1, -1)).controller.IsSolid(Direction.east) && chunk.GetBlock(pos.Add(-1, -1, -1)).controller.IsSolid(Direction.north);
swSolid = chunk.GetBlock(pos.Add(1, -1, -1)).controller.IsSolid(Direction.north) && chunk.GetBlock(pos.Add(1, -1, -1)).controller.IsSolid(Direction.east);
light = chunk.GetBlock(pos.Add(0, 0, -1)).data1 / 255f;
break;
case Direction.west:
nSolid = chunk.GetBlock(pos.Add(-1, 0, 1)).controller.IsSolid(Direction.up);
eSolid = chunk.GetBlock(pos.Add(-1, 1, 0)).controller.IsSolid(Direction.west);
sSolid = chunk.GetBlock(pos.Add(-1, 0, -1)).controller.IsSolid(Direction.down);
wSolid = chunk.GetBlock(pos.Add(-1, -1, 0)).controller.IsSolid(Direction.east);
esSolid = chunk.GetBlock(pos.Add(-1, 1, -1)).controller.IsSolid(Direction.west) && chunk.GetBlock(pos.Add(-1, 1, -1)).controller.IsSolid(Direction.north);
neSolid = chunk.GetBlock(pos.Add(-1, 1, 1)).controller.IsSolid(Direction.south) && chunk.GetBlock(pos.Add(-1, 1, 1)).controller.IsSolid(Direction.west);
wnSolid = chunk.GetBlock(pos.Add(-1, -1, 1)).controller.IsSolid(Direction.east) && chunk.GetBlock(pos.Add(-1, -1, 1)).controller.IsSolid(Direction.north);
swSolid = chunk.GetBlock(pos.Add(-1, -1, -1)).controller.IsSolid(Direction.north) && chunk.GetBlock(pos.Add(-1, -1, -1)).controller.IsSolid(Direction.east);
light = chunk.GetBlock(pos.Add(-1, 0, 0)).data1 / 255f;
break;
//.........这里部分代码省略.........
示例11: MakeFenceColors
static void MakeFenceColors(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction,Vector3 MeshSize, Direction[] Dir)
{
bool nSolid = false;
bool eSolid = false;
bool sSolid = false;
bool wSolid = false;
bool wnSolid = false;
bool neSolid = false;
bool esSolid = false;
bool swSolid = false;
float light = 0;
foreach (Direction localDir in Dir)
{
Vector3 vPos = new Vector3();
if (localDir == Direction.north)
{
vPos = new Vector3(pos.x, pos.y, pos.z + MeshSize.z);
}
else if (localDir == Direction.east)
{
vPos = new Vector3(pos.x + MeshSize.x, pos.y, pos.z);
}
else if (localDir == Direction.west)
{
vPos = new Vector3(pos.x - MeshSize.x, pos.y, pos.z);
}
else if (localDir == Direction.south)
{
vPos = new Vector3(pos.x, pos.y, pos.z - MeshSize.z);
}
else if (localDir == Direction.up)
{
vPos = new Vector3(pos.x, pos.y + MeshSize.y, pos.z);
}
else if (localDir == Direction.down)
{
vPos = new Vector3(pos.x, pos.y - MeshSize.y, pos.z);
}
pos = vPos;
switch (direction)
{
case Direction.up:
nSolid = chunk.GetBlock(pos.Add(0, 1, 1)).controller.IsSolid(Direction.south);
eSolid = chunk.GetBlock(pos.Add(1, 1, 0)).controller.IsSolid(Direction.west);
sSolid = chunk.GetBlock(pos.Add(0, 1, -1)).controller.IsSolid(Direction.north);
wSolid = chunk.GetBlock(pos.Add(-1, 1, 0)).controller.IsSolid(Direction.east);
wnSolid = chunk.GetBlock(pos.Add(-1, 1, 1)).controller.IsSolid(Direction.east) && chunk.GetBlock(pos.Add(-1, 1, 1)).controller.IsSolid(Direction.south);
neSolid = chunk.GetBlock(pos.Add(1, 1, 1)).controller.IsSolid(Direction.south) && chunk.GetBlock(pos.Add(1, 1, 1)).controller.IsSolid(Direction.west);
esSolid = chunk.GetBlock(pos.Add(1, 1, -1)).controller.IsSolid(Direction.west) && chunk.GetBlock(pos.Add(1, 1, -1)).controller.IsSolid(Direction.north);
swSolid = chunk.GetBlock(pos.Add(-1, 1, -1)).controller.IsSolid(Direction.north) && chunk.GetBlock(pos.Add(-1, 1, -1)).controller.IsSolid(Direction.east);
light = chunk.GetBlock(pos.Add(0, 1, 0)).data1 / 255f;
break;
case Direction.down:
nSolid = chunk.GetBlock(pos.Add(0, -1, -1)).controller.IsSolid(Direction.south);
eSolid = chunk.GetBlock(pos.Add(1, -1, 0)).controller.IsSolid(Direction.west);
sSolid = chunk.GetBlock(pos.Add(0, -1, 1)).controller.IsSolid(Direction.north);
wSolid = chunk.GetBlock(pos.Add(-1, -1, 0)).controller.IsSolid(Direction.east);
wnSolid = chunk.GetBlock(pos.Add(-1, -1, -1)).controller.IsSolid(Direction.east) && chunk.GetBlock(pos.Add(-1, -1, -1)).controller.IsSolid(Direction.south);
neSolid = chunk.GetBlock(pos.Add(1, -1, -1)).controller.IsSolid(Direction.south) && chunk.GetBlock(pos.Add(1, -1, -1)).controller.IsSolid(Direction.west);
esSolid = chunk.GetBlock(pos.Add(1, -1, 1)).controller.IsSolid(Direction.west) && chunk.GetBlock(pos.Add(1, -1, 1)).controller.IsSolid(Direction.north);
swSolid = chunk.GetBlock(pos.Add(-1, -1, 1)).controller.IsSolid(Direction.north) && chunk.GetBlock(pos.Add(-1, -1, 1)).controller.IsSolid(Direction.east);
light = chunk.GetBlock(pos.Add(0, -1, 0)).data1 / 255f;
break;
case Direction.north:
nSolid = chunk.GetBlock(pos.Add(1, 0, 1)).controller.IsSolid(Direction.west);
eSolid = chunk.GetBlock(pos.Add(0, 1, 1)).controller.IsSolid(Direction.down);
sSolid = chunk.GetBlock(pos.Add(-1, 0, 1)).controller.IsSolid(Direction.east);
wSolid = chunk.GetBlock(pos.Add(0, -1, 1)).controller.IsSolid(Direction.up);
esSolid = chunk.GetBlock(pos.Add(-1, 1, 1)).controller.IsSolid(Direction.east) && chunk.GetBlock(pos.Add(-1, 1, 1)).controller.IsSolid(Direction.south);
neSolid = chunk.GetBlock(pos.Add(1, 1, 1)).controller.IsSolid(Direction.south) && chunk.GetBlock(pos.Add(1, 1, 1)).controller.IsSolid(Direction.west);
wnSolid = chunk.GetBlock(pos.Add(1, -1, 1)).controller.IsSolid(Direction.west) && chunk.GetBlock(pos.Add(1, -1, 1)).controller.IsSolid(Direction.north);
swSolid = chunk.GetBlock(pos.Add(-1, -1, 1)).controller.IsSolid(Direction.north) && chunk.GetBlock(pos.Add(-1, -1, 1)).controller.IsSolid(Direction.east);
light = chunk.GetBlock(pos.Add(0, 0, 1)).data1 / 255f;
break;
case Direction.east:
nSolid = chunk.GetBlock(pos.Add(1, 0, -1)).controller.IsSolid(Direction.up);
eSolid = chunk.GetBlock(pos.Add(1, 1, 0)).controller.IsSolid(Direction.west);
sSolid = chunk.GetBlock(pos.Add(1, 0, 1)).controller.IsSolid(Direction.down);
wSolid = chunk.GetBlock(pos.Add(1, -1, 0)).controller.IsSolid(Direction.east);
esSolid = chunk.GetBlock(pos.Add(1, 1, 1)).controller.IsSolid(Direction.west) && chunk.GetBlock(pos.Add(1, 1, 1)).controller.IsSolid(Direction.north);
neSolid = chunk.GetBlock(pos.Add(1, 1, -1)).controller.IsSolid(Direction.south) && chunk.GetBlock(pos.Add(1, 1, -1)).controller.IsSolid(Direction.west);
wnSolid = chunk.GetBlock(pos.Add(1, -1, -1)).controller.IsSolid(Direction.east) && chunk.GetBlock(pos.Add(1, -1, -1)).controller.IsSolid(Direction.north);
swSolid = chunk.GetBlock(pos.Add(1, -1, 1)).controller.IsSolid(Direction.north) && chunk.GetBlock(pos.Add(1, -1, 1)).controller.IsSolid(Direction.east);
light = chunk.GetBlock(pos.Add(1, 0, 0)).data1 / 255f;
//.........这里部分代码省略.........
示例12: AddBlockData
public override void AddBlockData(Chunk chunk, BlockPos pos, MeshData meshData, Block block)
{
int initialVertCount = meshData.vertices.Count;
int colInitialVertCount = meshData.colVertices.Count;
foreach (var vert in verts)
{
meshData.AddVertex(vert + (Vector3)pos);
meshData.colVertices.Add(vert + (Vector3)pos);
if (uvs.Length == 0)
meshData.uv.Add(new Vector2(0, 0));
float lighting;
if (Config.Toggle.BlockLighting)
{
lighting = block.data1 / 255f;
}
else
{
lighting = 1;
}
meshData.colors.Add(new Color(lighting, lighting, lighting, 1));
}
if (uvs.Length != 0)
{
Rect texture;
if (collection != null)
texture = collection.GetTexture(chunk, pos, Direction.down);
else
texture = new Rect();
foreach (var uv in uvs)
{
meshData.uv.Add(new Vector2((uv.x * texture.width) + texture.x, (uv.y * texture.height) + texture.y));
}
}
if (!chunk.GetBlock(pos.Add(Direction.up)).controller.IsSolid(Direction.down))
{
foreach (var tri in trisUp)
{
meshData.AddTriangle(tri + initialVertCount);
meshData.colTriangles.Add(tri + colInitialVertCount);
}
}
if (!chunk.GetBlock(pos.Add(Direction.down)).controller.IsSolid(Direction.up))
{
foreach (var tri in trisDown)
{
meshData.AddTriangle(tri + initialVertCount);
meshData.colTriangles.Add(tri + colInitialVertCount);
}
}
if (!chunk.GetBlock(pos.Add(Direction.north)).controller.IsSolid(Direction.south))
{
foreach (var tri in trisNorth)
{
meshData.AddTriangle(tri + initialVertCount);
meshData.colTriangles.Add(tri + colInitialVertCount);
}
}
if (!chunk.GetBlock(pos.Add(Direction.south)).controller.IsSolid(Direction.north))
{
foreach (var tri in trisSouth)
{
meshData.AddTriangle(tri + initialVertCount);
meshData.colTriangles.Add(tri + colInitialVertCount);
}
}
if (!chunk.GetBlock(pos.Add(Direction.west)).controller.IsSolid(Direction.east))
{
foreach (var tri in trisWest)
{
meshData.AddTriangle(tri + initialVertCount);
meshData.colTriangles.Add(tri + colInitialVertCount);
}
}
if (!chunk.GetBlock(pos.Add(Direction.east)).controller.IsSolid(Direction.west))
{
foreach (var tri in trisEast)
{
meshData.AddTriangle(tri + initialVertCount);
meshData.colTriangles.Add(tri + colInitialVertCount);
}
}
foreach (var tri in trisOther)
{
meshData.AddTriangle(tri + initialVertCount);
meshData.colTriangles.Add(tri + colInitialVertCount);
}
}
示例13: UpdateAdjacentChunks
/// <summary>
/// Updates any chunks neighboring a block position
/// </summary>
/// <param name="pos">position of change</param>
public void UpdateAdjacentChunks(BlockPos pos)
{
BlockPos localPos = pos - pos.ContainingChunkCoordinates();
//Checks to see if the block position is on the border of the chunk
//and if so update the chunk it's touching
UpdateIfEqual(localPos.x, 0, pos.Add(-1, 0, 0));
UpdateIfEqual(localPos.x, Config.Env.ChunkSize - 1, pos.Add(1, 0, 0));
UpdateIfEqual(localPos.y, 0, pos.Add(0, -1, 0));
UpdateIfEqual(localPos.y, Config.Env.ChunkSize - 1, pos.Add(0, 1, 0));
UpdateIfEqual(localPos.z, 0, pos.Add(0, 0, -1));
UpdateIfEqual(localPos.z, Config.Env.ChunkSize - 1, pos.Add(0, 0, 1));
}
示例14: LoadChunkColumnInner
void LoadChunkColumnInner(BlockPos columnPosition)
{
Chunk chunk;
// Terrain generation can happen in another thread meaning that we will reach this point before the
//thread completes, we need to wait for all the chunks we depend on to finish generating before we
//can calculate any light spread or render the chunk
if (Config.Toggle.UseMultiThreading)
{
for (int y = Config.Env.WorldMaxY; y >= Config.Env.WorldMinY; y -= Config.Env.ChunkSize)
{
for (int x = -Config.Env.ChunkSize; x <= Config.Env.ChunkSize; x += Config.Env.ChunkSize)
{
for (int z = -Config.Env.ChunkSize; z <= Config.Env.ChunkSize; z += Config.Env.ChunkSize)
{
chunk = world.GetChunk(columnPosition.Add(x, y, z));
while (!chunk.GetFlag(Chunk.Flag.terrainGenerated))
{
Thread.Sleep(0);
}
}
}
}
}
//Render chunk
for (int y = Config.Env.WorldMaxY; y >= Config.Env.WorldMinY; y -= Config.Env.ChunkSize)
{
chunk = world.GetChunk(columnPosition.Add(0, y, 0));
if(Config.Toggle.LightSceneOnStart){
BlockLight.FloodLightChunkColumn(world, chunk);
}
chunk.UpdateChunk();
}
}
示例15: LoadChunkColumnInner
void LoadChunkColumnInner(BlockPos columnPosition)
{
Chunk chunk;
if (Config.Toggle.UseMultiThreading)
{
for (int y = Config.Env.WorldMaxY; y >= Config.Env.WorldMinY; y -= Config.Env.ChunkSize)
{
for (int x = -Config.Env.ChunkSize; x <= Config.Env.ChunkSize; x += Config.Env.ChunkSize)
{
for (int z = -Config.Env.ChunkSize; z <= Config.Env.ChunkSize; z += Config.Env.ChunkSize)
{
chunk = world.GetChunk(columnPosition.Add(x, y, z));
while (!chunk.terrainGenerated)
{
Thread.Sleep(0);
}
}
}
}
}
//Render chunk
for (int y = Config.Env.WorldMaxY; y >= Config.Env.WorldMinY; y -= Config.Env.ChunkSize)
{
chunk = world.GetChunk(columnPosition.Add(0, y, 0));
if(Config.Toggle.LightSceneOnStart){
BlockLight.FloodLightChunkColumn(world, chunk);
}
chunk.UpdateChunk();
}
}