Interface IActionManager


  • public interface IActionManager
    Manages a queue of IAction instances, allowing scheduling of delayed, repeating, or conditional "tasks" for NPC scripting.
    • Method Detail

      • start

        IActionManager start()
        Begin processing scheduled actions. Must be called once.
      • stop

        IActionManager stop()
        Halt processing of actions. Queued actions remain but will not run until start() is called again.
      • create

        IAction create​(java.lang.String name,
                       int maxDuration,
                       int delay,
                       java.util.function.Consumer<IAction> action)
        Create a new action instance without immediately scheduling it.
        Parameters:
        name - a unique name for this action
        maxDuration - the maximum lifetime of the action in ticks
        delay - number of ticks to wait before the first run
        action - code to execute each time the action "fires"
        Returns:
        a fresh IAction object
      • create

        IAction create​(int maxDuration,
                       int delay,
                       java.util.function.Consumer<IAction> task)
      • create

        IAction create​(java.lang.String name,
                       int delay,
                       java.util.function.Consumer<IAction> t)
      • create

        IAction create​(int delay,
                       java.util.function.Consumer<IAction> t)
      • create

        IAction create​(java.lang.String name,
                       java.util.function.Consumer<IAction> t)
      • getName

        java.lang.String getName()
      • inDebugMode

        boolean inDebugMode()
      • setDebugMode

        IActionManager setDebugMode​(boolean debug)
        Enabling prints to the console the life cycle of IActionManager, it's IActionQueues and the scheduled IActions
        Parameters:
        debug -
        Returns:
      • create

        IAction create​(java.lang.String name)
      • create

        IConditionalAction create​(java.util.function.Function<IAction,​java.lang.Boolean> condition,
                                  java.util.function.Consumer<IAction> task)
        Schedule a conditional action that gives up after at most maxChecks attempts.
        Parameters:
        condition - checked every tick, if it returns true, task is fired
        task - code to run once condition first becomes true
        Returns:
        the action scheduled
      • create

        IConditionalAction create​(java.lang.String name,
                                  java.util.function.Function<IAction,​java.lang.Boolean> condition,
                                  java.util.function.Consumer<IAction> task)
        Schedule a conditional action that gives up after at most maxChecks attempts.
        Parameters:
        name - unique name
        condition - checked every tick, if it returns true, task is fired
        task - code to run once condition first becomes true
        Returns:
        the action scheduled
      • create

        IConditionalAction create​(java.util.function.Function<IAction,​java.lang.Boolean> condition,
                                  java.util.function.Consumer<IAction> task,
                                  java.util.function.Function<IAction,​java.lang.Boolean> terminateWhen)
        Schedule a conditional action that gives up after at most maxChecks attempts.
        Parameters:
        condition - checked every tick, if it returns true, task is fired
        task - code to run once condition first becomes true
        terminateWhen - checked every tick, if it returns true, action is terminated (gets marked done)
        Returns:
        the action scheduled
      • create

        IConditionalAction create​(java.lang.String name,
                                  java.util.function.Function<IAction,​java.lang.Boolean> condition,
                                  java.util.function.Consumer<IAction> task,
                                  java.util.function.Function<IAction,​java.lang.Boolean> terminateWhen)
        Schedule a conditional action that gives up after at most maxChecks attempts.
        Parameters:
        name - unique name
        condition - checked every tick, if it returns true, task is fired
        task - code to run once condition first becomes true
        terminateWhen - checked every tick, if it returns true, action is terminated (gets marked done)
        Returns:
        the action scheduled
      • create

        IConditionalAction create​(java.util.function.Function<IAction,​java.lang.Boolean> condition,
                                  java.util.function.Consumer<IAction> task,
                                  java.util.function.Function<IAction,​java.lang.Boolean> terminateWhen,
                                  java.util.function.Consumer<IAction> onTermination)
        Schedule a conditional action that gives up after at most maxChecks attempts.
        Parameters:
        condition - checked every tick, if it returns true, task is fired
        task - code to run once condition first becomes true
        terminateWhen - checked every tick, if it returns true, action is terminated (gets marked done)
        onTermination - code to run when the termination condition returns true
        Returns:
        the action scheduled
      • create

        IConditionalAction create​(java.lang.String name,
                                  java.util.function.Function<IAction,​java.lang.Boolean> condition,
                                  java.util.function.Consumer<IAction> task,
                                  java.util.function.Function<IAction,​java.lang.Boolean> terminateWhen,
                                  java.util.function.Consumer<IAction> onTermination)
        Schedule a conditional action that gives up after at most maxChecks attempts.
        Parameters:
        name - unique name
        condition - checked every tick, if it returns true, task is fired
        task - code to run once condition first becomes true
        terminateWhen - checked every tick, if it returns true, action is terminated (gets marked done)
        onTermination - code to run when the termination condition returns true
        Returns:
        the action scheduled
      • createQueue

        IActionQueue createQueue​(java.lang.String name)
      • createQueue

        IActionQueue createQueue​(java.lang.String name,
                                 boolean isParallel)
      • getOrCreateQueue

        IActionQueue getOrCreateQueue​(java.lang.String name)
      • getOrCreateQueue

        IActionQueue getOrCreateQueue​(java.lang.String name,
                                      boolean isParallel)
      • getQueue

        IActionQueue getQueue​(java.lang.String name)
      • hasQueue

        boolean hasQueue​(java.lang.String name)
      • removeQueue

        boolean removeQueue​(java.lang.String name)
        Parameters:
        name -
        Returns:
        True if queue successfully removed from IActionManager and cleared
      • getSequentialQueue

        IActionQueue getSequentialQueue()
        Retrieve the entire action queue.
        Returns:
        live reference to the internal Queue of actions
      • schedule

        IAction schedule​(IAction action)
        Schedule an existing action for execution.
        Parameters:
        action - the action to enqueue
        Returns:
        the action scheduled
      • schedule

        void schedule​(IAction... actions)
        Multiple actions chained one after another i.e schedule(act1,act2,act3,...)
        Parameters:
        actions -
      • schedule

        IAction schedule​(java.util.function.Consumer<IAction> task)
        Convenience for create(Consumer) + enqueue.
        Parameters:
        task - code to execute each time the task "fires"
        Returns:
        the task scheduled
      • schedule

        void schedule​(java.util.function.Consumer<IAction>... tasks)
        Multiple tasks chained one after another i.e schedule(task1,task2,task3,...)
        Parameters:
        tasks -
      • schedule

        IAction schedule​(int delay,
                         java.util.function.Consumer<IAction> task)
        Convenience for create(String, Consumer) + enqueue.
        Parameters:
        delay - number of ticks to wait before the first task run
        task - code to execute each time the task "fires"
        Returns:
        the task scheduled
      • schedule

        IAction schedule​(java.lang.String name,
                         java.util.function.Consumer<IAction> task)
        Convenience for create(String, Consumer) + enqueue.
        Parameters:
        name - a unique name for this action
        task - code to execute each time the task "fires"
        Returns:
        the task scheduled
      • schedule

        IAction schedule​(java.lang.String name,
                         int delay,
                         java.util.function.Consumer<IAction> task)
        Convenience for create(String, int, Consumer) + enqueue.
        Parameters:
        name - a unique name for this action
        delay - number of ticks to wait before the first task run
        task - code to execute each time the task "fires"
        Returns:
        the task scheduled
      • schedule

        IAction schedule​(java.lang.String name,
                         int maxDuration,
                         int delay,
                         java.util.function.Consumer<IAction> task)
        Convenience for create(String, int, int, Consumer) + enqueue.
        Parameters:
        name - a unique name for this action
        maxDuration - the maximum lifetime of the action in ticks
        delay - number of ticks to wait before the first task run
        task - code to execute each time the task "fires"
        Returns:
        the task scheduled
      • schedule

        IAction schedule​(int maxDuration,
                         int delay,
                         java.util.function.Consumer<IAction> task)
      • scheduleActionAt

        IAction scheduleActionAt​(int index,
                                 IAction action)
        Insert an action at a specific position in the queue.
        Parameters:
        index - zero-based queue position to insert at
        action - the action to insert
        Returns:
        the action scheduled
      • getConditionalQueue

        IActionQueue getConditionalQueue()
        Returns:
        the list of all conditional actions scheduled
      • schedule

        void schedule​(IConditionalAction... actions)
        Multiple conditionals i.e schedule(act1,act2,act3,...)
        Parameters:
        actions -
      • schedule

        IConditionalAction schedule​(java.util.function.Function<IAction,​java.lang.Boolean> condition,
                                    java.util.function.Consumer<IAction> task)
        Schedule a conditional action that gives up after at most maxChecks attempts.
        Parameters:
        condition - checked every tick, if it returns true, task is fired
        task - code to run once condition first becomes true
        Returns:
        the action scheduled
      • schedule

        IConditionalAction schedule​(java.util.function.Function<IAction,​java.lang.Boolean> condition,
                                    java.util.function.Consumer<IAction> task,
                                    java.util.function.Function<IAction,​java.lang.Boolean> terminateWhen)
        Schedule a conditional action that gives up after at most maxChecks attempts.
        Parameters:
        condition - checked every tick, if it returns true, task is fired
        task - code to run once condition first becomes true
        terminateWhen - checked every tick, if it returns true, action is terminated (gets marked done)
        Returns:
        the action scheduled
      • schedule

        IConditionalAction schedule​(java.util.function.Function<IAction,​java.lang.Boolean> condition,
                                    java.util.function.Consumer<IAction> task,
                                    java.util.function.Function<IAction,​java.lang.Boolean> terminateWhen,
                                    java.util.function.Consumer<IAction> onTermination)
        Schedule a conditional action that gives up after at most maxChecks attempts.
        Parameters:
        condition - checked every tick, if it returns true, task is fired
        task - code to run once condition first becomes true
        terminateWhen - checked every tick, if it returns true, action is terminated (gets marked done)
        onTermination - code to run when the termination condition returns true
        Returns:
        the action scheduled
      • schedule

        IConditionalAction schedule​(java.lang.String name,
                                    java.util.function.Function<IAction,​java.lang.Boolean> condition,
                                    java.util.function.Consumer<IAction> task)
        Schedule a conditional action that gives up after at most maxChecks attempts.
        Parameters:
        name - unique name
        condition - checked every tick, if it returns true, task is fired
        task - code to run once condition first becomes true
        Returns:
        the action scheduled
      • schedule

        IConditionalAction schedule​(java.lang.String name,
                                    java.util.function.Function<IAction,​java.lang.Boolean> condition,
                                    java.util.function.Consumer<IAction> task,
                                    java.util.function.Function<IAction,​java.lang.Boolean> terminateWhen)
        Schedule a conditional action that gives up after at most maxChecks attempts.
        Parameters:
        name - unique name
        condition - checked every tick, if it returns true, task is fired
        task - code to run once condition first becomes true
        terminateWhen - checked every tick, if it returns true, action is terminated (gets marked done)
        Returns:
        the action scheduled
      • schedule

        IConditionalAction schedule​(java.lang.String name,
                                    java.util.function.Function<IAction,​java.lang.Boolean> condition,
                                    java.util.function.Consumer<IAction> task,
                                    java.util.function.Function<IAction,​java.lang.Boolean> terminateWhen,
                                    java.util.function.Consumer<IAction> onTermination)
        Schedule a conditional action that gives up after at most maxChecks attempts.
        Parameters:
        name - unique name
        condition - checked every tick, if it returns true, task is fired
        task - code to run once condition first becomes true
        terminateWhen - checked every tick, if it returns true, action is terminated (gets marked done)
        onTermination - code to run when the termination condition returns true
        Returns:
        the action scheduled
      • getParallelQueue

        IActionQueue getParallelQueue()
        Returns:
        the list of all parallel actions scheduled
      • scheduleParallel

        IAction scheduleParallel​(IAction action)
        Schedules actions on the parallelQueue, where all actions are executed simultaneously
        Parameters:
        action -
        Returns:
      • scheduleParallel

        void scheduleParallel​(IAction... actions)
        Multiple actions in parallel i.e scheduleParallel(act1,act2,act3,...)
        Parameters:
        actions -
      • scheduleParallel

        IAction scheduleParallel​(java.util.function.Consumer<IAction> task)
      • scheduleParallel

        void scheduleParallel​(java.util.function.Consumer<IAction>... tasks)
      • scheduleParallel

        IAction scheduleParallel​(int delay,
                                 java.util.function.Consumer<IAction> task)
      • scheduleParallel

        IAction scheduleParallel​(int maxDuration,
                                 int delay,
                                 java.util.function.Consumer<IAction> task)
      • scheduleParallel

        IAction scheduleParallel​(java.lang.String name,
                                 java.util.function.Consumer<IAction> task)
      • scheduleParallel

        IAction scheduleParallel​(java.lang.String name,
                                 int delay,
                                 java.util.function.Consumer<IAction> task)
      • scheduleParallel

        IAction scheduleParallel​(java.lang.String name,
                                 int maxDuration,
                                 int delay,
                                 java.util.function.Consumer<IAction> task)
      • getAllQueues

        IActionQueue[] getAllQueues()
        Returns:
        All the IActionQueues within this Manager, including main sequential, parallel and conditional
      • hasAny

        boolean hasAny​(java.lang.String name)
        Parameters:
        name - action name to check for
        Returns:
        true if action is scheduled in any of the available queues
      • getAny

        IAction getAny​(java.lang.String name)
        Parameters:
        name -
        Returns:
        Checks through all available queues and fetches the first IAction with given name
      • cancelAny

        boolean cancelAny​(java.lang.String name)
        Checks through all available queues and cancels (remove) the first action with the given name.
        Parameters:
        name - the name assigned when scheduling
        Returns:
        true if one was found and removed, false otherwise
      • clear

        void clear()
        Clears all available queues and kills all of their scheduled IActions.
      • chain

        IActionChain chain()
        Returns:
        a chain that can be used to fire Actions sequentially based on sequentialQueue
      • parallelChain

        IActionChain parallelChain()
        Returns:
        a chain that can be used to fire Actions in parallel based on parallelQueue
      • printQueues

        java.lang.String printQueues()
        Returns:
        a string containing all the IActionQueues active within the manager