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.
'14 Palazzo 33.3 bunkhouse 34' diesel
KingTailgater2 Dish HD, 100w/5a SOLAR, BlueOx
110,000+mi since '14 - US, Alaska, Canada (also, '14 Gulfstream Amerilite and '07 ForestRiver Rockwood) : )b