当前位置: 首页>>代码示例>>C++>>正文


C++ CEntity::GetId方法代码示例

本文整理汇总了C++中CEntity::GetId方法的典型用法代码示例。如果您正苦于以下问题:C++ CEntity::GetId方法的具体用法?C++ CEntity::GetId怎么用?C++ CEntity::GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CEntity的用法示例。


在下文中一共展示了CEntity::GetId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreatePoolEntity

bool CEntityPool::CreatePoolEntity(CEntity* &pOutEntity, bool bAddToInactiveList)
{
	FUNCTION_PROFILER(GetISystem(), PROFILE_ENTITY);

	assert(!gEnv->IsEditor());

	MEMSTAT_CONTEXT(EMemStatContextTypes::MSC_Other, EMemStatContextFlags::MSF_Instance, "Create Pool Entity");

	bool bResult = false;

	assert(m_pEntityPoolManager);
	CEntitySystem* pEntitySystem = m_pEntityPoolManager->GetEntitySystem();

	if (pEntitySystem)
	{
		SEntitySpawnParams params;
		CreateSpawnParams(params);
		params.vScale.Set(1.0f,1.0f,1.0f);

		CEntity* pEntity = (CEntity*)pEntitySystem->SpawnEntity(params);
		if (pEntity)
		{
			pEntity->SetPoolControl(true);

			// Put into map
			if (bAddToInactiveList)
			{
				const EntityId poolId = pEntity->GetId();
				stl::push_back_unique(m_InactivePoolIds, poolId);
			}

			pOutEntity = pEntity;
			bResult    = true;
		}
	}

	return bResult;
}
开发者ID:joewan,项目名称:pycmake,代码行数:38,代码来源:EntityPool.cpp

示例2: DebugDraw

void CEntityPool::DebugDraw(IRenderer* pRenderer, float &fColumnX, float &fColumnY, bool bExtraInfo) const
{
	assert(pRenderer);

	assert(m_pEntityPoolManager);
	CEntitySystem* pEntitySystem = m_pEntityPoolManager->GetEntitySystem();

	const float colWhite[]  = {1.0f,1.0f,1.0f,1.0f};
	const float colYellow[] = {1.0f,1.0f,0.0f,1.0f};
	const float colOrange[] = {1.0f,0.5f,0.25f,1.0f};
	const float colRed[]    = {1.0f,0.0f,0.0f,1.0f};

	const string::size_type activeCount   = m_ActivePoolIds.size();
	const string::size_type inactiveCount = m_InactivePoolIds.size();
	const bool              bAtMax        = (m_uMaxSize > 0 && activeCount >= m_uMaxSize);

	const float* pColor = colWhite;
	if (m_bDebug_HasExpanded)
		pColor = colRed;
	else if (m_iDebug_TakenFromActiveForced > 0)
		pColor = colOrange;
	else if (inactiveCount <= 0)
		pColor = colYellow;

	pRenderer->Draw2dLabel(fColumnX + 5.0f, fColumnY, 1.2f, pColor, false, "Pool \'%s\' (Default Class = \'%s\'):", m_sName.c_str(), m_sDefaultClass.c_str());
	fColumnY += 15.0f;

	if (m_iDebug_TakenFromActiveForced > 0)
	{
		pRenderer->Draw2dLabel(fColumnX + 5.0f, fColumnY, 1.5f, colRed, false, "Force Reused Counter: %d", m_iDebug_TakenFromActiveForced);
		fColumnY += 20.0f;
	}

	string sInactiveCount;
	sInactiveCount.Format("Not In Use - Count: %" PRISIZE_T, inactiveCount);
	pRenderer->Draw2dLabel(fColumnX + 10.0f, fColumnY, 1.0f, colWhite, false, "%s", sInactiveCount.c_str());
	fColumnY += 12.0f;

	if (bExtraInfo && inactiveCount > 0)
	{
		string sInactiveList;

		TPoolIdsVec::const_iterator itInactiveId    = m_InactivePoolIds.begin();
		TPoolIdsVec::const_iterator itInactiveIdEnd = m_InactivePoolIds.end();
		for (bool bFirstIt = true; itInactiveId != itInactiveIdEnd; ++itInactiveId, bFirstIt = false)
		{
			string         sId;
			const EntityId inactiveId = itInactiveId->poolId;
			sId.Format("%u", inactiveId);

			sInactiveList.append(bFirstIt ? " (" : ", ");
			sInactiveList += sId;
		}

		pRenderer->Draw2dLabel(fColumnX + 15.0f, fColumnY, 1.0f, colWhite, false, "%s", sInactiveList.c_str());
		fColumnY += 12.0f;
	}

	string sActiveCount;
	sActiveCount.Format("In Use - Count: %" PRISIZE_T, activeCount);
	pRenderer->Draw2dLabel(fColumnX + 10.0f, fColumnY, 1.0f, colWhite, false, "%s", sActiveCount.c_str());
	fColumnY += 12.0f;

	if (bExtraInfo && activeCount > 0)
	{
		TReturnToPoolWeights returnToPoolWeights;
		returnToPoolWeights.reserve(m_ActivePoolIds.size());

		// Go through the active list and ask if any are available for removal
		TPoolIdsVec::const_iterator itActiveId    = m_ActivePoolIds.begin();
		TPoolIdsVec::const_iterator itActiveIdEnd = m_ActivePoolIds.end();
		for (; itActiveId != itActiveIdEnd; ++itActiveId)
		{
			const EntityId activeId      = itActiveId->usingId;
			CEntity*       pActiveEntity = pEntitySystem->GetEntityFromID(activeId);
			if (!pActiveEntity)
				continue;

			SReturnToPoolWeight returnToPoolWeight;
			returnToPoolWeight.pEntity = pActiveEntity;
			returnToPoolWeight.weight  = m_pEntityPoolManager->GetReturnToPoolWeight(pActiveEntity, bAtMax);
			returnToPoolWeights.push_back(returnToPoolWeight);
		}
		if (!returnToPoolWeights.empty())
		{
			std::sort(returnToPoolWeights.begin(), returnToPoolWeights.end());
		}

		// Debug output each one
		TReturnToPoolWeights::iterator itActiveWeight    = returnToPoolWeights.begin();
		TReturnToPoolWeights::iterator itActiveWeightEnd = returnToPoolWeights.end();
		for (; itActiveWeight != itActiveWeightEnd; ++itActiveWeight)
		{
			SReturnToPoolWeight &activeWeight  = *itActiveWeight;
			CEntity*             pActiveEntity = activeWeight.pEntity;
			assert(pActiveEntity);

			const float* pActiveColor = colWhite;
			string       sActiveInfo;
			sActiveInfo.Format("%s (%u)", pActiveEntity->GetName(), pActiveEntity->GetId());
//.........这里部分代码省略.........
开发者ID:joewan,项目名称:pycmake,代码行数:101,代码来源:EntityPool.cpp


注:本文中的CEntity::GetId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。