OK, sorry, I didn't pay enough attention you were using RigidBody2D and not KinematicBody2D.
So, I think you can work with a raycast, get the normal of the collision, compute a tangent from it to get the "direction" of the ground and use this tangent as your "forward" unit for the next move, it should do the trick.
Looking at your code, I think you need to change the way it handles movement on the floor (line 173 to 186 in player_generic.gd). Instead of changing lv only on x, you can use the contact normal found earlier (line 149) to apply a change on y also.