storage to human bug fix

This commit is contained in:
2025-08-14 15:55:31 +05:30
parent ab3eb84277
commit 922085ec6c
2 changed files with 16 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ import { useProductContext } from "../../../products/productContext";
import { useHumanEventManager } from "../../../human/eventManager/useHumanEventManager";
export function useRetrieveHandler() {
const { materialStore, armBotStore, machineStore, vehicleStore, storageUnitStore, conveyorStore, craneStore, productStore, humanStore, assetStore } = useSceneContext();
const { materialStore, armBotStore, machineStore, vehicleStore, storageUnitStore, conveyorStore, craneStore, productStore, humanStore, assetStore, humanEventManagerRef } = useSceneContext();
const { selectedProductStore } = useProductContext();
const { addMaterial } = materialStore();
const { getModelUuidByActionUuid, getPointUuidByActionUuid, getEventByModelUuid, getActionByUuid } = productStore();
@@ -464,11 +464,20 @@ export function useRetrieveHandler() {
if (action && action.actionType === 'pickAndDrop' && !hasLock && !crane.isCarrying && !crane.isActive && crane.currentLoad < (action?.maxPickUpCount || 0)) {
const material = getLastMaterial(storageUnit.modelUuid);
if (material) {
incrementCraneLoad(crane.modelUuid, 1);
addCurrentActionToCrane(crane.modelUuid, action.actionUuid, material.materialType, material.materialId);
addCurrentMaterialToCrane(crane.modelUuid, material.materialType, material.materialId);
cranePickupLockRef.current.set(crane.modelUuid, true);
if (action.triggers[0].triggeredAsset?.triggeredModel.modelUuid && action.triggers[0].triggeredAsset.triggeredAction?.actionUuid) {
const human = getEventByModelUuid(selectedProduct.productUuid, action.triggers[0].triggeredAsset.triggeredModel.modelUuid);
if (human && human.type === 'human') {
if (!monitoredHumansRef.current.has(human.modelUuid)) {
addHumanToMonitor(human.modelUuid, () => {
incrementCraneLoad(crane.modelUuid, 1);
addCurrentActionToCrane(crane.modelUuid, action.actionUuid, material.materialType, material.materialId);
addCurrentMaterialToCrane(crane.modelUuid, material.materialType, material.materialId);
cranePickupLockRef.current.set(crane.modelUuid, true);
}, action.triggers[0].triggeredAsset.triggeredAction?.actionUuid)
}
monitoredHumansRef.current.add(human.modelUuid);
}
}
}
} else if (crane.isCarrying && crane.currentPhase === 'pickup-drop' && hasLock) {
cranePickupLockRef.current.set(crane.modelUuid, false);

View File

@@ -23,6 +23,7 @@ export function useHumanEventManager() {
}, [isReset, isPlaying]);
const addHumanToMonitor = (humanId: string, callback: () => void, actionUuid: string) => {
console.log('humanId: ', humanId);
const human = getHumanById(humanId);
const action = getActionByUuid(selectedProduct.productUuid, actionUuid);
if (!human || !action || (action.actionType !== 'assembly' && action.actionType !== 'worker' && action.actionType !== 'operator') || !humanEventManagerRef.current) return;