本文整理汇总了C#中BlockPos类的典型用法代码示例。如果您正苦于以下问题:C# BlockPos类的具体用法?C# BlockPos怎么用?C# BlockPos使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlockPos类属于命名空间,在下文中一共展示了BlockPos类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TerrainBlock
public IBlock this[BlockPos pos]
{
get {
var chunk = this[ChunkPos.FromBlockPos(pos)];
return new TerrainBlock(this, chunk, pos);
}
}
开发者ID:copygirl,项目名称:Immersion,代码行数:7,代码来源:Terrain.cs
示例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);
}
}
开发者ID:thegreatpl,项目名称:Voxelmetric,代码行数:29,代码来源:World.cs
示例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);
}
}
}
开发者ID:li5414,项目名称:Voxelmetric,代码行数:30,代码来源:StructureTree.cs
示例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();
}
}
}
开发者ID:li5414,项目名称:Voxelmetric,代码行数:29,代码来源:PathFinder.cs
示例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;
}
开发者ID:li5414,项目名称:Voxelmetric,代码行数:29,代码来源:LoadChunks.cs
示例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();
}
}
开发者ID:li5414,项目名称:Voxelmetric,代码行数:31,代码来源:BlockLight.cs
示例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);
}
开发者ID:FaizanDurrani,项目名称:Voxelmetric-ConnectedMeshes,代码行数:7,代码来源:ConnectedBuilder.cs
示例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));
}
开发者ID:copygirl,项目名称:Immersion,代码行数:9,代码来源:BlockRegion.cs
示例9: GetBlock
public static Block GetBlock(BlockPos pos, World world = null)
{
if (!world)
world = World.instance;
Block block = world.GetBlock(pos);
return block;
}
开发者ID:holmstrom,项目名称:Voxelmetric,代码行数:9,代码来源:Voxelmetric.cs
示例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);
}
}
开发者ID:renokun,项目名称:Voxelmetric,代码行数:10,代码来源:BlockCube.cs
示例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;
}
开发者ID:li5414,项目名称:Voxelmetric,代码行数:11,代码来源:wildgrassOverride.cs
示例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);
}
开发者ID:li5414,项目名称:Voxelmetric,代码行数:54,代码来源:MeshBuilder.cs
示例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;
}
开发者ID:mollari,项目名称:Voxelmetric,代码行数:16,代码来源:Chunk.cs
示例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);
}
}
}
开发者ID:renokun,项目名称:Voxelmetric,代码行数:11,代码来源:TerrainGen.cs
示例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;
}
开发者ID:holmstrom,项目名称:Voxelmetric,代码行数:12,代码来源:PathFinder.cs
示例16: LightArea
public static void LightArea(World world, BlockPos pos)
{
if (Config.Toggle.UseMultiThreading)
{
Thread thread = new Thread(() => { LightAreaInner(world, pos); });
thread.Start();
}
else
{
LightAreaInner(world, pos);
}
}
开发者ID:li5414,项目名称:Voxelmetric,代码行数:14,代码来源:BlockLight.cs
示例17: GenerateStructuresForChunk
public void GenerateStructuresForChunk(BlockPos chunkPos)
{
for (int i = 0; i < layerOrder.Length; i++)
{
if (layerOrder[i] == null)
continue;
if (layerOrder[i].layerType == TerrainLayer.LayerType.Structure)
{
layerOrder[i].GenerateStructures(chunkPos, this);
}
}
}
开发者ID:li5414,项目名称:Voxelmetric,代码行数:14,代码来源:TerrainGen.cs
示例18: GetBlock
/// <summary>
/// Gets and returns a block from a local position within the chunk
/// or fetches it from the world
/// </summary>
/// <param name="blockPos">A local block position</param>
/// <returns>The block at the position</returns>
public Block GetBlock(BlockPos blockPos)
{
Block returnBlock;
if (InRange(blockPos))
{
returnBlock = blocks[blockPos.x, blockPos.y, blockPos.z];
}
else
{
returnBlock = world.GetBlock(blockPos + pos);
}
return returnBlock;
}
开发者ID:mollari,项目名称:Voxelmetric,代码行数:21,代码来源:Chunk.cs
示例19: PathComplete
void PathComplete(BlockPos lastTile)
{
Heuristics pos;
closed.TryGetValue(lastTile, out pos);
path.Clear();
path.Add(lastTile);
open.TryGetValue(lastTile, out pos);
while (!pos.parent.Equals(startLocation))
{
path.Insert(0, pos.parent);
if (!closed.TryGetValue(pos.parent, out pos))
break;
}
}
开发者ID:li5414,项目名称:Voxelmetric,代码行数:16,代码来源:PathFinder.cs
示例20: Save
public Save(Chunk chunk)
{
try
{
//Because existing saved blocks aren't marked as modified we have to add the
//blocks already in the save fie if there is one. Then add
Dictionary<BlockPos, Block> blocksDictionary = AddSavedBlocks(chunk);
for (int x = 0; x < Config.Env.ChunkSize; x++)
{
for (int y = 0; y < Config.Env.ChunkSize; y++)
{
for (int z = 0; z < Config.Env.ChunkSize; z++)
{
BlockPos pos = new BlockPos(x, y, z);
if (chunk.GetBlock(pos).modified)
{
//remove any existing blocks in the dictionary as they're
//from the existing save and are overwritten
blocksDictionary.Remove(pos);
blocksDictionary.Add(pos, chunk.GetBlock(pos));
changed = true;
}
}
}
}
blocks = new Block[blocksDictionary.Keys.Count];
positions = new BlockPos[blocksDictionary.Keys.Count];
int index = 0;
foreach (var pair in blocksDictionary)
{
blocks[index] = pair.Value;
positions[index] = pair.Key;
index++;
}
}
catch (Exception ex)
{
Debug.LogError(ex);
}
}
开发者ID:li5414,项目名称:Voxelmetric,代码行数:47,代码来源:Save.cs
注:本文中的BlockPos类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论