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 Date
clock
private boolean
dayChanged
private static java.lang.Object
lock
Lock for guaranteeing thread safetyprivate IEventPropagator
messagePropagator
private com.google.common.eventbus.AsyncEventBus
timerEventBus
-
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 void
handlePause(PauseGame event)
void
handleResume(ResumeGame event)
protected void
onFinish()
This method is called once the timer has run for the specified duration.protected void
onTick()
This method is called periodically with the interval set as the delay between subsequent calls.private void
register()
void
tick()
Update the time by one tick.private void
unregister()
-
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:Timer
This method is called periodically with the interval set as the delay between subsequent calls.
-
onFinish
protected void onFinish()
Description copied from class:Timer
This 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)
-
-