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 WaveSpawner spawner;
public static BlockIndexer indexer; public static BlockIndexer indexer;
public static Pathfinder pathfinder; public static Pathfinder pathfinder;
public static HierarchyPathFinder hpath;
public static ControlPathfinder controlPath; public static ControlPathfinder controlPath;
public static FogControl fogControl; public static FogControl fogControl;
@@ -315,7 +314,6 @@ public class Vars implements Loadable{
indexer = new BlockIndexer(); indexer = new BlockIndexer();
pathfinder = new Pathfinder(); pathfinder = new Pathfinder();
controlPath = new ControlPathfinder(); controlPath = new ControlPathfinder();
hpath = new HierarchyPathFinder();
fogControl = new FogControl(); fogControl = new FogControl();
bases = new BaseRegistry(); bases = new BaseRegistry();
logicVars = new GlobalVars(); 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.math.geom.*;
import arc.struct.*; import arc.struct.*;
import arc.util.*; import arc.util.*;
import mindustry.*;
import mindustry.ai.*; import mindustry.ai.*;
import mindustry.core.*; import mindustry.core.*;
import mindustry.entities.*; import mindustry.entities.*;
@@ -35,7 +34,6 @@ public class CommandAI extends AIController{
protected boolean stopAtTarget, stopWhenInRange; protected boolean stopAtTarget, stopWhenInRange;
protected Vec2 lastTargetPos; protected Vec2 lastTargetPos;
protected int pathId = -1;
protected boolean blockingUnit; protected boolean blockingUnit;
protected float timeSpentBlocked; protected float timeSpentBlocked;
@@ -251,7 +249,7 @@ public class CommandAI extends AIController{
timeSpentBlocked = 0f; 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) //rare case where unit must be perfectly aligned (happens with 1-tile gaps)
alwaysArrive = vecOut.epsilonEquals(unit.tileX() * tilesize, unit.tileY() * tilesize); 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 //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 //this is an allocation, but it's relatively rarely called anyway, and outside mutations must be prevented
targetPos = lastTargetPos = pos.cpy(); targetPos = lastTargetPos = pos.cpy();
attackTarget = null; attackTarget = null;
pathId = Vars.controlPath.nextTargetId();
this.stopWhenInRange = stopWhenInRange; this.stopWhenInRange = stopWhenInRange;
} }
@@ -436,7 +433,6 @@ public class CommandAI extends AIController{
public void commandTarget(Teamc moveTo, boolean stopAtTarget){ public void commandTarget(Teamc moveTo, boolean stopAtTarget){
attackTarget = moveTo; attackTarget = moveTo;
this.stopAtTarget = stopAtTarget; this.stopAtTarget = stopAtTarget;
pathId = Vars.controlPath.nextTargetId();
} }
/* /*

View File

@@ -85,7 +85,7 @@ public class LogicAI extends AIController{
if(unit.isFlying()){ if(unit.isFlying()){
moveTo(Tmp.v1.set(moveX, moveY), 1f, 30f); moveTo(Tmp.v1.set(moveX, moveY), 1f, 30f);
}else{ }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); moveTo(Tmp.v1, 1f, Tmp.v2.epsilonEquals(Tmp.v1, 4.1f) ? 30f : 0f);
} }
} }