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:
2025-05-05 14:26:38 +05:30
parent 19d41a775c
commit 6b0ee0ae79
15 changed files with 372 additions and 178 deletions

View File

@@ -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();