Example #1
0
// Also used to reinitialize world.
void EldritchFramework::InitializeWorld(const HashedString& WorldDef,
                                        const bool CreateWorld) {
  XTRACE_FUNCTION;

  PrepareForLoad();

  ShutDownWorld();

  WBWorld::CreateInstance();
  WBWorld::GetInstance()->SetClock(GetClock());

  RegisterForEvents();

  m_World = new EldritchWorld;
  m_World->SetCurrentWorld(WorldDef);
  m_World->Initialize();

  m_Audio3DListener->SetWorld(m_World);

  m_UIManager->RegisterForEvents();

  if (m_Game) {
    m_Game->GetBank()->RegisterForEvents();
    m_Game->GetPersistence()->RegisterForEvents();
  }

  if (CreateWorld) {
    m_World->Create();
    InitializeTools();
  }
}
/*virtual*/ void EldritchFramework::ShutDown()
{
	XTRACE_FUNCTION;

	// Shutting down game also saves the game in progress.
	m_Game->ShutDown();

	WritePrefsConfig();

	PackStream::StaticShutDown();

	WBComponent::ShutDownBaseFactories();
	RodinBTNodeFactory::ShutDown();
	WBActionFactory::ShutDown();
	WBParamEvaluatorFactory::ShutDown();
	AnimEventFactory::DeleteInstance();
	UIFactory::ShutDown();
	WBActionStack::ShutDown();
	EldritchParticles::FlushConfigCache();
	SDPFactory::ShutDown();

	ShutDownWorld();

#if BUILD_WINDOWS
	SafeDelete( m_CheckForUpdates );
#endif
	SafeDelete( m_Game );
	SafeDelete( m_MainView );
	SafeDelete( m_FGView );
	SafeDelete( m_HUDView );
	SafeDelete( m_MirrorView );
	SafeDelete( m_MinimapView );
	SafeDelete( m_TargetManager );
	SafeDelete( m_InputSystem );
	SafeDelete( m_Controller );
	SafeDelete( m_Audio3DListener );

	DynamicMeshManager::DeleteInstance();

	Framework3D::ShutDown();

	ReverseHash::ShutDown();
}