예제 #1
0
void Clock::AdvanceTime(float deltaSecs)
{
	deltaSecs = min(m_maximumDelta, deltaSecs);
	deltaSecs *= m_timeScale;
	if (m_paused) {
		deltaSecs = 0.f;
	}

	m_currentTime += deltaSecs;
	m_deltaSeconds = deltaSecs;

	for (auto it = m_children.begin(); it != m_children.end(); ++it) {
		Clock* childClock = *it;
		childClock->AdvanceTime(deltaSecs);
	}

	for (auto it = m_alarms.begin(); it != m_alarms.end();) {
		Alarm* alarm = it->second;
		alarm->elapsedTime += deltaSecs;

		if (alarm->elapsedTime >= alarm->timeToFire) {
			it = m_alarms.erase(it);
			alarm->onAlarmFire(alarm->name, alarm->alarmFunctionData);
		}
		else {
			++it;
		}
	}
}
예제 #2
0
void Clock::AdvanceTime(double deltaTime)
{
	if(m_pause)
		return;

	if(deltaTime > m_maxDeltaTimeStep)
		deltaTime = m_maxDeltaTimeStep;

	std::vector<Clock*>::iterator clock_it = m_childClocks.begin();
	for( ; clock_it != m_childClocks.end(); ++clock_it)
	{
		Clock* currentClock = *clock_it;
		currentClock->AdvanceTime(deltaTime);
	}

	std::vector<Alarm*>::iterator alarm_it = m_alarms.begin();
	while(alarm_it != m_alarms.end())
	{
		Alarm* currentAlarm = *alarm_it;
		currentAlarm->AdvanceTime(deltaTime);
		if(currentAlarm->m_destroy)
		{
			alarm_it = m_alarms.erase(alarm_it);
			delete currentAlarm;
			currentAlarm = nullptr;
		}
		else
			++alarm_it;
	}

	m_currentTimeSeconds += deltaTime * m_timeScale;
	m_lastTimeStep = deltaTime;
}
예제 #3
0
void Clock::AdvanceTime(double deltaSeconds){
	
	//timescale it first
	deltaSeconds *= m_timeScale;
	//set to 0
	if (m_isPaused)
		deltaSeconds = 0.0;

	m_deltaSeconds = deltaSeconds;

	//advance time
	m_currentTime += m_deltaSeconds;
	

	UpdateTimers(m_deltaSeconds, m_timers);

	for (ClocksIterator it = m_children.begin(); it != m_children.end(); ++it){
		Clock* clock = (*it);
		if (clock) {
			//advance time on children
			clock->AdvanceTime(m_deltaSeconds);
		}
	}

}