Class ClockTickTimer
- java.lang.Object
-
- ch.sahits.game.openpatrician.utilities.service.Timer
-
- ch.sahits.game.openpatrician.engine.ClockTickTimer
-
public class ClockTickTimer extends Timer
This clock ticking timer extends the pausable timer.- Author:
- Andi Hotz, (c) Sahits GmbH, 2015 Created on Sep 07, 2015
-
-
Field Summary
Fields Modifier and Type Field Description private Dateclockprivate booleandayChangedprivate static java.lang.ObjectlockLock for guaranteeing thread safetyprivate IEventPropagatormessagePropagatorprivate com.google.common.eventbus.AsyncEventBustimerEventBus-
Fields inherited from class ch.sahits.game.openpatrician.utilities.service.Timer
DURATION_INFINITY
-
-
Constructor Summary
Constructors Constructor Description ClockTickTimer(long interval, long duration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidhandlePause(PauseGame event)voidhandleResume(ResumeGame event)protected voidonFinish()This method is called once the timer has run for the specified duration.protected voidonTick()This method is called periodically with the interval set as the delay between subsequent calls.private voidregister()voidtick()Update the time by one tick.private voidunregister()-
Methods inherited from class ch.sahits.game.openpatrician.utilities.service.Timer
cancel, getElapsedTime, getRemainingTime, isRunning, pause, resume, start
-
-
-
-
Field Detail
-
clock
@Autowired private Date clock
-
timerEventBus
@Autowired @Qualifier("timerEventBus") private com.google.common.eventbus.AsyncEventBus timerEventBus
-
messagePropagator
@Autowired private IEventPropagator messagePropagator
-
dayChanged
private boolean dayChanged
-
lock
private static java.lang.Object lock
Lock for guaranteeing thread safety
-
-
Method Detail
-
register
@PostConstruct private void register()
-
unregister
@PreDestroy private void unregister()
-
onTick
protected void onTick()
Description copied from class:TimerThis method is called periodically with the interval set as the delay between subsequent calls.
-
onFinish
protected void onFinish()
Description copied from class:TimerThis method is called once the timer has run for the specified duration. If the duration was set as infinity, then this method is never called.
-
tick
public void tick()
Update the time by one tick.
-
handlePause
public void handlePause(PauseGame event)
-
handleResume
public void handleResume(ResumeGame event)
-
-