Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
keyframe.qc
Go to the documentation of this file.
1#include "keyframe.qh"
2
3#include "../menu.qh"
4#include "easing.qh"
5
7
8.entity parent;
9
10 entity makeHostedKeyframe(entity obj, void(entity, float) objSetter, float animDuration, float animStart, float animEnd)
11 {
12 entity this = makeKeyframe(obj, objSetter, animDuration, animStart, animEnd);
13 anim.addAnim(anim, this);
14 return this;
15 }
16
17 entity makeKeyframe(entity obj, void(entity, float) objSetter, float animDuration, float animStart, float animEnd)
18 {
19 entity this = NEW(Keyframe);
20 this.configureAnimation(this, obj, objSetter, time, animDuration, animStart, animEnd);
21 return this;
22 }
23
24 METHOD(Keyframe, addEasing, entity(entity this, float animDurationTime, float animEnd, float(float, float, float, float) func))
25 {
26 entity other = makeEasing(this.object, this.setter, func, getNewChildStart(this), getNewChildDuration(this, animDurationTime), getNewChildValue(this), animEnd);
27 this.addAnim(this, other);
28 return other;
29 }
30
32 {
33 if (this.lastChild) return this.lastChild.startTime + this.lastChild.duration;
34 else return 0;
35 }
36
37 float getNewChildDuration(entity this, float durationTime)
38 {
39 float maxDura = this.duration;
40 if (this.lastChild) maxDura = maxDura - (this.lastChild.startTime + this.lastChild.duration);
41 float dura = durationTime;
42 if (0 >= dura || dura > maxDura) dura = maxDura;
43 return dura;
44 }
45
47 {
48 if (this.lastChild) return this.lastChild.startValue + this.lastChild.delta;
49 else return this.startValue;
50 }
51
53 {
54 if (other.parent) error("Can't add already added anim!");
55 if (other.finished) error("Can't add finished anim!");
56
57 other.parent = this;
58
59 entity l = this.lastChild;
60
61 if (l)
62 {
63 l.nextSibling = other;
64 }
65 else
66 {
67 this.currentChild = other;
68 this.firstChild = other;
69 }
70
71 other.prevSibling = l;
72 other.nextSibling = NULL;
73 this.lastChild = other;
74 }
75
76 METHOD(Keyframe, calcValue, float(entity this, float tickTime, float animDuration, float animStartValue, float animDelta))
77 {
78 if (this.currentChild && this.currentChild.finished)
79 this.currentChild = this.currentChild.nextSibling;
80
81 if (this.currentChild)
82 {
83 this.currentChild.tick(this.currentChild, tickTime);
84 return this.currentChild.value;
85 }
86
87 return animStartValue + animDelta;
88 }
entity parent
Definition animhost.qc:7
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
virtual void addEasing()
Definition keyframe.qc:24
virtual void calcValue()
Definition keyframe.qc:76
virtual void addAnim()
Definition keyframe.qc:52
entity other
float time
entity() spawn
entity makeEasing(entity obj, void(entity, float) objSetter, float(float, float, float, float) func, float animStartTime, float animDuration, float animStartValue, float animEnd)
Definition easing.qc:13
entity makeHostedKeyframe(entity obj, void(entity, float) objSetter, float animDuration, float animStart, float animEnd)
Definition keyframe.qc:10
entity makeKeyframe(entity obj, void(entity, float) objSetter, float animDuration, float animStart, float animEnd)
Definition keyframe.qc:17
float getNewChildStart(entity this)
Definition keyframe.qc:31
float getNewChildDuration(entity this, float durationTime)
Definition keyframe.qc:37
float getNewChildValue(entity this)
Definition keyframe.qc:46
entity anim
Definition menu.qh:25
entity firstChild
Definition menu_cmd.qc:12
#define NEW(cname,...)
Definition oo.qh:117
#define METHOD(cname, name, prototype)
Definition oo.qh:269
#define NULL
Definition post.qh:14
#define error
Definition pre.qh:6