Class TimeAnchor
java.lang.Object
dev.bouncingelf10.timelesslib.api.time.TimeAnchor
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new TimeAnchor that uses the game time.TimeAnchor(TimeSource timeSource) Creates a new TimeAnchor that uses the specified time source. -
Method Summary
Modifier and TypeMethodDescriptionstatic TimeAnchorCreates a new TimeAnchor that uses the game time.static TimeAnchorCreates a new TimeAnchor that is paused and uses the game time.static TimeAnchorcreatePaused(TimeSource source) Creates a new TimeAnchor that is paused and uses the specified time source.static TimeAnchorCreates a new TimeAnchor that uses the real time.elapsed()doubleelapsed(DurationUnit unit) Returns the elapsed time in the specified unit.doubledoublelongdoubleelapsedSince(Duration snapshot) longbooleanhasElapsed(long amount, DurationUnit unit) booleanhasElapsed(Duration duration) Returns true if the specified duration has elapsed.booleanhasElapsedSeconds(long seconds) booleanhasElapsedTicks(long ticks) booleanisPaused()voidpause()Pauses the anchor.
Note: If the anchor is already paused, this method does nothing.voidvoidlongremaining(long amount, DurationUnit unit) doubleremaining(long targetAmount, DurationUnit targetUnit, DurationUnit returnUnit) Returns the remaining time until the specified target.voidreset()voidvoidresume()Resumes the anchor.
Note: If the anchor is not paused, this method does nothing.snapshot()Creates a snapshot of the current time.toString()toString(TimeFormat format)
-
Constructor Details
-
TimeAnchor
public TimeAnchor()Creates a new TimeAnchor that uses the game time.- See Also:
-
TimeAnchor
Creates a new TimeAnchor that uses the specified time source.- Parameters:
timeSource- Time source to use- See Also:
-
-
Method Details
-
elapsedNanos
public long elapsedNanos() -
elapsed
-
elapsed
Returns the elapsed time in the specified unit. -
elapsedTicks
public long elapsedTicks() -
elapsedMillis
public double elapsedMillis() -
elapsedSeconds
public double elapsedSeconds() -
elapsedMinutes
public double elapsedMinutes() -
hasElapsed
Returns true if the specified duration has elapsed. -
hasElapsed
-
hasElapsedTicks
public boolean hasElapsedTicks(long ticks) -
hasElapsedSeconds
public boolean hasElapsedSeconds(long seconds) -
remaining
Returns the remaining time until the specified target. -
remaining
-
remaining
-
pause
public void pause()Pauses the anchor.
Note: If the anchor is already paused, this method does nothing. -
resume
public void resume()Resumes the anchor.
Note: If the anchor is not paused, this method does nothing. -
isPaused
public boolean isPaused() -
reset
public void reset() -
resetAndPause
public void resetAndPause() -
playOrReset
public void playOrReset() -
pauseOrUnpause
public void pauseOrUnpause() -
snapshot
Creates a snapshot of the current time. -
elapsedSince
-
getTimeSource
-
toString
-
toString
-
createGameTime
Creates a new TimeAnchor that uses the game time.- See Also:
-
createRealTime
Creates a new TimeAnchor that uses the real time.- See Also:
-
createPaused
Creates a new TimeAnchor that is paused and uses the game time.- See Also:
-
createPaused
Creates a new TimeAnchor that is paused and uses the specified time source.- See Also:
-