Improve indentation consistency in client.qc
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / anim / animation.qc
1 #include "animation.qh"
2
3 #include "../menu.qh"
4
5         METHOD(Animation, configureAnimation, void(entity this, entity obj, void(entity, float) objSetter, float animStartTime, float animDuration, float animStartValue, float animEndValue))
6         {
7                 this.setObjectSetter(this, obj, objSetter);
8                 this.setTimeStartDuration(this, animStartTime, animDuration);
9                 this.setValueStartEnd(this, animStartValue, animEndValue);
10         }
11
12         METHOD(Animation, update, void(entity this, float animDuration, float animStartValue, float animEndValue))
13         {
14                 this.setTimeStartDuration(this, time, animDuration);
15                 this.setValueStartEnd(this, animStartValue, animEndValue);
16         }
17
18         METHOD(Animation, setTimeStartEnd, void(entity this, float s, float e))
19         {
20                 this.startTime = s;
21                 this.duration = e - s;
22         }
23
24         METHOD(Animation, setTimeStartDuration, void(entity this, float s, float d))
25         {
26                 this.startTime = s;
27                 this.duration = d;
28         }
29
30         METHOD(Animation, setValueStartEnd, void(entity this, float s, float e))
31         {
32                 this.startValue = s;
33                 this.delta = e - s;
34         }
35
36         METHOD(Animation, setObjectSetter, void(entity this, entity o, void(entity, float) s))
37         {
38                 this.object = o;
39                 this.setter = s;
40         }
41
42         METHOD(Animation, tick, void(entity this, float tickTime))
43         {
44                 if (this.isStopped(this) || this.isFinished(this) || (tickTime < this.startTime)) return;
45
46                 if (tickTime >= (this.startTime + this.duration)) this.finishAnim(this);
47                 else this.value = this.calcValue(this, (tickTime - this.startTime), this.duration, this.startValue, this.delta);
48
49                 this.setter(this.object, this.value);
50         }
51
52         METHOD(Animation, calcValue, float(entity this, float tickTime, float animDuration, float animStartValue, float animDelta))
53         {
54                 return animStartValue;
55         }
56
57         METHOD(Animation, isStopped, bool(entity this))
58         {
59                 return this.stopped;
60         }
61
62         METHOD(Animation, stopAnim, void(entity this))
63         {
64                 this.stopped = true;
65         }
66
67         METHOD(Animation, resumeAnim, void(entity this))
68         {
69                 this.stopped = false;
70         }
71
72         METHOD(Animation, isFinished, bool(entity this))
73         {
74                 return this.finished;
75         }
76
77         METHOD(Animation, finishAnim, void(entity this))
78         {
79                 this.value = this.delta + this.startValue;
80                 this.finished = true;
81                 this.setter(this.object, this.value);
82         }