Release v0.1.3 2026-07-11
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { subscribeControllerToken } from "../input/controller";
|
||||
import { ABILITY_ORDER } from "./data";
|
||||
import { PERFORMANCE_PROBE_ENABLED, recordSimulationTick } from "./performance";
|
||||
import { useGameStore } from "./store";
|
||||
import type { AbilityId } from "./types";
|
||||
|
||||
function cycleRunBuff(direction: 1 | -1) {
|
||||
const store = useGameStore.getState();
|
||||
const currentIndex = store.draftBuffIds.indexOf(store.selectedRunBuffId);
|
||||
const nextIndex = (Math.max(0, currentIndex) + direction + store.draftBuffIds.length) % store.draftBuffIds.length;
|
||||
store.setSelectedRunBuff(store.draftBuffIds[nextIndex]);
|
||||
}
|
||||
|
||||
const gamepadAbilityMap: Record<number, AbilityId> = {
|
||||
0: "purify",
|
||||
1: "shield",
|
||||
@@ -23,7 +31,9 @@ export function useGameLoop() {
|
||||
previous = now;
|
||||
accumulator += delta;
|
||||
if (accumulator >= 0.1) {
|
||||
const tickStartedAt = PERFORMANCE_PROBE_ENABLED ? performance.now() : 0;
|
||||
useGameStore.getState().tick(accumulator);
|
||||
if (PERFORMANCE_PROBE_ENABLED) recordSimulationTick(performance.now() - tickStartedAt);
|
||||
accumulator = 0;
|
||||
}
|
||||
frame = requestAnimationFrame(loop);
|
||||
@@ -53,6 +63,14 @@ export function useActionBindings(enabled = true, onExit?: () => void) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (store.phase === "intermission") {
|
||||
if (["arrowleft", "arrowup", "arrowright", "arrowdown", "enter"].includes(key)) event.preventDefault();
|
||||
if (key === "arrowleft" || key === "arrowup") cycleRunBuff(-1);
|
||||
if (key === "arrowright" || key === "arrowdown") cycleRunBuff(1);
|
||||
if (key === "enter") store.chooseRunBuff(store.selectedRunBuffId);
|
||||
if (key === "escape") exitRef.current?.();
|
||||
return;
|
||||
}
|
||||
const numberIndex = Number(event.key) - 1;
|
||||
if (numberIndex >= 0 && numberIndex < ABILITY_ORDER.length) {
|
||||
store.castAbility(ABILITY_ORDER[numberIndex]);
|
||||
@@ -99,6 +117,13 @@ export function useActionBindings(enabled = true, onExit?: () => void) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (store.phase === "intermission") {
|
||||
if (["Button12", "Button14", "Axis0-", "Axis1-"].includes(token)) cycleRunBuff(-1);
|
||||
if (["Button13", "Button15", "Axis0+", "Axis1+"].includes(token)) cycleRunBuff(1);
|
||||
if (!repeat && token === "Button0") store.chooseRunBuff(store.selectedRunBuffId);
|
||||
if (!repeat && token === "Button1") exitRef.current?.();
|
||||
return;
|
||||
}
|
||||
if (repeat) return;
|
||||
if (token.startsWith("Button")) {
|
||||
const ability = gamepadAbilityMap[Number(token.slice("Button".length))];
|
||||
|
||||
Reference in New Issue
Block a user