Package net.thewinnt.cutscenes.time
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
FieldsModifier and TypeFieldDescriptionstatic final Map<String, it.unimi.dsi.fastutil.booleans.Boolean2ObjectFunction<Transition>> The registry of default transitions for time managers.static final Map<String, Supplier<TimeManager>> The registry of time managers. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIf this returnstrue, it means that cutscene length is synchronized with the server tickrate and can, therefore, be defined in ticksvoidsetGameTickRate(float tickrate) Notifies the time manager that the game tick rate has changed.voidstart()Starts the timer from zero.voidsyncGameTime(long gameTime) Notifies the time manager that the game time has been synchronized.doubletick()Updates the internal state and returns the current time.doubleReturns the amount of 1/20ths of a second (one game tick) in one unit under typical circumstances (e.g. 20 TPS).type()Returns the type of this manager.
-
Field Details
-
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_TRANSITIONSThe 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 totick()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 returnstrue, 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 inREGISTRY.- 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
-