Added IActionChain after(int delay, String name, Consumer<IAction> task) to IActionChain

This commit is contained in:
bigguy345 committed 2025-04-29 09:00:18 +03:00
1 parent e2225453c8
commit 284017ef80
2 files changed
+16 -4

No files matched your search

@@ -21,15 +21,21 @@ public class ActionChain implements IActionChain {
* schedule the next task ‘delay’ ticks after the previous one
*/
@Override
public IActionChain after(int delay, Consumer<IAction> task) {
public IActionChain after(int delay, String name, Consumer<IAction> task) {
offset += delay;
Consumer<IAction> wrapper = act -> {
task.accept(act);
act.markDone();
};
IAction a = scriptedActionManager.create("chain#" + (index++), offset, wrapper);
IAction a = scriptedActionManager.create(name, offset, wrapper);
index++;
a.setUpdateEveryXTick(1);
scriptedActionManager.scheduleAction(a);
return this;
}
@Override
public IActionChain after(int delay, Consumer<IAction> task) {
return after(delay, "chain#" + index, task);
}
}
@@ -18,17 +18,23 @@ public class ParallelActionChain implements IActionChain {
* schedule the next task ‘delay’ ticks after the previous one, fully in parallel
*/
@Override
public IActionChain after(int delay, Consumer<IAction> task) {
public IActionChain after(int delay, String name, Consumer<IAction> task) {
offset += delay;
Consumer<IAction> wrapper = act -> {
task.accept(act);
act.markDone();
};
IAction a = scriptedActionManager.create("parallel#" + (idx++),
IAction a = scriptedActionManager.create(name,
offset,
wrapper);
idx++;
a.setUpdateEveryXTick(1);
scriptedActionManager.scheduleParallelAction(a);
return this;
}
@Override
public IActionChain after(int delay, Consumer<IAction> task) {
return after(delay, "parallel#" + idx, task);
}
}