feat: Add human action handling with animation and animated travel capabilities

This commit is contained in:
2025-07-02 15:41:24 +05:30
parent 7519aa90c6
commit 2f0acbda3c
5 changed files with 122 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ import { useMachineActions } from "./machine/useMachineActions";
import { useRoboticArmActions } from "./roboticArm/useRoboticArmActions";
import { useStorageActions } from "./storageUnit/useStorageUnitActions";
import { useVehicleActions } from "./vehicle/useVehicleActions";
import { useHumanActions } from "./human/useHumanActions";
import { useCallback, useEffect } from "react";
export function useActionHandler() {
@@ -17,6 +18,7 @@ export function useActionHandler() {
const { handleRoboticArmAction, cleanup: cleanupRoboticArm } = useRoboticArmActions();
const { handleMachineAction, cleanup: cleanupMachine } = useMachineActions();
const { handleStorageAction, cleanup: cleanupStorage } = useStorageActions();
const { handleHumanAction, cleanup: cleanupHuman } = useHumanActions();
const handleAction = useCallback((action: Action, materialId?: string) => {
if (!action) return;
@@ -37,6 +39,9 @@ export function useActionHandler() {
case 'store': case 'retrieve':
handleStorageAction(action as StorageAction, materialId as string);
break;
case 'animation': case 'animatedTravel':
handleHumanAction(action as HumanAction, materialId as string);
break;
default:
console.warn(`Unknown action type: ${(action as Action).actionType}`);
}
@@ -44,7 +49,7 @@ export function useActionHandler() {
echo.error("Failed to handle action");
console.error("Error handling action:", error);
}
}, [handleConveyorAction, handleVehicleAction, handleRoboticArmAction, handleMachineAction, handleStorageAction,]);
}, [handleConveyorAction, handleVehicleAction, handleRoboticArmAction, handleMachineAction, handleStorageAction, handleHumanAction]);
const cleanup = useCallback(() => {
cleanupConveyor();
@@ -52,7 +57,8 @@ export function useActionHandler() {
cleanupRoboticArm();
cleanupMachine();
cleanupStorage();
}, [cleanupConveyor, cleanupVehicle, cleanupRoboticArm, cleanupMachine, cleanupStorage,]);
cleanupHuman();
}, [cleanupConveyor, cleanupVehicle, cleanupRoboticArm, cleanupMachine, cleanupStorage, cleanupHuman]);
useEffect(() => {
return () => {