1 | package agents.anac.y2014.BraveCat.necessaryClasses;
|
---|
2 |
|
---|
3 | import genius.core.timeline.Timeline;
|
---|
4 |
|
---|
5 | @SuppressWarnings("serial")
|
---|
6 | public class ContinuousTimeline extends Timeline {
|
---|
7 | protected long pauseTime = 0;
|
---|
8 | private final int totalSeconds;
|
---|
9 | protected long startTime;
|
---|
10 |
|
---|
11 | public ContinuousTimeline(int totalSecs) {
|
---|
12 | this.totalSeconds = totalSecs;
|
---|
13 | this.startTime = System.nanoTime();
|
---|
14 | this.hasDeadline = true;
|
---|
15 | System.out.println("Started time line of " + totalSecs + " seconds.");
|
---|
16 | }
|
---|
17 |
|
---|
18 | public double getElapsedSeconds() {
|
---|
19 | long t2 = System.nanoTime();
|
---|
20 | return (t2 - this.startTime) / 1000000000.0D;
|
---|
21 | }
|
---|
22 |
|
---|
23 | public double getElapsedMilliSeconds() {
|
---|
24 | long t2 = System.nanoTime();
|
---|
25 | return (t2 - this.startTime) / 1000000.0D;
|
---|
26 | }
|
---|
27 |
|
---|
28 | public long getTotalMiliseconds() {
|
---|
29 | return 1000 * this.totalSeconds;
|
---|
30 | }
|
---|
31 |
|
---|
32 | public long getTotalSeconds() {
|
---|
33 | return this.totalSeconds;
|
---|
34 | }
|
---|
35 |
|
---|
36 | @Override
|
---|
37 | public double getTime() {
|
---|
38 | double t = getElapsedSeconds() / this.totalSeconds;
|
---|
39 | if (t > 1.0D)
|
---|
40 | t = 1.0D;
|
---|
41 | return t;
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Override
|
---|
45 | public double getTotalTime() {
|
---|
46 | return getTotalSeconds();
|
---|
47 | }
|
---|
48 |
|
---|
49 | @Override
|
---|
50 | public double getCurrentTime() {
|
---|
51 | return getElapsedSeconds();
|
---|
52 | }
|
---|
53 | } |
---|