📄 eventmanager.cpp
字号:
//////////////////////////////////////////////////////////////////////////////// Filename : EventManager.cpp// Written by : Reiot//////////////////////////////////////////////////////////////////////////////#include "EventManager.h"#include "Assert.h"//////////////////////////////////////////////////////////////////////////////// constructor//////////////////////////////////////////////////////////////////////////////EventManager::EventManager () throw (Error){ __BEGIN_TRY Assert(m_Events.empty()); __END_CATCH} //////////////////////////////////////////////////////////////////////////////// destructor//////////////////////////////////////////////////////////////////////////////EventManager::~EventManager () throw (){ __BEGIN_TRY while (!m_Events.empty()) { SAFE_DELETE(m_Events.front()); m_Events.pop_front(); } __END_CATCH}//////////////////////////////////////////////////////////////////////////////// add effect and affect it to its target// priority_queue俊 殿废窍绊, affect茄促.//////////////////////////////////////////////////////////////////////////////void EventManager::addEvent (Event* pEvent) throw (){ __BEGIN_TRY __END_DEBUG Assert(pEvent != NULL); Event* pPrevEvent = getEvent(pEvent->getEventClass()); if (pPrevEvent == NULL) { // push to priority queue m_Events.push_back(pEvent); } else { //cerr << "EventManager::addEvent() : Duplicated event class" << endl; throw ("EventManager::addEvent() : Duplicated event class"); } __BEGIN_DEBUG __END_CATCH}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Event* EventManager::getEvent(Event::EventClass EClass) throw(){ __BEGIN_TRY list<Event*>::iterator itr = m_Events.begin(); for (; itr != m_Events.end(); itr++) { Event* pEvent = *itr; if (pEvent->getEventClass() == EClass) return pEvent; } return NULL; __END_CATCH}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////void EventManager::deleteEvent (Event::EventClass EClass) throw (){ __BEGIN_TRY list<Event*>::iterator current = m_Events.begin(); while (current != m_Events.end()) { Assert(*current != NULL); Event* pEvent = *current; if (pEvent->getEventClass() == EClass) { m_Events.erase(current); SAFE_DELETE(pEvent); break; } current++; } __END_CATCH}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////void EventManager::heartbeat () throw (Error){ __BEGIN_TRY // 泅犁 矫埃阑 螟沥茄促. Timeval currentTime; getCurrentTime(currentTime); list<Event*>::iterator before = m_Events.end(); list<Event*>::iterator current = m_Events.begin(); while (current != m_Events.end()) { Assert(*current != NULL); Event* pEvent = *current; //-------------------------------------------------------------------------------- // *WARNING* // // EventResurrect Event 狼 版快, GamePlayer 按眉啊 ZPM 俊辑 IPM 栏肺 // 家加捞 官差霸 等促. 巩力绰 ZPM 苞 IPM 捞 辑肺 促弗 静饭靛捞扁 // 锭巩俊, IPM 俊辑 肚促矫 EventResurrect 啊 activate 瞪 啊瓷己捞 乐促绰 // 巴捞促. (绢瞒乔 GamePlayer 按眉俊辑 EventResurrect 啊 肯傈洒 昏力登瘤 // 臼篮 惑怕俊辑 IPM 栏肺 颗败瘤扁 锭巩捞促.) 蝶扼辑, 捞繁 坷幅甫 // 乔窍扁 困秦辑绰 老雀侩 捞亥飘狼 版快, 快急 捞亥飘甫 // 捞亥飘概聪历俊辑 昏力窍绊 唱辑 IPM 栏肺 颗扁电瘤 秦具 茄促. // 捞锭, 康备利牢 捞亥飘狼 版快 PM 荤捞甫 颗败 促聪绰 老捞 绝档废 // 秦具 且 巴捞促!!!! - 乔且 规档啊 绝促 - //-------------------------------------------------------------------------------- if (currentTime > pEvent->getDeadline()) { // 老雀侩 捞亥飘狼 版快 if (pEvent->isTemporary()) { // 捞亥飘甫 昏力茄促. m_Events.erase(current); if (before == m_Events.end()) { // first effect current = m_Events.begin(); } else { // !first effect current = before; current ++; } } // 捞亥飘甫 角青茄促. pEvent->activate(); // 老雀侩 捞亥飘狼 版快 if (pEvent->isTemporary()) { // 捞亥飘 按眉甫 昏力茄促. SAFE_DELETE(pEvent); } } else { before = current ++; } } __END_CATCH}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -