import { useCallback } from 'react'; import type { Character, CustomWorldProfile, GameState } from '../../types'; type UseRpgEntryCharacterSelectParams = { gameState: GameState; handleBackToWorldSelect: () => void; setSelectionStage: (stage: 'platform') => void; handleCharacterSelect: (character: NonNullable) => void; }; /** * 统一角色选择页的返回与确认动作,保持主阶段路由器里只做装配。 */ export function useRpgEntryCharacterSelect( params: UseRpgEntryCharacterSelectParams, ) { const { gameState, handleBackToWorldSelect, setSelectionStage, handleCharacterSelect, } = params; const customWorldProfile: CustomWorldProfile | null = gameState.customWorldProfile; const handleBack = useCallback(() => { handleBackToWorldSelect(); setSelectionStage('platform'); }, [handleBackToWorldSelect, setSelectionStage]); const handleConfirm = useCallback( (character: Character) => { handleCharacterSelect(character); }, [handleCharacterSelect], ); return { worldType: gameState.worldType, customWorldProfile, handleBack, handleConfirm, }; }