5 Commits

Author SHA1 Message Date
math-pixel 1325b7b2af Merge branch 'develop' into feat/polish-mission-2
🔍 Lint / 🪄 Check lint (pull_request) Has been cancelled
🔍 Lint / 🎨 Check format (pull_request) Has been cancelled
🔍 Lint / 🔎 Typecheck (pull_request) Has been cancelled
📊 Quality / 🔒 Security Audit (pull_request) Has been cancelled
📊 Quality / 📋 Dependency Freshness (pull_request) Has been cancelled
📊 Quality / 📦 Bundle Size (pull_request) Has been cancelled
🔍 Lint / 🏗 Build (pull_request) Has been cancelled
2026-06-03 02:02:37 +02:00
math-pixel 63c2b294c1 Merge branch 'develop' into feat/polish-mission-2
🔍 Lint / 🪄 Check lint (pull_request) Has been cancelled
🔍 Lint / 🎨 Check format (pull_request) Has been cancelled
🔍 Lint / 🔎 Typecheck (pull_request) Has been cancelled
📊 Quality / 🔒 Security Audit (pull_request) Has been cancelled
📊 Quality / 📋 Dependency Freshness (pull_request) Has been cancelled
📊 Quality / 📦 Bundle Size (pull_request) Has been cancelled
🔍 Lint / 🏗 Build (pull_request) Has been cancelled
2026-06-03 01:52:20 +02:00
math-pixel 10b0d4fc16 outro anim + vid 2026-06-03 01:45:43 +02:00
math-pixel b1037d5107 split narrator srt 2026-06-03 01:01:48 +02:00
math-pixel 18fb5e39e9 edit electricienne + poto 2026-06-03 00:05:07 +02:00
21 changed files with 510 additions and 59 deletions
+6 -12
View File
@@ -2,24 +2,18 @@
"version": 1, "version": 1,
"cinematics": [ "cinematics": [
{ {
"id": "intro_overview", "id": "outro_farm_drone",
"timecode": 0, "timecode": 0,
"dialogueCues": [
{
"time": 0,
"dialogueId": "narrateur_bienvenueaaltera"
}
],
"cameraKeyframes": [ "cameraKeyframes": [
{ {
"time": 0, "time": 0,
"position": [8, 5, 12], "position": [-24, 5, 65],
"target": [0, 2, 0] "target": [-24, 2, 42]
}, },
{ {
"time": 4, "time": 10,
"position": [12, 4, -6], "position": [-24, 90, 200],
"target": [10, 1.4, -8] "target": [-24, 0, 42]
} }
] ]
} }
+3 -3
View File
@@ -39340,8 +39340,7 @@
"rotation": [0, 0.0027, 0.0819], "rotation": [0, 0.0027, 0.0819],
"scale": [1, 1, 1] "scale": [1, 1, 1]
} }
], ]
"id": "repair:pylon"
}, },
{ {
"name": "pylone", "name": "pylone",
@@ -39373,7 +39372,8 @@
"rotation": [0, 0.0027, 0.0819], "rotation": [0, 0.0027, 0.0819],
"scale": [1, 1, 1] "scale": [1, 1, 1]
} }
] ],
"id": "repair:pylon"
}, },
{ {
"name": "pylone", "name": "pylone",
+1 -1
View File
@@ -163,7 +163,7 @@
"id": "narrateur_histoireelectricienne", "id": "narrateur_histoireelectricienne",
"voice": "narrateur", "voice": "narrateur",
"audio": "/sounds/dialogue/narrateur_histoireelectricienne.mp3", "audio": "/sounds/dialogue/narrateur_histoireelectricienne.mp3",
"subtitleCueIndex": 23 "subtitleCueIndices": [23, 25, 26, 27, 28]
}, },
{ {
"id": "narrateur_demande_aide", "id": "narrateur_demande_aide",
@@ -87,5 +87,21 @@ Welcome to your workshop!! So? Pretty impressive, right? Okay, quick tour of wha
Here, this is a dashboard. You can imagine that if your fridge or oven breaks down, you won't be able to put it in the pipe haha! So here, it tells you when residents have a bulky item that broke down, or when there's a problem in the city. Uh oh... I've got an emergency, I'll have to leave you soon! So here, take your tools to repair most things: a mini 3D printer powered by electronic waste, Push-Parts gloves to disassemble objects, and a Relaunch pack! Here, this is a dashboard. You can imagine that if your fridge or oven breaks down, you won't be able to put it in the pipe haha! So here, it tells you when residents have a bulky item that broke down, or when there's a problem in the city. Uh oh... I've got an emergency, I'll have to leave you soon! So here, take your tools to repair most things: a mini 3D printer powered by electronic waste, Push-Parts gloves to disassemble objects, and a Relaunch pack!
23 23
00:00:00,000 --> 00:00:54,000 00:00:00,000 --> 00:00:07,500
The electrician helped you at the Power Plant? Aaaaah, that's what I love here: everyone helps each other, nobody judges anyone, it's like a real little family. You should know the electrician has quite a special story. She was born in the north of the continent, in the city of Kalska. She grew up happily with her mother Edith, her father Jordan, and her two little brothers, Malo and Justin. A few years ago, as you know, the northern countries were, quite unexpectedly, the first ones forced to migrate. So they began their journey, country by country, city by city, village by village. On a day of walking like so many others after several months, a climate storm caught them off guard. Having split up to find food in the village, her father and one of her two brothers sadly disappeared. It's tragic. But one day, they happened upon this place during their journey. We welcomed them with open arms, and they were slowly able to rebuild their lives among us. Today, they are an integral part of the community. The electrician helped you at the Power Plant? Aaaaah, that's what I love here: everyone helps each other, nobody judges anyone, it's like a real little family.
25
00:00:07,500 --> 00:00:19,100
You should know the electrician has quite a special story. She was born in the north of the continent, in the city of Kalska. She grew up happily with her mother Edith, her father Jordan, and her two little brothers, Malo and Justin.
26
00:00:19,100 --> 00:00:30,600
A few years ago, as you know, the northern countries were, quite unexpectedly, the first ones forced to migrate. So they began their journey, country by country, city by city, village by village.
27
00:00:30,600 --> 00:00:42,800
On a day of walking like so many others after several months, a climate storm caught them off guard. Having split up to find food in the village, her father and one of her two brothers sadly disappeared. It's tragic.
28
00:00:42,800 --> 00:00:54,000
But one day, they happened upon this place during their journey. We welcomed them with open arms, and they were slowly able to rebuild their lives among us. Today, they are an integral part of the community.
@@ -87,5 +87,21 @@ Bienvenue dans ton atelier !! Alors ? Ça claque hein ? Bon je te présente en r
Ici, c'est un tableau de bord. T'imagines bien que si ton frigo ou ton four tombe en panne, tu ne vas pas pouvoir le mettre dans le tuyau haha ! Donc ici, ça te signale quand des résidents ont un objet volumineux tombé en panne, ou quand il y a un problème dans la ville. Oh oh... j'ai une urgence, il va bientôt falloir que je te laisse ! Donc tiens, tes outils pour pouvoir réparer la plupart des choses : une mini imprimante 3D à base de déchets électroniques, des gants Pousse Pièces pour désassembler les objets, ainsi qu'un pack de Relance ! Ici, c'est un tableau de bord. T'imagines bien que si ton frigo ou ton four tombe en panne, tu ne vas pas pouvoir le mettre dans le tuyau haha ! Donc ici, ça te signale quand des résidents ont un objet volumineux tombé en panne, ou quand il y a un problème dans la ville. Oh oh... j'ai une urgence, il va bientôt falloir que je te laisse ! Donc tiens, tes outils pour pouvoir réparer la plupart des choses : une mini imprimante 3D à base de déchets électroniques, des gants Pousse Pièces pour désassembler les objets, ainsi qu'un pack de Relance !
23 23
00:00:00,000 --> 00:00:54,000 00:00:00,000 --> 00:00:07,500
L'électricienne t'a aidé à la Centrale ? Aaaaah c'est ça que j'adore ici, tout le monde s'entraide, personne se juge, une vraie petite famille. Sache que l'électricienne a une histoire assez particulière. Elle est née au nord du continent, dans la ville de Kalska. Elle a grandit heureuse, avec sa mère Edith, son père Jordan et ses deux petits frères Malo et Justin. Il y a quelques années de ça, comme tu le sais, c'est les pays du Nord, qui par grande surprise, ont été obligés de migrer en premier. Ils ont alors entamé leur périple, pays par pays, ville par ville, village par village. Un jour de marche comme les autres depuis plusieurs mois, une tempête climatique les a pris de court. S'étant séparés pour trouver des vivres dans le village, le père et un des deux frères sont malheureusement partis. C'est tragique. Mais un beau jour, ils sont tombés ici, par hasard dans leur périple. On les a accueillis les bras ouverts et ils ont pu se reconstruire doucement parmi nous et font partie intégrante de la communauté aujourd'hui. L'électricienne t'a aidé à la Centrale ? Aaaaah c'est ça que j'adore ici, tout le monde s'entraide, personne se juge, une vraie petite famille.
25
00:00:07,500 --> 00:00:19,100
Sache que l'électricienne a une histoire assez particulière. Elle est née au nord du continent, dans la ville de Kalska. Elle a grandit heureuse, avec sa mère Edith, son père Jordan et ses deux petits frères Malo et Justin.
26
00:00:19,100 --> 00:00:30,600
Il y a quelques années de ça, comme tu le sais, c'est les pays du Nord, qui par grande surprise, ont été obligés de migrer en premier. Ils ont alors entamé leur périple, pays par pays, ville par ville, village par village.
27
00:00:30,600 --> 00:00:42,800
Un jour de marche comme les autres depuis plusieurs mois, une tempête climatique les a pris de court. S'étant séparés pour trouver des vivres dans le village, le père et un des deux frères sont malheureusement partis. C'est tragique.
28
00:00:42,800 --> 00:00:54,000
Mais un beau jour, ils sont tombés ici, par hasard dans leur périple. On les a accueillis les bras ouverts et ils ont pu se reconstruire doucement parmi nous et font partie intégrante de la communauté aujourd'hui.
@@ -0,0 +1,165 @@
import { useEffect, useRef } from "react";
import { useGameStore } from "@/managers/stores/useGameStore";
import { useSubtitleStore } from "@/managers/stores/useSubtitleStore";
import { AudioManager } from "@/managers/AudioManager";
const HISTOIRE_AUDIO_PATH = "/sounds/dialogue/narrateur_histoireelectricienne.mp3";
const OUTRO_DELAY_MS = 5_000; // delay after audio ends before transitioning to outro
/**
* Text blocks for the electricienne history narration (max 5 lines each).
* Displayed sequentially — timings are calculated dynamically from the actual
* audio duration so they are always correct regardless of the mp3 length.
*/
const HISTOIRE_BLOCKS = [
"L'électricienne t'a aidé à la Centrale ? Aaaaah c'est ça que j'adore ici, tout le monde s'entraide, personne se juge, une vraie petite famille.",
"Sache que l'électricienne a une histoire assez particulière. Elle est née au nord du continent, dans la ville de Kalska. Elle a grandit heureuse, avec sa mère Edith, son père Jordan et ses deux petits frères Malo et Justin.",
"Il y a quelques années de ça, comme tu le sais, c'est les pays du Nord, qui par grande surprise, ont été obligés de migrer en premier. Ils ont alors entamé leur périple, pays par pays, ville par ville, village par village.",
"Un jour de marche comme les autres depuis plusieurs mois, une tempête climatique les a pris de court. S'étant séparés pour trouver des vivres dans le village, le père et un des deux frères sont malheureusement partis. C'est tragique.",
"Mais un beau jour, ils sont tombés ici, par hasard dans leur périple. On les a accueillis les bras ouverts et ils ont pu se reconstruire doucement parmi nous et font partie intégrante de la communauté aujourd'hui.",
] as const;
const TOTAL_CHARS = HISTOIRE_BLOCKS.reduce((sum, b) => sum + b.length, 0);
/** Compute start/end times for each block based on actual audio duration. */
function buildBlockTimings(
duration: number,
): Array<{ start: number; end: number }> {
let t = 0;
return HISTOIRE_BLOCKS.map((block) => {
const blockDuration = (block.length / TOTAL_CHARS) * duration;
const start = t;
t += blockDuration;
return { start, end: t };
});
}
/**
* Play the histoire audio and keep `useSubtitleStore` in sync with
* dynamically-computed block boundaries.
* Movement is intentionally NOT blocked so the player can explore while
* listening to the narration.
* `onAudioEnded` fires once when the audio element emits "ended".
*/
function useHistoireSubtitlePlayback(
enabled: boolean,
onAudioEnded?: () => void,
): void {
// Keep callback in a ref so the effect doesn't need it as a dependency.
const onAudioEndedRef = useRef(onAudioEnded);
useEffect(() => {
onAudioEndedRef.current = onAudioEnded;
});
useEffect(() => {
if (!enabled) return undefined;
let isCancelled = false;
const audio = AudioManager.getInstance().playSound(HISTOIRE_AUDIO_PATH, 1, {
category: "dialogue",
});
if (!audio) return undefined;
const { setActiveSubtitle, clearActiveSubtitle } =
useSubtitleStore.getState();
/** Wire up block-level subtitle sync once we know the audio duration. */
function startSync(): void {
const duration = audio.duration;
if (!duration || isNaN(duration) || isCancelled) return;
const timings = buildBlockTimings(duration);
function onTimeUpdate(): void {
const t = audio.currentTime;
const idx = timings.findIndex(
({ start, end }) => t >= start && t < end,
);
if (idx >= 0) {
setActiveSubtitle({
speaker: "Narrateur",
text: HISTOIRE_BLOCKS[idx],
});
}
}
function onEnded(): void {
clearActiveSubtitle();
onAudioEndedRef.current?.();
}
audio.addEventListener("timeupdate", onTimeUpdate);
audio.addEventListener("ended", onEnded, { once: true });
}
// If duration is already known (cached audio), start immediately.
if (audio.duration && !isNaN(audio.duration)) {
startSync();
} else {
audio.addEventListener("loadedmetadata", startSync, { once: true });
}
return () => {
isCancelled = true;
audio.pause();
useSubtitleStore.getState().clearActiveSubtitle();
};
}, [enabled]);
}
/**
* Handles the farm mission narrative intro:
* locked → (auto) → electricienne_history → plays audio with block subtitles
* → 5 s after audio ends → completeMission("farm") → outro
*/
export function FarmNarrativeFlow(): null {
const mainState = useGameStore((state) => state.mainState);
const step = useGameStore((state) => state.farm.currentStep);
const setMissionStep = useGameStore((state) => state.setMissionStep);
const completeMission = useGameStore((state) => state.completeMission);
// locked is purely a gate — transition immediately to electricienne_history.
useEffect(() => {
if (mainState !== "farm" || step !== "locked") return;
setMissionStep("farm", "electricienne_history");
}, [mainState, step, setMissionStep]);
// Ensure movement is always allowed during the electricienne_history narration,
// regardless of what the previous step may have blocked.
const setCanMove = useGameStore((state) => state.setCanMove);
useEffect(() => {
if (mainState !== "farm" || step !== "electricienne_history") return;
setCanMove(true);
}, [mainState, step, setCanMove]);
// After the audio finishes, wait 5 s then transition to outro.
// The timeout ID is kept in a ref so we can cancel on unmount.
const outroTimeoutRef = useRef<ReturnType<typeof window.setTimeout> | null>(null);
useEffect(() => {
return () => {
if (outroTimeoutRef.current !== null) {
window.clearTimeout(outroTimeoutRef.current);
}
};
}, []);
const handleAudioEnded = (): void => {
if (outroTimeoutRef.current !== null) {
window.clearTimeout(outroTimeoutRef.current);
}
outroTimeoutRef.current = window.setTimeout(() => {
outroTimeoutRef.current = null;
completeMission("farm");
}, OUTRO_DELAY_MS);
};
useHistoireSubtitlePlayback(
mainState === "farm" && step === "electricienne_history",
handleAudioEnded,
);
return null;
}
@@ -4,6 +4,8 @@ import { useGLTF } from "@react-three/drei";
import * as THREE from "three"; import * as THREE from "three";
import { InteractableObject } from "@/components/three/interaction/InteractableObject"; import { InteractableObject } from "@/components/three/interaction/InteractableObject";
import { useGameStore } from "@/managers/stores/useGameStore"; import { useGameStore } from "@/managers/stores/useGameStore";
import { useRepairMissionAnchorStore } from "@/managers/stores/useRepairMissionAnchorStore";
import { useTerrainSnappedPosition } from "@/hooks/three/useTerrainHeight";
import { loadDialogueManifest } from "@/utils/dialogues/loadDialogueManifest"; import { loadDialogueManifest } from "@/utils/dialogues/loadDialogueManifest";
import { playDialogueById } from "@/utils/dialogues/playDialogue"; import { playDialogueById } from "@/utils/dialogues/playDialogue";
import { import {
@@ -14,6 +16,7 @@ import {
PYLON_UPRIGHT_ROTATION, PYLON_UPRIGHT_ROTATION,
PYLON_WORLD_POSITION, PYLON_WORLD_POSITION,
} from "@/data/gameplay/pylonConfig"; } from "@/data/gameplay/pylonConfig";
import { isRepairGameStep } from "@/types/gameplay/repairMission";
import { pylonStraighteningSignal } from "@/components/gameplay/pylon/pylonSignals"; import { pylonStraighteningSignal } from "@/components/gameplay/pylon/pylonSignals";
const PYLON_MODEL_PATH = "/models/pylone/model.glb"; const PYLON_MODEL_PATH = "/models/pylone/model.glb";
@@ -22,6 +25,15 @@ export function PylonDownedPylon(): React.JSX.Element | null {
const mainState = useGameStore((state) => state.mainState); const mainState = useGameStore((state) => state.mainState);
const step = useGameStore((state) => state.pylon.currentStep); const step = useGameStore((state) => state.pylon.currentStep);
const setCanMove = useGameStore((state) => state.setCanMove); const setCanMove = useGameStore((state) => state.setCanMove);
// Use the repair:pylon anchor from the store so the downed pylon is always
// co-located with the instanced mesh it replaces. Falls back to the
// hard-coded constant while the map is loading or unavailable.
const pylonAnchor = useRepairMissionAnchorStore(
(state) => state.anchors.pylon,
);
// Snap to terrain so the downed/upright model sits flush on the ground,
// matching the Y adjustment that InstancedMapAsset applies to the same node.
const position = useTerrainSnappedPosition(pylonAnchor ?? PYLON_WORLD_POSITION);
const [isStraightening, setIsStraightening] = useState(false); const [isStraightening, setIsStraightening] = useState(false);
// Keeps the pylon upright after the animation completes while // Keeps the pylon upright after the animation completes while
// PylonFarmerNPC plays the post-raise audio sequence. // PylonFarmerNPC plays the post-raise audio sequence.
@@ -30,19 +42,9 @@ export function PylonDownedPylon(): React.JSX.Element | null {
const straightenStartRef = useRef<number | null>(null); const straightenStartRef = useRef<number | null>(null);
const hasPlayedFirstAudioRef = useRef(false); const hasPlayedFirstAudioRef = useRef(false);
const showUpright = // Hidden outside the pylon mission and once the pylon has been raised
isRaised || // (repair-game steps take over from there).
mainState !== "pylon" || const shouldRender = mainState === "pylon" && !isRepairGameStep(step);
step === "waiting" ||
step === "inspected" ||
step === "fragmented" ||
step === "scanning" ||
step === "repairing" ||
step === "reassembling" ||
step === "done" ||
step === "narrator-outro";
const isPylonInteractive = step === "arrived" || step === "npc-return";
useEffect(() => { useEffect(() => {
if (step === "arrived") { if (step === "arrived") {
@@ -61,9 +63,7 @@ export function PylonDownedPylon(): React.JSX.Element | null {
if (!group) return; if (!group) return;
if (!isStraightening || straightenStartRef.current === null) { if (!isStraightening || straightenStartRef.current === null) {
group.rotation.set( group.rotation.set(...(isRaised ? PYLON_UPRIGHT_ROTATION : PYLON_DOWNED_ROTATION));
...(showUpright ? PYLON_UPRIGHT_ROTATION : PYLON_DOWNED_ROTATION),
);
return; return;
} }
@@ -79,6 +79,8 @@ export function PylonDownedPylon(): React.JSX.Element | null {
); );
}); });
const isPylonInteractive = step === "arrived" || step === "npc-return";
const beginStraighten = (): void => { const beginStraighten = (): void => {
setIsStraightening(true); setIsStraightening(true);
pylonStraighteningSignal.started = true; pylonStraighteningSignal.started = true;
@@ -99,10 +101,12 @@ export function PylonDownedPylon(): React.JSX.Element | null {
}, PYLON_STRAIGHTEN_ANIMATION_DURATION_MS); }, PYLON_STRAIGHTEN_ANIMATION_DURATION_MS);
}; };
if (!shouldRender) return null;
return ( return (
<group <group
ref={groupRef} ref={groupRef}
position={PYLON_WORLD_POSITION} position={position}
rotation={PYLON_DOWNED_ROTATION} rotation={PYLON_DOWNED_ROTATION}
> >
<primitive object={scene.clone(true)} /> <primitive object={scene.clone(true)} />
@@ -112,7 +116,7 @@ export function PylonDownedPylon(): React.JSX.Element | null {
label={ label={
step === "arrived" ? "Inspecter le pylône" : "Redresser le pylône" step === "arrived" ? "Inspecter le pylône" : "Redresser le pylône"
} }
position={PYLON_WORLD_POSITION} position={position}
radius={PYLON_NARRATIVE_INTERACT_RADIUS} radius={PYLON_NARRATIVE_INTERACT_RADIUS}
onPress={() => { onPress={() => {
if (step === "arrived") { if (step === "arrived") {
@@ -43,9 +43,32 @@ function faceToward(
return Math.atan2(dx, dz); return Math.atan2(dx, dz);
} }
/**
* Outer shell — only checks visibility conditions.
* Rendering is delegated to PylonFarmerNPCContent so that the heavy hooks
* (useFrame, useAnimations) are only active while the NPC is actually shown.
*/
export function PylonFarmerNPC(): React.JSX.Element | null { export function PylonFarmerNPC(): React.JSX.Element | null {
const mainState = useGameStore((state) => state.mainState); const mainState = useGameStore((state) => state.mainState);
const step = useGameStore((state) => state.pylon.currentStep); const step = useGameStore((state) => state.pylon.currentStep);
if (mainState !== "pylon") return null;
// Visible during narrative + at repair completion (hides during repair steps)
if (
step !== "arrived" &&
step !== "npc-return" &&
step !== "inspected" &&
step !== "done"
) {
return null;
}
return <PylonFarmerNPCContent />;
}
// ─── Inner component — heavy hooks only run when NPC is mounted ──────────────
function PylonFarmerNPCContent(): React.JSX.Element {
const step = useGameStore((state) => state.pylon.currentStep);
const setMissionStep = useGameStore((state) => state.setMissionStep); const setMissionStep = useGameStore((state) => state.setMissionStep);
const camera = useThree((state) => state.camera); const camera = useThree((state) => state.camera);
@@ -102,7 +125,6 @@ export function PylonFarmerNPC(): React.JSX.Element | null {
const playPostRaiseAudioAndAdvance = useCallback(async () => { const playPostRaiseAudioAndAdvance = useCallback(async () => {
const manifest = await loadDialogueManifest(); const manifest = await loadDialogueManifest();
if (manifest) { if (manifest) {
// "N'hésite pas, si tu as besoin d'autre chose !"
const audio = await playDialogueById( const audio = await playDialogueById(
manifest, manifest,
PYLON_NARRATIVE_DIALOGUES.electricienneApresMontage, PYLON_NARRATIVE_DIALOGUES.electricienneApresMontage,
@@ -134,6 +156,15 @@ export function PylonFarmerNPC(): React.JSX.Element | null {
playAnim("walk"); playAnim("walk");
} else if (step === "inspected") { } else if (step === "inspected") {
playAnim("idle"); playAnim("idle");
} else if (step === "done") {
// NPC reappears at repair completion — position at the post-raise spot,
// facing the pylon, playing idle.
currentPosRef.current.set(...PYLON_FARMER_NPC_AFTER_POSITION_pylone_straight);
savedRotationYRef.current = faceToward(
currentPosRef.current,
PYLON_WORLD_POSITION,
);
playAnim("idle");
} }
}, [step, playAnim]); }, [step, playAnim]);
@@ -184,7 +215,7 @@ export function PylonFarmerNPC(): React.JSX.Element | null {
); );
} }
group.position.copy(currentPosRef.current); group.position.copy(currentPosRef.current);
} else if (step === "inspected") { } else if (step === "inspected" || step === "done") {
group.position.set(...PYLON_FARMER_NPC_AFTER_POSITION_pylone_straight); group.position.set(...PYLON_FARMER_NPC_AFTER_POSITION_pylone_straight);
} else if (isCompleted) { } else if (isCompleted) {
group.position.copy(currentPosRef.current); group.position.copy(currentPosRef.current);
@@ -211,10 +242,6 @@ export function PylonFarmerNPC(): React.JSX.Element | null {
}); });
/* eslint-enable react-hooks/immutability */ /* eslint-enable react-hooks/immutability */
if (mainState !== "pylon") return null;
if (step !== "arrived" && step !== "npc-return" && step !== "inspected")
return null;
return ( return (
<group ref={groupRef} position={PYLON_FARMER_NPC_POSITION}> <group ref={groupRef} position={PYLON_FARMER_NPC_POSITION}>
<primitive object={model} /> <primitive object={model} />
@@ -225,6 +252,13 @@ export function PylonFarmerNPC(): React.JSX.Element | null {
position={PYLON_FARMER_NPC_POSITION} position={PYLON_FARMER_NPC_POSITION}
radius={PYLON_NARRATIVE_INTERACT_RADIUS} radius={PYLON_NARRATIVE_INTERACT_RADIUS}
onPress={() => { onPress={() => {
// Turn to face the player the moment they engage the NPC
savedRotationYRef.current = faceToward(currentPosRef.current, [
camera.position.x,
camera.position.y,
camera.position.z,
]);
void (async () => { void (async () => {
const manifest = await loadDialogueManifest(); const manifest = await loadDialogueManifest();
if (!manifest) { if (!manifest) {
@@ -19,9 +19,13 @@ export function PylonLightingEffect(): null {
const mainState = useGameStore((state) => state.mainState); const mainState = useGameStore((state) => state.mainState);
const step = useGameStore((state) => state.pylon.currentStep); const step = useGameStore((state) => state.pylon.currentStep);
// True from "approaching" until narrator-outro (lighting resets before the outro audio) // True from "approaching" until done — lighting starts reverting as soon as
// the repair is complete (powerup sfx plays at "done", outro dialogue at "narrator-outro").
const isActive = const isActive =
mainState === "pylon" && step !== "locked" && step !== "narrator-outro"; mainState === "pylon" &&
step !== "locked" &&
step !== "done" &&
step !== "narrator-outro";
// Working THREE.Color instances — lerped every frame // Working THREE.Color instances — lerped every frame
const ambientRef = useRef(new THREE.Color(LIGHTING_STATE.ambientColor)); const ambientRef = useRef(new THREE.Color(LIGHTING_STATE.ambientColor));
@@ -1,3 +1,4 @@
import { useEffect } from "react";
import { useGameStore } from "@/managers/stores/useGameStore"; import { useGameStore } from "@/managers/stores/useGameStore";
import { useDialoguePlayback } from "@/hooks/gameplay/useDialoguePlayback"; import { useDialoguePlayback } from "@/hooks/gameplay/useDialoguePlayback";
import { ZoneDetection } from "@/components/zone/ZoneDetection"; import { ZoneDetection } from "@/components/zone/ZoneDetection";
@@ -5,22 +6,122 @@ import { PylonFarmerNPC } from "@/components/gameplay/pylon/PylonFarmerNPC";
import { PylonNarratorOutro } from "@/components/gameplay/pylon/PylonNarratorOutro"; import { PylonNarratorOutro } from "@/components/gameplay/pylon/PylonNarratorOutro";
import { PYLON_APPROACH_ZONE, PYLON_ARRIVED_ZONE } from "@/data/gameplay/zones"; import { PYLON_APPROACH_ZONE, PYLON_ARRIVED_ZONE } from "@/data/gameplay/zones";
import { PYLON_NARRATIVE_DIALOGUES } from "@/data/gameplay/pylonConfig"; import { PYLON_NARRATIVE_DIALOGUES } from "@/data/gameplay/pylonConfig";
import { AudioManager } from "@/managers/AudioManager";
import { loadDialogueManifest } from "@/utils/dialogues/loadDialogueManifest";
import { playDialogueById } from "@/utils/dialogues/playDialogue";
const PYLON_POWERDOWN_SFX = "/sounds/effect/generateur-powerdown.mp3";
const PYLON_POWERUP_SFX = "/sounds/effect/generateur-powerup.mp3";
export function PylonNarrativeFlow(): React.JSX.Element | null { export function PylonNarrativeFlow(): React.JSX.Element | null {
const mainState = useGameStore((state) => state.mainState); const mainState = useGameStore((state) => state.mainState);
const step = useGameStore((state) => state.pylon.currentStep); const step = useGameStore((state) => state.pylon.currentStep);
const setMissionStep = useGameStore((state) => state.setMissionStep); const setMissionStep = useGameStore((state) => state.setMissionStep);
const setCanMove = useGameStore((state) => state.setCanMove);
useDialoguePlayback({ // ── approaching : powerdown sfx → then electricOutage dialogue ────────────
enabled: mainState === "pylon" && step === "approaching", useEffect(() => {
dialogueId: PYLON_NARRATIVE_DIALOGUES.electricOutage, if (mainState !== "pylon" || step !== "approaching") return undefined;
});
let isCancelled = false;
setCanMove(false);
void (async () => {
// 1. Play the generator powerdown sound effect
const sfx = AudioManager.getInstance().playSound(
PYLON_POWERDOWN_SFX,
1,
{ category: "sfx" },
);
// 2. Wait for it to finish (or skip if it can't load)
if (sfx) {
await new Promise<void>((resolve) => {
sfx.addEventListener("ended", () => resolve(), { once: true });
sfx.addEventListener("error", () => resolve(), { once: true });
});
}
if (isCancelled) return;
// 3. Play the narrative dialogue
const manifest = await loadDialogueManifest();
if (isCancelled || !manifest) {
setCanMove(true);
return;
}
const audio = await playDialogueById(
manifest,
PYLON_NARRATIVE_DIALOGUES.electricOutage,
);
if (isCancelled || !audio) {
setCanMove(true);
return;
}
audio.addEventListener(
"ended",
() => {
setCanMove(true);
},
{ once: true },
);
})();
return () => {
isCancelled = true;
setCanMove(true);
};
}, [mainState, step, setCanMove]);
// ── arrived : searchCentral dialogue (unchanged) ──────────────────────────
useDialoguePlayback({ useDialoguePlayback({
enabled: mainState === "pylon" && step === "arrived", enabled: mainState === "pylon" && step === "arrived",
dialogueId: PYLON_NARRATIVE_DIALOGUES.searchCentral, dialogueId: PYLON_NARRATIVE_DIALOGUES.searchCentral,
}); });
// ── inspected (demo skip) : jump straight to done after 5 s ─────────────
useEffect(() => {
if (mainState !== "pylon" || step !== "inspected") return undefined;
const timeoutId = window.setTimeout(() => {
setMissionStep("pylon", "done");
}, 5_000);
return () => {
window.clearTimeout(timeoutId);
};
}, [mainState, step, setMissionStep]);
// ── done : powerup sfx + lighting revert → auto-transition to narrator-outro
useEffect(() => {
if (mainState !== "pylon" || step !== "done") return undefined;
const sfx = AudioManager.getInstance().playSound(PYLON_POWERUP_SFX, 1, {
category: "sfx",
});
if (sfx) {
sfx.addEventListener(
"ended",
() => setMissionStep("pylon", "narrator-outro"),
{ once: true },
);
sfx.addEventListener(
"error",
() => setMissionStep("pylon", "narrator-outro"),
{ once: true },
);
} else {
// Fallback if the audio can't load
setMissionStep("pylon", "narrator-outro");
}
return undefined;
}, [mainState, step, setMissionStep]);
// narrator-outro audio sequence + completeMission are handled in PylonNarratorOutro // narrator-outro audio sequence + completeMission are handled in PylonNarratorOutro
if (mainState !== "pylon") return null; if (mainState !== "pylon") return null;
@@ -45,7 +146,12 @@ export function PylonNarrativeFlow(): React.JSX.Element | null {
); );
} }
if (step === "arrived" || step === "npc-return" || step === "inspected") { if (
step === "arrived" ||
step === "npc-return" ||
step === "inspected" ||
step === "done"
) {
return <PylonFarmerNPC />; return <PylonFarmerNPC />;
} }
+1 -1
View File
@@ -204,7 +204,7 @@ export function RepairGame({
onComplete={() => setMissionStep(mission, "done")} onComplete={() => setMissionStep(mission, "done")}
/> />
) : null} ) : null}
{step === "done" ? ( {step === "done" && mission !== "pylon" ? (
<RepairCompletionStep <RepairCompletionStep
config={config} config={config}
onComplete={() => completeMission(mission)} onComplete={() => completeMission(mission)}
+2
View File
@@ -4,6 +4,7 @@ import { GameSettingsMenu } from "@/components/ui/GameSettingsMenu";
import { HandTrackingFallback } from "@/components/ui/HandTrackingFallback"; import { HandTrackingFallback } from "@/components/ui/HandTrackingFallback";
import { HandTrackingVisualizer } from "@/components/ui/HandTrackingVisualizer"; import { HandTrackingVisualizer } from "@/components/ui/HandTrackingVisualizer";
import { InteractPrompt } from "@/components/ui/InteractPrompt"; import { InteractPrompt } from "@/components/ui/InteractPrompt";
import { OutroVideoOverlay } from "@/components/ui/OutroVideoOverlay";
import { Subtitles } from "@/components/ui/Subtitles"; import { Subtitles } from "@/components/ui/Subtitles";
import { TalkieDialogueOverlay } from "@/components/ui/TalkieDialogueOverlay"; import { TalkieDialogueOverlay } from "@/components/ui/TalkieDialogueOverlay";
import { HandTrackingTutorial } from "@/components/ui/tutorial/HandTrackingTutorial"; import { HandTrackingTutorial } from "@/components/ui/tutorial/HandTrackingTutorial";
@@ -22,6 +23,7 @@ export function GameUI(): React.JSX.Element {
<Subtitles /> <Subtitles />
<TalkieDialogueOverlay /> <TalkieDialogueOverlay />
<GameSettingsMenu /> <GameSettingsMenu />
<OutroVideoOverlay />
</> </>
); );
} }
+55
View File
@@ -0,0 +1,55 @@
import { useEffect, useRef, useState } from "react";
const OUTRO_VIDEO_SRC = "/cinematics/outro.mp4";
/**
* Full-screen video overlay that plays once after the outro drone-shot
* cinematic ends. Triggered by the "outro-cinematic-complete" window event
* dispatched from GameCinematics.tsx.
*/
export function OutroVideoOverlay(): React.JSX.Element | null {
const [visible, setVisible] = useState(false);
const videoRef = useRef<HTMLVideoElement>(null);
useEffect(() => {
function handleCinematicComplete(): void {
setVisible(true);
}
window.addEventListener("outro-cinematic-complete", handleCinematicComplete);
return () => {
window.removeEventListener(
"outro-cinematic-complete",
handleCinematicComplete,
);
};
}, []);
useEffect(() => {
if (!visible) return;
void videoRef.current?.play();
}, [visible]);
if (!visible) return null;
return (
<div
style={{
position: "fixed",
inset: 0,
zIndex: 10000,
background: "#000",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
<video
ref={videoRef}
src={OUTRO_VIDEO_SRC}
style={{ width: "100%", height: "100%", objectFit: "cover" }}
playsInline
/>
</div>
);
}
+4 -1
View File
@@ -161,7 +161,10 @@ function completePylonState(state: GameState): GameStateUpdate {
}, },
farm: { farm: {
...state.farm, ...state.farm,
currentStep: "waiting", // Farm starts at "locked" so FarmNarrativeFlow can auto-transition
// to "electricienne_history" and play the intro audio before the
// repair game begins.
currentStep: "locked",
}, },
}; };
} }
+12 -1
View File
@@ -100,7 +100,8 @@ export type MissionStep =
| "repairing" | "repairing"
| "reassembling" | "reassembling"
| "done" | "done"
| "narrator-outro"; | "narrator-outro"
| "electricienne_history";
export const PYLON_NARRATIVE_STEPS = [ export const PYLON_NARRATIVE_STEPS = [
"approaching", "approaching",
@@ -109,6 +110,12 @@ export const PYLON_NARRATIVE_STEPS = [
"narrator-outro", "narrator-outro",
] as const; ] as const;
/** Farm-specific steps that bypass the repair-game flow. */
export const FARM_NARRATIVE_STEPS = [
"locked",
"electricienne_history",
] as const;
export const REPAIR_GAME_STEPS = [ export const REPAIR_GAME_STEPS = [
"waiting", "waiting",
"inspected", "inspected",
@@ -123,6 +130,10 @@ export function isPylonNarrativeStep(step: MissionStep): boolean {
return (PYLON_NARRATIVE_STEPS as readonly MissionStep[]).includes(step); return (PYLON_NARRATIVE_STEPS as readonly MissionStep[]).includes(step);
} }
export function isFarmNarrativeStep(step: MissionStep): boolean {
return (FARM_NARRATIVE_STEPS as readonly MissionStep[]).includes(step);
}
export function isRepairGameStep(step: MissionStep): boolean { export function isRepairGameStep(step: MissionStep): boolean {
return (REPAIR_GAME_STEPS as readonly MissionStep[]).includes(step); return (REPAIR_GAME_STEPS as readonly MissionStep[]).includes(step);
} }
+2
View File
@@ -11,6 +11,8 @@ export interface MapNode {
} }
export interface MapNodeInstanceTransform { export interface MapNodeInstanceTransform {
/** Node id from map.json — preserved so specific instances can be excluded at runtime. */
id?: string;
position: Vector3Tuple; position: Vector3Tuple;
rotation: Vector3Tuple; rotation: Vector3Tuple;
scale: Vector3Tuple; scale: Vector3Tuple;
+1
View File
@@ -4,6 +4,7 @@ export function mapNodeToInstanceTransform(
node: MapNode, node: MapNode,
): MapNodeInstanceTransform { ): MapNodeInstanceTransform {
return { return {
id: node.id,
position: node.position, position: node.position,
rotation: node.rotation, rotation: node.rotation,
scale: node.scale, scale: node.scale,
+9 -1
View File
@@ -118,7 +118,15 @@ function playCinematic(
onUpdate: () => camera.lookAt(target), onUpdate: () => camera.lookAt(target),
onComplete: () => { onComplete: () => {
timelineRef.current = null; timelineRef.current = null;
useGameStore.getState().setCinematicPlaying(false); // During the outro the camera is intentionally left at its final
// position — don't release cinematic lock so the player camera system
// can't snap it back to the player's eye position.
const { mainState } = useGameStore.getState();
if (mainState === "outro") {
window.dispatchEvent(new CustomEvent("outro-cinematic-complete"));
} else {
useGameStore.getState().setCinematicPlaying(false);
}
}, },
}); });
+11 -1
View File
@@ -2,6 +2,7 @@ import { Ebike } from "@/components/ebike/Ebike";
import { InteractableObject } from "@/components/three/interaction/InteractableObject"; import { InteractableObject } from "@/components/three/interaction/InteractableObject";
import { RepairFocusBubble } from "@/components/three/gameplay/RepairFocusBubble"; import { RepairFocusBubble } from "@/components/three/gameplay/RepairFocusBubble";
import { RepairGame } from "@/components/three/gameplay/RepairGame"; import { RepairGame } from "@/components/three/gameplay/RepairGame";
import { FarmNarrativeFlow } from "@/components/gameplay/farm/FarmNarrativeFlow";
import { PylonDownedPylon } from "@/components/gameplay/pylon/PylonDownedPylon"; import { PylonDownedPylon } from "@/components/gameplay/pylon/PylonDownedPylon";
import { PylonLightingEffect } from "@/components/gameplay/pylon/PylonLightingEffect"; import { PylonLightingEffect } from "@/components/gameplay/pylon/PylonLightingEffect";
import { PylonNarrativeFlow } from "@/components/gameplay/pylon/PylonNarrativeFlow"; import { PylonNarrativeFlow } from "@/components/gameplay/pylon/PylonNarrativeFlow";
@@ -19,7 +20,10 @@ import {
import { useGameStore } from "@/managers/stores/useGameStore"; import { useGameStore } from "@/managers/stores/useGameStore";
import { useRepairFocusStore } from "@/managers/stores/useRepairFocusStore"; import { useRepairFocusStore } from "@/managers/stores/useRepairFocusStore";
import { useRepairMissionAnchorStore } from "@/managers/stores/useRepairMissionAnchorStore"; import { useRepairMissionAnchorStore } from "@/managers/stores/useRepairMissionAnchorStore";
import { isPylonNarrativeStep } from "@/types/gameplay/repairMission"; import {
isFarmNarrativeStep,
isPylonNarrativeStep,
} from "@/types/gameplay/repairMission";
import type { RepairMissionTriggerConfig } from "@/types/gameplay/repairMission"; import type { RepairMissionTriggerConfig } from "@/types/gameplay/repairMission";
import type { Vector3Tuple } from "@/types/three/three"; import type { Vector3Tuple } from "@/types/three/three";
import { getRepairMissionPosition } from "@/utils/gameplay/repairMissionPosition"; import { getRepairMissionPosition } from "@/utils/gameplay/repairMissionPosition";
@@ -90,8 +94,12 @@ export function GameStageContent(): React.JSX.Element {
const anchors = useRepairMissionAnchorStore((state) => state.anchors); const anchors = useRepairMissionAnchorStore((state) => state.anchors);
const repairFocusActive = useRepairFocusStore((state) => state.active); const repairFocusActive = useRepairFocusStore((state) => state.active);
const farmStep = useGameStore((state) => state.farm.currentStep);
const pylonInNarrative = const pylonInNarrative =
mainState === "pylon" && isPylonNarrativeStep(pylonStep); mainState === "pylon" && isPylonNarrativeStep(pylonStep);
const farmInNarrative =
mainState === "farm" && isFarmNarrativeStep(farmStep);
return ( return (
<> <>
@@ -106,10 +114,12 @@ export function GameStageContent(): React.JSX.Element {
</> </>
) : null} ) : null}
{mainState === "pylon" ? <PylonNarrativeFlow /> : null} {mainState === "pylon" ? <PylonNarrativeFlow /> : null}
{mainState === "farm" ? <FarmNarrativeFlow /> : null}
{REPAIR_MISSION_POSITION_ENTRIES.map(({ mission }) => { {REPAIR_MISSION_POSITION_ENTRIES.map(({ mission }) => {
const position = getRepairMissionPosition(mission, anchors); const position = getRepairMissionPosition(mission, anchors);
if (!position) return null; if (!position) return null;
if (mission === "pylon" && pylonInNarrative) return null; if (mission === "pylon" && pylonInNarrative) return null;
if (mission === "farm" && farmInNarrative) return null;
return ( return (
<RepairGame key={mission} mission={mission} position={position} /> <RepairGame key={mission} mission={mission} position={position} />
); );
+1 -1
View File
@@ -271,7 +271,7 @@ export function TestMap({ onOctreeReady }: TestMapProps): React.JSX.Element {
</mesh> </mesh>
*/} */}
{/* GPS Map screen plane */} {/* GPS Map screen plane */}
<group position={[0, 0, 0.06]}> <group position={[0, -8, 0.06]}>
<EbikeGPSMap <EbikeGPSMap
width={4} width={4}
height={4} height={4}
@@ -20,6 +20,7 @@ import {
isMapModelVisible, isMapModelVisible,
useMapPerformanceStore, useMapPerformanceStore,
} from "@/managers/stores/useMapPerformanceStore"; } from "@/managers/stores/useMapPerformanceStore";
import { useGameStore } from "@/managers/stores/useGameStore";
import { InstancedMapAsset } from "@/world/map-instancing/InstancedMapAsset"; import { InstancedMapAsset } from "@/world/map-instancing/InstancedMapAsset";
import { import {
MAP_INSTANCING_ASSETS, MAP_INSTANCING_ASSETS,
@@ -27,6 +28,8 @@ import {
type MapInstancingAssetConfig, type MapInstancingAssetConfig,
type MapInstancingAssetType, type MapInstancingAssetType,
} from "@/data/world/mapInstancingConfig"; } from "@/data/world/mapInstancingConfig";
import { REPAIR_MISSION_ANCHOR_IDS } from "@/data/gameplay/repairMissionAnchors";
import { isRepairGameStep } from "@/types/gameplay/repairMission";
import { useMapInstancingData } from "@/hooks/world/useMapInstancingData"; import { useMapInstancingData } from "@/hooks/world/useMapInstancingData";
import type { MapAssetInstance } from "@/types/map/mapScene"; import type { MapAssetInstance } from "@/types/map/mapScene";
import type { GraphicsPreset } from "@/data/world/graphicsConfig"; import type { GraphicsPreset } from "@/data/world/graphicsConfig";
@@ -146,6 +149,8 @@ export function MapInstancingSystem({
const groups = useMapPerformanceStore((state) => state.groups); const groups = useMapPerformanceStore((state) => state.groups);
const models = useMapPerformanceStore((state) => state.models); const models = useMapPerformanceStore((state) => state.models);
const { data, isLoading } = useMapInstancingData(); const { data, isLoading } = useMapInstancingData();
const mainState = useGameStore((state) => state.mainState);
const pylonStep = useGameStore((state) => state.pylon.currentStep);
const streamingEnabled = const streamingEnabled =
streaming && streaming &&
CHUNK_CONFIG.enabled && CHUNK_CONFIG.enabled &&
@@ -153,6 +158,15 @@ export function MapInstancingSystem({
sceneMode === "game" && sceneMode === "game" &&
cameraMode === "player"; cameraMode === "player";
// During the pylon narrative phase (before the pylon is raised), hide the
// repair:pylon instanced mesh so the PylonDownedPylon component takes its place.
// Once the pylon is raised (repair-game steps), restore it so the normal model
// appears upright in the world while the repair mini-game runs.
const hidePylonAnchorId =
mainState === "pylon" && !isRepairGameStep(pylonStep)
? REPAIR_MISSION_ANCHOR_IDS.pylon
: undefined;
const chunks = useMemo(() => { const chunks = useMemo(() => {
if (!data) return []; if (!data) return [];
@@ -168,12 +182,18 @@ export function MapInstancingSystem({
return []; return [];
} }
const instances = data.get(type); let instances = data.get(type);
if (!instances || instances.length === 0) return []; if (!instances || instances.length === 0) return [];
// Filter out the repair-mission pylon instance during the narrative phase
if (hidePylonAnchorId && config.mapName === "pylone") {
instances = instances.filter((inst) => inst.id !== hidePylonAnchorId);
if (instances.length === 0) return [];
}
return createMapAssetChunks(type, config, instances); return createMapAssetChunks(type, config, instances);
}); });
}, [data, groups, models, onlyMapName]); }, [data, groups, models, onlyMapName, hidePylonAnchorId]);
const visibleChunks = useVisibleWorldChunks(chunks, streamingEnabled, { const visibleChunks = useVisibleWorldChunks(chunks, streamingEnabled, {
loadRadius: graphicsPresetConfig.chunkLoadRadius, loadRadius: graphicsPresetConfig.chunkLoadRadius,