예제 #1
0
void CRivalStateCategory::AddState(uint32 uLevel, CStateFuncArg& aStateFuncArg)
{
	if(m_mapRivalLevel.empty())
	{
		aStateFuncArg.m_pSkillInst->AddRef();
		m_mapRivalLevel.insert(make_pair(uLevel, make_pair(1, aStateFuncArg.m_pSkillInst)));
		//Setup New;
		SetupState(aStateFuncArg.m_pSkillInst, aStateFuncArg);
		return;
	}
	uint32 uMaxLevel = m_mapRivalLevel.begin()->first;
	MapRivalLevel::iterator itr = m_mapRivalLevel.find(uLevel);
	if(itr == m_mapRivalLevel.end())
	{
		aStateFuncArg.m_pSkillInst->AddRef();
		m_mapRivalLevel.insert(make_pair(uLevel, make_pair(1, aStateFuncArg.m_pSkillInst)));
	}
	else
	{
		//如果需要考虑同等级不同人的替换,这里需要调用pSkillInst->AddRef()
		++itr->second.first;
	}

	if(uLevel > uMaxLevel)
	{
		//Cancel Max
		CancelState(m_mapRivalLevel.begin()->second.second, aStateFuncArg);
		//Setup Level
		SetupState(aStateFuncArg.m_pSkillInst, aStateFuncArg);
	}
	else if(uLevel == uMaxLevel)
	{
		//如果需要考虑同等级不同人的替换,这里需要调用以上的Cancel Setup逻辑
	}
}
 bool AutomatedScreenshotController::NextScene()
 {
     if (m_sceneIndex < AutomatedScreenshotController::NumScenes)
     {
         m_waitPredicate = SetupState(m_sceneIndex);
         m_sceneIndex++;
         return true;
     }
     else
     {
         return false;
     }
 }
예제 #3
0
bool CRivalStateCategory::DelState(uint32 uLevel, CStateFuncArg& aStateFuncArg)
{
	MapRivalLevel::iterator itr = m_mapRivalLevel.find(uLevel);
	if(itr == m_mapRivalLevel.end())
	{
		//stringstream str;
		//str << uLevel;
		//LogErr("优先级不存在于竞争状态管理器中", str.str());
		return false;
	}

	if(itr->second.first > 1)
	{
		//如果需要考虑同等级不同人的替换,这里需要在判断uLevel == uMaxLevel后调用pSkillInst->DelRef()和Cancel逻辑
		--itr->second.first;
	}
	else
	{
		CSkillInstServer* pSkillInst = itr->second.second;
		m_mapRivalLevel.erase(itr);
		if(m_mapRivalLevel.empty())
		{
			//Cancel Level
			CancelState(pSkillInst, aStateFuncArg);
			pSkillInst->DelRef();
			return true;
		}
		uint32 uMaxLevel = m_mapRivalLevel.begin()->first;
		if(uLevel > uMaxLevel)
		{
			//Cancel Level
			CancelState(pSkillInst, aStateFuncArg);
			pSkillInst->DelRef();
			//Setup Max
			SetupState(m_mapRivalLevel.begin()->second.second, aStateFuncArg);
		}
		else if(uLevel == uMaxLevel)
		{
			//这里不会进,因为uLevel的结点已经删了,剩下的uMaxLevel一定是小于uLevel的
			//如果需要考虑同等级不同人的替换,这里需要调用以上的Cancel Setup逻辑
		}
	}
	return false;
}