fix(repair-ebike): stop subtitle leak and fake cooling swap
🔍 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:
Tom Boullay
2026-06-03 06:47:10 +02:00
parent 8d66391fa9
commit 08c10acd48
6 changed files with 114 additions and 23 deletions
@@ -1,34 +1,85 @@
import { useState } from "react";
import { GrabbableObject } from "@/components/three/interaction/GrabbableObject";
import { TriggerObject } from "@/components/three/interaction/TriggerObject";
import { RepairObjectModel } from "@/components/three/gameplay/RepairObjectModel";
import { REPAIR_INTERACTION_RADIUS } from "@/data/gameplay/repairGameConfig";
import type { Vector3Tuple } from "@/types/three/three";
interface RepairEbikeRepairTriggerProps {
anchor: Vector3Tuple;
onRepair: () => void;
}
const TRIGGER_POSITION: Vector3Tuple = [0, 1.4, 0];
const REPLACEMENT_MODEL_PATH = "/models/refroidisseur/model.gltf";
const TRIGGER_OFFSET: Vector3Tuple = [0, 0.9, 0];
/**
* Minimal interactable used for the ebike `repairing` step. Replaces
* the heavier RepairRepairingStep (grabbable parts + placeholder
* circles) with a single "Changez le refroidisseur" prompt. The
* collider is invisible — the player just walks up and presses E.
* Ebike-specific fake replacement flow: the broken radiator node is
* hidden in the shared ExplodableModel, a grabbable copy appears at the
* same anchor, then pressing E respawns a fresh part with a halo before
* the reassembly step starts.
*/
export function RepairEbikeRepairTrigger({
anchor,
onRepair,
}: RepairEbikeRepairTriggerProps): React.JSX.Element {
const [isInstalled, setIsInstalled] = useState(false);
function handleRepair(): void {
if (isInstalled) return;
setIsInstalled(true);
window.setTimeout(onRepair, 450);
}
return (
<TriggerObject
position={TRIGGER_POSITION}
colliders="ball"
label="Changez le refroidisseur"
radius={REPAIR_INTERACTION_RADIUS}
onTrigger={onRepair}
>
<mesh>
<sphereGeometry args={[0.6, 16, 16]} />
<meshBasicMaterial colorWrite={false} depthWrite={false} />
</mesh>
</TriggerObject>
<group>
{!isInstalled ? (
<GrabbableObject
position={anchor}
colliders="ball"
handControlled
label="Retirer le refroidisseur"
>
<RepairObjectModel
label="Refroidisseur"
modelPath={REPLACEMENT_MODEL_PATH}
scale={0.24}
/>
</GrabbableObject>
) : (
<group position={anchor}>
<RepairObjectModel
label="Refroidisseur"
modelPath={REPLACEMENT_MODEL_PATH}
scale={0.24}
/>
<mesh>
<sphereGeometry args={[0.65, 32, 16]} />
<meshBasicMaterial color="#22c55e" transparent opacity={0.18} />
</mesh>
<mesh rotation={[Math.PI / 2, 0, 0]}>
<torusGeometry args={[0.72, 0.025, 8, 96]} />
<meshBasicMaterial color="#86efac" transparent opacity={0.85} />
</mesh>
</group>
)}
<TriggerObject
position={[
anchor[0] + TRIGGER_OFFSET[0],
anchor[1] + TRIGGER_OFFSET[1],
anchor[2] + TRIGGER_OFFSET[2],
]}
colliders="ball"
label="Changez le refroidisseur"
radius={REPAIR_INTERACTION_RADIUS}
onTrigger={handleRepair}
>
<mesh>
<sphereGeometry args={[0.55, 16, 16]} />
<meshBasicMaterial colorWrite={false} depthWrite={false} />
</mesh>
</TriggerObject>
</group>
);
}
+30 -3
View File
@@ -16,6 +16,7 @@ import { RepairReassemblyStep } from "@/components/three/gameplay/RepairReassemb
import { RepairScanSequence } from "@/components/three/gameplay/RepairScanSequence";
import { REPAIR_CASE_MODEL_PATH } from "@/data/gameplay/repairCaseConfig";
import {
REPAIR_FRAGMENT_SPLIT_DURATION_SECONDS,
REPAIR_DONE_DIALOGUE_FALLBACK_MS,
REPAIR_FRAGMENTATION_SEQUENCE_SECONDS,
REPAIR_FRAGMENT_SPLIT_SPEED,
@@ -27,7 +28,11 @@ import { useRepairFragmentationInput } from "@/hooks/gameplay/useRepairFragmenta
import { useRepairMissionStep } from "@/hooks/gameplay/useRepairMissionStep";
import { useTerrainSnappedPosition } from "@/hooks/three/useTerrainHeight";
import { loadDialogueManifest } from "@/utils/dialogues/loadDialogueManifest";
import { playDialogueById } from "@/utils/dialogues/playDialogue";
import {
clearQueuedDialogues,
playDialogueById,
stopCurrentDialogue,
} from "@/utils/dialogues/playDialogue";
import { useSubtitleStore } from "@/managers/stores/useSubtitleStore";
import type {
MissionStep,
@@ -128,6 +133,17 @@ export function RepairGame({
);
const isSplitPhase = (SPLIT_PHASES as readonly MissionStep[]).includes(step);
const isRepairing = step === "repairing";
const ebikeBrokenNodeName = config.brokenParts[0]?.targetNodeName;
const ebikeBrokenWorldAnchor = ebikeBrokenNodeName
? brokenAnchors[ebikeBrokenNodeName]
: undefined;
const ebikeBrokenLocalAnchor = ebikeBrokenWorldAnchor
? ([
ebikeBrokenWorldAnchor[0] - snappedPosition[0],
ebikeBrokenWorldAnchor[1] - snappedPosition[1],
ebikeBrokenWorldAnchor[2] - snappedPosition[2],
] satisfies Vector3Tuple)
: ([0, 1, 0] satisfies Vector3Tuple);
useRepairFragmentationInput({
enabled: mainState === mission && readyForFragmentation,
@@ -150,6 +166,15 @@ export function RepairGame({
};
}, [mainState, mission, step]);
useEffect(() => {
if (mission !== "ebike") return;
if (mainState === "ebike") return;
clearQueuedDialogues();
stopCurrentDialogue();
useSubtitleStore.getState().clearActiveSubtitle();
}, [mainState, mission]);
// Drive the global focus bubble: active during the immersive repair
// phases so the world dims/hides outside the dark sphere shroud.
const focusCenterX = snappedPosition[0];
@@ -355,6 +380,7 @@ export function RepairGame({
scale={config.modelScale ?? 1}
split={isSplitPhase}
splitSpeed={REPAIR_FRAGMENT_SPLIT_SPEED}
splitDurationSeconds={REPAIR_FRAGMENT_SPLIT_DURATION_SECONDS}
onPartsReady={setExplodedParts}
onSplitSettled={handleSplitSettled}
{...(isRepairing
@@ -378,6 +404,7 @@ export function RepairGame({
) : null}
{step === "repairing" && mission === "ebike" ? (
<RepairEbikeRepairTrigger
anchor={ebikeBrokenLocalAnchor}
onRepair={() => setMissionStep(mission, "reassembling")}
/>
) : null}
@@ -409,8 +436,8 @@ export function RepairGame({
config={config}
onPlaceholdersChange={setCasePlaceholders}
onAnchorsChange={setCaseAnchors}
open={step === "repairing"}
zoomed={step === "repairing"}
open={mission !== "ebike" && step === "repairing"}
zoomed={mission !== "ebike" && step === "repairing"}
showFragmentationPrompt={
readyForFragmentation && mission !== "ebike"
}
@@ -76,6 +76,7 @@ interface ExplodableModelInnerProps extends ModelTransformProps {
* Defaults to ExplodedModel's internal default (6) when omitted.
*/
splitSpeed?: number;
splitDurationSeconds?: number;
onPartsReady?: (parts: readonly ExplodedPart[]) => void;
/**
* Fired once each time the explode/reassemble lerp converges on its
@@ -112,6 +113,7 @@ function ExplodableModelInner({
scale = 1,
splitDistance = 1.2,
splitSpeed,
splitDurationSeconds,
onPartsReady,
onSplitSettled,
hideNodeNames,
@@ -144,10 +146,13 @@ function ExplodableModelInner({
// eslint-disable-next-line react-hooks/refs
new ExplodedModel(model, {
distance: splitDistance,
...(splitDurationSeconds !== undefined
? { durationSeconds: splitDurationSeconds }
: {}),
...(splitSpeed !== undefined ? { speed: splitSpeed } : {}),
onSettled: handleSettled,
}),
[model, splitDistance, splitSpeed, handleSettled],
[model, splitDistance, splitDurationSeconds, splitSpeed, handleSettled],
);
const parsedScale = toVector3Scale(scale);
const anchorSignatureRef = useRef("");