Пример #1
0
        static void DoLavaUniformFlow(Level lvl, ref Check C, bool checkWait)
        {
            Random rand = lvl.physRandom;

            lvl.liquids.Remove(C.b);
            ushort x, y, z;

            lvl.IntToPos(C.b, out x, out y, out z);

            if (!lvl.CheckSpongeLava(x, y, z))
            {
                byte block = lvl.blocks[C.b];
                LiquidPhysics.PhysLava(lvl, (ushort)(x + 1), y, z, block);
                LiquidPhysics.PhysLava(lvl, (ushort)(x - 1), y, z, block);
                LiquidPhysics.PhysLava(lvl, x, y, (ushort)(z + 1), block);
                LiquidPhysics.PhysLava(lvl, x, y, (ushort)(z - 1), block);
                LiquidPhysics.PhysLava(lvl, x, (ushort)(y - 1), z, block);
            }
            else     //was placed near sponge
            {
                lvl.AddUpdate(C.b, Block.air);
            }
            if (!checkWait || !C.data.HasWait)
            {
                C.data.Data = 255;
            }
        }
Пример #2
0
        public static void DoMagma(Level lvl, ref Check C)
        {
            C.data.Data++;
            if (C.data.Data < 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];
                LiquidPhysics.PhysLava(lvl, (ushort)(x + 1), y, z, block);
                LiquidPhysics.PhysLava(lvl, (ushort)(x - 1), y, z, block);
                LiquidPhysics.PhysLava(lvl, x, y, (ushort)(z + 1), block);
                LiquidPhysics.PhysLava(lvl, x, y, (ushort)(z - 1), block);
            }

            if (lvl.physics <= 1 || C.data.Data <= 10)
            {
                return;
            }
            C.data.Data = 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);
            }
        }
Пример #3
0
        public static void DoLavafall(Level lvl, ref Check C)
        {
            Random rand = lvl.physRandom;
            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.data.HasWait)
                {
                    C.data.Data = 255;
                }
                break;

            case Block.air_flood_down:
            case Block.lavastill:
            case Block.waterstill:
            case Block.LavaDown:
                break;

            default:
                byte block = lvl.blocks[C.b];
                LiquidPhysics.PhysLava(lvl, (ushort)(x + 1), y, z, block);
                LiquidPhysics.PhysLava(lvl, (ushort)(x - 1), y, z, block);
                LiquidPhysics.PhysLava(lvl, x, y, (ushort)(z + 1), block);
                LiquidPhysics.PhysLava(lvl, x, y, (ushort)(z - 1), block);
                if (!C.data.HasWait)
                {
                    C.data.Data = 255;
                }
                break;
            }
        }
Пример #4
0
        static void DoLavaRandowFlow(Level lvl, ref Check C, bool checkWait)
        {
            Random rand = lvl.physRandom;

            bool[] blocked = null;
            ushort x, y, z;

            lvl.IntToPos(C.b, out x, out y, out z);

            if (!lvl.CheckSpongeLava(x, y, z))
            {
                C.data.Data = (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)
                {
                    LiquidPhysics.PhysLava(lvl, (ushort)(x + 1), y, z, block);
                    blocked[0] = true;
                }
                if (!blocked[1] && rand.Next(4) == 0)
                {
                    LiquidPhysics.PhysLava(lvl, (ushort)(x - 1), y, z, block);
                    blocked[1] = true;
                }
                if (!blocked[2] && rand.Next(4) == 0)
                {
                    LiquidPhysics.PhysLava(lvl, x, y, (ushort)(z + 1), block);
                    blocked[2] = true;
                }
                if (!blocked[3] && rand.Next(4) == 0)
                {
                    LiquidPhysics.PhysLava(lvl, x, y, (ushort)(z - 1), block);
                    blocked[3] = true;
                }
                if (!blocked[4] && rand.Next(4) == 0)
                {
                    LiquidPhysics.PhysLava(lvl, 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.data.HasWait)
                {
                    C.data.Data = 255;
                }
            }

            if (blocked != null && (!checkWait || !C.data.HasWait))
            {
                if (blocked[0] && blocked[1] && blocked[2] && blocked[3] && blocked[4])
                {
                    lvl.liquids.Remove(C.b);
                    C.data.Data = 255;
                }
            }
        }