HPA* merged in

This commit is contained in:
Anuken 2024-04-18 12:48:04 -04:00
parent 1ac1263aa4
commit 3a7d7647d9
5 changed files with 1331 additions and 1990 deletions

View File

@ -241,7 +241,6 @@ public class Vars implements Loadable{
public static WaveSpawner spawner;
public static BlockIndexer indexer;
public static Pathfinder pathfinder;
public static HierarchyPathFinder hpath;
public static ControlPathfinder controlPath;
public static FogControl fogControl;
@ -315,7 +314,6 @@ public class Vars implements Loadable{
indexer = new BlockIndexer();
pathfinder = new Pathfinder();
controlPath = new ControlPathfinder();
hpath = new HierarchyPathFinder();
fogControl = new FogControl();
bases = new BaseRegistry();
logicVars = new GlobalVars();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,6 @@ import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
import mindustry.*;
import mindustry.ai.*;
import mindustry.core.*;
import mindustry.entities.*;
@ -35,7 +34,6 @@ public class CommandAI extends AIController{
protected boolean stopAtTarget, stopWhenInRange;
protected Vec2 lastTargetPos;
protected int pathId = -1;
protected boolean blockingUnit;
protected float timeSpentBlocked;
@ -251,7 +249,7 @@ public class CommandAI extends AIController{
timeSpentBlocked = 0f;
}
move = hpath.getPathPosition(unit, vecMovePos, targetPos, vecOut, noFound) && (!blockingUnit || timeSpentBlocked > maxBlockTime);
move = controlPath.getPathPosition(unit, vecMovePos, targetPos, vecOut, noFound) && (!blockingUnit || timeSpentBlocked > maxBlockTime);
//rare case where unit must be perfectly aligned (happens with 1-tile gaps)
alwaysArrive = vecOut.epsilonEquals(unit.tileX() * tilesize, unit.tileY() * tilesize);
//we've reached the final point if the returned coordinate is equal to the supplied input
@ -421,7 +419,6 @@ public class CommandAI extends AIController{
//this is an allocation, but it's relatively rarely called anyway, and outside mutations must be prevented
targetPos = lastTargetPos = pos.cpy();
attackTarget = null;
pathId = Vars.controlPath.nextTargetId();
this.stopWhenInRange = stopWhenInRange;
}
@ -436,7 +433,6 @@ public class CommandAI extends AIController{
public void commandTarget(Teamc moveTo, boolean stopAtTarget){
attackTarget = moveTo;
this.stopAtTarget = stopAtTarget;
pathId = Vars.controlPath.nextTargetId();
}
/*

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, Tmp.v2.set(moveX, moveY), Tmp.v2, Tmp.v1, null)){
if(controlPath.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);
}
}