Interface TimeManager

All Known Implementing Classes:
GameTickManager, RealTimeManager

public interface TimeManager
A TimeManager controls the speed of the cutscene and its length. It operates with "time units", which may differ in each implementation. It's usually seconds or game ticks.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Map<String,it.unimi.dsi.fastutil.booleans.Boolean2ObjectFunction<Transition>>
    The registry of default transitions for time managers.
    The registry of time managers.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    If this returns true, it means that cutscene length is synchronized with the server tickrate and can, therefore, be defined in ticks
    void
    setGameTickRate(float tickrate)
    Notifies the time manager that the game tick rate has changed.
    void
    Starts the timer from zero.
    void
    syncGameTime(long gameTime)
    Notifies the time manager that the game time has been synchronized.
    double
    Updates the internal state and returns the current time.
    double
    Returns the amount of 1/20ths of a second (one game tick) in one unit under typical circumstances (e.g. 20 TPS).
    Returns the type of this manager.
  • Field Details

    • REGISTRY

      static final Map<String,Supplier<TimeManager>> REGISTRY
      The registry of time managers. I don't expect anyone to ever use this, so it's just a simple mutable map.
    • DEFAULT_TRANSITIONS

      static final Map<String,it.unimi.dsi.fastutil.booleans.Boolean2ObjectFunction<Transition>> DEFAULT_TRANSITIONS
      The registry of default transitions for time managers. This is because with different units come different scales that may or may not be very compatible with each other.
  • Method Details

    • tick

      double tick()
      Updates the internal state and returns the current time.
      Returns:
      a value representing the current time since a cutscene started, in time units.
    • start

      void start()
      Starts the timer from zero. The next call to tick() is not guaranteed to return exactly zero after this.
    • setGameTickRate

      void setGameTickRate(float tickrate)
      Notifies the time manager that the game tick rate has changed.
      Parameters:
      tickrate - the new tickrate, in game ticks per second.
    • syncGameTime

      void syncGameTime(long gameTime)
      Notifies the time manager that the game time has been synchronized.
      Parameters:
      gameTime - the current game time
    • isServerSynched

      boolean isServerSynched()
      If this returns true, it means that cutscene length is synchronized with the server tickrate and can, therefore, be defined in ticks
      Returns:
      whether the length of the cutscene is related to server tickrate
    • type

      String type()
      Returns the type of this manager. Must be one of the entries in REGISTRY.
      Returns:
      the type of this time manager
    • ticksPerUnit

      double ticksPerUnit()
      Returns the amount of 1/20ths of a second (one game tick) in one unit under typical circumstances (e.g. 20 TPS).
      Returns:
      (unit length in seconds) * 20