v0.14: 放置系统 (Idle Operations) — 采矿无人机舰队 + 6放置工程 + 永久产能加成 + idle徽章

This commit is contained in:
2026-06-24 10:19:40 +00:00
parent 1701a908c9
commit 17820b1f28
189 changed files with 2718 additions and 35 deletions
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
+11 -6
View File
@@ -3,11 +3,12 @@
import { useEffect, useRef } from "react";
import { useGameStore } from "@/store/gameStore";
/** 250ms tick:产能 + 自动产晶体 + 自动解码 + 星潮 + 成就检测 */
/** 250ms tick:产能 + 自动产晶体 + 自动解码 + 星潮 + 成就检测 + 放置工程 */
export function useGameLoop() {
const tick = useGameStore((s) => s.tick);
const autoDecodeTick = useGameStore((s) => s.autoDecodeTick);
const tickTide = useGameStore((s) => s.tickTide);
const tickIdleProjects = useGameStore((s) => s.tickIdleProjects);
const checkAchievements = useGameStore((s) => s.checkAchievements);
const init = useGameStore((s) => s.init);
const inited = useRef(false);
@@ -35,6 +36,8 @@ export function useGameLoop() {
const now = Date.now();
tick(now);
autoDecodeTick();
// v0.14 放置工程 tick:更新剩余时间 + 标记完成
tickIdleProjects(now);
// 星潮检测每 tick 都查(结束/触发判定需及时)
tickTide(now);
counter++;
@@ -48,19 +51,21 @@ export function useGameLoop() {
if (unsub) unsub();
if (fallback) clearTimeout(fallback);
};
}, [tick, autoDecodeTick, tickTide, checkAchievements, init]);
}, [tick, autoDecodeTick, tickTide, tickIdleProjects, checkAchievements, init]);
// 页面可见性:切回时补 tick + 星潮 + 成就
// 页面可见性:切回时补 tick + 放置工程 + 星潮 + 成就
useEffect(() => {
const onVis = () => {
if (document.visibilityState === "visible") {
tick(Date.now());
tickTide(Date.now());
const now = Date.now();
tick(now);
tickIdleProjects(now);
tickTide(now);
checkAchievements();
}
};
document.addEventListener("visibilitychange", onVis);
return () => document.removeEventListener("visibilitychange", onVis);
}, [tick, tickTide, checkAchievements]);
}, [tick, tickTide, tickIdleProjects, checkAchievements]);
}