Complex life cycles drive community assembly through immigration and adaptive diversification