Exemple #1
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;
        }