From fd597080a692c816d9cc7c4aba2973762bdd1a30 Mon Sep 17 00:00:00 2001 From: WayZer Date: Sun, 23 Feb 2025 14:35:37 +0800 Subject: [PATCH] Update CargoAI.java (#10494) --- core/src/mindustry/ai/types/CargoAI.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/mindustry/ai/types/CargoAI.java b/core/src/mindustry/ai/types/CargoAI.java index 8fb522e900..fa3770831f 100644 --- a/core/src/mindustry/ai/types/CargoAI.java +++ b/core/src/mindustry/ai/types/CargoAI.java @@ -74,18 +74,20 @@ public class CargoAI extends AIController{ //deposit items when it's possible if(max > 0){ - noDestTimer = 0f; Call.transferItemTo(unit, unit.item(), max, unit.x, unit.y, unloadTarget); - //try the next target later + //reset wait timer if we can't fill the unload point. if(!unit.hasItem()){ - targetIndex ++; + noDestTimer = 0f; } - }else if((noDestTimer += dropSpacing) >= emptyWaitTime){ + } + //keep the target for at most emptyWaitTime, then we try change if other need. + if((noDestTimer += dropSpacing) >= emptyWaitTime){ //oh no, it's out of space - wait for a while, and if nothing changes, try the next destination //next targeting attempt will try the next destination point targetIndex = findDropTarget(unit.item(), targetIndex, unloadTarget) + 1; + noDestTimer = 0f; //nothing found at all, clear item if(unloadTarget == null){