本文整理汇总了C#中World.GetChunk方法的典型用法代码示例。如果您正苦于以下问题:C# World.GetChunk方法的具体用法?C# World.GetChunk怎么用?C# World.GetChunk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World
的用法示例。
在下文中一共展示了World.GetChunk方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
}
示例2: SetBlock
public static bool SetBlock(BlockPos pos, Block block, World world = null)
{
if (!world)
world = World.instance;
Chunk chunk = world.GetChunk(pos);
if (chunk == null)
return false;
chunk.world.SetBlock(pos, block, !Config.Toggle.BlockLighting);
if (Config.Toggle.BlockLighting)
{
BlockLight.LightArea(world, pos);
}
return true;
}
示例3: SetBlock
public static bool SetBlock(World world, int x, int y, int z, BlockBase block, bool adjacent) {
Chunk chunk = world.GetChunk (0, 0, 0);
if (chunk == null)
return false;
WorldPos pos = GetBlockPos(new Vector3(x, y, z));
chunk.world.SetBlock(pos.x, pos.y, pos.z, block);
// now save whenever i update blocks
//Serialization.SaveChunk(chunk);
return true;
}
示例4: TestSkyLight
public void TestSkyLight()
{
World world = new World(null, new TestWorldGenerator());
world.GetChunk(new Vector3(0, 0, 0));
}
示例5: applySphere
//.........这里部分代码省略.........
if ((T_pos.z - current_pos.z) > 1.15f)
continue;
if ((T_pos.x - current_pos.x) < -0.15f)
continue;
if ((T_pos.y - current_pos.y) < -0.15f)
continue;
if ((T_pos.z - current_pos.z) < -0.15f)
continue;
brush [a, b, c].offx = Mathf.Clamp((T_pos.x) - (current_pos.x), 0.0f, 1.0f);
brush [a, b, c].offy = Mathf.Clamp((T_pos.y) - (current_pos.y), 0.0f, 1.0f);
brush [a, b, c].offz = Mathf.Clamp((T_pos.z) - (current_pos.z), 0.0f, 1.0f);
brush [a, b, c].material = 1; //marked as "participating"
}
//second loop to find and cancel out "participating" voxels that need to NOT change material
for(int a = size-1; a > -1; a-=1)
for(int b = size-1; b > -1; b-=1)
for(int c = size-1; c > -1; c-=1)
{
current_pos = GetBlockPos(new Vector3(center.x+a-half,center.y+b-half,center.z+c-half));
current_block = world.GetBlock(current_pos.x,current_pos.y,current_pos.z);
if(brush[a,b,c].material == -2) { //this is outside, so any prime voxel connected needs to NOT change material
//we will need to see if any connecting voxels are "participating"
for (int d = 0; d < 2; d += 1) {
if (a + d > (size-1))
continue;
else
for (int e = 0; e < 2; e += 1) {
if (b + e > (size-1))
continue;
else
for (int f = 0; f < 2; f += 1) {
if (c + f > (size-1))
continue;
else if (brush [d+a, e+b, f+c].material == 1)
brush [d+a, e+b, f+c].material = -1; //mark as "NOT-affected"
}
}
}
}
}
//third loop to act on our markings
if (false) {
for (int a = size - 1; a > -1; a -= 1)
for (int b = size - 1; b > -1; b -= 1)
for (int c = size - 1; c > -1; c -= 1) {
current_pos = GetBlockPos (new Vector3 (center.x + a - half, center.y + b - half, center.z + c - half));
current_block = world.GetBlock (current_pos.x, current_pos.y, current_pos.z);
int flagmat = brush [a, b, c].material;
if (flagmat == 0) { //"Inside"
BlendBlock (current_block, world, current_pos, 0.2f, 0.02f);
//current_block.material = 0;
} else if (flagmat == 1) { //"Participating" volume inside, voxel coord on the perimeter
BlendBlock (current_block, world, current_pos, 0.1f, 0.02f);
//current_block.material = 0;
//current_block.setoffset (brush [a, b, c].offx, brush [a, b, c].offy, brush [a, b, c].offz);
} else if (flagmat == -1) { //"NON-Affected" volume outside even though cord is on perimeter
//current_block.setoffset (brush [a, b, c].offx, brush [a, b, c].offy, brush [a, b, c].offz);
} else {
}
//SetBlock(world.GetChunk(current_pos.x,current_pos.y,current_pos.z), current_pos, current_block);
}
} else {
for (int a = size - 1; a > -1; a -= 1)
for (int b = size - 1; b > -1; b -= 1)
for (int c = size - 1; c > -1; c -= 1) {
current_pos = GetBlockPos (new Vector3 (center.x + a - half, center.y + b - half, center.z + c - half));
current_block = world.GetBlock (current_pos.x, current_pos.y, current_pos.z);
int flagmat = brush [a, b, c].material;
if (flagmat == 0) { //"Inside"
//BlendBlock (current_block, world, current_pos, 0.2f, -0.001f);
current_block.material = 0;
} else if (flagmat == 1) { //"Participating"
//BlendBlock (current_block, world, current_pos, 0.1f, -0.001f);
current_block.material = 0;
current_block.setoffset (brush [a, b, c].offx, brush [a, b, c].offy, brush [a, b, c].offz);
} else if (flagmat == -1) { //"NON-Affected"
current_block.setoffset (brush [a, b, c].offx, brush [a, b, c].offy, brush [a, b, c].offz);
} else {
}
SetBlock(world.GetChunk(current_pos.x,current_pos.y,current_pos.z), current_pos, current_block);
}
}
return true;
}
示例6: UpdateInChunk
public void UpdateInChunk() {
//Debug.LogError ("Updating in chunk");
PreviousChunkPosition = InChunkPosition;
InChunkPosition = transform.position;
int InChunkPositionX = Mathf.RoundToInt (InChunkPosition.x);// / Mathf.RoundToInt(16));
int InChunkPositionY = Mathf.RoundToInt(InChunkPosition.y);// / Mathf.RoundToInt(16));
int InChunkPositionZ = Mathf.RoundToInt(InChunkPosition.z);// / Mathf.RoundToInt(16));
InChunkPosition = new Vector3(InChunkPositionX, InChunkPositionY, InChunkPositionZ);
if (InChunkPosition != PreviousChunkPosition || InChunk == null) {
BaseWorld = GetManager.GetWorld ();
if (BaseWorld != null)
InChunk = BaseWorld.GetChunk (Mathf.RoundToInt (InChunkPosition.x), Mathf.RoundToInt (InChunkPosition.y), Mathf.RoundToInt (InChunkPosition.z));
else
Debug.LogError ("No base world for in chunk update at : " + name);
}
}
示例7: ResetLightColumn
public static void ResetLightColumn(World world, int x, int z, List<BlockPos> chunksToUpdate)
{
bool sunlightObstructed = false;
for (int y = Config.Env.WorldMaxY - 1; y >= Config.Env.WorldMinY; y--)
{
Chunk chunk = world.GetChunk(new BlockPos(x, y, z));
BlockPos localPos = new BlockPos(x, y, z).Subtract(chunk.pos);
if (chunk == null){
continue;
}
Block block = chunk.GetBlock(localPos);
if (!block.controller.IsTransparent())
{
sunlightObstructed = true;
continue;
}
if (block.controller.IsTransparent())
{
byte originalData1 = block.data1;
if (sunlightObstructed)
{
block.data1 = block.controller.LightEmmitted();
}
else
{
block.data1 = 255;
}
chunk.SetBlock(localPos, block, false);
if (block.data1 != originalData1 && !chunksToUpdate.Contains(chunk.pos))
chunksToUpdate.Add(chunk.pos);
}
}
}
示例8: SpillLight
public static void SpillLight(World world, BlockPos pos, byte light, List<BlockPos> chunksToUpdate, Chunk chunk = null)
{
bool stayWithinChunk = true;
if (chunk == null)
{
chunk = world.GetChunk(pos);
stayWithinChunk = false;
}
BlockPos localPos = pos.Subtract(chunk.pos);
if (!Chunk.InRange(localPos))
return;
Block block = chunk.GetBlock(localPos);
if (!block.controller.IsTransparent())
return;
if (block.data1 >= light)
return;
if (!chunksToUpdate.Contains(chunk.pos))
chunksToUpdate.Add(chunk.pos);
block.data1 = light;
chunk.SetBlock(localPos, block, false);
if (block.data1 > lightReduceBy)
{
block.data1 -= lightReduceBy;
CallSpillLight(world, chunk, pos.Add(1, 0, 0), block.data1, chunksToUpdate, stayWithinChunk);
CallSpillLight(world, chunk, pos.Add(0, 1, 0), block.data1, chunksToUpdate, stayWithinChunk);
CallSpillLight(world, chunk, pos.Add(0, 0, 1), block.data1, chunksToUpdate, stayWithinChunk);
CallSpillLight(world, chunk, pos.Add(-1, 0, 0), block.data1, chunksToUpdate, stayWithinChunk);
CallSpillLight(world, chunk, pos.Add(0, -1, 0), block.data1, chunksToUpdate, stayWithinChunk);
CallSpillLight(world, chunk, pos.Add(0, 0, -1), block.data1, chunksToUpdate, stayWithinChunk);
}
return;
}