public static void DoMagma(Level lvl, Check C, Random rand) { C.time++; if (C.time < 3) return; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); byte below = lvl.GetTile(x, (ushort)(y - 1), z); if (below == Block.air) { lvl.AddUpdate(lvl.PosToInt(x, (ushort)(y - 1), z), Block.magma); } else if (below != Block.magma) { byte block = lvl.blocks[C.b]; lvl.PhysLava(lvl.PosToInt((ushort)(x + 1), y, z), block); lvl.PhysLava(lvl.PosToInt((ushort)(x - 1), y, z), block); lvl.PhysLava(lvl.PosToInt(x, y, (ushort)(z + 1)), block); lvl.PhysLava(lvl.PosToInt(x, y, (ushort)(z - 1)), block); } if (lvl.physics <= 1 || C.time <= 10) return; C.time = 0; bool flowUp = false; MagmaFlow(lvl, x - 1, y, z, ref flowUp); MagmaFlow(lvl, x + 1, y, z, ref flowUp); MagmaFlow(lvl, x, y - 1, z, ref flowUp); MagmaFlow(lvl, x, y, z - 1, ref flowUp); MagmaFlow(lvl, x, y, z + 1, ref flowUp); if (flowUp) MagmaFlow(lvl, x, y + 1, z, ref flowUp); }
static void DoLavaUniformFlow(Level lvl, Check C, Random rand, bool checkWait) { lvl.liquids.Remove(C.b); ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); if (!lvl.PhysSpongeCheck(C.b, true)) { byte block = lvl.blocks[C.b]; lvl.PhysLava(lvl.PosToInt((ushort)(x + 1), y, z), block); lvl.PhysLava(lvl.PosToInt((ushort)(x - 1), y, z), block); lvl.PhysLava(lvl.PosToInt(x, y, (ushort)(z + 1)), block); lvl.PhysLava(lvl.PosToInt(x, y, (ushort)(z - 1)), block); lvl.PhysLava(lvl.PosToInt(x, (ushort)(y - 1), z), block); } else { //was placed near sponge lvl.AddUpdate(C.b, Block.air); } if (!checkWait || C.extraInfo.IndexOf("wait") == -1) C.time = 255; }
static void DoLavaRandowFlow(Level lvl, Check C, Random rand, bool checkWait) { bool[] blocked = null; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); if (!lvl.PhysSpongeCheck(C.b, true)) { C.time = (byte)rand.Next(3); 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 (!blocked[0] && rand.Next(4) == 0) { lvl.PhysLava(lvl.PosToInt((ushort)(x + 1), y, z), block); blocked[0] = true; } if (!blocked[1] && rand.Next(4) == 0) { lvl.PhysLava(lvl.PosToInt((ushort)(x - 1), y, z), block); blocked[1] = true; } if (!blocked[2] && rand.Next(4) == 0) { lvl.PhysLava(lvl.PosToInt(x, y, (ushort)(z + 1)), block); blocked[2] = true; } if (!blocked[3] && rand.Next(4) == 0) { lvl.PhysLava(lvl.PosToInt(x, y, (ushort)(z - 1)), block); blocked[3] = true; } if (!blocked[4] && rand.Next(4) == 0) { lvl.PhysLava(lvl.PosToInt(x, (ushort)(y - 1), z), block); blocked[4] = true; } if (!blocked[0] && LavaBlocked(lvl, (ushort)(x + 1), y, z)) blocked[0] = true; if (!blocked[1] && LavaBlocked(lvl, (ushort)(x - 1), y, z)) blocked[1] = true; if (!blocked[2] && LavaBlocked(lvl, x, y, (ushort)(z + 1))) blocked[2] = true; if (!blocked[3] && LavaBlocked(lvl, x, y, (ushort)(z - 1))) blocked[3] = true; if (!blocked[4] && LavaBlocked(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 (!checkWait || C.extraInfo.IndexOf("wait") == -1) C.time = 255; } if (blocked != null && (!checkWait || C.extraInfo.IndexOf("wait") == -1)) if (blocked[0] && blocked[1] && blocked[2] && blocked[3] && blocked[4]) { lvl.liquids.Remove(C.b); C.time = 255; } }
public static void DoLavafall(Level lvl, Check C, Random rand) { ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); byte below = lvl.GetTile(x, (ushort)(y - 1), z); switch (below) { case Block.air: lvl.AddUpdate(lvl.PosToInt(x, (ushort)(y - 1), z), Block.LavaDown); if (C.extraInfo.IndexOf("wait") == -1) C.time = 255; break; case Block.air_flood_down: case Block.lavastill: case Block.waterstill: case Block.LavaDown: break; default: byte block = lvl.blocks[C.b]; lvl.PhysLava(lvl.PosToInt((ushort)(x + 1), y, z), block); lvl.PhysLava(lvl.PosToInt((ushort)(x - 1), y, z), block); lvl.PhysLava(lvl.PosToInt(x, y, (ushort)(z + 1)),block); lvl.PhysLava(lvl.PosToInt(x, y, (ushort)(z - 1)), block); if (C.extraInfo.IndexOf("wait") == -1) C.time = 255; break; } }