cWorld3D::~cWorld3D()
	{
		if(cHaptic::GetIsUsed())
		{
			//mpHaptic->GetLowLevel()->DestroyAllShapes();
			//Not so good to do it here..
		}

		STLDeleteAll(mlstMeshEntities);
		STLDeleteAll(mlstLights);
		STLDeleteAll(mlstBillboards);
		STLDeleteAll(mlstBeams);
		STLDeleteAll(mlstColliders);
		STLDeleteAll(mlstParticleSystems);
		STLDeleteAll(mlstStartPosEntities);
		STLMapDeleteAll(m_mapAreaEntities);

		STLDeleteAll(mlstAINodeContainers);
		STLDeleteAll(mlstAStarHandlers);
		STLMapDeleteAll(m_mapTempNodes);

		if(mpScript){
			mpResources->GetScriptManager()->Destroy(mpScript);
		}

		if(mpPhysicsWorld && mbAutoDeletePhysicsWorld)
			mpPhysics->DestroyWorld(mpPhysicsWorld);

		//So that bodies can stop sound entities on destruction.
		STLDeleteAll(mlstSoundEntities);

		hplDelete(mpPortalContainer);

		hplDelete(mpRootNode);
	}
Exemple #2
0
	cResources::~cResources()
	{
		Log("Exiting Resources Module\n");
		Log("--------------------------------------------------------\n");

		STLMapDeleteAll(m_mEntity3DLoaders);
		STLMapDeleteAll(m_mArea3DLoaders);
		STLMapDeleteAll(m_mMapEntity2DLoaders);
		STLMapDeleteAll(m_mMapArea2DLoaders);

		hplDelete(mpTileSetManager);
		hplDelete(mpFontManager);
		hplDelete(mpScriptManager);
		hplDelete(mpParticleManager);
		hplDelete(mpSoundManager);
		hplDelete(mpImageEntityManager);
		hplDelete(mpMeshManager);
		hplDelete(mpMaterialManager);
		hplDelete(mpGpuProgramManager);
		hplDelete(mpImageManager);
		hplDelete(mpTextureManager);
		hplDelete(mpSoundEntityManager);
		hplDelete(mpAnimationManager);
		hplDelete(mpVideoManager);
		
		Log(" All resources deleted\n");

		hplDelete(mpFileSearcher);
		hplDelete(mpMeshLoaderHandler);

		if(mpLanguageFile) hplDelete(mpLanguageFile);
		
		mlstManagers.clear();
		Log("--------------------------------------------------------\n\n");
	}
	cPortalContainer::~cPortalContainer()
	{
		hplDelete(mpEntityCallback);
		hplDelete(mpNormalEntityCallback);
		
		STLMapDeleteAll(m_mapSectors);
	}
Exemple #4
0
	cPhysics::~cPhysics()
	{
		Log("Exiting Physics Module\n");
		Log("--------------------------------------------------------\n");

		STLDeleteAll(mlstWorlds);
		STLMapDeleteAll(m_mapSurfaceData);

		Log("--------------------------------------------------------\n\n");
	}
void cMapHandler::DestroyAll()
{
	mbDestroyingAll = true;
	RemoveLocalTimers();

	//Game entities
	STLMapDeleteAll(m_mapGameEntities);
	m_mapGameEntities.clear();
	mlstGameEnemies.clear();
	mlstGameItems.clear();

	//Light flashes
	STLDeleteAll(mlstLightFlashes);
	mlstLightFlashes.clear();
	mbDestroyingAll = false;
}
	void iPhysicsWorld::DestroyAll()
	{
		STLDeleteAll(mlstCharBodies);

		//Bodies
		tPhysicsBodyListIt it = mlstBodies.begin();
		for(; it != mlstBodies.end(); ++it)
		{
			iPhysicsBody *pBody = *it;
			pBody->Destroy();
			hplDelete(pBody);
		}
		mlstBodies.clear();

		STLDeleteAll(mlstShapes);
		STLDeleteAll(mlstJoints);
		STLDeleteAll(mlstControllers);
		STLMapDeleteAll(m_mapMaterials);
	}
Exemple #7
0
	cStateMachine::~cStateMachine()
	{
		STLMapDeleteAll(m_mapStates);
	}
iGameEntity::~iGameEntity()
{
	cWorld3D *pWorld = mpInit->mpGame->GetScene()->GetWorld3D();

	//////////////////////////////////////////////
	// Remove all references to from all otter
	//Log("Deleting '%s'\n",msName.c_str());

	//Player
	mpInit->mpPlayer->RemoveCollideScriptWithChildEntity(this);

	//Other entities (check so not all entities are being destroyed, 
	//                 in that case it is not needed and might be bad).
	if(mpInit->mpMapHandler->IsDestroyingAll()==false)
	{
		tGameEntityIterator it = mpInit->mpMapHandler->GetGameEntityIterator();
		while(it.HasNext())
		{
			iGameEntity *pEntity = it.Next();
			pEntity->RemoveCollideScriptWithChildEntity(this);
		}
	}

	////////////////////////////////////////////
	// Destroy haptic
	for(size_t i=0; i< mvHapticShapes.size(); ++i)
	{
		if(mvHapticShapes[i])
		{
			mpInit->mpGame->GetHaptic()->GetLowLevel()->DestroyShape(mvHapticShapes[i]);
		}
	}
	
	//////////////////////////////////////////////
	// Destroy all graphics in the entity!
    if(pWorld && mpInit->mbDestroyGraphics)
	{
		for(size_t i=0; i<mvBodies.size(); ++i)
		{
			//Make sure that this body is not picked!
			if(mpInit->mpPlayer->GetPickedBody() == mvBodies[i])
				mpInit->mpPlayer->GetPickRay()->mpPickedBody = NULL;

			if(mpInit->mpPlayer->GetPushBody() == mvBodies[i])
			{
				ePlayerState state = mpInit->mpPlayer->GetState();
				if(	state == ePlayerState_Move ||
					state == ePlayerState_Grab ||
					state == ePlayerState_Push)
				{
					ePlayerState prevState = mpInit->mpPlayer->GetStateData(state)->mPreviuosState;
					if(prevState == ePlayerState_InteractMode)
						mpInit->mpPlayer->ChangeState(ePlayerState_InteractMode);
					else
						mpInit->mpPlayer->ChangeState(ePlayerState_Normal);
				}

				mpInit->mpPlayer->SetPushBody(NULL);
			}
			
			
			pWorld->GetPhysicsWorld()->DestroyBody(mvBodies[i]);
		}
		if(mpMeshEntity) pWorld->DestroyMeshEntity(mpMeshEntity);
	
		for(size_t i=0; i<mvLights.size(); ++i) 
			pWorld->DestroyLight(mvLights[i]);
		for(size_t i=0; i<mvParticleSystems.size(); ++i) 
			if(mvParticleSystems[i]) mvParticleSystems[i]->Kill();
		for(size_t i=0; i<mvBillboards.size(); ++i) 
			pWorld->DestroyBillboard(mvBillboards[i]);
		for(size_t i=0; i<mvBeams.size(); ++i) 
			pWorld->DestroyBeam(mvBeams[i]);
		for(size_t i=0; i<mvSoundEntities.size(); ++i) 
		{
			pWorld->DestroySoundEntity(mvSoundEntities[i]);
		}

		if(mpCharBody)
			pWorld->GetPhysicsWorld()->DestroyCharacterBody(mpCharBody);
	}
	
	//Delete callbacks
	for(int i=0; i< eGameEntityScriptType_LastEnum; ++i) 
	{
		if( mvCallbackScripts[i]) hplDelete( mvCallbackScripts[i] );
	}
	STLMapDeleteAll(m_mapCollideCallbacks);

	STLDeleteAll(mvTransMaterials);

	for(size_t i=0; i<mvPreloadedBreakMeshes.size();++i)
	{
		mpInit->mpGame->GetResources()->GetMeshManager()->Destroy(mvPreloadedBreakMeshes[i]);
	}
}
	cLanguageFile::~cLanguageFile()
	{
		STLMapDeleteAll(m_mapCategories);
	}