storage to human bug fix
This commit is contained in:
@@ -6,7 +6,7 @@ import { useProductContext } from "../../../products/productContext";
|
|||||||
import { useHumanEventManager } from "../../../human/eventManager/useHumanEventManager";
|
import { useHumanEventManager } from "../../../human/eventManager/useHumanEventManager";
|
||||||
|
|
||||||
export function useRetrieveHandler() {
|
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 { selectedProductStore } = useProductContext();
|
||||||
const { addMaterial } = materialStore();
|
const { addMaterial } = materialStore();
|
||||||
const { getModelUuidByActionUuid, getPointUuidByActionUuid, getEventByModelUuid, getActionByUuid } = productStore();
|
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)) {
|
if (action && action.actionType === 'pickAndDrop' && !hasLock && !crane.isCarrying && !crane.isActive && crane.currentLoad < (action?.maxPickUpCount || 0)) {
|
||||||
const material = getLastMaterial(storageUnit.modelUuid);
|
const material = getLastMaterial(storageUnit.modelUuid);
|
||||||
if (material) {
|
if (material) {
|
||||||
|
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);
|
incrementCraneLoad(crane.modelUuid, 1);
|
||||||
addCurrentActionToCrane(crane.modelUuid, action.actionUuid, material.materialType, material.materialId);
|
addCurrentActionToCrane(crane.modelUuid, action.actionUuid, material.materialType, material.materialId);
|
||||||
addCurrentMaterialToCrane(crane.modelUuid, material.materialType, material.materialId);
|
addCurrentMaterialToCrane(crane.modelUuid, material.materialType, material.materialId);
|
||||||
|
|
||||||
cranePickupLockRef.current.set(crane.modelUuid, true);
|
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) {
|
} else if (crane.isCarrying && crane.currentPhase === 'pickup-drop' && hasLock) {
|
||||||
cranePickupLockRef.current.set(crane.modelUuid, false);
|
cranePickupLockRef.current.set(crane.modelUuid, false);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export function useHumanEventManager() {
|
|||||||
}, [isReset, isPlaying]);
|
}, [isReset, isPlaying]);
|
||||||
|
|
||||||
const addHumanToMonitor = (humanId: string, callback: () => void, actionUuid: string) => {
|
const addHumanToMonitor = (humanId: string, callback: () => void, actionUuid: string) => {
|
||||||
|
console.log('humanId: ', humanId);
|
||||||
const human = getHumanById(humanId);
|
const human = getHumanById(humanId);
|
||||||
const action = getActionByUuid(selectedProduct.productUuid, actionUuid);
|
const action = getActionByUuid(selectedProduct.productUuid, actionUuid);
|
||||||
if (!human || !action || (action.actionType !== 'assembly' && action.actionType !== 'worker' && action.actionType !== 'operator') || !humanEventManagerRef.current) return;
|
if (!human || !action || (action.actionType !== 'assembly' && action.actionType !== 'worker' && action.actionType !== 'operator') || !humanEventManagerRef.current) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user