4 #ifndef ANIM_ANIMHOST_H
5 #define ANIM_ANIMHOST_H
6 CLASS(AnimHost, Object)
7 METHOD(AnimHost, addAnim, void(entity, entity));
8 METHOD(AnimHost, removeAnim, void(entity, entity));
9 METHOD(AnimHost, removeAllAnim, void(entity));
10 METHOD(AnimHost, removeObjAnim, void(entity, entity));
11 METHOD(AnimHost, stopAllAnim, void(entity));
12 METHOD(AnimHost, stopObjAnim, void(entity, entity));
13 METHOD(AnimHost, resumeAllAnim, void(entity));
14 METHOD(AnimHost, resumeObjAnim, void(entity, entity));
15 METHOD(AnimHost, finishAllAnim, void(entity));
16 METHOD(AnimHost, finishObjAnim, void(entity, entity));
17 METHOD(AnimHost, tickAll, void(entity));
18 ATTRIB(AnimHost, firstChild, entity, NULL)
19 ATTRIB(AnimHost, lastChild, entity, NULL)
26 METHOD(AnimHost, addAnim, void(entity this, entity other))
28 if (other.parent) error("Can't add already added anim!");
30 if (other.isFinished(other)) error("Can't add finished anim!");
34 entity l = this.lastChild;
36 if (l) l.nextSibling = other;
37 else this.firstChild = other;
39 other.prevSibling = l;
40 other.nextSibling = NULL;
41 this.lastChild = other;
44 METHOD(AnimHost, removeAnim, void(entity this, entity other))
46 if (other.parent != this) error("Can't remove from wrong AnimHost!");
50 entity n = other.nextSibling;
51 entity p = other.prevSibling;
53 if (p) p.nextSibling = n;
54 else this.firstChild = n;
56 if (n) n.prevSibling = p;
57 else this.lastChild = p;
61 METHOD(AnimHost, removeAllAnim, void(entity this))
63 for (entity e = this.firstChild; e; e = e.nextSibling)
67 this.removeAnim(this, tmp);
71 METHOD(AnimHost, removeObjAnim, void(entity this, entity obj))
73 for (entity e = this.firstChild; e; e = e.nextSibling)
79 this.removeAnim(this, tmp);
84 METHOD(AnimHost, stopAllAnim, void(entity this))
86 for (entity e = this.firstChild; e; e = e.nextSibling)
90 METHOD(AnimHost, stopObjAnim, void(entity this, entity obj))
92 for (entity e = this.firstChild; e; e = e.nextSibling)
93 if (e.object == obj) e.stopAnim(e);
96 METHOD(AnimHost, resumeAllAnim, void(entity this))
98 for (entity e = this.firstChild; e; e = e.nextSibling)
102 METHOD(AnimHost, resumeObjAnim, void(entity this, entity obj))
104 for (entity e = this.firstChild; e; e = e.nextSibling)
105 if (e.object == obj) e.resumeAnim(e);
108 METHOD(AnimHost, finishAllAnim, void(entity this))
110 for (entity e = this.firstChild; e; e = e.nextSibling)
118 METHOD(AnimHost, finishObjAnim, void(entity this, entity obj))
120 for (entity e = this.firstChild; e; e = e.nextSibling)
131 METHOD(AnimHost, tickAll, void(entity this))
133 for (entity e = this.firstChild; e; e = e.nextSibling)
140 this.removeAnim(this, tmp);