📄 scheduler.h
字号:
// Scheduler.h
//
// Maintains internal timers and executes scheduled tasks
//
// Notes:
// timerChangesLastFrame is the key to execute scheduled tasks.
// It stores the number of counter limit changes this frame (relative to
// initial game time). Its value can be:
// 0x1 -> 1 hundredth of a second
// 0x2 -> 10 hundredths of a second
// 0x3 -> 1 second
// 0x4 -> 10 seconds
// 0x5 -> 1 minute
// 0x6 -> 10 minutes
// 0x7 -> 1 hour
// 0x8 -> 10 hours
// 0x9 -> 100 hours
//
// Note that when a task is scheduled, the time it takes to be excuted
// it's not 100% accurate, because it depends on the initial game time.
//
/////////////////////////////////////////////////////////////////////////////
#ifndef _SCHEDULER_H_
#define _SCHEDULER_H_
#include <list>
#include "../util/Singleton.h"
#include "Task.h"
#define theScheduler Scheduler::getSingletonPtr()
class Scheduler : public Singleton<Scheduler>
{
// types
protected:
typedef std::list<Task *> TasksList;
// fields
protected:
// tasks
TasksList tasksList;
// internal timer
enum timerValues {
HUNDREDTHS = 0,
SECONDS = 1,
MINUTES = 2,
HOURS = 3
};
int internalTimer[4];
int timerChangesLastFrame;
// methods
public:
void updateInternalTimers();
void executeScheduledTasks();
void addScheduledTask(Task *t);
// initialization and cleanup
Scheduler();
~Scheduler();
};
#endif // _SCHEDULER_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -