The influence of environmental spatial structure on the life-history traits and diversity of species in a metacommunity