Enhance material handling: add support for additional materials in conveyor and machine mechanics, update action types, and implement material model loading.
This commit is contained in:
@@ -6,14 +6,12 @@ import { useVehicleActions } from "./vehicle/useVehicleActions";
|
||||
import { useCallback, useEffect } from "react";
|
||||
|
||||
export function useActionHandler() {
|
||||
// Initialize all action handlers
|
||||
const { handleConveyorAction, cleanup: cleanupConveyor } = useConveyorActions();
|
||||
const { handleVehicleAction, cleanup: cleanupVehicle } = useVehicleActions();
|
||||
const { handleRoboticArmAction, cleanup: cleanupRoboticArm } = useRoboticArmActions();
|
||||
const { handleMachineAction, cleanup: cleanupMachine } = useMachineActions();
|
||||
const { handleStorageAction, cleanup: cleanupStorage } = useStorageActions();
|
||||
|
||||
// Main handler function
|
||||
const handleAction = useCallback((action: Action) => {
|
||||
if (!action) return;
|
||||
|
||||
@@ -39,32 +37,17 @@ export function useActionHandler() {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error handling action:', error);
|
||||
// Consider adding error recovery or notification here
|
||||
}
|
||||
}, [
|
||||
handleConveyorAction,
|
||||
handleVehicleAction,
|
||||
handleRoboticArmAction,
|
||||
handleMachineAction,
|
||||
handleStorageAction
|
||||
]);
|
||||
}, [handleConveyorAction, handleVehicleAction, handleRoboticArmAction, handleMachineAction, handleStorageAction]);
|
||||
|
||||
// Cleanup all actions
|
||||
const cleanup = useCallback(() => {
|
||||
cleanupConveyor();
|
||||
cleanupVehicle();
|
||||
cleanupRoboticArm();
|
||||
cleanupMachine();
|
||||
cleanupStorage();
|
||||
}, [
|
||||
cleanupConveyor,
|
||||
cleanupVehicle,
|
||||
cleanupRoboticArm,
|
||||
cleanupMachine,
|
||||
cleanupStorage
|
||||
]);
|
||||
}, [cleanupConveyor, cleanupVehicle, cleanupRoboticArm, cleanupMachine, cleanupStorage]);
|
||||
|
||||
// Auto cleanup on unmount
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
cleanup();
|
||||
|
||||
Reference in New Issue
Block a user