A census of cool-core galaxy clusters in IllustrisTNG