Update CargoAI.java (#10494)

This commit is contained in:
WayZer
2025-02-23 14:35:37 +08:00
committed by GitHub
parent 46fcd7b84a
commit fd597080a6

View File

@@ -74,18 +74,20 @@ public class CargoAI extends AIController{
//deposit items when it's possible //deposit items when it's possible
if(max > 0){ if(max > 0){
noDestTimer = 0f;
Call.transferItemTo(unit, unit.item(), max, unit.x, unit.y, unloadTarget); 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()){ 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 //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 //next targeting attempt will try the next destination point
targetIndex = findDropTarget(unit.item(), targetIndex, unloadTarget) + 1; targetIndex = findDropTarget(unit.item(), targetIndex, unloadTarget) + 1;
noDestTimer = 0f;
//nothing found at all, clear item //nothing found at all, clear item
if(unloadTarget == null){ if(unloadTarget == null){