your ATS, automatic transfer switch, handles that for you
it will default to the Generator whenever it is cranking/running
and fail back over to the Shore Power, if you are still plugged in, when the Generator stops
the ATS is what allows you to do anything, power wise, without fear of 'overlapping' of power sources, since it's job is to switch to only one.
You could have your RV engine running, the generator running, and be plugged into shore power, all at the same time - no problem. Your ATS would use your Generator's power primarily, the Shore Power secondarily, and the Alternator, otherwise.
two Campers, two Electric cars
former diesel pusher traveler