]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/anim/animhost.c
remove unused locals
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / anim / animhost.c
1 #ifdef INTERFACE
2 CLASS(AnimHost) EXTENDS(Object)
3         METHOD(AnimHost, addAnim, void(entity, entity))
4         METHOD(AnimHost, removeAnim, void(entity, entity))
5         METHOD(AnimHost, removeAllAnim, void(entity))
6         METHOD(AnimHost, removeObjAnim, void(entity, entity))
7         METHOD(AnimHost, stopAllAnim, void(entity))
8         METHOD(AnimHost, stopObjAnim, void(entity, entity))
9         METHOD(AnimHost, resumeAllAnim, void(entity))
10         METHOD(AnimHost, resumeObjAnim, void(entity, entity))
11         METHOD(AnimHost, finishAllAnim, void(entity))
12         METHOD(AnimHost, finishObjAnim, void(entity, entity))
13         METHOD(AnimHost, tickAll, void(entity))
14         ATTRIB(AnimHost, firstChild, entity, NULL)
15         ATTRIB(AnimHost, lastChild, entity, NULL)
16 ENDCLASS(AnimHost)
17 .entity nextSibling;
18 .entity prevSibling;
19 #endif
20
21 #ifdef IMPLEMENTATION
22 void AnimHost_addAnim(entity me, entity other)
23 {
24         if(other.parent)
25                 error("Can't add already added anim!");
26
27         if(other.isFinished(other))
28                 error("Can't add finished anim!");
29
30         other.parent = me;
31
32         entity f, l;
33         f = me.firstChild;
34         l = me.lastChild;
35
36         if(l)
37                 l.nextSibling = other;
38         else
39                 me.firstChild = other;
40
41         other.prevSibling = l;
42         other.nextSibling = NULL;
43         me.lastChild = other;
44 }
45
46 void AnimHost_removeAnim(entity me, entity other)
47 {
48         if(other.parent != me)
49                 error("Can't remove from wrong AnimHost!");
50
51         other.parent = NULL;
52
53         entity n, p;
54         n = other.nextSibling;
55         p = other.prevSibling;
56
57         if(p)
58                 p.nextSibling = n;
59         else
60                 me.firstChild = n;
61
62         if(n)
63                 n.prevSibling = p;
64         else
65                 me.lastChild = p;
66         remove(other);
67 }
68
69 void AnimHost_removeAllAnim(entity me)
70 {
71         entity e, tmp;
72         for(e = me.firstChild; e; e = e.nextSibling)
73         {
74                 tmp = e;
75                 e = tmp.prevSibling;
76                 me.removeAnim(me, tmp);
77         }
78 }
79
80 void AnimHost_removeObjAnim(entity me, entity obj)
81 {
82         entity e, tmp;
83         for(e = me.firstChild; e; e = e.nextSibling)
84         {
85                 if (e.object == obj)
86                 {
87                         tmp = e;
88                         e = tmp.prevSibling;
89                         me.removeAnim(me, tmp);
90                 }
91         }
92 }
93
94 void AnimHost_stopAllAnim(entity me)
95 {
96         entity e;
97         for(e = me.firstChild; e; e = e.nextSibling)
98         {
99                 e.stopAnim(e);
100         }
101 }
102
103 void AnimHost_stopObjAnim(entity me, entity obj)
104 {
105         entity e;
106         for(e = me.firstChild; e; e = e.nextSibling)
107         {
108                 if (e.object == obj)
109                 {
110                         e.stopAnim(e);
111                 }
112         }
113 }
114
115 void AnimHost_resumeAllAnim(entity me)
116 {
117         entity e;
118         for(e = me.firstChild; e; e = e.nextSibling)
119         {
120                 e.resumeAnim(e);
121         }
122 }
123
124 void AnimHost_resumeObjAnim(entity me, entity obj)
125 {
126         entity e;
127         for(e = me.firstChild; e; e = e.nextSibling)
128         {
129                 if (e.object == obj)
130                 {
131                         e.resumeAnim(e);
132                 }
133         }
134 }
135
136 void AnimHost_finishAllAnim(entity me)
137 {
138         entity e, tmp;
139         for(e = me.firstChild; e; e = e.nextSibling)
140         {
141                 tmp = e;
142                 e = tmp.prevSibling;
143                 tmp.finishAnim(tmp);
144         }
145 }
146
147 void AnimHost_finishObjAnim(entity me, entity obj)
148 {
149         entity e, tmp;
150         for(e = me.firstChild; e; e = e.nextSibling)
151         {
152                 if (e.object == obj)
153                 {
154                         tmp = e;
155                         e = tmp.prevSibling;
156                         tmp.finishAnim(tmp);
157                 }
158         }
159 }
160
161 void AnimHost_tickAll(entity me)
162 {
163         entity e, tmp;
164         for(e = me.firstChild; e; e = e.nextSibling)
165         {
166                 e.tick(e, time);
167                 if (e.isFinished(e))
168                 {
169                         tmp = e;
170                         e = tmp.prevSibling;
171                         me.removeAnim(me, tmp);
172                 }
173         }
174 }
175 #endif