Package-level declarations

Types

Link copied to clipboard

A value a run requires, read as a delegate.

Link copied to clipboard

Where suspended code waits for game ticks, found in the coroutine context. TickScope is one for hosts that tick themselves; a host with its own tick loop puts its own into the context, so library waits run on that loop.

Link copied to clipboard
class TickScope @JvmOverloads constructor(logger: Logger = LoggerFactory.getLogger("Agent/Ticks")) : CoroutineScope, Ticker

Runs suspend code on the game tick of the thread that calls tick: code launched on it starts with the next tick, and everything resumed in a tick runs before tick returns. Each launch is a run with its own requires. A failure is logged to logger and ends only its own run.

Functions

Link copied to clipboard
suspend fun <T : Any> requires(read: () -> T?): Required<T>

Requires what read returns for the rest of this run: false or null ends it. Every wait (tickUntil, waitTicks, tickConditional) reads it again on each tick it waits and once more right before the code after it runs. Once it fails, the run ends there quietly: nothing after that wait runs, finally blocks still do. If it fails right now, the run ends here.

Link copied to clipboard
suspend fun tickConditional(ticks: Int, breakLoop: BooleanSupplier): Boolean

Waits ticks ticks or until breakLoop holds; true when the time ran out without it.

Link copied to clipboard
suspend fun tickUntil(stopAt: IntPredicate): Int

Waits on the Ticker of the coroutine until stopAt holds, see Ticker.tickUntil. What the run requires is checked each tick before stopAt and once more before returning; once it fails, the run ends here quietly.

Link copied to clipboard
suspend fun unchanged(read: () -> Any?)

Requires that read returns the same instance it returns now, such as the level.

Link copied to clipboard
suspend fun waitTicks(ticks: Int)

Waits ticks ticks; 0 returns at once.