コード例 #1
0
ファイル: world.cpp プロジェクト: DeadFuze/swarm-sdk
void CWorld::Precache( void )
{
	COM_TimestampedLog( "CWorld::Precache - Start" );

	g_WorldEntity = this;
	g_fGameOver = false;
	g_pLastSpawn = NULL;
	g_Language.SetValue( LANGUAGE_ENGLISH );	// TODO use VGUI to get current language

#ifndef INFESTED_DLL
	ConVarRef stepsize( "sv_stepsize" );
	stepsize.SetValue( 24 );
#endif

	ConVarRef roomtype( "room_type" );
	roomtype.SetValue( 0 );

	// Set up game rules
	Assert( !g_pGameRules );
	if (g_pGameRules)
	{
		delete g_pGameRules;
	}

	InstallGameRules();
	Assert( g_pGameRules );
	g_pGameRules->Init();

	CSoundEnt::InitSoundEnt();

	// UNDONE: Make most of these things server systems or precache_registers
	// =================================================
	//	Activities
	// =================================================
	ActivityList_Free();
	RegisterSharedActivities();

	EventList_Free();
	RegisterSharedEvents();

	// Only allow precaching between LevelInitPreEntity and PostEntity
	CBaseEntity::SetAllowPrecache( true );

	COM_TimestampedLog( "IGameSystem::LevelInitPreEntityAllSystems" );
	IGameSystem::LevelInitPreEntityAllSystems( STRING( GetModelName() ) );

	COM_TimestampedLog( "g_pGameRules->CreateStandardEntities()" );
	// Create the player resource
	g_pGameRules->CreateStandardEntities();

	COM_TimestampedLog( "InitBodyQue()" );
	InitBodyQue();
	
	COM_TimestampedLog( "SENTENCEG_Init()" );
	// init sentence group playback stuff from sentences.txt.
	// ok to call this multiple times, calls after first are ignored.
	SENTENCEG_Init();

	COM_TimestampedLog( "PrecacheStandardParticleSystems()" );
	// Precache standard particle systems
	PrecacheStandardParticleSystems( );

	// the area based ambient sounds MUST be the first precache_sounds

	COM_TimestampedLog( "W_Precache()" );
	// player precaches     
	W_Precache ();									// get weapon precaches
	COM_TimestampedLog( "ClientPrecache()" );
	ClientPrecache();
	
	COM_TimestampedLog( "PrecacheTempEnts()" );
	// precache all temp ent stuff
	CBaseTempEntity::PrecacheTempEnts();

	COM_TimestampedLog( "LightStyles" );
	//
	// Setup light animation tables. 'a' is total darkness, 'z' is maxbright.
	//
	for ( int i = 0; i < ARRAYSIZE(g_DefaultLightstyles); i++ )
	{
		engine->LightStyle( i, GetDefaultLightstyleString(i) );
	}

	// styles 32-62 are assigned by the light program for switchable lights

	// 63 testing
	engine->LightStyle(63, "a");

	COM_TimestampedLog( "InitializeAINetworks" );
	// =================================================
	//	Load and Init AI Networks
	// =================================================
	CAI_NetworkManager::InitializeAINetworks();
	// =================================================
	//	Load and Init AI Schedules
	// =================================================
	COM_TimestampedLog( "LoadAllSchedules" );
	g_AI_SchedulesManager.LoadAllSchedules();
	// =================================================
	//	Initialize NPC Relationships
	// =================================================
	COM_TimestampedLog( "InitDefaultAIRelationships" );
	g_pGameRules->InitDefaultAIRelationships();
	COM_TimestampedLog( "InitInteractionSystem" );
	CBaseCombatCharacter::InitInteractionSystem();

	COM_TimestampedLog( "g_pGameRules->Precache" );
	// Call the gamerules precache after the AI precache so that games can precache NPCs that are always loaded
	g_pGameRules->Precache();
	
	if ( m_iszChapterTitle != NULL_STRING )
	{
		DevMsg( 2, "Chapter title: %s\n", STRING(m_iszChapterTitle) );
		CMessage *pMessage = (CMessage *)CBaseEntity::Create( "env_message", vec3_origin, vec3_angle, NULL );
		if ( pMessage )
		{
			pMessage->SetMessage( m_iszChapterTitle );
			m_iszChapterTitle = NULL_STRING;

			// send the message entity a play message command, delayed by 1 second
			pMessage->AddSpawnFlags( SF_MESSAGE_ONCE );
			pMessage->SetThink( &CMessage::SUB_CallUseToggle );
			pMessage->SetNextThink( gpGlobals->curtime + 1.0f );
		}
	}

	g_iszFuncBrushClassname = AllocPooledString("func_brush");

	if ( m_iszDetailSpriteMaterial.Get() != NULL_STRING )
	{
		PrecacheMaterial( STRING( m_iszDetailSpriteMaterial.Get() ) );
	}

	COM_TimestampedLog( "CWorld::Precache - Finish" );
}
コード例 #2
0
void CWorld::Precache( void )
{
	g_WorldEntity = this;
	g_fGameOver = false;
	g_pLastSpawn = NULL;

	ConVar *gravity = ( ConVar * )cvar->FindVar( "sv_gravity" );
	if ( gravity )
	{
// UNDONE: Disabled this.  This makes sv_gravity reset of each level.  Is that what we want?
//		gravity->SetValue( 800 );// 67ft/sec^2
	}

	ConVar *stepsize = ( ConVar * )cvar->FindVar( "sv_stepsize" );
	if ( stepsize )
	{
		stepsize->SetValue( 18 );
	}

	ConVar *roomtype = ( ConVar * )cvar->FindVar( "room_type" );
	if ( roomtype )
	{
		roomtype->SetValue( 0 );
	}

	// Set up game rules
	Assert( !g_pGameRules );
	if (g_pGameRules)
	{
		delete g_pGameRules;
	}

	g_pGameRules = InstallGameRules( );
	Assert( g_pGameRules );
	g_pGameRules->LevelInit();

	CSoundEnt::InitSoundEnt();

	IGameSystem::LevelInitPreEntityAllSystems( STRING( GetModelName() ) );

	// UNDONE: Make most of these things server systems or precache_registers
	// =================================================
	//	Activities
	// =================================================
	ActivityList_Free();
	RegisterSharedActivities();

	InitBodyQue();
// init sentence group playback stuff from sentences.txt.
// ok to call this multiple times, calls after first are ignored.

	SENTENCEG_Init();

// the area based ambient sounds MUST be the first precache_sounds

// player precaches     
	W_Precache ();									// get weapon precaches
	ClientPrecache();
	g_pGameRules->Precache();
	// precache all temp ent stuff
	CBaseTempEntity::PrecacheTempEnts();

	// sounds used from C physics code
	enginesound->PrecacheSound("common/null.wav");				// clears sound channels

	ConVar const *language = cvar->FindVar( "sv_language" );

	g_Language = language ? language->GetInt() : LANGUAGE_ENGLISH;
	if ( g_Language == LANGUAGE_GERMAN )
	{
		engine->PrecacheModel( "models/germangibs.mdl" );
	}
	else
	{
		engine->PrecacheModel( "models/gibs/hgibs.mdl" );
	}

//
// Setup light animation tables. 'a' is total darkness, 'z' is maxbright.
//
	// 0 normal
	engine->LightStyle(0, "m");
	
	// 1 FLICKER (first variety)
	engine->LightStyle(1, "mmnmmommommnonmmonqnmmo");
	
	// 2 SLOW STRONG PULSE
	engine->LightStyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
	
	// 3 CANDLE (first variety)
	engine->LightStyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
	
	// 4 FAST STROBE
	engine->LightStyle(4, "mamamamamama");
	
	// 5 GENTLE PULSE 1
	engine->LightStyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
	
	// 6 FLICKER (second variety)
	engine->LightStyle(6, "nmonqnmomnmomomno");
	
	// 7 CANDLE (second variety)
	engine->LightStyle(7, "mmmaaaabcdefgmmmmaaaammmaamm");
	
	// 8 CANDLE (third variety)
	engine->LightStyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
	
	// 9 SLOW STROBE (fourth variety)
	engine->LightStyle(9, "aaaaaaaazzzzzzzz");
	
	// 10 FLUORESCENT FLICKER
	engine->LightStyle(10, "mmamammmmammamamaaamammma");

	// 11 SLOW PULSE NOT FADE TO BLACK
	engine->LightStyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
	
	// 12 UNDERWATER LIGHT MUTATION
	// this light only distorts the lightmap - no contribution
	// is made to the brightness of affected surfaces
	engine->LightStyle(12, "mmnnmmnnnmmnn");
	
	// styles 32-62 are assigned by the light program for switchable lights

	// 63 testing
	engine->LightStyle(63, "a");

	// =================================================
	//	Load and Init AI Networks
	// =================================================
	CAI_NetworkManager::InitializeAINetworks();
	// =================================================
	//	Load and Init AI Schedules
	// =================================================
	g_AI_SchedulesManager.LoadAllSchedules();
	// =================================================
	//	Initialize NPC Relationships
	// =================================================
	g_pGameRules->InitDefaultAIRelationships();
	CBaseCombatCharacter::InitInteractionSystem();

	// Call all registered precachers.
	CPrecacheRegister::Precache();	

	if ( m_iszChapterTitle != NULL_STRING )
	{
		DevMsg( 2, "Chapter title: %s\n", STRING(m_iszChapterTitle) );
		CMessage *pMessage = (CMessage *)CBaseEntity::Create( "env_message", vec3_origin, vec3_angle, NULL );
		if ( pMessage )
		{
			pMessage->SetMessage( m_iszChapterTitle );
			m_iszChapterTitle = NULL_STRING;

			// send the message entity a play message command, delayed by 0.3 seconds
			pMessage->AddSpawnFlags( SF_MESSAGE_ONCE );
			pMessage->SetThink( &CMessage::SUB_CallUseToggle );
			pMessage->SetNextThink( gpGlobals->curtime + 0.3 );
		}
	}
}