static void DoWaterRandowFlow(Level lvl, Check C, Random rand) { bool[] blocked = null; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); if (!lvl.PhysSpongeCheck(C.b)) { if (!lvl.liquids.TryGetValue(C.b, out blocked)) { blocked = new bool[5]; lvl.liquids.Add(C.b, blocked); } byte block = lvl.blocks[C.b]; if (lvl.GetTile(x, (ushort)(y + 1), z) != Block.Zero) { lvl.PhysSandCheck(lvl.PosToInt(x, (ushort)(y + 1), z)); } if (!blocked[0] && rand.Next(4) == 0) { lvl.PhysWater(lvl.PosToInt((ushort)(x + 1), y, z), block); blocked[0] = true; } if (!blocked[1] && rand.Next(4) == 0) { lvl.PhysWater(lvl.PosToInt((ushort)(x - 1), y, z), block); blocked[1] = true; } if (!blocked[2] && rand.Next(4) == 0) { lvl.PhysWater(lvl.PosToInt(x, y, (ushort)(z + 1)), block); blocked[2] = true; } if (!blocked[3] && rand.Next(4) == 0) { lvl.PhysWater(lvl.PosToInt(x, y, (ushort)(z - 1)), block); blocked[3] = true; } if (!blocked[4] && rand.Next(4) == 0) { lvl.PhysWater(lvl.PosToInt(x, (ushort)(y - 1), z), block); blocked[4] = true; } if (!blocked[0] && WaterBlocked(lvl, (ushort)(x + 1), y, z)) blocked[0] = true; if (!blocked[1] && WaterBlocked(lvl, (ushort)(x - 1), y, z)) blocked[1] = true; if (!blocked[2] && WaterBlocked(lvl, x, y, (ushort)(z + 1))) blocked[2] = true; if (!blocked[3] && WaterBlocked(lvl, x, y, (ushort)(z - 1))) blocked[3] = true; if (!blocked[4] && WaterBlocked(lvl, x, (ushort)(y - 1), z)) blocked[4] = true; } else { //was placed near sponge lvl.liquids.TryGetValue(C.b, out blocked); lvl.AddUpdate(C.b, Block.air); if (C.extraInfo.IndexOf("wait") == -1) C.time = 255; } if (C.extraInfo.IndexOf("wait") == -1 && blocked != null) if (blocked[0] && blocked[1] && blocked[2] && blocked[3] && blocked[4]) { lvl.liquids.Remove(C.b); C.time = 255; } }
static void DoWaterUniformFlow(Level lvl, Check C, Random rand) { lvl.liquids.Remove(C.b); ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); if (!lvl.PhysSpongeCheck(C.b)) { byte block = lvl.blocks[C.b]; if (lvl.GetTile(x, (ushort)(y + 1), z) != Block.Zero) { lvl.PhysSandCheck(lvl.PosToInt(x, (ushort)(y + 1), z)); } lvl.PhysWater(lvl.PosToInt((ushort)(x + 1), y, z), block); lvl.PhysWater(lvl.PosToInt((ushort)(x - 1), y, z), block); lvl.PhysWater(lvl.PosToInt(x, y, (ushort)(z + 1)), block); lvl.PhysWater(lvl.PosToInt(x, y, (ushort)(z - 1)), block); lvl.PhysWater(lvl.PosToInt(x, (ushort)(y - 1), z), block); } else { //was placed near sponge lvl.AddUpdate(C.b, Block.air); } if (C.extraInfo.IndexOf("wait") == -1) C.time = 255; }