cobengine.h
来自「这是整套横扫千军3D版游戏的源码」· C头文件 代码 · 共 57 行
H
57 行
#ifndef __COB_ENGINE_H__
#define __COB_ENGINE_H__
/*
* The cob engine is responsible for "scheduling" and running threads that are running in
* infinite loops.
* It also manages reading and caching of the actual .cob files
*/
#include "CobThread.h"
#include "LogOutput.h"
#include <list>
#include <queue>
#include <map>
class CCobThread;
class CCobInstance;
class CCobFile;
using namespace std;
class CCobThreadPtr_less : public binary_function<CCobThread *, CCobThread *, bool> {
CCobThread *a, *b;
public:
bool operator() (const CCobThread *const &a, const CCobThread *const &b) const {return a->GetWakeTime() > b->GetWakeTime();}
};
class CCobEngine
{
protected:
list<CCobThread *> running;
list<CCobThread *> wantToRun; //Threads are added here if they are in Running. And moved to real running after running is empty
priority_queue<CCobThread *, vector<CCobThread *>, CCobThreadPtr_less> sleeping;
list<CCobInstance *> animating; //hash would be optimal. but not crucial.
map<string, CCobFile *> cobFiles;
CCobThread *curThread;
public:
CCobEngine(void);
~CCobEngine(void);
void AddThread(CCobThread *thread);
void AddInstance(CCobInstance *instance);
void RemoveInstance(CCobInstance *instance);
void Tick(int deltaTime);
void SetCurThread(CCobThread *cur);
void ShowScriptError(const string& msg);
CCobFile& GetCobFile(const string& name);
CCobFile& ReloadCobFile(const string& name);
const CCobFile* GetScriptAddr(const string& name) const;
};
extern CCobEngine GCobEngine;
extern int GCurrentTime;
#endif // __COB_ENGINE_H__
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?