diff --git a/src/main/java/noppes/npcs/controllers/data/action/ActionManager.java b/src/main/java/noppes/npcs/controllers/data/action/ActionManager.java index e15ff9cf2..152048992 100644 --- a/src/main/java/noppes/npcs/controllers/data/action/ActionManager.java +++ b/src/main/java/noppes/npcs/controllers/data/action/ActionManager.java @@ -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) { diff --git a/src/main/java/noppes/npcs/controllers/data/action/ActionQueue.java b/src/main/java/noppes/npcs/controllers/data/action/ActionQueue.java index 69d0c5357..744822cfd 100644 --- a/src/main/java/noppes/npcs/controllers/data/action/ActionQueue.java +++ b/src/main/java/noppes/npcs/controllers/data/action/ActionQueue.java @@ -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