diff --git a/core/src/mindustry/ai/HierarchyPathFinder.java b/core/src/mindustry/ai/HierarchyPathFinder.java index 741285a5f1..31b8f1cdba 100644 --- a/core/src/mindustry/ai/HierarchyPathFinder.java +++ b/core/src/mindustry/ai/HierarchyPathFinder.java @@ -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. diff --git a/core/src/mindustry/ai/types/CommandAI.java b/core/src/mindustry/ai/types/CommandAI.java index de1f2f5cfc..eb05008d27 100644 --- a/core/src/mindustry/ai/types/CommandAI.java +++ b/core/src/mindustry/ai/types/CommandAI.java @@ -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); diff --git a/core/src/mindustry/ai/types/LogicAI.java b/core/src/mindustry/ai/types/LogicAI.java index cb7250cd7b..2ac8840d3f 100644 --- a/core/src/mindustry/ai/types/LogicAI.java +++ b/core/src/mindustry/ai/types/LogicAI.java @@ -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); } } diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index 4ff6b3168f..d6483f8f25 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -403,7 +403,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I return type.allowLegStep && type.legPhysicsLayer ? PhysicsProcess.layerLegs : isGrounded() ? PhysicsProcess.layerGround : PhysicsProcess.layerFlying; } - /** @return pathfinder path type for calculating costs */ + /** @return pathfinder path type for calculating costs. This is used for wave AI only. (TODO: remove) */ public int pathType(){ return Pathfinder.costGround; } diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index a8623a6d65..3a2cf891b8 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -286,6 +286,8 @@ public class UnitType extends UnlockableContent implements Senseable{ /** Function used for calculating cost of moving with ControlPathfinder. Does not affect "normal" flow field pathfinding. */ public @Nullable PathCost pathCost; + /** ID for path cost, to be used in the control path finder. This is the value that actually matters; do not assign manually. Set in init(). */ + public int pathCostId; /** A sample of the unit that this type creates. Do not modify! */ public @Nullable Unit sample; @@ -689,6 +691,9 @@ public class UnitType extends UnlockableContent implements Senseable{ ControlPathfinder.costGround; } + pathCostId = ControlPathfinder.costTypes.indexOf(pathCost); + if(pathCostId == -1) pathCostId = 0; + if(flying){ envEnabled |= Env.space; } diff --git a/gradle.properties b/gradle.properties index 090150dba9..da998b39a0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,4 +25,4 @@ org.gradle.caching=true #used for slow jitpack builds; TODO see if this actually works org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 -archash=e2fdbab477 +archash=96dd703d5d