Xonotic
animhost.qc
Go to the documentation of this file.
1 #include "animhost.qh"
2 
3 #include "../menu.qh"
4 
5 #include "animation.qh"
6 
7  .entity parent;
8  METHOD(AnimHost, addAnim, void(entity this, entity other))
9  {
10  if (other.parent) error("Can't add already added anim!");
11 
12  if (other.isFinished(other)) error("Can't add finished anim!");
13 
14  other.parent = this;
15 
16  entity l = this.lastChild;
17 
18  if (l) l.nextSibling = other;
19  else this.firstChild = other;
20 
21  other.prevSibling = l;
22  other.nextSibling = NULL;
23  this.lastChild = other;
24  }
25 
26  METHOD(AnimHost, removeAnim, void(entity this, entity other))
27  {
28  if (other.parent != this) error("Can't remove from wrong AnimHost!");
29 
30  other.parent = NULL;
31 
32  entity n = other.nextSibling;
33  entity p = other.prevSibling;
34 
35  if (p) p.nextSibling = n;
36  else this.firstChild = n;
37 
38  if (n) n.prevSibling = p;
39  else this.lastChild = p;
40  delete(other);
41  }
42 
43  METHOD(AnimHost, removeAllAnim, void(entity this))
44  {
45  for (entity e = this.firstChild; e; e = e.nextSibling)
46  {
47  entity tmp = e;
48  e = tmp.prevSibling;
49  this.removeAnim(this, tmp);
50  }
51  }
52 
53  METHOD(AnimHost, removeObjAnim, void(entity this, entity obj))
54  {
55  for (entity e = this.firstChild; e; e = e.nextSibling)
56  {
57  if (e.object == obj)
58  {
59  entity tmp = e;
60  e = tmp.prevSibling;
61  this.removeAnim(this, tmp);
62  }
63  }
64  }
65 
66  METHOD(AnimHost, stopAllAnim, void(entity this))
67  {
68  for (entity e = this.firstChild; e; e = e.nextSibling)
69  e.stopAnim(e);
70  }
71 
72  METHOD(AnimHost, stopObjAnim, void(entity this, entity obj))
73  {
74  for (entity e = this.firstChild; e; e = e.nextSibling)
75  if (e.object == obj) e.stopAnim(e);
76  }
77 
78  METHOD(AnimHost, resumeAllAnim, void(entity this))
79  {
80  for (entity e = this.firstChild; e; e = e.nextSibling)
81  e.resumeAnim(e);
82  }
83 
84  METHOD(AnimHost, resumeObjAnim, void(entity this, entity obj))
85  {
86  for (entity e = this.firstChild; e; e = e.nextSibling)
87  if (e.object == obj) e.resumeAnim(e);
88  }
89 
90  METHOD(AnimHost, finishAllAnim, void(entity this))
91  {
92  for (entity e = this.firstChild; e; e = e.nextSibling)
93  {
94  entity tmp = e;
95  e = tmp.prevSibling;
96  tmp.finishAnim(tmp);
97  }
98  }
99 
100  METHOD(AnimHost, finishObjAnim, void(entity this, entity obj))
101  {
102  for (entity e = this.firstChild; e; e = e.nextSibling)
103  {
104  if (e.object == obj)
105  {
106  entity tmp = e;
107  e = tmp.prevSibling;
108  tmp.finishAnim(tmp);
109  }
110  }
111  }
112 
113  METHOD(AnimHost, tickAll, void(entity this))
114  {
115  for (entity e = this.firstChild; e; e = e.nextSibling)
116  {
117  e.tick(e, time);
118  if (e.isFinished(e))
119  {
120  entity tmp = e;
121  e = tmp.prevSibling;
122  this.removeAnim(this, tmp);
123  }
124  }
125  }
entity parent
Definition: animhost.qc:7
entity() spawn
#define METHOD(cname, name, prototype)
Definition: oo.qh:257
entity other
Definition: csprogsdefs.qc:14
#define NULL
Definition: post.qh:17
float time
Definition: csprogsdefs.qc:16