public override ChunkData[,] Generate(World world, int seed) { var size = world.WorldWidth * world.ChunkSize; var noise = PerlinNoise.Generate(size, size, octaveCount, amplitude, seed); for (int exp = 0; exp < ExplosionsCount; exp++) { int randomExpX = Random.Range(0, size); int randomExpZ = Random.Range(0, size); var selection = Selections.SelectSphere( new Vector3Int(randomExpX, (int)(world.ChunkHeight * 0.25f), randomExpZ), ExplosionsSize).ToList(); for (int i = 0; i < selection.Count; i++) { if (selection[i].x < 0 || selection[i].x >= size || selection[i].z < 0 || selection[i].z >= size) { continue; } noise[selection[i].x, selection[i].z] = 0; } } for (int x = 0; x < size; x++) { for (int z = 0; z < size; z++) { noise[x, z] *= CurveX.Evaluate((float)x / size) * CurveZ.Evaluate((float)z / size); } } var data = new ChunkData[world.WorldWidth, world.WorldDepth]; for (byte i = 0; i < world.WorldWidth; i++) { for (byte j = 0; j < world.WorldDepth; j++) { var chunk = new ChunkData(world.ChunkSize, world.ChunkHeight); FillChunk(world, chunk, noise, i, j); data[i, j] = chunk; } } return(data); }
public Vector3 Evaluate(float time) { return(new Vector3(CurveX.Evaluate(time), CurveY.Evaluate(time), CurveZ.Evaluate(time))); }
public void AddKey(float time, Vector3 pos) { CurveX.AddKey(time, pos.x); CurveY.AddKey(time, pos.y); CurveZ.AddKey(time, pos.z); }