forked from phenom/healer-man
Release Healer Man 0.1.36
This commit is contained in:
1 parent
40d9f346d8
commit
03a4e3f51c
22 files changed
+1389
-153
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { useRapier } from "@react-three/rapier";
|
||||
import { useEffect, useMemo } from "react";
|
||||
import { combatNavigationGraph } from "../game/combatSpatial";
|
||||
import { createMobPursuit } from "../game/mobPursuit";
|
||||
import { registerDungeonRuntimeReset } from "../game/dungeonRuntimeReset";
|
||||
import { hasDungeonLineOfSight } from "./dungeonLineOfSight";
|
||||
import { createPartyDirectSegmentValidator, createPartyRecoveryPointValidator, createPartyRouteSegmentValidator } from "./partyTraversal";
|
||||
|
||||
/** Uses terrain only; actors remain non-blocking and the graph is loaded only once. */
|
||||
export function useMobNavigation() {
|
||||
const { rapier, world } = useRapier();
|
||||
const navigator = useMemo(() => {
|
||||
let graph = combatNavigationGraph();
|
||||
let landing = createPartyRecoveryPointValidator(rapier, world, graph);
|
||||
return createMobPursuit({
|
||||
graph: combatNavigationGraph,
|
||||
hasLineOfSight: (from, to) => hasDungeonLineOfSight(rapier, world, from, to),
|
||||
directAllowed: createPartyDirectSegmentValidator(rapier, world),
|
||||
routeAllowed: createPartyRouteSegmentValidator(rapier, world),
|
||||
validateLanding: (point, anchor) => {
|
||||
const currentGraph = combatNavigationGraph();
|
||||
if (graph !== currentGraph) {
|
||||
graph = currentGraph;
|
||||
landing = createPartyRecoveryPointValidator(rapier, world, graph);
|
||||
}
|
||||
return landing(point, anchor);
|
||||
},
|
||||
});
|
||||
}, [rapier, world]);
|
||||
useEffect(() => registerDungeonRuntimeReset(navigator.clear), [navigator]);
|
||||
return navigator;
|
||||
}
|
||||
Reference in new issue
Block a user