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


C++ CBaseEntity::Delete方法代码示例

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


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

示例1: DestroyAllEntities

void CGameServer::DestroyAllEntities(const tvector<tstring>& asSpare, bool bRemakeGame)
{
	if (!GameNetwork()->IsHost() && !IsLoading())
		return;

	if (m_pWorkListener)
		m_pWorkListener->SetAction("Locating dead nodes", GameServer()->GetMaxEntities());

	for (size_t i = 0; i < GameServer()->GetMaxEntities(); i++)
	{
		CBaseEntity* pEntity = CBaseEntity::GetEntity(i);
		if (!pEntity)
			continue;

		bool bSpare = false;
		for (size_t j = 0; j < asSpare.size(); j++)
		{
			if (asSpare[j] == pEntity->GetClassName())
			{
				bSpare = true;
				break;
			}
		}

		if (bSpare)
			continue;

		pEntity->Delete();

		if (m_pWorkListener)
			m_pWorkListener->WorkProgress(i);
	}

	if (m_pWorkListener)
		m_pWorkListener->SetAction("Clearing buffers", GameServer()->m_ahDeletedEntities.size());

	for (size_t i = 0; i < GameServer()->m_ahDeletedEntities.size(); i++)
	{
		delete GameServer()->m_ahDeletedEntities[i];

		if (m_pWorkListener)
			m_pWorkListener->WorkProgress(i);
	}

	GameServer()->m_ahDeletedEntities.clear();

	if (CBaseEntity::GetNumEntities() == 0)
		CBaseEntity::s_iNextEntityListIndex = 0;

	if (bRemakeGame && GameNetwork()->IsHost())
		m_hGame = CreateGame();
}
开发者ID:BSVino,项目名称:LunarWorkshop,代码行数:52,代码来源:gameserver.cpp

示例2: OnDeleted

void CCPU::OnDeleted()
{
	if (!GameNetwork()->IsHost())
		return;

	if (!GetDigitanksPlayer())
		return;

	tvector<CBaseEntity*> apDeleteThese;

	for (size_t i = 0; i < GetDigitanksPlayer()->GetNumUnits(); i++)
	{
		CBaseEntity* pMember = GetDigitanksPlayer()->GetUnit(i);
		if (pMember == this)
			continue;

		apDeleteThese.push_back(pMember);
	}

	if (GameServer()->IsLoading())
		return;

	for (size_t i = 0; i < apDeleteThese.size(); i++)
	{
		CBaseEntity* pMember = apDeleteThese[i];

		if (!pMember)
			continue;

		CStructure* pStructure = dynamic_cast<CStructure*>(pMember);
		// Delete? I meant... repurpose.
		if (pStructure && !pStructure->IsConstructing())
		{
			GetDigitanksPlayer()->RemoveUnit(pStructure);
		}
		else
		{
			bool bColorSwap = (pStructure || dynamic_cast<CDigitank*>(pMember));
			Color clrTeam = GetDigitanksPlayer()->GetColor();
			CModelDissolver::AddModel(pMember, bColorSwap?&clrTeam:NULL);
			pMember->Delete();
		}
	}
}
开发者ID:BSVino,项目名称:Digitanks,代码行数:44,代码来源:cpu.cpp


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