A general theory of ecology