As gentiles also worshipped in the Holy Temple, I wonder if ritual impurity also applied to them
According to Pesachim 92a, a gentile is not susceptible to ritual impurity:
He was a gentile and therefore he was not susceptible to ritual impurity, because gentiles do not contract ritual impurity according to Torah law, but now he is a Jew and is susceptible to ritual impurity.
See however Niddah 69b:
Because his impurity that he transmits even when alive is not by Torah law, but by rabbinic law. The Sages decreed that every living gentile imparts ritual impurity in the manner of a zav; they did not extend their decree to include the corpse of a gentile in the manner of the corpse of a zav.
Also, see this related posts: