PR: refactor state game
This commit is contained in:
@@ -4,8 +4,8 @@ import { useGameStore } from "@/managers/stores/useGameStore";
|
||||
import { AUDIO_PATHS } from "@/data/audioConfig";
|
||||
|
||||
export function GameFlow(): null {
|
||||
const step = useGameStore((state) => state.missionFlow.step);
|
||||
const setStep = useGameStore((state) => state.setFlowStep);
|
||||
const step = useGameStore((state) => state.intro.currentStep);
|
||||
const setStep = useGameStore((state) => state.setIntroStep);
|
||||
const setActivityCity = useGameStore((state) => state.setActivityCity);
|
||||
const setCanMove = useGameStore((state) => state.setCanMove);
|
||||
const hasInitialized = useRef(false);
|
||||
|
||||
@@ -8,8 +8,8 @@ interface NPCHelperProps {
|
||||
}
|
||||
|
||||
export function NPCHelper({ position }: NPCHelperProps): React.JSX.Element {
|
||||
const step = useGameStore((state) => state.missionFlow.step);
|
||||
const setStep = useGameStore((state) => state.setFlowStep);
|
||||
const step = useGameStore((state) => state.intro.currentStep);
|
||||
const setStep = useGameStore((state) => state.setIntroStep);
|
||||
const debug = Debug.getInstance();
|
||||
|
||||
const handlePress = (): void => {
|
||||
|
||||
@@ -10,8 +10,8 @@ interface PyloneDestroyedProps {
|
||||
export function PyloneDestroyed({
|
||||
position,
|
||||
}: PyloneDestroyedProps): React.JSX.Element {
|
||||
const step = useGameStore((state) => state.missionFlow.step);
|
||||
const setStep = useGameStore((state) => state.setFlowStep);
|
||||
const step = useGameStore((state) => state.intro.currentStep);
|
||||
const setStep = useGameStore((state) => state.setIntroStep);
|
||||
const setCanMove = useGameStore((state) => state.setCanMove);
|
||||
const showDialog = useGameStore((state) => state.showDialog);
|
||||
const debug = Debug.getInstance();
|
||||
|
||||
@@ -2,9 +2,9 @@ import { useState } from "react";
|
||||
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||
|
||||
export function IntroUI(): React.JSX.Element | null {
|
||||
const step = useGameStore((state) => state.missionFlow.step);
|
||||
const step = useGameStore((state) => state.intro.currentStep);
|
||||
const setPlayerName = useGameStore((state) => state.setPlayerName);
|
||||
const setStep = useGameStore((state) => state.setFlowStep);
|
||||
const setStep = useGameStore((state) => state.setIntroStep);
|
||||
const [inputValue, setInputValue] = useState("");
|
||||
|
||||
if (step !== "naming") return null;
|
||||
@@ -100,7 +100,7 @@ export function IntroUI(): React.JSX.Element | null {
|
||||
}
|
||||
|
||||
export function BienvenueDisplay(): React.JSX.Element | null {
|
||||
const step = useGameStore((state) => state.missionFlow.step);
|
||||
const step = useGameStore((state) => state.intro.currentStep);
|
||||
const playerName = useGameStore((state) => state.missionFlow.playerName);
|
||||
|
||||
if (step !== "bienvenue") return null;
|
||||
|
||||
@@ -26,8 +26,8 @@ export function ZoneDetection(): null {
|
||||
const camera = useThree((state) => state.camera);
|
||||
const triggeredZones = useRef<Set<string>>(new Set());
|
||||
const debug = Debug.getInstance();
|
||||
const step = useGameStore((state) => state.missionFlow.step);
|
||||
const setStep = useGameStore((state) => state.setFlowStep);
|
||||
const step = useGameStore((state) => state.intro.currentStep);
|
||||
const setStep = useGameStore((state) => state.setIntroStep);
|
||||
|
||||
useEffect(() => {
|
||||
if (!debug.active) return;
|
||||
@@ -45,7 +45,7 @@ export function ZoneDetection(): null {
|
||||
folder.add(playerPos, "z").name("Player Z").listen().disable();
|
||||
|
||||
const unsubStore = useGameStore.subscribe((state) => {
|
||||
gameState.step = state.missionFlow.step;
|
||||
gameState.step = state.intro.currentStep;
|
||||
folder.controllersRecursive().forEach((c) => c.updateDisplay());
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user