How to check what a punch has hit?

That’s a way to do it, at least it differentiates between ‘punchable’ things and ‘unpunchable’ things. However it doesn’t really tell me things like “is the enemy temporarily invincible?”. I can try to cast to every type of enemy to check the “isInvincible” variable, but I would like a simpler/ more elegant solution.