animate and fix electricienne
🔍 Lint / 🪄 Check lint (push) Has been cancelled
🔍 Lint / 🎨 Check format (push) Has been cancelled
🔍 Lint / 🔎 Typecheck (push) Has been cancelled
📊 Quality / 🔒 Security Audit (push) Has been cancelled
📊 Quality / 📋 Dependency Freshness (push) Has been cancelled
📊 Quality / 📦 Bundle Size (push) Has been cancelled
🔍 Lint / 🏗 Build (push) Has been cancelled
🔍 Lint / 🪄 Check lint (push) Has been cancelled
🔍 Lint / 🎨 Check format (push) Has been cancelled
🔍 Lint / 🔎 Typecheck (push) Has been cancelled
📊 Quality / 🔒 Security Audit (push) Has been cancelled
📊 Quality / 📋 Dependency Freshness (push) Has been cancelled
📊 Quality / 📦 Bundle Size (push) Has been cancelled
🔍 Lint / 🏗 Build (push) Has been cancelled
This commit is contained in:
@@ -1,11 +1,72 @@
|
||||
import { useEffect } from "react";
|
||||
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||
import { loadDialogueManifest } from "@/utils/dialogues/loadDialogueManifest";
|
||||
import { playDialogueById } from "@/utils/dialogues/playDialogue";
|
||||
import { PYLON_NARRATIVE_DIALOGUES } from "@/data/gameplay/pylonConfig";
|
||||
|
||||
export function PylonNarratorOutro(): React.JSX.Element | null {
|
||||
const mainState = useGameStore((state) => state.mainState);
|
||||
const step = useGameStore((state) => state.pylon.currentStep);
|
||||
/**
|
||||
* Plays the narrator-outro audio sequence:
|
||||
* 1. electricienne_aurevoir ("À la prochaine !")
|
||||
* 2. narrateur_courantrepare ("powerRestored")
|
||||
* then completes the pylon mission.
|
||||
*/
|
||||
export function PylonNarratorOutro(): null {
|
||||
const completeMission = useGameStore((state) => state.completeMission);
|
||||
const setCanMove = useGameStore((state) => state.setCanMove);
|
||||
|
||||
if (mainState !== "pylon") return null;
|
||||
if (step !== "narrator-outro") return null;
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
setCanMove(false);
|
||||
|
||||
void (async () => {
|
||||
const manifest = await loadDialogueManifest();
|
||||
if (cancelled || !manifest) {
|
||||
setCanMove(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. Électricienne : "À la prochaine !"
|
||||
const audio1 = await playDialogueById(
|
||||
manifest,
|
||||
PYLON_NARRATIVE_DIALOGUES.electricienneAurevoir,
|
||||
);
|
||||
if (audio1 && !cancelled) {
|
||||
await new Promise<void>((resolve) => {
|
||||
audio1.addEventListener("ended", () => resolve(), { once: true });
|
||||
audio1.addEventListener("error", () => resolve(), { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
if (cancelled) {
|
||||
setCanMove(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. Narrateur : "Le courant est réparé"
|
||||
const audio2 = await playDialogueById(
|
||||
manifest,
|
||||
PYLON_NARRATIVE_DIALOGUES.powerRestored,
|
||||
);
|
||||
if (audio2 && !cancelled) {
|
||||
audio2.addEventListener(
|
||||
"ended",
|
||||
() => {
|
||||
setCanMove(true);
|
||||
completeMission("pylon");
|
||||
},
|
||||
{ once: true },
|
||||
);
|
||||
} else {
|
||||
setCanMove(true);
|
||||
completeMission("pylon");
|
||||
}
|
||||
})();
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
setCanMove(true);
|
||||
};
|
||||
}, [completeMission, setCanMove]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user