#pragma once #ifndef MENUQC #include "oo.qh" #include "self.qh" entityclass(Defer); class(Defer).entity owner; class(Defer).void() think; class(Defer).float nextthink; /** Remove self */ void SUB_Remove(entity this) { remove(this); } /** Remove self */ void SUB_Remove_self() { SELFPARAM(); remove(this); } void defer_think() { SELFPARAM(); this.think = SUB_Remove_self; this.nextthink = time; WITHSELF(this.owner, this.use()); } /* Execute func() after time + fdelay. self when func is executed = self when defer is called */ void defer(entity this, float fdelay, void() func) { entity e = new_pure(deferred); e.owner = this; e.use = func; e.think = defer_think; e.nextthink = time + fdelay; } #endif