Implemented debug mode for ActionQueue and ActionManager

This commit is contained in:
bigguy345 committed 2025-07-07 13:39:45 +03:00
1 parent e6d4e1f3fd
commit e186bb0bd0
2 files changed
+36 -2

No files matched your search

@@ -423,6 +423,9 @@ public class ActionManager implements IActionManager {
public void tick() {
if (!isWorking) return;
if (debug)
logDebug(String.format("Started '%s' Tick Cycle", getInternalName()));
// ─── Sequential (head only) ─────────────────────────────────
sequentialQueue.tick();
@@ -440,9 +443,14 @@ public class ActionManager implements IActionManager {
if (other.isDead()) {
other.clear();
if (debug)
logDebug(String.format("Removing queue '%s' from '%s'", other.getName(), getInternalName()));
it.remove();
}
}
if (debug)
logDebug(String.format("Finished '%s' Tick Cycle", getInternalName()));
}
@Override
@@ -451,6 +459,13 @@ public class ActionManager implements IActionManager {
parallelQueue.clear();
conditionalQueue.clear();
otherQueues.forEach((name, queue) -> queue.clear());
if (debug)
logDebug(String.format("Cleared '%s'", getInternalName()));
}
public String getInternalName() {
return name.isEmpty() ? "Action Manager" : name;
}
public void logDebug(String err) {
@@ -100,6 +100,9 @@ public class ActionQueue implements IActionQueue {
@Override
public IActionQueue kill() {
this.isDead = true;
if (manager.debug)
manager.logDebug(String.format("Killing queue '%s' on '%s'", name, manager.getInternalName()));
return this;
}
@@ -277,6 +280,9 @@ public class ActionQueue implements IActionQueue {
if (!isWorking || isDead)
return;
if (manager.debug)
manager.logDebug(String.format("Started ticking queue '%s'", name));
if (!isParallel) {
if (tick((Action) getCurrentAction()))
queue.pollFirst();
@@ -288,16 +294,26 @@ public class ActionQueue implements IActionQueue {
}
killWhenEmpty();
if (manager.debug)
manager.logDebug(String.format("Finished ticking queue '%s'", name));
}
protected void killWhenEmpty() {
if (killWhenEmpty && !hasActiveTasks() && autoKill == null)
if (killWhenEmpty && !hasActiveTasks() && autoKill == null) {
if (manager.debug)
manager.logDebug(String.format("Queue '%s' is empty! Killing in %s ticks", name, killWhenEmptyAfter));
autoKill = (Action) manager.create(killWhenEmptyAfter, (act) -> {
if (hasActiveTasks())
if (hasActiveTasks()) {
if (manager.debug)
manager.logDebug(String.format("Scheduled Actions found! Aborted kill process for queue '%s'", name));
return;
}
manager.removeQueue(name);
}).everyTick().once();
}
if (autoKill != null) {
autoKill.tick();
@@ -310,6 +326,9 @@ public class ActionQueue implements IActionQueue {
public void clear() {
queue.forEach((act) -> act.kill());
queue.clear();
if (manager.debug)
manager.logDebug(String.format("Cleared queue '%s' on '%s'", name, manager.getInternalName()));
}
@Override