import React, { useRef, useEffect } from 'react'; import { GameState, StoryData, Choice, SystemStatus } from '../types'; import SaveLoadControls from './SaveLoadControls'; import PlayerInput from './PlayerInput'; import LoadingSpinner from './LoadingSpinner'; import SystemMonitor from './SystemMonitor'; import GuardianConsole from './GuardianConsole'; import ConstellationMap from './ConstellationMap'; interface GameScreenProps { gameState: GameState; story: StoryData; onChoice: (choice: Choice) => void; onCustomAction: (input: string) => void; isLoading: boolean; onSave: () => void; onLoad: () => void; onRestart: () => void; isSaveDataPresent: boolean; codexStatus: SystemStatus; } const GameScreen: React.FC = ({ gameState, story, onChoice, onCustomAction, isLoading, onSave, onLoad, onRestart, isSaveDataPresent, codexStatus }) => { const currentScene = story[gameState.currentSceneId]; const scrollRef = useRef(null); useEffect(() => { if (scrollRef.current) { scrollRef.current.scrollTop = scrollRef.current.scrollHeight; } }, [gameState.history, gameState.currentSceneId]); if (!currentScene) { return (
Error: Scene '{gameState.currentSceneId}' not found.
) } return (

{currentScene.title || gameState.currentPillar || 'Codex'}

{gameState.history.map((hist, index) => { const scene = story[hist.sceneId]; if (!scene) return null; return (
{scene.text.map((p, i) =>

{p}

)} {hist.choiceText && (

> {hist.choiceText}

)}
) })}
{currentScene.text.map((paragraph, index) => (

{paragraph}

))}
{isLoading && (

Codex is processing...

)}
{!gameState.isGameOver && currentScene.choices.length > 0 && (
{currentScene.choices.map((choice, index) => ( ))}
)} {gameState.isGameOver && (
)} {!gameState.isGameOver && }
); }; export default GameScreen;