public static Vector3[] createFace(Vector3 location, BlockVec.Direction dir) { Vector3 start = location; Vector3 end = location; switch (dir) { case BlockVec.Direction.XPos: case BlockVec.Direction.XNeg: BlockVec modifiedDirVecX = BlockVec.DirectionAsVec(dir); modifiedDirVecX.x -= 1; modifiedDirVecX.x = (int)(modifiedDirVecX.x * 0.5f); start += new Vector3(modifiedDirVecX.x, -1, -1); end += new Vector3(modifiedDirVecX.x, 0, 0); break; case BlockVec.Direction.YPos: case BlockVec.Direction.YNeg: BlockVec modifiedDirVecY = BlockVec.DirectionAsVec(dir); modifiedDirVecY.y -= 1; modifiedDirVecY.y = (int)(modifiedDirVecY.y * 0.5f); start += new Vector3(-1, modifiedDirVecY.y, -1); end += new Vector3(0, modifiedDirVecY.y, 0); break; case BlockVec.Direction.ZPos: case BlockVec.Direction.ZNeg: BlockVec modifiedDirVecZ = BlockVec.DirectionAsVec(dir); modifiedDirVecZ.z -= 1; modifiedDirVecZ.z = (int)(modifiedDirVecZ.z * 0.5f); start += new Vector3(-1, -1, modifiedDirVecZ.z); end += new Vector3(0, 0, modifiedDirVecZ.z); break; /* * case BlockVec.Direction.XPos: * case BlockVec.Direction.XNeg: * start += new Vector3(BlockVec.DirectionAsVec(dir).x, -1, -1); * end += new Vector3(BlockVec.DirectionAsVec(dir).x, 1, 1); * break; * case BlockVec.Direction.YPos: * case BlockVec.Direction.YNeg: * start += new Vector3(-1, BlockVec.DirectionAsVec(dir).y, -1); * end += new Vector3(1, BlockVec.DirectionAsVec(dir).y, 1); * break; * case BlockVec.Direction.ZPos: * case BlockVec.Direction.ZNeg: * start += new Vector3(-1, -1, BlockVec.DirectionAsVec(dir).z); * end += new Vector3(1, 1, BlockVec.DirectionAsVec(dir).z); * break; */ } return(createFace(start, end, dir)); }
public List <BlockVec.Direction> GetEmptyAround(BlockVec pos) { List <BlockVec.Direction> outDirs = new List <BlockVec.Direction>(); foreach (BlockVec.Direction dir in Enum.GetValues(typeof(BlockVec.Direction))) { BlockVec checkPos = pos.Add(BlockVec.DirectionAsVec(dir)); /* * print(pos.x + " " + pos.y + " " + pos.z); * print(checkPos.x + " " + checkPos.y + " " + checkPos.z); * print(BlockVec.DirectionAsVec(dir).x + " " + BlockVec.DirectionAsVec(dir).y + " " + BlockVec.DirectionAsVec(dir).z); */ if (GetBlockByPos(checkPos) == null)//when fixed, also check isInRange(checkPos, startChunkPos, endChunkPos) { outDirs.Add(dir); } } return(outDirs); }