本文整理汇总了C#中IChunk类的典型用法代码示例。如果您正苦于以下问题:C# IChunk类的具体用法?C# IChunk怎么用?C# IChunk使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IChunk类属于命名空间,在下文中一共展示了IChunk类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: LoadChunk
public void LoadChunk(IChunk runtimeChunk)
{
using (var file = new FileStream(Path.Combine(this.m_Path, this.GetName(runtimeChunk)), FileMode.Open))
{
var serializer = new TychaiaDataSerializer();
var chunk = new Chunk();
serializer.Deserialize(file, chunk, typeof(Chunk));
runtimeChunk.Cells = chunk.Cells;
runtimeChunk.GeneratedIndices = chunk.Indexes;
if (chunk.Vertexes == null)
{
runtimeChunk.GeneratedVertexes = new VertexPositionTexture[0];
}
else
{
runtimeChunk.GeneratedVertexes = new VertexPositionTexture[chunk.Vertexes.Length];
for (var i = 0; i < chunk.Vertexes.Length; i++)
{
runtimeChunk.GeneratedVertexes[i] =
new VertexPositionTexture(
new Vector3(chunk.Vertexes[i].X, chunk.Vertexes[i].Y, chunk.Vertexes[i].Z),
new Vector2(chunk.Vertexes[i].U, chunk.Vertexes[i].V));
}
}
runtimeChunk.Generated = true;
}
}
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:31,代码来源:SimpleLevel.cs
示例2: GenerateChunk
public IChunk[] GenerateChunk(IPlanet planet, Index2 index)
{
IChunk[] result = new IChunk[planet.Size.Z];
for (int layer = 0; layer < planet.Size.Z; layer++)
result[layer] = new Chunk(new Index3(index.X, index.Y, layer), planet.Id);
int part = (planet.Size.Z * Chunk.CHUNKSIZE_Z) / 4;
for (int y = 0; y < Chunk.CHUNKSIZE_Y; y++)
{
float heightY = (float)Math.Sin((float)(y * Math.PI) / 15f);
for (int x = 0; x < Chunk.CHUNKSIZE_X; x++)
{
float heightX = (float)Math.Sin((float)(x * Math.PI) / 18f);
float height = ((heightX + heightY + 2) / 4) * (2 * part);
for (int z = 0; z < planet.Size.Z * Chunk.CHUNKSIZE_Z; z++)
{
if (z < (int)(height + part))
{
int block = z % (Chunk.CHUNKSIZE_Z);
int layer = (int)(z / Chunk.CHUNKSIZE_Z);
result[layer].SetBlock(x, y, block, new SandBlock());
}
}
}
}
return result;
}
开发者ID:Vengarioth,项目名称:octoawesome,代码行数:31,代码来源:DebugMapGenerator.cs
示例3: GenerateChunk
public IChunk[] GenerateChunk(IEnumerable<IBlockDefinition> blockDefinitions, IPlanet planet, Index2 index)
{
IBlockDefinition sandDefinition = blockDefinitions.FirstOrDefault(d => typeof(SandBlockDefinition) == d.GetType());
ushort sandIndex = (ushort)(Array.IndexOf(blockDefinitions.ToArray(), sandDefinition) + 1);
IChunk[] result = new IChunk[planet.Size.Z];
for (int layer = 0; layer < planet.Size.Z; layer++)
result[layer] = new Chunk(new Index3(index.X, index.Y, layer), planet.Id);
int part = (planet.Size.Z * Chunk.CHUNKSIZE_Z) / 4;
for (int y = 0; y < Chunk.CHUNKSIZE_Y; y++)
{
float heightY = (float)Math.Sin((float)(y * Math.PI) / 15f);
for (int x = 0; x < Chunk.CHUNKSIZE_X; x++)
{
float heightX = (float)Math.Sin((float)(x * Math.PI) / 18f);
float height = ((heightX + heightY + 2) / 4) * (2 * part);
for (int z = 0; z < planet.Size.Z * Chunk.CHUNKSIZE_Z; z++)
{
if (z < (int)(height + part))
{
int block = z % (Chunk.CHUNKSIZE_Z);
int layer = (int)(z / Chunk.CHUNKSIZE_Z);
result[layer].SetBlock(x, y, block, sandIndex);
}
}
}
}
return result;
}
开发者ID:RapidHelmus,项目名称:octoawesome,代码行数:34,代码来源:DebugMapGenerator.cs
示例4: Decorate
public void Decorate(IWorld world, IChunk chunk, IBiomeRepository biomes)
{
var noise = new Perlin();
noise.Seed = world.Seed;
var chanceNoise = new ClampNoise(noise);
chanceNoise.MaxValue = 2;
for (int x = 0; x < 16; x++)
{
for (int z = 0; z < 16; z++)
{
var biome = biomes.GetBiome(chunk.Biomes[x * Chunk.Width + z]);
var blockX = MathHelper.ChunkToBlockX(x, chunk.Coordinates.X);
var blockZ = MathHelper.ChunkToBlockZ(z, chunk.Coordinates.Z);
var height = chunk.HeightMap[x * Chunk.Width + z];
if (biome.Plants.Contains(PlantSpecies.Cactus) && chanceNoise.Value2D(blockX, blockZ) > 1.7)
{
var blockLocation = new Coordinates3D(x, height, z);
var cactiPosition = blockLocation + Coordinates3D.Up;
if (chunk.GetBlockID(blockLocation).Equals(SandBlock.BlockID))
{
var HeightChance = chanceNoise.Value2D(blockX, blockZ);
var CactusHeight = (HeightChance < 1.4) ? 2 : 3;
Decoration.GenerateColumn(chunk, cactiPosition, CactusHeight, CactusBlock.BlockID);
}
}
}
}
}
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:28,代码来源:CactusDecorator.cs
示例5: GenerateCuboid
/*
* Cuboid Modes
* 0x0 - Solid cuboid of the specified block
* 0x1 - Hollow cuboid of the specified block
* 0x2 - Outlines the area of the cuboid using the specified block
*/
public static void GenerateCuboid(IChunk chunk, Coordinates3D location, Vector3 size, byte block, byte meta = 0x0, byte mode = 0x0)
{
//If mode is 0x2 offset the size by 2 and change mode to 0x1
if (mode.Equals(0x2))
{
size += new Vector3(2, 2, 2);
mode = 0x1;
}
for (int w = location.X; w < location.X + size.X; w++)
{
for (int l = location.Z; l < location.Z + size.Z; l++)
{
for (int h = location.Y; h < location.Y + size.Y; h++)
{
if (w < 0 || w >= Chunk.Width || l < 0 || l >= Chunk.Depth || h < 0 || h >= Chunk.Height)
continue;
Coordinates3D BlockLocation = new Coordinates3D(w, h, l);
if (!h.Equals(location.Y) && !h.Equals(location.Y + (int)size.Y - 1)
&& !IsCuboidWall(new Coordinates2D(w, l), location, size)
&& !IsCuboidCorner(new Coordinates2D(w, l), location, size))
continue;
chunk.SetBlockID(BlockLocation, block);
if (meta != 0x0)
chunk.SetMetadata(BlockLocation, meta);
}
}
}
}
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:37,代码来源:Decoration.cs
示例6: ChunkColumn
/// <summary>
/// Erzeugt eine neue Instanz einer ChunkColumn.
/// </summary>
/// <param name="chunks">Die Chunks für die Säule</param>
/// <param name="planet">Der Index des Planeten</param>
/// <param name="columnIndex">Die Position der Säule</param>
public ChunkColumn(IChunk[] chunks, int planet, Index2 columnIndex)
: this()
{
Planet = planet;
Chunks = chunks;
Index = columnIndex;
}
开发者ID:reicheltp,项目名称:octoawesome,代码行数:13,代码来源:ChunkColumn.cs
示例7: Chunk2D
public Chunk2D(IChunk[] chunks)
{
ushort[] blocks = new ushort[Chunk.CHUNKSIZE_X*Chunk.CHUNKSIZE_Y];
float[] heights = new float[Chunk.CHUNKSIZE_X * Chunk.CHUNKSIZE_Y];
int maxHeight = Chunk.CHUNKSIZE_Z*chunks.Length;
int index = 0;
for (int y = 0; y < Chunk.CHUNKSIZE_Y; y++) {
for (int x = 0; x < Chunk.CHUNKSIZE_X; x++,index++) {
bool found=false;
for (int i=chunks.Length-1;i>=0;i--)
{
IChunk current = chunks [i];
for (int z = Chunk.CHUNKSIZE_Z - 1; z >= 0; z--) {
if ((blocks [index] = current.GetBlock (x, y, z)) != 0) {
float percent = (float)(i * Chunk.CHUNKSIZE_Z + z) / maxHeight;
heights[index] = percent - 0.5f;
found = true;
break;
}
}
if (found)
break;
}
}
}
CreateBitmap(blocks,heights);
}
开发者ID:jvbsl,项目名称:OctoAwesome-MapViewer,代码行数:27,代码来源:Chunk2D.cs
示例8: Decorate
public void Decorate(IWorld world, IChunk chunk, IBiomeRepository biomes)
{
for (int attempts = 0; attempts < 8; attempts++)
{
var noise = new Perlin();
noise.Seed = world.Seed - (chunk.Coordinates.X + chunk.Coordinates.Z);
var offsetNoise = new ClampNoise(noise);
offsetNoise.MaxValue = 3;
var x = 0;
var z = 0;
var offset = 0.0;
offset += offsetNoise.Value2D(x, z);
int finalX = (int)Math.Floor(x + offset);
int finalZ = (int)Math.Floor(z + offset);
var y = (int)(10 + offset);
var blockX = MathHelper.ChunkToBlockX(finalX, chunk.Coordinates.X);
var blockZ = MathHelper.ChunkToBlockZ(finalZ, chunk.Coordinates.Z);
var spawnValue = offsetNoise.Value2D(blockX, blockZ);
if (spawnValue > 1.95 && spawnValue < 2.09)
{
var generated = new Dungeon().GenerateAt(world, chunk, new Coordinates3D(blockX, y, blockZ));
if (generated)
break;
}
}
}
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:27,代码来源:DungeonDecorator.cs
示例9: GenerateHeightMap
private void GenerateHeightMap(IChunk chunk)
{
Coordinates3D coords;
var map = new byte[Chunk.Width, Chunk.Depth];
for (byte x = 0; x < Chunk.Width; x++)
{
for (byte z = 0; z < Chunk.Depth; z++)
{
for (byte y = (byte)(chunk.GetHeight(x, z) + 2); y > 0; y--)
{
if (y >= Chunk.Height)
continue;
coords.X = x; coords.Y = y - 1; coords.Z = z;
var id = chunk.GetBlockID(coords);
if (id == 0)
continue;
var provider = BlockRepository.GetBlockProvider(id);
if (provider.LightOpacity != 0)
{
map[x, z] = y;
break;
}
}
}
}
HeightMaps[chunk.Coordinates] = map;
}
开发者ID:ricucremop,项目名称:TrueCraft,代码行数:27,代码来源:WorldLighting.cs
示例10: GenerateChunk
public IChunk GenerateChunk(IChunk chunk, int x, int z, bool external)
{
InitGen();
#if PROFILE
Stopwatch watch = new Stopwatch();
watch.Start();
#endif
GenerateTerrain(chunk, x, z);
GenerateFlora(chunk, x, z);
if (!external)
{
chunk.RecalculateHeight();
chunk.LightToRecalculate = true;
#if PROFILE
watch.Stop();
_World.Logger.Log(Logger.LogLevel.Info, "Chunk {0} {1}, {2}", false, x, z, watch.ElapsedMilliseconds);
#endif
_World.AddChunk(chunk);
chunk.MarkToSave();
}
return chunk;
}
开发者ID:TheaP,项目名称:c-raft,代码行数:28,代码来源:CustomChunkGenerator.cs
示例11: SaveChunk
public void SaveChunk(IChunk runtimeChunk)
{
using (var file = new FileStream(Path.Combine(this.m_Path, this.GetName(runtimeChunk)), FileMode.Create))
{
var size = this.m_ChunkSizePolicy.ChunkCellWidth * this.m_ChunkSizePolicy.ChunkCellHeight
* this.m_ChunkSizePolicy.ChunkCellDepth;
var chunk = new Chunk
{
X = runtimeChunk.X,
Y = runtimeChunk.Y,
Z = runtimeChunk.Z,
Cells = new Cell[size],
Indexes = runtimeChunk.GeneratedIndices,
Vertexes = new Vertex[runtimeChunk.GeneratedVertexes.Length]
};
chunk.Cells = runtimeChunk.Cells;
for (var i = 0; i < runtimeChunk.GeneratedVertexes.Length; i++)
{
chunk.Vertexes[i] = new Vertex
{
X = runtimeChunk.GeneratedVertexes[i].Position.X,
Y = runtimeChunk.GeneratedVertexes[i].Position.Y,
Z = runtimeChunk.GeneratedVertexes[i].Position.Z,
U = runtimeChunk.GeneratedVertexes[i].TextureCoordinate.X,
V = runtimeChunk.GeneratedVertexes[i].TextureCoordinate.Y,
};
}
var serializer = new TychaiaDataSerializer();
serializer.Serialize(file, chunk);
}
}
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:34,代码来源:SimpleLevel.cs
示例12: SaveAsync
/// <inheritdoc/>
public Task SaveAsync(Point index, IChunk chunk)
{
if (!_chunks.ContainsKey(index))
_chunks[index] = chunk;
return Task.CompletedTask;
}
开发者ID:SvenEV,项目名称:OrangeBugReloaded,代码行数:8,代码来源:InMemoryChunkStorage.cs
示例13: SaveChunk
public async Task SaveChunk(IChunk chunk)
{
await ChunkSaver.SaveFile(Destination, chunk.Start, chunk.Data);
if (ChunkSaved != null)
{
ChunkSaved.Invoke(this, chunk);
}
}
开发者ID:RichTeaMan,项目名称:Podcatcher,代码行数:8,代码来源:FileDownload.cs
示例14: Request
public void Request(IChunk chunk)
{
lock (_in)
{
_in.Enqueue(chunk);
Monitor.Pulse(_in);
}
}
开发者ID:dvdbrink,项目名称:Procedural,代码行数:8,代码来源:ThreadedChunkGenerator.cs
示例15: WriteDataDirectory
/// <summary>
/// Writes a data directory
/// </summary>
/// <param name="writer">Writer</param>
/// <param name="chunk">The data</param>
internal static void WriteDataDirectory(this BinaryWriter writer, IChunk chunk) {
if (chunk == null || chunk.GetVirtualSize() == 0)
writer.Write(0UL);
else {
writer.Write((uint)chunk.RVA);
writer.Write(chunk.GetVirtualSize());
}
}
开发者ID:EmilZhou,项目名称:dnlib,代码行数:13,代码来源:IChunk.cs
示例16: Save
public void Save(int universe, int planet, IChunk chunk)
{
var root = GetRoot();
string filename = planet.ToString() + "_" + chunk.Index.X + "_" + chunk.Index.Y + "_" + chunk.Index.Z + ".chunk";
using (Stream stream = File.Open(root.FullName + Path.DirectorySeparatorChar + filename, FileMode.Create, FileAccess.Write))
{
serializer.Serialize(stream, chunk);
}
}
开发者ID:thedomingo,项目名称:octoawesome,代码行数:10,代码来源:ChunkDiskPersistence.cs
示例17: GenerateTopper
/*
* Generates the top of the pine/conifer trees.
* Type:
* 0x0 - two level topper
* 0x1 - three level topper
*/
protected void GenerateTopper(IChunk chunk, Coordinates3D location, byte type = 0x0)
{
const int sectionRadius = 1;
GenerateCircle(chunk, location, sectionRadius, LeavesBlock.BlockID, 0x1);
var top = location + Coordinates3D.Up;
chunk.SetBlockID(top, LeavesBlock.BlockID);
chunk.SetMetadata(top, 0x1);
if (type == 0x1 && (top + Coordinates3D.Up).Y < Chunk.Height)
GenerateVanillaCircle(chunk, top + Coordinates3D.Up, sectionRadius, LeavesBlock.BlockID, 0x1);
}
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:16,代码来源:PineTree.cs
示例18: Grow
public void Grow(IStructBlock iBlock, IChunk ichunk)
{
var chunk = ichunk as Chunk;
var block = (StructBlock) iBlock;
if (!CanGrow(block, chunk))
return;
var blockUp = UniversalCoords.FromWorld(block.Coords.WorldX, block.Coords.WorldY + 1, block.Coords.WorldZ);
if (block.World.GetEffectiveLight(blockUp) < 9)
return;
if (block.World.Server.Rand.Next(29) != 0)
return;
if ((block.MetaData & 8) == 0)
{
chunk.SetData(block.Coords, (byte)(block.MetaData | 8));
return;
}
for (int i = block.Coords.WorldY; i < block.Coords.WorldY + 4; i++)
{
chunk.SetBlockAndData(block.Coords.BlockX, i, block.Coords.BlockZ, (byte)BlockData.Blocks.Wood, block.MetaData);
if(chunk.GetType(block.Coords.BlockX, i + 1, block.Coords.BlockZ) != BlockData.Blocks.Air)
break;
}
// Grow leaves
for (int i = block.Coords.WorldY + 2; i < block.Coords.WorldY + 5; i++)
for (int j = block.Coords.WorldX - 2; j <= block.Coords.WorldX + 2; j++)
for (int k = block.Coords.WorldZ - 2; k <= block.Coords.WorldZ + 2; k++)
{
var nearbyChunk = block.World.GetChunkFromWorld(i, k) as Chunk;
if (nearbyChunk == null || (nearbyChunk.GetType(j & 0xF, i, k & 0xF) != BlockData.Blocks.Air))
continue;
nearbyChunk.SetBlockAndData(j & 0xF, i, k & 0xF, (byte)BlockData.Blocks.Leaves,
block.MetaData);
}
for (int i = block.Coords.WorldX - 1; i <= block.Coords.WorldX + 1; i++)
for (int j = block.Coords.WorldZ - 1; j <= block.Coords.WorldZ + 1; j++)
{
var nearbyChunk = block.World.GetChunkFromWorld(i, j) as Chunk;
if (nearbyChunk == null || nearbyChunk.GetType(i & 0xF, block.Coords.WorldY + 5, j & 0xF) != BlockData.Blocks.Air)
continue;
nearbyChunk.SetBlockAndData(i & 0xF, block.Coords.WorldY + 5, j & 0xF, (byte)BlockData.Blocks.Leaves,
block.MetaData);
}
}
开发者ID:TheaP,项目名称:c-raft,代码行数:55,代码来源:BlockSapling.cs
示例19: Decorate
public void Decorate(IWorld world, IChunk chunk, IBiomeRepository biomes)
{
var noise = new Perlin();
noise.Seed = world.Seed;
var chanceNoise = new ClampNoise(noise);
chanceNoise.MaxValue = 2;
for (int x = 0; x < 16; x++)
{
for (int z = 0; z < 16; z++)
{
var biome = biomes.GetBiome(chunk.Biomes[x * Chunk.Width + z]);
var blockX = MathHelper.ChunkToBlockX(x, chunk.Coordinates.X);
var blockZ = MathHelper.ChunkToBlockZ(z, chunk.Coordinates.Z);
var height = chunk.HeightMap[x * Chunk.Width + z];
if (noise.Value2D(blockX, blockZ) > 0)
{
var blockLocation = new Coordinates3D(x, height, z);
var plantPosition = blockLocation + Coordinates3D.Up;
if (chunk.GetBlockID(blockLocation) == biome.SurfaceBlock && plantPosition.Y < Chunk.Height)
{
var chance = chanceNoise.Value2D(blockX, blockZ);
if (chance < 1)
{
var bushNoise = chanceNoise.Value2D(blockX * 0.7, blockZ * 0.7);
var grassNoise = chanceNoise.Value2D(blockX * 0.3, blockZ * 0.3);
if (biome.Plants.Contains(PlantSpecies.Deadbush) && bushNoise > 1 && chunk.GetBlockID(blockLocation) == SandBlock.BlockID)
{
GenerateDeadBush(chunk, plantPosition);
continue;
}
if (biome.Plants.Contains(PlantSpecies.TallGrass) && grassNoise > 0.3 && grassNoise < 0.95)
{
byte meta = (grassNoise > 0.3 && grassNoise < 0.45 && biome.Plants.Contains(PlantSpecies.Fern)) ? (byte)0x2 : (byte)0x1;
GenerateTallGrass(chunk, plantPosition, meta);
continue;
}
}
else
{
var flowerTypeNoise = chanceNoise.Value2D(blockX * 1.2, blockZ * 1.2);
if (biome.Plants.Contains(PlantSpecies.Rose) && flowerTypeNoise > 0.8 && flowerTypeNoise < 1.5)
{
GenerateRose(chunk, plantPosition);
}
else if (biome.Plants.Contains(PlantSpecies.Dandelion) && flowerTypeNoise <= 0.8)
{
GenerateDandelion(chunk, plantPosition);
}
}
}
}
}
}
}
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:55,代码来源:PlantDecorator.cs
示例20: MossFloor
private void MossFloor(IChunk chunk, Coordinates3D location, Random random)
{
for (int x = location.X; x < location.X + Size.X; x++)
{
for (int z = location.Z; z < location.Z + Size.Z; z++)
{
if (random.Next(0, 3) == 0)
chunk.SetBlockID(new Coordinates3D(x, location.Y, z), MossStoneBlock.BlockID);
}
}
}
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:11,代码来源:Dungeon.cs
注:本文中的IChunk类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论