Class TimeAnchor

java.lang.Object
dev.bouncingelf10.timelesslib.api.time.TimeAnchor

public class TimeAnchor extends Object
  • Constructor Details

    • TimeAnchor

      public TimeAnchor()
      Creates a new TimeAnchor that uses the game time.
      See Also:
    • TimeAnchor

      public TimeAnchor(TimeSource timeSource)
      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

      public Duration elapsed()
    • elapsed

      public double elapsed(DurationUnit unit)
      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

      public boolean hasElapsed(Duration duration)
      Returns true if the specified duration has elapsed.
    • hasElapsed

      public boolean hasElapsed(long amount, DurationUnit unit)
    • hasElapsedTicks

      public boolean hasElapsedTicks(long ticks)
    • hasElapsedSeconds

      public boolean hasElapsedSeconds(long seconds)
    • remaining

      public Duration remaining(Duration target)
      Returns the remaining time until the specified target.
    • remaining

      public long remaining(long amount, DurationUnit unit)
    • remaining

      public double remaining(long targetAmount, DurationUnit targetUnit, DurationUnit returnUnit)
    • 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

      public Duration snapshot()
      Creates a snapshot of the current time.
    • elapsedSince

      public Duration elapsedSince(Duration snapshot)
    • getTimeSource

      public TimeSource getTimeSource()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(TimeFormat format)
    • createGameTime

      public static TimeAnchor createGameTime()
      Creates a new TimeAnchor that uses the game time.
      See Also:
    • createRealTime

      public static TimeAnchor createRealTime()
      Creates a new TimeAnchor that uses the real time.
      See Also:
    • createPaused

      public static TimeAnchor createPaused()
      Creates a new TimeAnchor that is paused and uses the game time.
      See Also:
    • createPaused

      public static TimeAnchor createPaused(TimeSource source)
      Creates a new TimeAnchor that is paused and uses the specified time source.
      See Also: