You don't need to do this! Tiles that are flat with no slope are typically "flagged" (more info), which means they essentially have no angle. In the case of Sonic (or any player character), the sensors that find this tile instead return the nearest 90 degrees to Sonic's current Ground Angle. This simple solution allows him to walk on all sides of them in any normal situation! Note: this obviously causes issues if the terrain is set up in ways that are unintended (example). Otherwise if the tile is not flagged, Sonic's Ground Angle is just set to the tile's angle no matter what mode he is in. There's no algorithm for changing the returned angle based on the current mode. A 45 degree slope is a 45 degree slope no matter what You also aren't supposed to be in situations where you are trying to walk on the sides or "back" of a sloped tile, so no need to worry about that either. The tiles' returned angle IS changed depending on how it's flipped, of course.
I was talking about days ago about the Insta-Shield and it came up that the Classics made Sonic invincible, but it's not mentioned in the Insta-Shield section proper. I checked with Mania's decompilation, and that game seems to set the player's invincibility to -8 and increments towards 0.