I didn't want to point it out before, but they showed us Mao in really quick camera shots the past few episodes. As early as episode 12 there was a really brief shot of Mao standing on top of the roof of the school, watching Lelouch and Shirley. So he was seemingly planning that confrontation for a while. It's amusing how quick they showed him with 0 context haha. Just a neat detail.