Release v0.1.4 2026-07-12
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
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";
|
||||
|
||||
@@ -21,28 +20,6 @@ const gamepadAbilityMap: Record<number, AbilityId> = {
|
||||
5: "barrier",
|
||||
};
|
||||
|
||||
export function useGameLoop() {
|
||||
useEffect(() => {
|
||||
let frame = 0;
|
||||
let previous = performance.now();
|
||||
let accumulator = 0;
|
||||
const loop = (now: number) => {
|
||||
const delta = Math.min((now - previous) / 1000, 0.25);
|
||||
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);
|
||||
};
|
||||
frame = requestAnimationFrame(loop);
|
||||
return () => cancelAnimationFrame(frame);
|
||||
}, []);
|
||||
}
|
||||
|
||||
export function useActionBindings(enabled = true, onExit?: () => void) {
|
||||
const exitRef = useRef(onExit);
|
||||
exitRef.current = onExit;
|
||||
|
||||
Reference in New Issue
Block a user