Пример #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 = PhysicsArgs.RemoveFromChecks;
            }
        }
Пример #2
0
        public static void DoLavafall(Level lvl, ref PhysInfo C)
        {
            ushort  x = C.X, y = C.Y, z = C.Z;
            int     index;
            BlockID below = lvl.GetBlock(x, (ushort)(y - 1), z, out index);

            switch (below)
            {
            case Block.Air:
                lvl.AddUpdate(index, Block.LavaDown, default(PhysicsArgs));
                if (!C.Data.HasWait)
                {
                    C.Data.Data = PhysicsArgs.RemoveFromChecks;
                }
                break;

            case Block.Air_FloodDown:
            case Block.StillLava:
            case Block.StillWater:
            case Block.LavaDown:
                break;

            default:
                BlockID block = C.Block;
                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 = PhysicsArgs.RemoveFromChecks;
                }
                break;
            }
        }
Пример #3
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);
            }
        }
Пример #4
0
        public static void DoMagma(Level lvl, ref PhysInfo C)
        {
            C.Data.Data++;
            if (C.Data.Data < 3)
            {
                return;
            }

            ushort  x = C.X, y = C.Y, z = C.Z;
            int     index;
            BlockID below = lvl.GetBlock(x, (ushort)(y - 1), z, out index);

            if (below == Block.Air)
            {
                lvl.AddUpdate(index, Block.Magma, default(PhysicsArgs));
            }
            else if (below != Block.Magma)
            {
                BlockID block = C.Block;
                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);
            }
        }
Пример #5
0
        static void DoLavaUniformFlow(Level lvl, ref PhysInfo C, bool checkWait)
        {
            ushort x = C.X, y = C.Y, z = C.Z;

            if (!lvl.CheckSpongeLava(x, y, z))
            {
                BlockID block = C.Block;
                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.Index, Block.Air, default(PhysicsArgs));
            }

            if (!checkWait || !C.Data.HasWait)
            {
                C.Data.Data = PhysicsArgs.RemoveFromChecks;
            }
        }
Пример #6
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 = PhysicsArgs.RemoveFromChecks;
                }
                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 = PhysicsArgs.RemoveFromChecks;
                }
                break;
            }
        }
Пример #7
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 = PhysicsArgs.RemoveFromChecks;
                }
            }

            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 = PhysicsArgs.RemoveFromChecks;
                }
            }
        }
Пример #8
0
        static void DoLavaRandowFlow(Level lvl, ref PhysInfo C, bool checkWait)
        {
            Random rand = lvl.physRandom;
            ushort x = C.X, y = C.Y, z = C.Z;

            if (!lvl.CheckSpongeLava(x, y, z))
            {
                byte data = C.Data.Data;
                // Upper 3 bits are time flags - reset random delay
                data &= flowed_maskAll;
                data |= (byte)(rand.Next(3) << 5);
                BlockID block = C.Block;

                if ((data & flowed_xMax) == 0 && rand.Next(4) == 0)
                {
                    LiquidPhysics.PhysLava(lvl, (ushort)(x + 1), y, z, block);
                    data |= flowed_xMax;
                }
                if ((data & flowed_xMin) == 0 && rand.Next(4) == 0)
                {
                    LiquidPhysics.PhysLava(lvl, (ushort)(x - 1), y, z, block);
                    data |= flowed_xMin;
                }
                if ((data & flowed_zMax) == 0 && rand.Next(4) == 0)
                {
                    LiquidPhysics.PhysLava(lvl, x, y, (ushort)(z + 1), block);
                    data |= flowed_zMax;
                }
                if ((data & flowed_zMin) == 0 && rand.Next(4) == 0)
                {
                    LiquidPhysics.PhysLava(lvl, x, y, (ushort)(z - 1), block);
                    data |= flowed_zMin;
                }
                if ((data & flowed_yMin) == 0 && rand.Next(4) == 0)
                {
                    LiquidPhysics.PhysLava(lvl, x, (ushort)(y - 1), z, block);
                    data |= flowed_yMin;
                }

                if ((data & flowed_xMax) == 0 && LavaBlocked(lvl, (ushort)(x + 1), y, z))
                {
                    data |= flowed_xMax;
                }
                if ((data & flowed_xMin) == 0 && LavaBlocked(lvl, (ushort)(x - 1), y, z))
                {
                    data |= flowed_xMin;
                }
                if ((data & flowed_zMax) == 0 && LavaBlocked(lvl, x, y, (ushort)(z + 1)))
                {
                    data |= flowed_zMax;
                }
                if ((data & flowed_zMin) == 0 && LavaBlocked(lvl, x, y, (ushort)(z - 1)))
                {
                    data |= flowed_zMin;
                }
                if ((data & flowed_yMin) == 0 && LavaBlocked(lvl, x, (ushort)(y - 1), z))
                {
                    data |= flowed_yMin;
                }

                // Have we spread now (or been blocked from spreading) in all directions?
                C.Data.Data = data;
                if ((!checkWait || !C.Data.HasWait) && (data & flowed_maskAll) == flowed_maskAll)
                {
                    C.Data.Data = PhysicsArgs.RemoveFromChecks;
                }
            }
            else     //was placed near sponge
            {
                lvl.AddUpdate(C.Index, Block.Air, default(PhysicsArgs));
                if (!checkWait || !C.Data.HasWait)
                {
                    C.Data.Data = PhysicsArgs.RemoveFromChecks;
                }
            }
        }