1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package net.sourceforge.basher.impl;
16
17 import net.sourceforge.basher.events.EventManager;
18 import net.sourceforge.basher.events.TickEvent;
19
20
21
22
23
24 public class TickTimerTask implements Runnable
25 {
26 private long _tick;
27 private EventManager _eventManager;
28
29 public void setEventManager( final EventManager eventManager )
30 {
31 _eventManager = eventManager;
32 }
33
34 public void run()
35 {
36 _eventManager.publish(new TickEvent(_tick++));
37 }
38
39 public boolean equals(final Object o)
40 {
41 if (this == o)
42 {
43 return true;
44 }
45 if (o == null || getClass() != o.getClass())
46 {
47 return false;
48 }
49
50 final TickTimerTask that = (TickTimerTask) o;
51
52 if (_tick != that._tick)
53 {
54 return false;
55 }
56 if (_eventManager != null ? !_eventManager.equals(that._eventManager) : that._eventManager != null)
57 {
58 return false;
59 }
60
61 return true;
62 }
63
64 public int hashCode()
65 {
66 int result;
67 result = (int) (_tick ^ (_tick >>> 32));
68 result = 31 * result + (_eventManager != null ? _eventManager.hashCode() : 0);
69 return result;
70 }
71 }