IActionManager and IAction QoL

This commit is contained in:
bigguy345 committed 2025-06-29 09:07:08 +03:00
1 parent 8ad0c21ef4
commit 4d8b345a42
2 files changed
+33 -5

No files matched your search

@@ -118,16 +118,35 @@ public interface IActionManager {
*/
IAction scheduleAction(IAction action);
/**
* Convenience for {@link #create(String, Consumer)} + enqueue.
*
* @param name a unique name for this action
* @param task code to execute each time the task "fires"
* @return the task scheduled
*/
IAction scheduleAction(String name, Consumer<IAction> task);
/**
* Convenience for {@link #create(String, int, Consumer)} + enqueue.
*
* @param name a unique name for this action
* @param startAfterTicks number of ticks to wait before the first task run
* @param task code to execute each time the task "fires"
* @return the task scheduled
*/
IAction scheduleAction(String name, int startAfterTicks, Consumer<IAction> task);
/**
* Convenience for {@link #create(String, int, int, Consumer)} + enqueue.
*
* @param name a unique name for this action
* @param maxDuration the maximum lifetime of the action in ticks
* @param startAfterTicks number of ticks to wait before the first run
* @param action code to execute each time the action "fires"
* @return the action scheduled
* @param startAfterTicks number of ticks to wait before the first task run
* @param task code to execute each time the task "fires"
* @return the task scheduled
*/
IAction scheduleAction(String name, int maxDuration, int startAfterTicks, Consumer<IAction> action);
IAction scheduleAction(String name, int maxDuration, int startAfterTicks, Consumer<IAction> task);
/**
* Insert an action at a specific position in the queue.
+10 -1
View File
@@ -77,7 +77,8 @@ public interface IAction {
boolean hasData(String key);
/**
* @return how many ticks between each invocation of the action callback
* @return how many ticks between each execution of the action's task
* Default is 5 ticks (4 times per second)
*/
int getUpdateEveryXTick();
@@ -117,11 +118,13 @@ public interface IAction {
/**
* Resumes thread that was previously paused by {@link #pause()}, {@link #pauseUntil(Supplier)}, {@link #pauseFor(int)} or {@link #pauseFor(long)}
* Must be called from a different thread than the IAction one, as that one is paused, so it won't reach this function if it comes after any of the pausing functions.
*/
void resume();
/**
* @return checks if IAction's getStartAfterTicks > 0, or if IAction's thread is paused if threaded
* Preferably called from a different thread than the IAction one if it's paused.
*/
boolean isPaused();
@@ -130,6 +133,12 @@ public interface IAction {
*/
IAction threadify();
/**
*
* @return starts the IActionManager
*/
IAction start();
/**
* @return the next action in the queue (or null if none or at end)
*/