// Can this lesson be displayed right now? bool C_SDKPlayer::Instructor_IsLessonValid(const CLessonProgress* pLessonProgress) { if (!m_pInstructor) return false; Assert(pLessonProgress); if (!pLessonProgress) return true; CLesson* pLesson = m_pInstructor->GetLesson(pLessonProgress->m_sLessonName); Assert(pLesson); if (!pLesson) return true; if (Instructor_IsLessonLearned(pLessonProgress)) return false; if (pLessonProgress->m_flLastTimeShowed != 0 && gpGlobals->curtime < pLessonProgress->m_flLastTimeShowed + lesson_downtime.GetFloat()) return false; if (pLesson->m_iMaxShows > 0 && pLessonProgress->m_iTimesShown > pLesson->m_iMaxShows) return false; for (int i = 0; i < pLesson->m_asPrerequisites.Count(); i++) { if (!Instructor_IsLessonLearned(&m_apLessonProgress[m_apLessonProgress.Find(pLesson->m_asPrerequisites[i])])) return false; } if (pLesson->m_pfnConditions) return pLesson->m_pfnConditions(this, pLesson); else return true; }
// Can this lesson be displayed right now? bool CPlayer::Instructor_IsLessonValid(const CLessonProgress* pLessonProgress) { TAssert(pLessonProgress); if (!pLessonProgress) return true; CLesson* pLesson = GameWindow()->GetInstructor()->GetLesson(pLessonProgress->m_sLessonName); TAssert(pLesson); if (!pLesson) return true; if (Instructor_IsLessonLearned(pLessonProgress)) return false; if (pLessonProgress->m_flLastTimeShowed != 0 && GameServer()->GetGameTime() < pLessonProgress->m_flLastTimeShowed + lesson_downtime.GetFloat()) return false; for (size_t i = 0; i < pLesson->m_asPrerequisites.size(); i++) { if (!Instructor_IsLessonLearned(&m_apLessonProgress[pLesson->m_asPrerequisites[i]])) return false; } if (pLesson->m_pfnConditions) return pLesson->m_pfnConditions(this, pLesson); else return true; }