Package noppes.npcs.api.handler.data
Interface IAction
-
- All Known Subinterfaces:
IConditionalAction
public interface IActionRepresents a single "task" that can be executed over multiple ticks, supports delayed start, limited duration, repeating intervals, data storage, and chaining to neighboring tasks.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IActionaddData(java.lang.String key, java.lang.Object value)Store arbitrary per-action data.IActionafter(int delay, java.util.function.Consumer<IAction> t)IActionafter(java.lang.String name, int maxDuration, int delay, java.util.function.Consumer<IAction> t)IActionafter(java.lang.String name, int delay, java.util.function.Consumer<IAction> t)IActionafter(java.lang.String name, java.util.function.Consumer<IAction> t)IActionafter(java.util.function.Consumer<IAction> t)IActionafter(IAction after)Enqueue another action immediately after this one.IActionbefore(int delay, java.util.function.Consumer<IAction> t)IActionbefore(java.lang.String name, int maxDuration, int delay, java.util.function.Consumer<IAction> t)IActionbefore(java.lang.String name, int delay, java.util.function.Consumer<IAction> t)IActionbefore(java.lang.String name, java.util.function.Consumer<IAction> t)IActionbefore(java.util.function.Consumer<IAction> t)IActionbefore(IAction before)Enqueue another action immediately before this one (pausing this one until done).intgetCount()java.lang.ObjectgetData(java.lang.String key)Retrieve arbitrary per-action data.intgetDuration()IActionManagergetManager()intgetMaxDuration()java.lang.StringgetName()IActiongetNext()IActiongetPrevious()intgetStartAfterTicks()intgetUpdateEveryXTick()booleanisDone()voidmarkDone()Mark this action as complete.IActionpauseFor(int ticks)IActionremoveData(java.lang.String key)IActionsetMaxDuration(int x)IActionsetTask(java.util.function.Consumer<IAction> task)IActionsetUpdateEveryXTick(int X)Set how many ticks between each invocation of the action callback.
-
-
-
Method Detail
-
setTask
IAction setTask(java.util.function.Consumer<IAction> task)
- Parameters:
task- code to execute each time the action fires- Returns:
-
getManager
IActionManager getManager()
- Returns:
- action manager the action is scheduled on
-
getCount
int getCount()
- Returns:
- how many times this action’s
action.accept(this)callback has run (or how many times task ran)
-
getDuration
int getDuration()
- Returns:
- how many ticks have elapsed since this action actually began (excluding start delay)
-
getName
java.lang.String getName()
- Returns:
- the name given at creation/scheduling time
-
getMaxDuration
int getMaxDuration()
- Returns:
- the maximum number of ticks this action is allowed to run before auto-terminating
-
setMaxDuration
IAction setMaxDuration(int x)
-
markDone
void markDone()
Mark this action as complete. Once done, it will be removed on the next tick.
-
isDone
boolean isDone()
- Returns:
- true if
markDone()was called (or maxDuration reached)
-
getData
java.lang.Object getData(java.lang.String key)
Retrieve arbitrary per-action data.- Parameters:
key- a string key- Returns:
- the stored value, or null if not set
-
addData
IAction addData(java.lang.String key, java.lang.Object value)
Store arbitrary per-action data.- Parameters:
key- a string keyvalue- any object to associate with this action
-
removeData
IAction removeData(java.lang.String key)
-
getUpdateEveryXTick
int getUpdateEveryXTick()
- Returns:
- how many ticks between each invocation of the action callback
-
setUpdateEveryXTick
IAction setUpdateEveryXTick(int X)
Set how many ticks between each invocation of the action callback.- Parameters:
X- tick interval (e.g. 1 = every tick, 20 = once per second)
-
getStartAfterTicks
int getStartAfterTicks()
- Returns:
- how many ticks remain before the action begins (initial delay)
-
pauseFor
IAction pauseFor(int ticks)
- Parameters:
ticks- pauses action for this number of ticks (any subsequent action is paused too)- Returns:
-
getNext
IAction getNext()
- Returns:
- the next action in the queue (or null if none or at end)
-
getPrevious
IAction getPrevious()
- Returns:
- the previous action in the queue (or null if none or at front)
-
after
IAction after(IAction after)
Enqueue another action immediately after this one.- Parameters:
after- the action to run next
-
after
IAction after(java.lang.String name, int maxDuration, int delay, java.util.function.Consumer<IAction> t)
-
before
IAction before(IAction before)
Enqueue another action immediately before this one (pausing this one until done).- Parameters:
before- the action to run prior
-
before
IAction before(java.lang.String name, int maxDuration, int delay, java.util.function.Consumer<IAction> t)
-
-