Energetically consistent model of slipping and sticking frictional impacts in multibody systems