1 void round_handler_Think()
5 if(time < game_starttime)
7 round_handler_Reset(game_starttime);
13 round_handler_Reset(0);
14 round_handler_Remove();
21 self.cnt = self.count + 1; // init countdown
22 round_starttime = time + self.count;
26 if(self.cnt > 0) // countdown running
28 if(self.canRoundStart())
30 if(self.cnt == self.count + 1)
31 round_starttime = time + self.count;
36 self.round_endtime = (self.round_timelimit) ? time + self.round_timelimit : 0;
37 self.nextthink = time;
42 self.cnt = self.cnt - 1;
46 round_handler_Reset(0);
48 self.nextthink = time + 1; // canRoundStart every second
52 if(self.canRoundEnd())
54 // schedule a new round
56 self.nextthink = time + self.delay;
60 self.nextthink = time; // canRoundEnd every frame
65 void round_handler_Init(float the_delay, float the_count, float the_round_timelimit)
67 round_handler.delay = (the_delay > 0) ? the_delay : 0;
68 round_handler.count = fabs(floor(the_count));
69 round_handler.cnt = round_handler.count + 1;
70 round_handler.round_timelimit = (the_round_timelimit > 0) ? the_round_timelimit : 0;
73 // NOTE: this is only needed because if round_handler spawns at time 1
74 // gamestarttime isn't initialized yet
75 void round_handler_FirstThink()
77 round_starttime = max(time, game_starttime) + round_handler.count;
78 round_handler.think = round_handler_Think;
79 round_handler.nextthink = max(time, game_starttime);
82 void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, void() roundStart_func)
86 backtrace("Can't spawn round_handler again!");
89 round_handler = spawn();
90 round_handler.classname = "round_handler";
92 round_handler.think = round_handler_FirstThink;
93 round_handler.canRoundStart = canRoundStart_func;
94 round_handler.canRoundEnd = canRoundEnd_func;
95 round_handler.roundStart = roundStart_func;
96 round_handler.wait = FALSE;
97 round_handler_Init(5, 5, 180);
98 round_handler.nextthink = time;
101 void round_handler_Reset(float next_think)
103 round_handler.wait = FALSE;
104 if(round_handler.count)
105 if(round_handler.cnt < round_handler.count + 1)
106 round_handler.cnt = round_handler.count + 1;
107 round_handler.nextthink = next_think;
108 round_starttime = (next_think) ? (next_think + round_handler.count) : -1;
111 void round_handler_Remove()
113 remove(round_handler);
114 round_handler = world;