update: reset repair runtime state
This commit is contained in:
@@ -19,7 +19,10 @@ import {
|
|||||||
} from "@/data/gameplay/repairMissions";
|
} from "@/data/gameplay/repairMissions";
|
||||||
import { useRepairFragmentationInput } from "@/hooks/gameplay/useRepairFragmentationInput";
|
import { useRepairFragmentationInput } from "@/hooks/gameplay/useRepairFragmentationInput";
|
||||||
import { useRepairMissionStep } from "@/hooks/gameplay/useRepairMissionStep";
|
import { useRepairMissionStep } from "@/hooks/gameplay/useRepairMissionStep";
|
||||||
import type { RepairMissionId } from "@/types/gameplay/repairMission";
|
import type {
|
||||||
|
MissionStep,
|
||||||
|
RepairMissionId,
|
||||||
|
} from "@/types/gameplay/repairMission";
|
||||||
import { useGameStore } from "@/managers/stores/useGameStore";
|
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||||
import type { ModelTransformProps, Vector3Tuple } from "@/types/three/three";
|
import type { ModelTransformProps, Vector3Tuple } from "@/types/three/three";
|
||||||
import { toVector3Scale } from "@/utils/three/scale";
|
import { toVector3Scale } from "@/utils/three/scale";
|
||||||
@@ -75,6 +78,19 @@ export function RepairGame({
|
|||||||
onFragment: () => setMissionStep(mission, "fragmented"),
|
onFragment: () => setMissionStep(mission, "fragmented"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (mainState === mission && shouldKeepRepairRuntimeState(step)) return;
|
||||||
|
|
||||||
|
const timeoutId = window.setTimeout(() => {
|
||||||
|
setCasePlaceholders([]);
|
||||||
|
setScannedBrokenParts([]);
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.clearTimeout(timeoutId);
|
||||||
|
};
|
||||||
|
}, [mainState, mission, step]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (mainState !== mission) return undefined;
|
if (mainState !== mission) return undefined;
|
||||||
|
|
||||||
@@ -156,6 +172,10 @@ export function RepairGame({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shouldKeepRepairRuntimeState(step: MissionStep): boolean {
|
||||||
|
return step === "repairing" || step === "reassembling" || step === "done";
|
||||||
|
}
|
||||||
|
|
||||||
function getRepairMissionModelPaths(config: RepairMissionConfig): string[] {
|
function getRepairMissionModelPaths(config: RepairMissionConfig): string[] {
|
||||||
return [
|
return [
|
||||||
...new Set([
|
...new Set([
|
||||||
|
|||||||
Reference in New Issue
Block a user