From c0aae432d6a69b25a6f4b1c78fb46079383cef73 Mon Sep 17 00:00:00 2001 From: bigguy345 Date: Mon, 30 Jun 2025 07:15:33 +0300 Subject: [PATCH] INFINITE OVERLOADS !!!!! --- .../npcs/api/handler/IActionManager.java | 37 +++++++++++++ .../noppes/npcs/api/handler/data/IAction.java | 54 +++++++++++++------ .../data/actions/IConditionalAction.java | 13 ----- 3 files changed, 74 insertions(+), 30 deletions(-) diff --git a/java/noppes/npcs/api/handler/IActionManager.java b/java/noppes/npcs/api/handler/IActionManager.java index 671c468..a4e6dd8 100644 --- a/java/noppes/npcs/api/handler/IActionManager.java +++ b/java/noppes/npcs/api/handler/IActionManager.java @@ -26,6 +26,8 @@ public interface IActionManager { */ IAction create(String name, int maxDuration, int delay, Consumer action); + IAction create(int maxDuration, int delay, Consumer task); + IAction create(String name, int delay, Consumer t); IAction create(int delay, Consumer t); @@ -165,6 +167,8 @@ public interface IActionManager { */ IAction scheduleAction(String name, int maxDuration, int delay, Consumer task); + IAction scheduleAction(int maxDuration, int delay, Consumer task); + /** * Insert an action at a specific position in the queue. * @@ -202,6 +206,39 @@ public interface IActionManager { */ Queue getActionQueue(); + /////////////////////////////////////////////////// + /////////////////////////////////////////////////// + // Conditionals + + /** + * Schedule a conditional action that gives up after at most maxChecks attempts. + * + * @param condition supplier checked every tick, if it returns true, task is fired + * @param task code to run once condition first becomes true + * @return the action scheduled + */ + IConditionalAction scheduleAction(Supplier condition, Consumer task); + + /** + * Schedule a conditional action that gives up after at most maxChecks attempts. + * + * @param condition supplier checked every tick, if it returns true, task is fired + * @param task code to run once condition first becomes true + * @param terminateWhen supplier checked every tick, if it returns true, action is terminated (gets marked done) + * @return the action scheduled + */ + IConditionalAction scheduleAction(Supplier condition, Consumer task, Supplier terminateWhen); + + /** + * Schedule a conditional action that gives up after at most maxChecks attempts. + * + * @param condition supplier checked every tick, if it returns true, task is fired + * @param task code to run once condition first becomes true + * @param terminateWhen supplier checked every tick, if it returns true, action is terminated (gets marked done) + * @param onTermination code to run when the termination condition returns true + * @return the action scheduled + */ + IConditionalAction scheduleAction(Supplier condition, Consumer task, Supplier terminateWhen, Consumer onTermination); /** * Schedule a conditional action that gives up after at most maxChecks attempts. diff --git a/java/noppes/npcs/api/handler/data/IAction.java b/java/noppes/npcs/api/handler/data/IAction.java index 1cbfb9c..2b21ac5 100644 --- a/java/noppes/npcs/api/handler/data/IAction.java +++ b/java/noppes/npcs/api/handler/data/IAction.java @@ -1,6 +1,7 @@ package noppes.npcs.api.handler.data; import noppes.npcs.api.handler.IActionManager; +import noppes.npcs.api.handler.data.actions.IConditionalAction; import java.util.function.Consumer; import java.util.function.Supplier; @@ -154,23 +155,6 @@ public interface IAction { */ IAction getPrevious(); - /** - * Enqueue another IAction on the parallel chain which starts firing simultaneously as this. - * - * @param after the action to run next - */ - IAction parallel(IAction after); - - IAction parallel(Consumer task); - - IAction parallel(int delay, Consumer task); - - IAction parallel(String name, Consumer task); - - IAction parallel(String name, int startAfterTicks, Consumer task); - - IAction parallel(String name, int maxDuration, int delay, Consumer t); - /** * Enqueue another action immediately after this one. * @@ -204,4 +188,40 @@ public interface IAction { IAction before(String name, Consumer t); IAction before(Consumer t); + + /** + * Enqueue an IConditionalAction on the conditional chain + * + * @param after the scheduled IConditionalAction + */ + IConditionalAction conditional(IConditionalAction after); + + IConditionalAction conditional(Supplier condition, Consumer task); + + IConditionalAction conditional(String name, Supplier condition, Consumer task); + + IConditionalAction conditional(Supplier condition, Consumer task, Supplier terminate); + + IConditionalAction conditional(String name, Supplier condition, Consumer task, Supplier terminate); + + IConditionalAction conditional(Supplier condition, Consumer task, Supplier terminateWhen, Consumer onTermination); + + IConditionalAction conditional(String name, Supplier condition, Consumer task, Supplier terminateWhen, Consumer onTermination); + + /** + * Enqueue another IAction on the parallel chain which starts firing simultaneously as this. + * + * @param after the scheduled parallel action + */ + IAction parallel(IAction after); + + IAction parallel(Consumer task); + + IAction parallel(int delay, Consumer task); + + IAction parallel(String name, Consumer task); + + IAction parallel(String name, int startAfterTicks, Consumer task); + + IAction parallel(String name, int maxDuration, int delay, Consumer t); } diff --git a/java/noppes/npcs/api/handler/data/actions/IConditionalAction.java b/java/noppes/npcs/api/handler/data/actions/IConditionalAction.java index d50aded..66502a2 100644 --- a/java/noppes/npcs/api/handler/data/actions/IConditionalAction.java +++ b/java/noppes/npcs/api/handler/data/actions/IConditionalAction.java @@ -57,17 +57,4 @@ public interface IConditionalAction extends IAction { */ IConditionalAction setMaxChecks(int maxChecks); - IConditionalAction after(IConditionalAction after); - - IConditionalAction after(Supplier condition, Consumer task); - - IConditionalAction after(String name, Supplier condition, Consumer task); - - IConditionalAction after(Supplier condition, Consumer task, Supplier terminate); - - IConditionalAction after(String name, Supplier condition, Consumer task, Supplier terminate); - - IConditionalAction after(Supplier condition, Consumer task, Supplier terminateWhen, Consumer onTermination); - - IConditionalAction after(String name, Supplier condition, Consumer task, Supplier terminateWhen, Consumer onTermination); }