Class ScriptSequence
- All Implemented Interfaces:
Subscription, AutoCloseable
A cancellable ordered sequence of delayed actions owned by a script context.
Build a sequence with then(Runnable) and waitFor(int), then call start(). Delays are
accumulated until the next action. Closing the sequence cancels its pending scheduled action.
-
Method Summary
Modifier and TypeMethodDescriptioncameraPanTo(IEntity target, int durationTicks) Schedules a camera pan to center on a target entity.cameraPanTo(Point2D target, int durationTicks) Schedules a camera pan to a given map location.cameraZoom(float targetZoom, int delayMs) Schedules a smooth camera zoom transition.voidclose()booleanReturns whether the sequence has pending actions.Schedules playing a sound effect.Schedules playing a sound effect by resource name.screenShake(double intensity, int intervalMs, int durationMs) Schedules a screen shake effect.start()Starts the sequence and transfers cancellation ownership to its context.Appends an action after the currently accumulated delay.waitFor(int delay) Adds a delay before the next appended action.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Subscription
unsubscribe
-
Method Details
-
then
Appends an action after the currently accumulated delay.- Parameters:
action- The action to invoke.- Returns:
- This sequence.
- Throws:
IllegalStateException- if the sequence has started.
-
waitFor
Adds a delay before the next appended action.- Parameters:
delay- The non-negative delay in milliseconds.- Returns:
- This sequence.
- Throws:
IllegalStateException- if the sequence has started.IllegalArgumentException- ifdelayis negative.ArithmeticException- if the accumulated delay overflows.
-
cameraPanTo
Schedules a camera pan to a given map location.- Parameters:
target- The target in map coordinates.durationTicks- The transition duration in update ticks.- Returns:
- This sequence.
-
cameraPanTo
Schedules a camera pan to center on a target entity.- Parameters:
target- The target entity.durationTicks- The transition duration in update ticks.- Returns:
- This sequence.
-
cameraZoom
Schedules a smooth camera zoom transition.- Parameters:
targetZoom- The target zoom factor.delayMs- The transition duration in milliseconds.- Returns:
- This sequence.
-
screenShake
Schedules a screen shake effect.- Parameters:
intensity- The shake intensity.intervalMs- The minimum interval between generated shake offsets, in milliseconds.durationMs- The shake duration in milliseconds.- Returns:
- This sequence.
-
playSound
Schedules playing a sound effect by resource name.
Missing resources are silently skipped when the action runs.
- Parameters:
soundName- The sound resource name.- Returns:
- This sequence.
-
playSound
Schedules playing a sound effect.- Parameters:
sound- The sound to play.- Returns:
- This sequence.
-
start
Starts the sequence and transfers cancellation ownership to its context.- Returns:
- This sequence as a cancellable subscription.
- Throws:
IllegalStateException- if it has already started.
-
isRunning
public boolean isRunning()Returns whether the sequence has pending actions.- Returns:
truewhile a started sequence has not completed or been closed.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSubscription
-