Ejemplo n.º 1
0
        public static void DoLeaf(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.leafDecay)
            {
                lvl.leaves.Clear();
                C.data.Data = PhysicsArgs.RemoveFromChecks; return;
            }
            if (C.data.Data < 5)
            {
                if (rand.Next(10) == 0)
                {
                    C.data.Data++;
                }
                return;
            }
            if (DoLeafDecay(lvl, ref C))
            {
                lvl.AddUpdate(C.b, Block.air);
            }
            C.data.Data = PhysicsArgs.RemoveFromChecks;
        }
Ejemplo n.º 2
0
        public static void DoOther(Level lvl, ref Check C)
        {
            if (lvl.physics <= 1)
            {
                C.data.Data = PhysicsArgs.RemoveFromChecks; return;
            }
            ushort x, y, z;

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

            //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));
            C.data.Data = PhysicsArgs.RemoveFromChecks;
        }
Ejemplo n.º 3
0
        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 = PhysicsArgs.RemoveFromChecks; return;
            }
            if (C.data.Data < 20)
            {
                if (rand.Next(20) == 0)
                {
                    C.data.Data++;
                }
                return;
            }

            lvl.SetTile(x, y, z, Block.air);
            Tree tree = new NormalTree();

            tree.SetData(rand);
            tree.Output(x, y, z, (xT, yT, zT, bT) =>
            {
                if (lvl.GetTile(xT, yT, zT) == Block.air)
                {
                    lvl.Blockchange(xT, yT, zT, bT);
                }
            });

            C.data.Data = PhysicsArgs.RemoveFromChecks;
        }
Ejemplo n.º 4
0
        public static void DoFalling(Level lvl, ref Check C)
        {
            ushort x, y, z;

            lvl.IntToPos(C.b, out x, out y, out z);
            int  index     = C.b;
            bool movedDown = false;
            byte block     = lvl.blocks[C.b];

            do
            {
                index = lvl.IntOffset(index, 0, -1, 0); //Get block below each loop
                if (lvl.GetTile(index) == Block.Invalid)
                {
                    break;
                }
                bool hitBlock = false;

                switch (lvl.blocks[index])
                {
                case Block.air:
                case Block.water:
                case Block.lava:
                    movedDown = true;
                    break;

                //Adv physics crushes plants with sand
                case Block.shrub:
                case Block.yellowflower:
                case Block.redflower:
                case Block.mushroom:
                case Block.redmushroom:
                    if (lvl.physics > 1)
                    {
                        movedDown = true;
                    }
                    break;

                default:
                    hitBlock = true;
                    break;
                }
                if (hitBlock || lvl.physics > 1)
                {
                    break;
                }
            } while (true);

            if (movedDown)
            {
                lvl.AddUpdate(C.b, Block.air);
                if (lvl.physics > 1)
                {
                    lvl.AddUpdate(index, block);
                }
                else
                {
                    lvl.AddUpdate(lvl.IntOffset(index, 0, 1, 0), block);
                }

                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));
            }
            C.data.Data = PhysicsArgs.RemoveFromChecks;
        }