Exemplo n.º 1
0
void GameTimerManager::SetTimerInternal(TimerHandle& outHandle, Object* obj, TimerDelegatePtr delegate, float duration, bool looping)
{
	outHandle.mValue = mNextTimerId;
	
	TimerInfo timer;
	timer.mObj = obj;
	timer.mDelegate = delegate;
	timer.mHandle = outHandle;
	timer.mDuration = duration;
	timer.mRemainingTime = duration;
	timer.mIsLooping = looping;

	if (mAreTimersTicking)
	{
		// Add to pending set
		timer.mStatus = Pending;
		mPendingTimers.emplace(outHandle, timer);
	}
	else
	{
		// Add to active set
		timer.mStatus = Active;
		mActiveTimers.emplace(outHandle, timer);
	}

	// Add to the timers associated with this object
	AddToObjMap(obj, outHandle);

	mNextTimerId++;
}
Exemplo n.º 2
0
void GameTimerManager::SetTimerInternal(TimerHandle& outHandle, Object* obj, TimerDelegatePtr delegate, float duration, bool looping)
{
    outHandle.mValue = mNextTimerId;
    mNextTimerId += 1;
    TimerInfo mTimerInfo;
    mTimerInfo.mDuration = duration;
    mTimerInfo.mRemainingTime = duration;
    mTimerInfo.mObj = obj;
    mTimerInfo.mDelegate = delegate;
    mTimerInfo.mHandle = outHandle;
    mTimerInfo.mStatus = Pending;
    mTimerInfo.mIsLooping = looping;
    if ( mAreTimersTicking )
    {
        //Add into pending map
        mPendingTimers.emplace(outHandle, mTimerInfo);
    }
    else
    {
        //Add into active map
        mTimerInfo.mStatus = Active;
        mActiveTimers.emplace(outHandle, mTimerInfo);
    }
    AddToObjMap(obj, outHandle);
}