Pregenerator tracking nets

This commit is contained in:
Daniel Mills 2021-07-20 04:56:54 -04:00
parent 35220e1c4d
commit d3fe0b48d8
2 changed files with 66 additions and 0 deletions

View File

@ -43,6 +43,8 @@ public class PregeneratorJob implements PregenListener {
public static PregeneratorJob instance;
private static final Color COLOR_EXISTS = parseColor("#4d7d5b");
private static final Color COLOR_GENERATING = parseColor("#0062ff");
private static final Color COLOR_NETWORK = parseColor("#a863c2");
private static final Color COLOR_NETWORK_GENERATING = parseColor("#836b8c");
private static final Color COLOR_GENERATED = parseColor("#34eb93");
private JFrame frame;
private final PregenTask task;
@ -127,6 +129,16 @@ public class PregeneratorJob implements PregenListener {
return instance.paused();
}
public void drawRegion(int x, int z, Color color)
{
J.a(() -> {
PregenTask.iterateRegion(x, z, (xx,zz)->{
draw(xx,zz,color);
J.sleep(3);
});
});
}
public void draw(int x, int z, Color color)
{
try
@ -237,6 +249,31 @@ public class PregeneratorJob implements PregenListener {
}
@Override
public void onNetworkStarted(int x, int z) {
drawRegion(x, z, COLOR_NETWORK);
}
@Override
public void onNetworkFailed(int x, int z) {
}
@Override
public void onNetworkReclaim(int revert) {
}
@Override
public void onNetworkGeneratedChunk(int x, int z) {
draw(x, z, COLOR_NETWORK_GENERATING);
}
@Override
public void onNetworkDownloaded(int x, int z) {
drawRegion(x, z, COLOR_NETWORK);
}
@Override
public void onClose() {
close();

View File

@ -50,6 +50,8 @@ public class IrisPregenerator {
private final ChronoLatch minuteLatch;
private final AtomicReference<String> currentGeneratorMethod;
private final KSet<Position2> generatedRegions;
private final KSet<Position2> retry;
private final KSet<Position2> net;
public IrisPregenerator(PregenTask task, PregeneratorMethod generator, PregenListener listener)
{
@ -59,6 +61,8 @@ public class IrisPregenerator {
this.paused = new AtomicBoolean(false);
this.task = task;
this.generator = generator;
retry = new KSet<>();
net = new KSet<>();
currentGeneratorMethod = new AtomicReference<>("Void");
minuteLatch = new ChronoLatch(60000, false);
chunksPerSecond = new RollingSequence(10);
@ -230,6 +234,31 @@ public class IrisPregenerator {
listener.onRegionSkipped(x, z);
}
@Override
public void onNetworkStarted(int x, int z) {
net.add(new Position2(x, z));
}
@Override
public void onNetworkFailed(int x, int z) {
retry.add(new Position2(x, z));
}
@Override
public void onNetworkReclaim(int revert) {
generated.addAndGet(-revert);
}
@Override
public void onNetworkGeneratedChunk(int x, int z) {
generated.addAndGet(1);
}
@Override
public void onNetworkDownloaded(int x, int z) {
net.remove(new Position2(x, z));
}
@Override
public void onClose() {
listener.onClose();