Пример #1
0
//------------------------------------------------------------------------
void CProjectile::Destroy()
{
	if(m_destroying)
		return;

	m_destroying=true;

	EndScaledEffect(m_pAmmoParams->pScaledEffect);

	GetGameObject()->ReleaseProfileManager(this);
	GetGameObject()->EnablePhysicsEvent(false, eEPE_OnCollisionLogged);

	if(m_obstructObject)
		gEnv->pPhysicalWorld->DestroyPhysicalEntity(m_obstructObject);

	if(m_hitListener)
		if(CGameRules *pGameRules = g_pGame->GetGameRules())
			pGameRules->RemoveHitListener(this);

	WhizSound(false, ZERO, ZERO);

	bool returnToPoolOK = true;

	if(m_pAmmoParams->reusable)
	{
		returnToPoolOK = g_pGame->GetWeaponSystem()->ReturnToPool(this);
	}

	if(!m_pAmmoParams->reusable || !returnToPoolOK)
	{
		if((GetEntity()->GetFlags()&ENTITY_FLAG_CLIENT_ONLY) || gEnv->bServer)
			gEnv->pEntitySystem->RemoveEntity(GetEntity()->GetId());
	}
}
Пример #2
0
//------------------------------------------------------------------------
CProjectile::~CProjectile()
{
	SetTracked(false);
	EndScaledEffect(m_pAmmoParams->pScaledEffect);

	GetGameObject()->ReleaseProfileManager(this);
	GetGameObject()->EnablePhysicsEvent(false, eEPE_OnCollisionLogged);

	if (m_obstructObject)
		gEnv->pPhysicalWorld->DestroyPhysicalEntity(m_obstructObject);

	if(m_hitListener)
		if (CGameRules * pGameRules = g_pGame->GetGameRules())
			pGameRules->RemoveHitListener(this);
	
	if (g_pGame)
		g_pGame->GetWeaponSystem()->RemoveProjectile(this);
}