This commit is contained in:
2026-04-21 18:27:46 +08:00
parent 04bff9617d
commit 4372ab5be1
358 changed files with 30788 additions and 14737 deletions

View File

@@ -0,0 +1,46 @@
import { useCallback } from 'react';
import type { Character, CustomWorldProfile, GameState } from '../../types';
type UseRpgEntryCharacterSelectParams = {
gameState: GameState;
handleBackToWorldSelect: () => void;
setSelectionStage: (stage: 'platform') => void;
handleCharacterSelect: (character: NonNullable<GameState['playerCharacter']>) => 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,
};
}