3 #ifndef ANIM_ANIMHOST_H
4 #define ANIM_ANIMHOST_H
5 CLASS(AnimHost, Object)
6 METHOD(AnimHost, addAnim, void(entity, entity));
7 METHOD(AnimHost, removeAnim, void(entity, entity));
8 METHOD(AnimHost, removeAllAnim, void(entity));
9 METHOD(AnimHost, removeObjAnim, void(entity, entity));
10 METHOD(AnimHost, stopAllAnim, void(entity));
11 METHOD(AnimHost, stopObjAnim, void(entity, entity));
12 METHOD(AnimHost, resumeAllAnim, void(entity));
13 METHOD(AnimHost, resumeObjAnim, void(entity, entity));
14 METHOD(AnimHost, finishAllAnim, void(entity));
15 METHOD(AnimHost, finishObjAnim, void(entity, entity));
16 METHOD(AnimHost, tickAll, void(entity));
17 ATTRIB(AnimHost, firstChild, entity, NULL)
18 ATTRIB(AnimHost, lastChild, entity, NULL)
25 METHOD(AnimHost, addAnim, void(entity this, entity other))
27 if (other.parent) error("Can't add already added anim!");
29 if (other.isFinished(other)) error("Can't add finished anim!");
33 entity l = this.lastChild;
35 if (l) l.nextSibling = other;
36 else this.firstChild = other;
38 other.prevSibling = l;
39 other.nextSibling = NULL;
40 this.lastChild = other;
43 METHOD(AnimHost, removeAnim, void(entity this, entity other))
45 if (other.parent != this) error("Can't remove from wrong AnimHost!");
49 entity n = other.nextSibling;
50 entity p = other.prevSibling;
52 if (p) p.nextSibling = n;
53 else this.firstChild = n;
55 if (n) n.prevSibling = p;
56 else this.lastChild = p;
60 METHOD(AnimHost, removeAllAnim, void(entity this))
62 for (entity e = this.firstChild; e; e = e.nextSibling)
66 this.removeAnim(this, tmp);
70 METHOD(AnimHost, removeObjAnim, void(entity this, entity obj))
72 for (entity e = this.firstChild; e; e = e.nextSibling)
78 this.removeAnim(this, tmp);
83 METHOD(AnimHost, stopAllAnim, void(entity this))
85 for (entity e = this.firstChild; e; e = e.nextSibling)
89 METHOD(AnimHost, stopObjAnim, void(entity this, entity obj))
91 for (entity e = this.firstChild; e; e = e.nextSibling)
92 if (e.object == obj) e.stopAnim(e);
95 METHOD(AnimHost, resumeAllAnim, void(entity this))
97 for (entity e = this.firstChild; e; e = e.nextSibling)
101 METHOD(AnimHost, resumeObjAnim, void(entity this, entity obj))
103 for (entity e = this.firstChild; e; e = e.nextSibling)
104 if (e.object == obj) e.resumeAnim(e);
107 METHOD(AnimHost, finishAllAnim, void(entity this))
109 for (entity e = this.firstChild; e; e = e.nextSibling)
117 METHOD(AnimHost, finishObjAnim, void(entity this, entity obj))
119 for (entity e = this.firstChild; e; e = e.nextSibling)
130 METHOD(AnimHost, tickAll, void(entity this))
132 for (entity e = this.firstChild; e; e = e.nextSibling)
139 this.removeAnim(this, tmp);