Exchange-correlation energy of a multicomponent two-dimensional electron gas