本文整理汇总了C#中BlockPos类的典型用法代码示例。如果您正苦于以下问题:C# BlockPos类的具体用法?C# BlockPos怎么用?C# BlockPos使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlockPos类属于命名空间,在下文中一共展示了BlockPos类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TerrainBlock
public IBlock this[BlockPos pos]
{
get {
var chunk = this[ChunkPos.FromBlockPos(pos)];
return new TerrainBlock(this, chunk, pos);
}
}
示例2: CreateChunk
//Instantiates a chunk at the supplied coordinates using the chunk prefab,
//then runs terrain generation on it and loads the chunk's save file
public void CreateChunk(BlockPos pos)
{
GameObject newChunkObject = Instantiate(
chunkPrefab, pos,
Quaternion.Euler(Vector3.zero)
) as GameObject;
newChunkObject.transform.parent = gameObject.transform;
newChunkObject.transform.name = "Chunk (" + pos + ")";
Chunk newChunk = newChunkObject.GetComponent<Chunk>();
newChunk.pos = pos;
newChunk.world = this;
//Add it to the chunks dictionary with the position as the key
chunks.Add(pos, newChunk);
if (Config.Toggle.UseMultiThreading) {
Thread thread = new Thread(() => { GenAndLoadChunk(newChunk); });
thread.Start();
}
else
{
GenAndLoadChunk(newChunk);
}
}
示例3: 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);
}
}
}
示例4: PathFinder
public PathFinder(BlockPos startLocation, BlockPos targetLocation, World world, int entityHeight=2)
{
this.startLocation = startLocation;
this.targetLocation = targetLocation;
distanceFromStartToTarget = Distance(startLocation, targetLocation);
this.world = world;
this.entityHeight = entityHeight;
open.Add(startLocation, new Heuristics(0, distanceFromStartToTarget, startLocation));
if (Config.Toggle.UseMultiThreading)
{
Thread thread = new Thread(() =>
{
while (path.Count == 0)
{
update();
}
});
thread.Start();
}
else
{
while (path.Count == 0)
{
update();
}
}
}
示例5: FindChunksAndLoad
bool FindChunksAndLoad()
{
//Cycle through the array of positions
for (int i = 0; i < Data.chunkLoadOrder.Length; i++)
{
//Get the position of this gameobject to generate around
BlockPos playerPos = ((BlockPos)transform.position).ContainingChunkCoordinates();
//translate the player position and array position into chunk position
BlockPos newChunkPos = new BlockPos(
Data.chunkLoadOrder[i].x * Config.Env.ChunkSize + playerPos.x,
0,
Data.chunkLoadOrder[i].z * Config.Env.ChunkSize + playerPos.z
);
//Get the chunk in the defined position
Chunk newChunk = world.GetChunk(newChunkPos);
//If the chunk already exists and it's already
//rendered or in queue to be rendered continue
if (newChunk != null && newChunk.GetFlag(Chunk.Flag.loaded))
continue;
LoadChunkColumn(newChunkPos);
return true;
}
return false;
}
示例6: LightAreaInner
static void LightAreaInner(World world, BlockPos pos)
{
List<BlockPos> chunksToUpdate = new List<BlockPos>();
for (int x = pos.x - lightEffectRadius; x < pos.x + lightEffectRadius; x++)
{
for (int z = pos.z - lightEffectRadius; z < pos.z + lightEffectRadius; z++)
{
ResetLightColumn(world, x, z, chunksToUpdate);
}
}
for (int x = pos.x - lightEffectRadius - 1; x < pos.x + lightEffectRadius + 1; x++)
{
for (int z = pos.z - lightEffectRadius - 1; z < pos.z + lightEffectRadius + 1; z++)
{
for (int y = Config.Env.WorldMaxY - 1; y >= Config.Env.WorldMinY; y--)
{
FloodLight(world, x, y, z, chunksToUpdate);
}
}
}
world.GetChunk(pos).UpdateChunk();
world.UpdateAdjacentChunks(pos);
foreach (var chunkPos in chunksToUpdate)
{
world.GetChunk(chunkPos).UpdateChunk();
}
}
示例7: BuildRenderer
public static void BuildRenderer(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction, Vector3 ModelSize, Vector3 ConnMeshSizeX, Vector3 ConnMeshSizeY, Vector3 ConnMeshSizeZ, Direction[] Dir)
{
MakeStickFace(chunk, pos, meshData, direction, false, ModelSize);
Debug.Log(Dir.Length);
if (Dir.Length > 0)
MakeFenceFace(chunk, pos, meshData, direction, false, ModelSize, ConnMeshSizeX, ConnMeshSizeY, ConnMeshSizeZ, Dir);
}
示例8: BlockRegion
public BlockRegion(BlockPos start, BlockPos end)
{
this.start = start;
this.end = end;
if ((width < 0) || (height < 0) || (depth < 0))
throw new ArgumentException(string.Format(
"End position must be larger or equal to start" +
"position for all dimensions ({0} : {1})", start, end));
}
示例9: GetBlock
public static Block GetBlock(BlockPos pos, World world = null)
{
if (!world)
world = World.instance;
Block block = world.GetBlock(pos);
return block;
}
示例10: BuildFace
public override void BuildFace(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction, Block block)
{
BlockBuilder.BuildRenderer(chunk, pos, meshData, direction);
BlockBuilder.BuildTexture(chunk, pos, meshData, direction, textures);
BlockBuilder.BuildColors(chunk, pos, meshData, direction);
if (Config.Toggle.UseCollisionMesh)
{
BlockBuilder.BuildCollider(chunk, pos, meshData, direction);
}
}
示例11: OnCreate
// On create set the height to 10 and schedule and update in 1 second
public override Block OnCreate(Chunk chunk, BlockPos pos, Block block)
{
block.data2 = (byte)(64 + ((chunk.world.noiseGen.Generate(pos.x * 1000, pos.y * 1000, pos.z * 1000) + 1) * 96));
int offset1 = (int)((chunk.world.noiseGen.Generate(pos.x* 1000, pos.y* 1000, pos.z * 1000) + 1) * 16);
block.data3 = (byte)((block.data3 & 240) | (offset1 & 15));
int offset2 = (int)((chunk.world.noiseGen.Generate(pos.x*1000, pos.y * 10000, pos.z * 1000) + 1) * 16);
block.data3 = (byte)((offset2 << 4) | (block.data3 & 15));
return block;
}
示例12: CrossMeshRenderer
public static void CrossMeshRenderer(Chunk chunk, BlockPos pos, MeshData meshData, TextureCollection texture, Block block)
{
float halfBlock = (Config.Env.BlockSize / 2) + Config.Env.BlockFacePadding;
float colliderOffest = 0.05f * Config.Env.BlockSize;
float blockHeight = halfBlock * 2 * (block.data2 / 255f);
float offsetX = (halfBlock * 2 * ((byte)(block.data3 & 0x0F) / 32f)) - (halfBlock/2);
float offsetZ = (halfBlock * 2 * ((byte)((block.data3 & 0xF0) >> 4) / 32f)) - (halfBlock/2);
//Converting the position to a vector adjusts it based on block size and gives us real world coordinates for x, y and z
Vector3 vPos = pos;
Vector3 vPosCollider = pos;
vPos += new Vector3(offsetX, 0, offsetZ);
float blockLight = ( (block.data1/255f) * Config.Env.BlockLightStrength) + (0.8f*Config.Env.AOStrength);
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
meshData.AddQuadTriangles();
BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
meshData.AddQuadTriangles();
BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
meshData.AddQuadTriangles();
BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
meshData.AddQuadTriangles();
BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);
meshData.AddVertex(new Vector3(vPosCollider.x - halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z + halfBlock), collisionMesh: true);
meshData.AddVertex(new Vector3(vPosCollider.x + halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z + halfBlock), collisionMesh: true);
meshData.AddVertex(new Vector3(vPosCollider.x + halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z - halfBlock), collisionMesh: true);
meshData.AddVertex(new Vector3(vPosCollider.x - halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z - halfBlock), collisionMesh: true);
meshData.AddQuadTriangles(collisionMesh:true);
}
示例13: InRange
/// <summary>
/// Returns true if the block local block position is contained in the chunk boundaries
/// </summary>
/// <param name="localPos">A local block position</param>
/// <returns>true or false depending on if the position is in range</returns>
public static bool InRange(BlockPos localPos)
{
if (!InRange(localPos.x))
return false;
if (!InRange(localPos.y))
return false;
if (!InRange(localPos.z))
return false;
return true;
}
示例14: SetBlock
public static void SetBlock(Chunk chunk, Block block, BlockPos pos, bool replaceBlocks = false)
{
if (Chunk.InRange(pos))
{
if (replaceBlocks || chunk.GetBlock(pos).type == Block.Air.type)
{
block.modified = false;
chunk.SetBlock(pos, block, false);
}
}
}
示例15: 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;
}