public static void DoShrub(Level lvl, ref Check C) { Random rand = lvl.physRandom; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); if (lvl.physics > 1) //Adv physics kills flowers and mushroos in water/lava { AirPhysics.PhysAir(lvl, lvl.PosToInt((ushort)(x + 1), y, z)); AirPhysics.PhysAir(lvl, lvl.PosToInt((ushort)(x - 1), y, z)); AirPhysics.PhysAir(lvl, lvl.PosToInt(x, y, (ushort)(z + 1))); AirPhysics.PhysAir(lvl, lvl.PosToInt(x, y, (ushort)(z - 1))); AirPhysics.PhysAir(lvl, lvl.PosToInt(x, (ushort)(y + 1), z)); } if (!lvl.growTrees) { C.data.Data = 255; return; } if (C.data.Data < 20) { if (rand.Next(20) == 0) { C.data.Data++; } return; } TreeDrawOp op = new TreeDrawOp(); op.random = rand; op.method = DrawOp.M_BlockChange; op.Perform(new [] { new Vec3U16(x, y, z) }, null, lvl, null); C.data.Data = 255; }
void GenNonLavaColumn(ushort x, ushort y, ushort z, Level Lvl, int index) { if (y > LiquidLevel) { int pos = x + Lvl.Width * (z + y * Lvl.Length); for (ushort yy = 0; y - yy >= 0; yy++) { if (genParams.SimpleColumns) { Lvl.blocks[pos] = Block.sand; } else if (overlay[index] < 0.72f) { if (genParams.IslandColumns) //increase sand height for island { if (y > LiquidLevel + 2) { if (yy == 0) { Lvl.blocks[pos] = Block.grass; //top layer } else if (yy < 3) { Lvl.blocks[pos] = Block.dirt; //next few } else { Lvl.blocks[pos] = Block.rock; //ten rock it } } else { Lvl.blocks[pos] = Block.sand; //SAAAND extra for islands } } else { if (yy == 0) { Lvl.blocks[pos] = Block.grass; } else if (yy < 3) { Lvl.blocks[pos] = Block.dirt; } else { Lvl.blocks[pos] = Block.rock; } } } else { Lvl.blocks[pos] = Block.rock; } pos -= Lvl.Width * Lvl.Length; } if (genParams.GenFlowers && overlay[index] < 0.25f) { switch (rand.Next(12)) { case 10: Lvl.SetTile(x, (ushort)(y + 1), z, Block.redflower); break; case 11: Lvl.SetTile(x, (ushort)(y + 1), z, Block.yellowflower); break; default: break; } } if (genParams.GenTrees && overlay[index] < 0.65f && overlay2[index] < treeDens) { if (Lvl.GetTile(x, (ushort)(y + 1), z) == Block.air) { if (Lvl.GetTile(x, y, z) == Block.grass || genParams.UseCactus) { if (rand.Next(13) == 0 && !TreeDrawOp.TreeCheck(Lvl, x, y, z, treeDist)) { treeDrawer.Type = genParams.UseCactus ? TreeDrawOp.T_Cactus : TreeDrawOp.T_Tree; treeCoords[0].X = x; treeCoords[0].Y = (ushort)(y + 1); treeCoords[0].Z = z; treeDrawer.Perform(treeCoords, null, Lvl, null); } } } } } else //Must be on/under the water line then { int pos = x + Lvl.Width * (z + LiquidLevel * Lvl.Length); for (ushort yy = 0; LiquidLevel - yy >= 0; yy++) { if (LiquidLevel - yy > y) { Lvl.blocks[pos] = Block.water; //better fill the water above me } else if (LiquidLevel - yy > y - 3) { byte block = overlay[index] < 0.75f ? Block.sand : Block.gravel; // sand on top Lvl.blocks[pos] = block; } else { Lvl.blocks[pos] = Block.rock; } pos -= Lvl.Width * Lvl.Length; } } }