Esempio n. 1
0
        internal static ChangeResult RocketStart(Player p, BlockID old, ushort x, ushort y, ushort z)
        {
            if (p.level.physics < 2 || p.level.physics == 5)
            {
                return(ChangeResult.Unchanged);
            }

            int dx = 0, dy = 0, dz = 0;

            DirUtils.EightYaw(p.Rot.RotY, out dx, out dz);
            DirUtils.Pitch(p.Rot.HeadX, out dy);

            // Looking straight up or down
            byte pitch = p.Rot.HeadX;

            if (pitch >= 192 && pitch <= 196 || pitch >= 60 && pitch <= 64)
            {
                dx = 0; dz = 0;
            }
            Vec3U16 head = new Vec3U16((ushort)(x + dx * 2), (ushort)(y + dy * 2), (ushort)(z + dz * 2));
            Vec3U16 tail = new Vec3U16((ushort)(x + dx), (ushort)(y + dy), (ushort)(z + dz));

            bool headFree = p.level.IsAirAt(head.X, head.Y, head.Z) && p.level.CheckClear(head.X, head.Y, head.Z);
            bool tailFree = p.level.IsAirAt(tail.X, tail.Y, tail.Z) && p.level.CheckClear(tail.X, tail.Y, tail.Z);

            if (headFree && tailFree)
            {
                p.level.Blockchange(head.X, head.Y, head.Z, Block.RocketHead);
                p.level.Blockchange(tail.X, tail.Y, tail.Z, Block.LavaFire);
            }
            return(ChangeResult.Unchanged);
        }
Esempio n. 2
0
        internal static bool RocketStart(Player p, byte block, ushort x, ushort y, ushort z)
        {
            if (p.level.physics < 2 || p.level.physics == 5)
            {
                p.RevertBlock(x, y, z); return(true);
            }

            int dx = 0, dy = 0, dz = 0;

            p.RevertBlock(x, y, z);
            DirUtils.EightYaw(p.rot[0], out dx, out dz);
            DirUtils.Pitch(p.rot[1], out dy);

            // Looking straight up or down
            if (p.rot[1] >= 192 && p.rot[1] <= 196 || p.rot[1] >= 60 && p.rot[1] <= 64)
            {
                dx = 0; dz = 0;
            }

            byte b1 = p.level.GetTile((ushort)(x + dx * 2), (ushort)(y + dy * 2), (ushort)(z + dz * 2));
            byte b2 = p.level.GetTile((ushort)(x + dx), (ushort)(y + dy), (ushort)(z + dz));

            if (b1 == Block.air && b2 == Block.air && p.level.CheckClear((ushort)(x + dx * 2), (ushort)(y + dy * 2), (ushort)(z + dz * 2)) &&
                p.level.CheckClear((ushort)(x + dx), (ushort)(y + dy), (ushort)(z + dz)))
            {
                p.level.Blockchange((ushort)(x + dx * 2), (ushort)(y + dy * 2), (ushort)(z + dz * 2), Block.rockethead);
                p.level.Blockchange((ushort)(x + dx), (ushort)(y + dy), (ushort)(z + dz), Block.lava_fire);
            }
            return(true);
        }