human movement improvement
This commit is contained in:
@@ -14,7 +14,7 @@ function WorkerInstance({ human }: { human: HumanStatus }) {
|
||||
const { navMesh } = useNavMesh();
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { scene } = useThree();
|
||||
const { assetStore, materialStore, armBotStore, conveyorStore, machineStore, vehicleStore, humanStore, storageUnitStore, productStore } = useSceneContext();
|
||||
const { assetStore, materialStore, armBotStore, conveyorStore, machineStore, vehicleStore, humanStore, storageUnitStore, productStore, humanEventManagerRef } = useSceneContext();
|
||||
const { removeMaterial, setEndTime, setIsVisible } = materialStore();
|
||||
const { getStorageUnitById } = storageUnitStore();
|
||||
const { getArmBotById } = armBotStore();
|
||||
@@ -129,23 +129,47 @@ function WorkerInstance({ human }: { human: HumanStatus }) {
|
||||
humanStatus(human.modelUuid, 'Started from pickup point, heading to drop point');
|
||||
}
|
||||
} else if (human.currentMaterials.length > 0 && human.currentLoad > 0 && humanAsset?.animationState?.current !== 'pickup') {
|
||||
setTimeout(()=>{
|
||||
setTimeout(() => {
|
||||
if (human.currentMaterials[0]?.materialId) {
|
||||
setIsVisible(human.currentMaterials[0]?.materialId, false);
|
||||
}
|
||||
humanStatus(human.modelUuid, 'Started to pickup in pickup point');
|
||||
setCurrentAnimation(human.modelUuid, 'pickup', true, false, false);
|
||||
},1)
|
||||
}, 1)
|
||||
}
|
||||
} else if (!human.isActive && human.state === 'idle' && human.currentPhase === 'dropping' && human.currentLoad === 0) {
|
||||
if (action.pickUpPoint && action.dropPoint) {
|
||||
const dropToPickup = computePath(action.dropPoint.position || [0, 0, 0], action.pickUpPoint.position || [0, 0, 0]);
|
||||
setPath(dropToPickup);
|
||||
setCurrentPhase(human.modelUuid, 'init');
|
||||
setHumanState(human.modelUuid, 'running');
|
||||
setHumanActive(human.modelUuid, true);
|
||||
setCurrentAnimation(human.modelUuid, 'walking', true, true, true);
|
||||
humanStatus(human.modelUuid, 'Started from dropping point, heading to pickup point');
|
||||
// const dropToPickup = computePath(action.dropPoint.position || [0, 0, 0], action.pickUpPoint.position || [0, 0, 0]);
|
||||
// setPath(dropToPickup);
|
||||
// setCurrentPhase(human.modelUuid, 'drop-pickup');
|
||||
// setHumanState(human.modelUuid, 'running');
|
||||
// setHumanActive(human.modelUuid, true);
|
||||
// setCurrentAnimation(human.modelUuid, 'walking', true, true, true);
|
||||
if (humanEventManagerRef.current) {
|
||||
let state = humanEventManagerRef.current.humanStates.find(h => h.humanId === human.modelUuid);
|
||||
if (state) {
|
||||
const existingAction = state.actionQueue.find(a => a.actionUuid === action.actionUuid);
|
||||
if (existingAction) {
|
||||
const currentCount = existingAction.count ?? 0;
|
||||
if (existingAction.actionType === 'worker') {
|
||||
if (currentCount < existingAction.maxLoadCount) {
|
||||
const dropToPickup = computePath(action.dropPoint.position || [0, 0, 0], action.pickUpPoint.position || [0, 0, 0]);
|
||||
setPath(dropToPickup);
|
||||
setCurrentPhase(human.modelUuid, 'drop-pickup');
|
||||
setHumanState(human.modelUuid, 'running');
|
||||
setHumanActive(human.modelUuid, true);
|
||||
setCurrentAnimation(human.modelUuid, 'walking', true, true, true);
|
||||
} else {
|
||||
setCurrentPhase(human.modelUuid, 'picking');
|
||||
setHumanState(human.modelUuid, 'idle');
|
||||
setHumanActive(human.modelUuid, false);
|
||||
setCurrentAnimation(human.modelUuid, 'idle', true, true, true);
|
||||
humanStatus(human.modelUuid, 'Started from dropping point, heading to pickup point');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user