Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

733 lines
18 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Precaches and defs for entities and other data that must always be available.
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #include "cbase.h"
  8. #include "soundent.h"
  9. #include "client.h"
  10. #include "decals.h"
  11. #include "EnvMessage.h"
  12. #include "player.h"
  13. #include "gamerules.h"
  14. #include "teamplay_gamerules.h"
  15. #include "physics.h"
  16. #include "isaverestore.h"
  17. #include "activitylist.h"
  18. #include "eventlist.h"
  19. #include "eventqueue.h"
  20. #include "ai_network.h"
  21. #include "ai_schedule.h"
  22. #include "ai_networkmanager.h"
  23. #include "ai_utils.h"
  24. #include "basetempentity.h"
  25. #include "world.h"
  26. #include "mempool.h"
  27. #include "igamesystem.h"
  28. #include "engine/IEngineSound.h"
  29. #include "globals.h"
  30. #include "engine/IStaticPropMgr.h"
  31. #include "particle_parse.h"
  32. #include "globalstate.h"
  33. // memdbgon must be the last include file in a .cpp file!!!
  34. #include "tier0/memdbgon.h"
  35. extern CBaseEntity *g_pLastSpawn;
  36. void InitBodyQue(void);
  37. extern void W_Precache(void);
  38. extern void ActivityList_Free( void );
  39. extern CUtlMemoryPool g_EntityListPool;
  40. #define SF_DECAL_NOTINDEATHMATCH 2048
  41. class CDecal : public CPointEntity
  42. {
  43. public:
  44. DECLARE_CLASS( CDecal, CPointEntity );
  45. void Spawn( void );
  46. bool KeyValue( const char *szKeyName, const char *szValue );
  47. // Need to apply static decals here to get them into the signon buffer for the server appropriately
  48. virtual void Activate();
  49. void TriggerDecal( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  50. // Input handlers.
  51. void InputActivate( inputdata_t &inputdata );
  52. DECLARE_DATADESC();
  53. public:
  54. int m_nTexture;
  55. bool m_bLowPriority;
  56. private:
  57. void StaticDecal( void );
  58. };
  59. BEGIN_DATADESC( CDecal )
  60. DEFINE_FIELD( m_nTexture, FIELD_INTEGER ),
  61. DEFINE_KEYFIELD( m_bLowPriority, FIELD_BOOLEAN, "LowPriority" ), // Don't mark as FDECAL_PERMANENT so not save/restored and will be reused on the client preferentially
  62. // Function pointers
  63. DEFINE_FUNCTION( StaticDecal ),
  64. DEFINE_FUNCTION( TriggerDecal ),
  65. DEFINE_INPUTFUNC( FIELD_VOID, "Activate", InputActivate ),
  66. END_DATADESC()
  67. LINK_ENTITY_TO_CLASS( infodecal, CDecal );
  68. // UNDONE: These won't get sent to joining players in multi-player
  69. void CDecal::Spawn( void )
  70. {
  71. if ( m_nTexture < 0 ||
  72. (gpGlobals->deathmatch && HasSpawnFlags( SF_DECAL_NOTINDEATHMATCH )) )
  73. {
  74. UTIL_Remove( this );
  75. return;
  76. }
  77. }
  78. void CDecal::Activate()
  79. {
  80. BaseClass::Activate();
  81. if ( !GetEntityName() )
  82. {
  83. StaticDecal();
  84. }
  85. else
  86. {
  87. // if there IS a targetname, the decal sprays itself on when it is triggered.
  88. SetThink ( &CDecal::SUB_DoNothing );
  89. SetUse(&CDecal::TriggerDecal);
  90. }
  91. }
  92. void CDecal::TriggerDecal ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
  93. {
  94. // this is set up as a USE function for info_decals that have targetnames, so that the
  95. // decal doesn't get applied until it is fired. (usually by a scripted sequence)
  96. trace_t trace;
  97. int entityIndex;
  98. UTIL_TraceLine( GetAbsOrigin() - Vector(5,5,5), GetAbsOrigin() + Vector(5,5,5), MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &trace );
  99. entityIndex = trace.m_pEnt ? trace.m_pEnt->entindex() : 0;
  100. CBroadcastRecipientFilter filter;
  101. te->BSPDecal( filter, 0.0,
  102. &GetAbsOrigin(), entityIndex, m_nTexture );
  103. SetThink( &CDecal::SUB_Remove );
  104. SetNextThink( gpGlobals->curtime + 0.1f );
  105. }
  106. void CDecal::InputActivate( inputdata_t &inputdata )
  107. {
  108. TriggerDecal( inputdata.pActivator, inputdata.pCaller, USE_ON, 0 );
  109. }
  110. void CDecal::StaticDecal( void )
  111. {
  112. class CTraceFilterValidForDecal : public CTraceFilterSimple
  113. {
  114. public:
  115. CTraceFilterValidForDecal(const IHandleEntity *passentity, int collisionGroup )
  116. : CTraceFilterSimple( passentity, collisionGroup )
  117. {
  118. }
  119. virtual bool ShouldHitEntity( IHandleEntity *pServerEntity, int contentsMask )
  120. {
  121. static const char *ppszIgnoredClasses[] =
  122. {
  123. "weapon_*",
  124. "item_*",
  125. "prop_ragdoll",
  126. "prop_dynamic",
  127. "prop_static",
  128. "prop_physics",
  129. "npc_bullseye", // Tracker 15335
  130. };
  131. CBaseEntity *pEntity = EntityFromEntityHandle( pServerEntity );
  132. // Tracker 15335: Never impact decals against entities which are not rendering, either.
  133. if ( pEntity->IsEffectActive( EF_NODRAW ) )
  134. return false;
  135. for ( int i = 0; i < ARRAYSIZE(ppszIgnoredClasses); i++ )
  136. {
  137. if ( pEntity->ClassMatches( ppszIgnoredClasses[i] ) )
  138. return false;
  139. }
  140. return CTraceFilterSimple::ShouldHitEntity( pServerEntity, contentsMask );
  141. }
  142. };
  143. trace_t trace;
  144. CTraceFilterValidForDecal traceFilter( this, COLLISION_GROUP_NONE );
  145. int entityIndex, modelIndex = 0;
  146. Vector position = GetAbsOrigin();
  147. UTIL_TraceLine( position - Vector(5,5,5), position + Vector(5,5,5), MASK_SOLID, &traceFilter, &trace );
  148. bool canDraw = true;
  149. entityIndex = trace.m_pEnt ? (short)trace.m_pEnt->entindex() : 0;
  150. if ( entityIndex )
  151. {
  152. CBaseEntity *ent = trace.m_pEnt;
  153. if ( ent )
  154. {
  155. modelIndex = ent->GetModelIndex();
  156. VectorITransform( GetAbsOrigin(), ent->EntityToWorldTransform(), position );
  157. canDraw = ( modelIndex != 0 );
  158. if ( !canDraw )
  159. {
  160. Warning( "Suppressed StaticDecal which would have hit entity %i (class:%s, name:%s) with modelindex = 0\n",
  161. ent->entindex(),
  162. ent->GetClassname(),
  163. STRING( ent->GetEntityName() ) );
  164. }
  165. }
  166. }
  167. if ( canDraw )
  168. {
  169. engine->StaticDecal( position, m_nTexture, entityIndex, modelIndex, m_bLowPriority );
  170. }
  171. SUB_Remove();
  172. }
  173. bool CDecal::KeyValue( const char *szKeyName, const char *szValue )
  174. {
  175. if (FStrEq(szKeyName, "texture"))
  176. {
  177. // FIXME: should decals all be preloaded?
  178. m_nTexture = UTIL_PrecacheDecal( szValue, true );
  179. // Found
  180. if (m_nTexture >= 0 )
  181. return true;
  182. Warning( "Can't find decal %s\n", szValue );
  183. }
  184. else
  185. {
  186. return BaseClass::KeyValue( szKeyName, szValue );
  187. }
  188. return true;
  189. }
  190. //-----------------------------------------------------------------------------
  191. // Purpose: Projects a decal against a prop
  192. //-----------------------------------------------------------------------------
  193. class CProjectedDecal : public CPointEntity
  194. {
  195. public:
  196. DECLARE_CLASS( CProjectedDecal, CPointEntity );
  197. void Spawn( void );
  198. bool KeyValue( const char *szKeyName, const char *szValue );
  199. // Need to apply static decals here to get them into the signon buffer for the server appropriately
  200. virtual void Activate();
  201. void TriggerDecal( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  202. // Input handlers.
  203. void InputActivate( inputdata_t &inputdata );
  204. DECLARE_DATADESC();
  205. public:
  206. int m_nTexture;
  207. float m_flDistance;
  208. private:
  209. void ProjectDecal( CRecipientFilter& filter );
  210. void StaticDecal( void );
  211. };
  212. BEGIN_DATADESC( CProjectedDecal )
  213. DEFINE_FIELD( m_nTexture, FIELD_INTEGER ),
  214. DEFINE_KEYFIELD( m_flDistance, FIELD_FLOAT, "Distance" ),
  215. // Function pointers
  216. DEFINE_FUNCTION( StaticDecal ),
  217. DEFINE_FUNCTION( TriggerDecal ),
  218. DEFINE_INPUTFUNC( FIELD_VOID, "Activate", InputActivate ),
  219. END_DATADESC()
  220. LINK_ENTITY_TO_CLASS( info_projecteddecal, CProjectedDecal );
  221. // UNDONE: These won't get sent to joining players in multi-player
  222. void CProjectedDecal::Spawn( void )
  223. {
  224. if ( m_nTexture < 0 ||
  225. (gpGlobals->deathmatch && HasSpawnFlags( SF_DECAL_NOTINDEATHMATCH )) )
  226. {
  227. UTIL_Remove( this );
  228. return;
  229. }
  230. }
  231. void CProjectedDecal::Activate()
  232. {
  233. BaseClass::Activate();
  234. if ( !GetEntityName() )
  235. {
  236. StaticDecal();
  237. }
  238. else
  239. {
  240. // if there IS a targetname, the decal sprays itself on when it is triggered.
  241. SetThink ( &CProjectedDecal::SUB_DoNothing );
  242. SetUse(&CProjectedDecal::TriggerDecal);
  243. }
  244. }
  245. void CProjectedDecal::InputActivate( inputdata_t &inputdata )
  246. {
  247. TriggerDecal( inputdata.pActivator, inputdata.pCaller, USE_ON, 0 );
  248. }
  249. void CProjectedDecal::ProjectDecal( CRecipientFilter& filter )
  250. {
  251. te->ProjectDecal( filter, 0.0,
  252. &GetAbsOrigin(), &GetAbsAngles(), m_flDistance, m_nTexture );
  253. }
  254. void CProjectedDecal::TriggerDecal ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
  255. {
  256. CBroadcastRecipientFilter filter;
  257. ProjectDecal( filter );
  258. SetThink( &CProjectedDecal::SUB_Remove );
  259. SetNextThink( gpGlobals->curtime + 0.1f );
  260. }
  261. void CProjectedDecal::StaticDecal( void )
  262. {
  263. CBroadcastRecipientFilter initFilter;
  264. initFilter.MakeInitMessage();
  265. ProjectDecal( initFilter );
  266. SUB_Remove();
  267. }
  268. bool CProjectedDecal::KeyValue( const char *szKeyName, const char *szValue )
  269. {
  270. if (FStrEq(szKeyName, "texture"))
  271. {
  272. // FIXME: should decals all be preloaded?
  273. m_nTexture = UTIL_PrecacheDecal( szValue, true );
  274. // Found
  275. if (m_nTexture >= 0 )
  276. return true;
  277. Warning( "Can't find decal %s\n", szValue );
  278. }
  279. else
  280. {
  281. return BaseClass::KeyValue( szKeyName, szValue );
  282. }
  283. return true;
  284. }
  285. //=======================
  286. // CWorld
  287. //
  288. // This spawns first when each level begins.
  289. //=======================
  290. LINK_ENTITY_TO_CLASS( worldspawn, CWorld );
  291. BEGIN_DATADESC( CWorld )
  292. DEFINE_FIELD( m_flWaveHeight, FIELD_FLOAT ),
  293. // keyvalues are parsed from map, but not saved/loaded
  294. DEFINE_KEYFIELD( m_iszChapterTitle, FIELD_STRING, "chaptertitle" ),
  295. DEFINE_KEYFIELD( m_bStartDark, FIELD_BOOLEAN, "startdark" ),
  296. DEFINE_KEYFIELD( m_bDisplayTitle, FIELD_BOOLEAN, "gametitle" ),
  297. DEFINE_FIELD( m_WorldMins, FIELD_VECTOR ),
  298. DEFINE_FIELD( m_WorldMaxs, FIELD_VECTOR ),
  299. #ifdef _X360
  300. DEFINE_KEYFIELD( m_flMaxOccludeeArea, FIELD_FLOAT, "maxoccludeearea_x360" ),
  301. DEFINE_KEYFIELD( m_flMinOccluderArea, FIELD_FLOAT, "minoccluderarea_x360" ),
  302. #else
  303. DEFINE_KEYFIELD( m_flMaxOccludeeArea, FIELD_FLOAT, "maxoccludeearea" ),
  304. DEFINE_KEYFIELD( m_flMinOccluderArea, FIELD_FLOAT, "minoccluderarea" ),
  305. #endif
  306. DEFINE_KEYFIELD( m_flMaxPropScreenSpaceWidth, FIELD_FLOAT, "maxpropscreenwidth" ),
  307. DEFINE_KEYFIELD( m_flMinPropScreenSpaceWidth, FIELD_FLOAT, "minpropscreenwidth" ),
  308. DEFINE_KEYFIELD( m_iszDetailSpriteMaterial, FIELD_STRING, "detailmaterial" ),
  309. DEFINE_KEYFIELD( m_bColdWorld, FIELD_BOOLEAN, "coldworld" ),
  310. END_DATADESC()
  311. // SendTable stuff.
  312. IMPLEMENT_SERVERCLASS_ST(CWorld, DT_WORLD)
  313. SendPropFloat (SENDINFO(m_flWaveHeight), 8, SPROP_ROUNDUP, 0.0f, 8.0f),
  314. SendPropVector (SENDINFO(m_WorldMins), -1, SPROP_COORD),
  315. SendPropVector (SENDINFO(m_WorldMaxs), -1, SPROP_COORD),
  316. SendPropInt (SENDINFO(m_bStartDark), 1, SPROP_UNSIGNED ),
  317. SendPropFloat (SENDINFO(m_flMaxOccludeeArea), 0, SPROP_NOSCALE ),
  318. SendPropFloat (SENDINFO(m_flMinOccluderArea), 0, SPROP_NOSCALE ),
  319. SendPropFloat (SENDINFO(m_flMaxPropScreenSpaceWidth), 0, SPROP_NOSCALE ),
  320. SendPropFloat (SENDINFO(m_flMinPropScreenSpaceWidth), 0, SPROP_NOSCALE ),
  321. SendPropStringT (SENDINFO(m_iszDetailSpriteMaterial) ),
  322. SendPropInt (SENDINFO(m_bColdWorld), 1, SPROP_UNSIGNED ),
  323. END_SEND_TABLE()
  324. //
  325. // Just to ignore the "wad" field.
  326. //
  327. bool CWorld::KeyValue( const char *szKeyName, const char *szValue )
  328. {
  329. if ( FStrEq(szKeyName, "skyname") )
  330. {
  331. // Sent over net now.
  332. ConVarRef skyname( "sv_skyname" );
  333. skyname.SetValue( szValue );
  334. }
  335. else if ( FStrEq(szKeyName, "newunit") )
  336. {
  337. // Single player only. Clear save directory if set
  338. if ( atoi(szValue) )
  339. {
  340. extern void Game_SetOneWayTransition();
  341. Game_SetOneWayTransition();
  342. }
  343. }
  344. else if ( FStrEq(szKeyName, "world_mins") )
  345. {
  346. Vector vec;
  347. sscanf( szValue, "%f %f %f", &vec.x, &vec.y, &vec.z );
  348. m_WorldMins = vec;
  349. }
  350. else if ( FStrEq(szKeyName, "world_maxs") )
  351. {
  352. Vector vec;
  353. sscanf( szValue, "%f %f %f", &vec.x, &vec.y, &vec.z );
  354. m_WorldMaxs = vec;
  355. }
  356. else
  357. return BaseClass::KeyValue( szKeyName, szValue );
  358. return true;
  359. }
  360. extern bool g_fGameOver;
  361. static CWorld *g_WorldEntity = NULL;
  362. CWorld* GetWorldEntity()
  363. {
  364. return g_WorldEntity;
  365. }
  366. CWorld::CWorld( )
  367. {
  368. AddEFlags( EFL_NO_AUTO_EDICT_ATTACH | EFL_KEEP_ON_RECREATE_ENTITIES );
  369. NetworkProp()->AttachEdict( INDEXENT(RequiredEdictIndex()) );
  370. ActivityList_Init();
  371. EventList_Init();
  372. SetSolid( SOLID_BSP );
  373. SetMoveType( MOVETYPE_NONE );
  374. m_bColdWorld = false;
  375. }
  376. CWorld::~CWorld( )
  377. {
  378. EventList_Free();
  379. ActivityList_Free();
  380. if ( g_pGameRules )
  381. {
  382. g_pGameRules->LevelShutdown();
  383. delete g_pGameRules;
  384. g_pGameRules = NULL;
  385. }
  386. g_WorldEntity = NULL;
  387. }
  388. //------------------------------------------------------------------------------
  389. // Purpose : Add a decal to the world
  390. // Input :
  391. // Output :
  392. //------------------------------------------------------------------------------
  393. void CWorld::DecalTrace( trace_t *pTrace, char const *decalName)
  394. {
  395. int index = decalsystem->GetDecalIndexForName( decalName );
  396. if ( index < 0 )
  397. return;
  398. CBroadcastRecipientFilter filter;
  399. if ( pTrace->hitbox != 0 )
  400. {
  401. te->Decal( filter, 0.0f, &pTrace->endpos, &pTrace->startpos, 0, pTrace->hitbox, index );
  402. }
  403. else
  404. {
  405. te->WorldDecal( filter, 0.0, &pTrace->endpos, index );
  406. }
  407. }
  408. void CWorld::RegisterSharedActivities( void )
  409. {
  410. ActivityList_RegisterSharedActivities();
  411. }
  412. void CWorld::RegisterSharedEvents( void )
  413. {
  414. EventList_RegisterSharedEvents();
  415. }
  416. void CWorld::Spawn( void )
  417. {
  418. SetLocalOrigin( vec3_origin );
  419. SetLocalAngles( vec3_angle );
  420. // NOTE: SHOULD NEVER BE ANYTHING OTHER THAN 1!!!
  421. SetModelIndex( 1 );
  422. // world model
  423. SetModelName( AllocPooledString( modelinfo->GetModelName( GetModel() ) ) );
  424. AddFlag( FL_WORLDBRUSH );
  425. g_EventQueue.Init();
  426. Precache( );
  427. GlobalEntity_Add( "is_console", STRING(gpGlobals->mapname), ( IsConsole() ) ? GLOBAL_ON : GLOBAL_OFF );
  428. GlobalEntity_Add( "is_pc", STRING(gpGlobals->mapname), ( !IsConsole() ) ? GLOBAL_ON : GLOBAL_OFF );
  429. }
  430. static const char *g_DefaultLightstyles[] =
  431. {
  432. // 0 normal
  433. "m",
  434. // 1 FLICKER (first variety)
  435. "mmnmmommommnonmmonqnmmo",
  436. // 2 SLOW STRONG PULSE
  437. "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba",
  438. // 3 CANDLE (first variety)
  439. "mmmmmaaaaammmmmaaaaaabcdefgabcdefg",
  440. // 4 FAST STROBE
  441. "mamamamamama",
  442. // 5 GENTLE PULSE 1
  443. "jklmnopqrstuvwxyzyxwvutsrqponmlkj",
  444. // 6 FLICKER (second variety)
  445. "nmonqnmomnmomomno",
  446. // 7 CANDLE (second variety)
  447. "mmmaaaabcdefgmmmmaaaammmaamm",
  448. // 8 CANDLE (third variety)
  449. "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa",
  450. // 9 SLOW STROBE (fourth variety)
  451. "aaaaaaaazzzzzzzz",
  452. // 10 FLUORESCENT FLICKER
  453. "mmamammmmammamamaaamammma",
  454. // 11 SLOW PULSE NOT FADE TO BLACK
  455. "abcdefghijklmnopqrrqponmlkjihgfedcba",
  456. // 12 UNDERWATER LIGHT MUTATION
  457. // this light only distorts the lightmap - no contribution
  458. // is made to the brightness of affected surfaces
  459. "mmnnmmnnnmmnn",
  460. };
  461. const char *GetDefaultLightstyleString( int styleIndex )
  462. {
  463. if ( styleIndex < ARRAYSIZE(g_DefaultLightstyles) )
  464. {
  465. return g_DefaultLightstyles[styleIndex];
  466. }
  467. return "m";
  468. }
  469. void CWorld::Precache( void )
  470. {
  471. g_WorldEntity = this;
  472. g_fGameOver = false;
  473. g_pLastSpawn = NULL;
  474. ConVarRef stepsize( "sv_stepsize" );
  475. stepsize.SetValue( 18 );
  476. ConVarRef roomtype( "room_type" );
  477. roomtype.SetValue( 0 );
  478. // Set up game rules
  479. Assert( !g_pGameRules );
  480. if (g_pGameRules)
  481. {
  482. delete g_pGameRules;
  483. }
  484. InstallGameRules();
  485. Assert( g_pGameRules );
  486. g_pGameRules->Init();
  487. CSoundEnt::InitSoundEnt();
  488. // Only allow precaching between LevelInitPreEntity and PostEntity
  489. CBaseEntity::SetAllowPrecache( true );
  490. IGameSystem::LevelInitPreEntityAllSystems( STRING( GetModelName() ) );
  491. // Create the player resource
  492. g_pGameRules->CreateStandardEntities();
  493. // UNDONE: Make most of these things server systems or precache_registers
  494. // =================================================
  495. // Activities
  496. // =================================================
  497. ActivityList_Free();
  498. RegisterSharedActivities();
  499. EventList_Free();
  500. RegisterSharedEvents();
  501. InitBodyQue();
  502. // init sentence group playback stuff from sentences.txt.
  503. // ok to call this multiple times, calls after first are ignored.
  504. SENTENCEG_Init();
  505. // Precache standard particle systems
  506. PrecacheStandardParticleSystems( );
  507. // the area based ambient sounds MUST be the first precache_sounds
  508. // player precaches
  509. W_Precache (); // get weapon precaches
  510. ClientPrecache();
  511. g_pGameRules->Precache();
  512. // precache all temp ent stuff
  513. CBaseTempEntity::PrecacheTempEnts();
  514. g_Language.SetValue( LANGUAGE_ENGLISH ); // TODO use VGUI to get current language
  515. if ( g_Language.GetInt() == LANGUAGE_GERMAN )
  516. {
  517. PrecacheModel( "models/germangibs.mdl" );
  518. }
  519. else
  520. {
  521. PrecacheModel( "models/gibs/hgibs.mdl" );
  522. }
  523. PrecacheScriptSound( "BaseEntity.EnterWater" );
  524. PrecacheScriptSound( "BaseEntity.ExitWater" );
  525. //
  526. // Setup light animation tables. 'a' is total darkness, 'z' is maxbright.
  527. //
  528. for ( int i = 0; i < ARRAYSIZE(g_DefaultLightstyles); i++ )
  529. {
  530. engine->LightStyle( i, GetDefaultLightstyleString(i) );
  531. }
  532. // styles 32-62 are assigned by the light program for switchable lights
  533. // 63 testing
  534. engine->LightStyle(63, "a");
  535. // =================================================
  536. // Load and Init AI Networks
  537. // =================================================
  538. CAI_NetworkManager::InitializeAINetworks();
  539. // =================================================
  540. // Load and Init AI Schedules
  541. // =================================================
  542. g_AI_SchedulesManager.LoadAllSchedules();
  543. // =================================================
  544. // Initialize NPC Relationships
  545. // =================================================
  546. g_pGameRules->InitDefaultAIRelationships();
  547. CBaseCombatCharacter::InitInteractionSystem();
  548. // Call all registered precachers.
  549. CPrecacheRegister::Precache();
  550. if ( m_iszChapterTitle != NULL_STRING )
  551. {
  552. DevMsg( 2, "Chapter title: %s\n", STRING(m_iszChapterTitle) );
  553. CMessage *pMessage = (CMessage *)CBaseEntity::Create( "env_message", vec3_origin, vec3_angle, NULL );
  554. if ( pMessage )
  555. {
  556. pMessage->SetMessage( m_iszChapterTitle );
  557. m_iszChapterTitle = NULL_STRING;
  558. // send the message entity a play message command, delayed by 1 second
  559. pMessage->AddSpawnFlags( SF_MESSAGE_ONCE );
  560. pMessage->SetThink( &CMessage::SUB_CallUseToggle );
  561. pMessage->SetNextThink( gpGlobals->curtime + 1.0f );
  562. }
  563. }
  564. g_iszFuncBrushClassname = AllocPooledString("func_brush");
  565. }
  566. //-----------------------------------------------------------------------------
  567. // Purpose:
  568. // Output : float
  569. //-----------------------------------------------------------------------------
  570. float GetRealTime()
  571. {
  572. return engine->Time();
  573. }
  574. bool CWorld::GetDisplayTitle() const
  575. {
  576. return m_bDisplayTitle;
  577. }
  578. bool CWorld::GetStartDark() const
  579. {
  580. return m_bStartDark;
  581. }
  582. void CWorld::SetDisplayTitle( bool display )
  583. {
  584. m_bDisplayTitle = display;
  585. }
  586. void CWorld::SetStartDark( bool startdark )
  587. {
  588. m_bStartDark = startdark;
  589. }
  590. bool CWorld::IsColdWorld( void )
  591. {
  592. return m_bColdWorld;
  593. }