public override float GenerateLayer(Chunk chunk, int layerIndex, int x, int z, float heightSoFar, float strength) { Vector3 lpos = new Vector3(chunk.Pos.x + x, heightSoFar + 1f, chunk.Pos.z); float posChance = Randomization.Random(lpos.GetHashCode(), 200); if (Chance > posChance) { SetBlocks(chunk, x, z, (int)heightSoFar, (int)(heightSoFar + 1f), blockToPlace); return(heightSoFar + 1); } return(heightSoFar); }
public override void GenerateStructures(Chunk chunk, int layerIndex) { //if (chunk.pos.x!=-30 || chunk.pos.y!=30 || chunk.pos.z!=0) return; int minX = chunk.Pos.x; int maxX = chunk.Pos.x + Env.CHUNK_SIZE_1; int minZ = chunk.Pos.z; int maxZ = chunk.Pos.z + Env.CHUNK_SIZE_1; int structureID = 0; for (int x = minX; x <= maxX; x++) { for (int z = minZ; z <= maxZ; z++) { Vector3Int pos = new Vector3Int(x, 0, z); float chanceAtPos = Randomization.RandomPrecise(pos.GetHashCode(), 44); if (Chance > chanceAtPos) { if (Randomization.RandomPrecise(pos.Add(1, 0, 0).GetHashCode(), 44) > chanceAtPos && Randomization.RandomPrecise(pos.Add(-1, 0, 0).GetHashCode(), 44) > chanceAtPos && Randomization.RandomPrecise(pos.Add(0, 0, 1).GetHashCode(), 44) > chanceAtPos && Randomization.RandomPrecise(pos.Add(0, 0, -1).GetHashCode(), 44) > chanceAtPos) { int xx = Helpers.Mod(x, Env.CHUNK_SIZE); int zz = Helpers.Mod(z, Env.CHUNK_SIZE); int height = Helpers.FastFloor(terrainGen.GetTerrainHeightForChunk(chunk, xx, zz)); if (chunk.Pos.y <= height && chunk.Pos.y + Env.CHUNK_SIZE_1 >= height) { Vector3Int worldPos = new Vector3Int(x, height, z); structure.Build(chunk, structureID++, ref worldPos, this); } } } } } }