void ExecuteEventManager::nextEvent() { WorkerThreads::getInstance()->runOnThread(WorkerThreads::Main, [this](float dt) { assert(!m_eventList.empty()); if (m_eventList.empty()) //Just a hack, protect { //event over eventFinished(); return; } EEventPtr event = *m_eventList.begin(); m_eventList.pop_front(); if (m_eventList.empty()) { //event over eventFinished(); return; } event = *m_eventList.begin(); event->excute([this]() { this->nextEvent(); }); }); }
void TimeAdvancer::onFrame(float dt) { if (!mRunning) return; if (mCurHour == mInterruptAt) { stop(); eventInterrupted(); return; } mRemainingTime -= dt; while (mRemainingTime <= 0) { mRemainingTime += mDelay; ++mCurHour; if (mCurHour <= mHours) eventProgressChanged(mCurHour, mHours); else { stop(); eventFinished(); return; } } }