Xonotic
defer.qh
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef GAMEQC
4 
5  #include "oo.qh"
6  #include "self.qh"
7 
8  entityclass(Defer);
9  classfield(Defer).entity owner;
10  classfield(Defer).void(entity) defer_func;
11 
13  void SUB_Remove(entity this)
14  {
15  delete(this);
16  }
17 
18  void defer_think(entity this)
19  {
20  setthink(this, SUB_Remove);
21  this.nextthink = time;
22  this.defer_func(this.owner);
23  }
24 
29  void defer(entity this, float fdelay, void(entity) func)
30  {
31  entity e = new_pure(deferred);
32  e.owner = this;
33  e.defer_func = func;
34  setthink(e, defer_think);
35  e.nextthink = time + fdelay;
36  }
37 
38 #endif
entity() spawn
#define classfield(name)
Definition: oo.qh:52
entity owner
Definition: main.qh:73
float nextthink
Definition: csprogsdefs.qc:121
#define new_pure(class)
purely logical entities (.origin doesn't work)
Definition: oo.qh:62
#define setthink(e, f)
#define entityclass(...)
Definition: oo.qh:47
float time
Definition: csprogsdefs.qc:16