Payload resprites

This commit is contained in:
Anuken
2022-02-09 00:00:50 -05:00
parent d7cd9ab744
commit 257ecd397f
32 changed files with 75 additions and 25 deletions

View File

@@ -1,10 +1,13 @@
package mindustry.ai;
import arc.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
import arc.util.async.*;
import mindustry.game.EventType.*;
import mindustry.gen.*;
import mindustry.world.*;
import static mindustry.Vars.*;
@@ -22,13 +25,7 @@ public class ControlPathfinder implements Runnable{
TaskQueue queue = new TaskQueue();
//PATHFINDING THREAD DATA
IntMap<PathRequest> requests = new IntMap<>();
/** @return the next target ID to use as a unique path identifier. */
public int nextTargetId(){
return lastTargetId ++;
}
ObjectMap<Unit, PathRequest> requests = new ObjectMap<>();
public ControlPathfinder(){
Events.on(WorldLoadEvent.class, event -> {
@@ -41,6 +38,16 @@ public class ControlPathfinder implements Runnable{
Events.on(ResetEvent.class, event -> stop());
}
/** @return the next target ID to use as a unique path identifier. */
public int nextTargetId(){
return lastTargetId ++;
}
public void getPathPosition(Unit unit, int pathId, Vec2 destination){
}
/** Starts or restarts the pathfinding thread. */
private void start(){
stop();
@@ -56,6 +63,15 @@ public class ControlPathfinder implements Runnable{
requests.clear();
}
//distance heuristic: manhattan
private static float dstCost(float x, float y, float x2, float y2){
return Math.abs(x - x2) + Math.abs(x2 - y2);
}
private static float tileCost(Tile a, Tile b){
return 1f;
}
@Override
public void run(){
while(true){
@@ -88,10 +104,34 @@ public class ControlPathfinder implements Runnable{
}
class PathRequest{
public int lastRequestFrame;
GridBits closed;
PQueue<Tile> queue;
public void update(long maxUpdateNs){
//TODO how will costs be computed? where will they be stored...?
int lastId;
int curId;
int lastFrame;
PathRequest(){
clear();
lastId = curId;
}
void update(long maxUpdateNs){
if(curId != lastId){
clear();
}
}
void clear(){
//TODO
closed = new GridBits(world.width(), world.height());
queue = new PQueue<>(16, (a, b) -> 0);
}
}
}