Proper path cost support

This commit is contained in:
Anuken
2023-11-15 20:03:55 -05:00
parent 997702b9de
commit 587ff8bb46
6 changed files with 12 additions and 6 deletions

View File

@@ -992,8 +992,8 @@ public class HierarchyPathFinder implements Runnable{
return ControlPathfinder.costTypes.get(costId);
}
public boolean getPathPosition(Unit unit, int pathId, Vec2 destination, Vec2 mainDestination, Vec2 out, @Nullable boolean[] noResultFound){
int costId = 0;
public boolean getPathPosition(Unit unit, Vec2 destination, Vec2 mainDestination, Vec2 out, @Nullable boolean[] noResultFound){
int costId = unit.type.pathCostId;
PathCost cost = idToCost(costId);
int
@@ -1006,6 +1006,7 @@ public class HierarchyPathFinder implements Runnable{
actualDestY = World.toTile(destination.y),
destPos = destX + destY * wwidth;
//TODO: what if the destination is different...?
PathRequest request = unitRequests.get(unit);
//if the destination can be trivially reached in a straight line, do that.

View File

@@ -248,7 +248,7 @@ public class CommandAI extends AIController{
}
//if you've spent 3 seconds stuck, something is wrong, move regardless
move = hpath.getPathPosition(unit, pathId, vecMovePos, targetPos, vecOut, noFound) && (!blockingUnit || timeSpentBlocked > maxBlockTime);
move = hpath.getPathPosition(unit, vecMovePos, targetPos, vecOut, noFound) && (!blockingUnit || timeSpentBlocked > maxBlockTime);
//we've reached the final point if the returned coordinate is equal to the supplied input
isFinalPoint &= vecMovePos.epsilonEquals(vecOut, 4.1f);

View File

@@ -85,7 +85,7 @@ public class LogicAI extends AIController{
if(unit.isFlying()){
moveTo(Tmp.v1.set(moveX, moveY), 1f, 30f);
}else{
if(hpath.getPathPosition(unit, lastPathId, Tmp.v2.set(moveX, moveY), Tmp.v2, Tmp.v1, null)){
if(hpath.getPathPosition(unit, Tmp.v2.set(moveX, moveY), Tmp.v2, Tmp.v1, null)){
moveTo(Tmp.v1, 1f, Tmp.v2.epsilonEquals(Tmp.v1, 4.1f) ? 30f : 0f);
}
}