本文整理汇总了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();
}
示例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();
}
}
}