Self-conscious cooperation: implications of a functional approach to emotions for behavior in social dilemmas