Refactor #3935 Base code for cc.game.