Instead of being trampled by the transition to green energy, oil-and-gas giants are now positioned to profit from it.