feat: Add human action handling with animation and animated travel capabilities
This commit is contained in:
45
app/src/modules/simulation/actions/human/useHumanActions.ts
Normal file
45
app/src/modules/simulation/actions/human/useHumanActions.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { useEffect, useCallback } from 'react';
|
||||
import { useAnimationHandler } from './actionHandler/useAnimationHandler';
|
||||
import { useAnimatedTravelHandler } from './actionHandler/useAnimatedTravelHandler';
|
||||
|
||||
export function useHumanActions() {
|
||||
const { handleAnimation } = useAnimationHandler();
|
||||
const { handleAnimatedTravel } = useAnimatedTravelHandler();
|
||||
|
||||
const handleAnimationAction = useCallback((action: HumanAction, materialId: string) => {
|
||||
handleAnimation(action, materialId);
|
||||
}, [handleAnimation]);
|
||||
|
||||
const handleAnimatedTravelAction = useCallback((action: HumanAction) => {
|
||||
handleAnimatedTravel(action);
|
||||
}, [handleAnimatedTravel]);
|
||||
|
||||
const handleHumanAction = useCallback((action: HumanAction, materialId: string) => {
|
||||
if (!action) return;
|
||||
|
||||
switch (action.actionType) {
|
||||
case 'animation':
|
||||
handleAnimationAction(action, materialId);
|
||||
break;
|
||||
case 'animatedTravel':
|
||||
handleAnimatedTravelAction(action);
|
||||
break;
|
||||
default:
|
||||
console.warn(`Unknown Human action type: ${action.actionType}`);
|
||||
}
|
||||
}, [handleAnimationAction, handleAnimatedTravelAction]);
|
||||
|
||||
const cleanup = useCallback(() => {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
cleanup();
|
||||
};
|
||||
}, [cleanup]);
|
||||
|
||||
return {
|
||||
handleHumanAction,
|
||||
cleanup
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user