Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
animation.qc
Go to the documentation of this file.
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.stopped || this.finished || (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
58 {
59 this.stopped = true;
60 }
61
63 {
64 this.stopped = false;
65 }
66
68 {
69 this.value = this.delta + this.startValue;
70 this.finished = true;
71 this.setter(this.object, this.value);
72 }
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float value
Definition animation.qh:20
virtual void calcValue()
Definition animation.qc:52
virtual void stopAnim()
Definition animation.qc:57
virtual void configureAnimation()
Definition animation.qc:5
virtual void update()
Definition animation.qc:12
float startTime
Definition animation.qh:21
virtual void setTimeStartEnd()
Definition animation.qc:18
virtual void tick()
Definition animation.qc:42
float duration
Definition animation.qh:22
virtual void setValueStartEnd()
Definition animation.qc:30
float delta
Definition animation.qh:24
float finished
Definition animation.qh:26
virtual void setTimeStartDuration()
Definition animation.qc:24
virtual void setObjectSetter()
Definition animation.qc:36
float startValue
Definition animation.qh:23
float stopped
Definition animation.qh:25
virtual void finishAnim()
Definition animation.qc:67
virtual void resumeAnim()
Definition animation.qc:62
float time
#define METHOD(cname, name, prototype)
Definition oo.qh:269