public abstract class Trigger extends Object
@T
. The Trigger type
provides a Linkable.Int for listening for triggers, and maintains a count of
each time the trigger has been called (useful for sequencing). It is also
possible to connect Runnable functions to be called on each trigger.Modifier and Type | Method and Description |
---|---|
Trigger |
clearLinks()
Clear all Linkables from this Trigger.
|
int |
index()
Get the current index.
|
Trigger |
index(int idx)
Set the current index.
|
Trigger |
link(Runnable runnable)
Run the provided Runnable each time this Trigger is triggered.
|
int |
maxIndex()
Get the current maximum index.
|
Trigger |
maxIndex(int max)
Set the maximum index, at which the index will wrap back to zero.
|
Linkable.Int |
on()
Returns a new
Linkable.Int for listening to each trigger. |
abstract boolean |
poll()
Deprecated.
|
Trigger |
trigger()
Manually trigger this Trigger.
|
@Deprecated public abstract boolean poll()
public Trigger clearLinks()
public Trigger link(Runnable runnable)
on().link(i -> runnable.run());
.runnable
- function to run on triggerpublic Linkable.Int on()
Linkable.Int
for listening to each trigger. The int
passed to the created linkable will be the same as index, incrementing
each time, wrapping at maxIndex.public Trigger index(int idx)
idx
- new indexpublic Trigger maxIndex(int max)
max
- maximum indexpublic int index()
public int maxIndex()
public Trigger trigger()