Counter Strike : Global Offensive Source Code
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.

127 lines
3.9 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #include "cbase.h"
  14. #include "mathlib/mathlib.h"
  15. #include "basetempentity.h"
  16. // memdbgon must be the last include file in a .cpp file!!!
  17. #include "tier0/memdbgon.h"
  18. IMPLEMENT_SERVERCLASS_ST_NOBASE(CBaseTempEntity, DT_BaseTempEntity)
  19. END_SEND_TABLE()
  20. // Global list of temp entity event classes
  21. CBaseTempEntity *CBaseTempEntity::s_pTempEntities = NULL;
  22. //-----------------------------------------------------------------------------
  23. // Purpose: Returns head of list
  24. // Output : CBaseTempEntity * -- head of list
  25. //-----------------------------------------------------------------------------
  26. CBaseTempEntity *CBaseTempEntity::GetList( void )
  27. {
  28. return s_pTempEntities;
  29. }
  30. //-----------------------------------------------------------------------------
  31. // Purpose: Creates temp entity, sets name, adds to global list
  32. // Input : *name -
  33. //-----------------------------------------------------------------------------
  34. CBaseTempEntity::CBaseTempEntity( const char *name )
  35. {
  36. m_pszName = name;
  37. Assert( m_pszName );
  38. // Add to list
  39. m_pNext = s_pTempEntities;
  40. s_pTempEntities = this;
  41. }
  42. //-----------------------------------------------------------------------------
  43. // Purpose:
  44. //-----------------------------------------------------------------------------
  45. CBaseTempEntity::~CBaseTempEntity( void )
  46. {
  47. }
  48. //-----------------------------------------------------------------------------
  49. // Purpose: Get the name of this temp entity
  50. // Output : const char *
  51. //-----------------------------------------------------------------------------
  52. const char *CBaseTempEntity::GetName( void )
  53. {
  54. return m_pszName ? m_pszName : "Unnamed";
  55. }
  56. //-----------------------------------------------------------------------------
  57. // Purpose: Get next temp ent in chain
  58. // Output : CBaseTempEntity *
  59. //-----------------------------------------------------------------------------
  60. CBaseTempEntity *CBaseTempEntity::GetNext( void )
  61. {
  62. return m_pNext;
  63. }
  64. //-----------------------------------------------------------------------------
  65. // Purpose:
  66. //-----------------------------------------------------------------------------
  67. void CBaseTempEntity::Precache( void )
  68. {
  69. // Nothing...
  70. }
  71. //-----------------------------------------------------------------------------
  72. // Purpose: Default test implementation. Should only be called by derived classes
  73. // Input : *current_origin -
  74. // *current_angles -
  75. //-----------------------------------------------------------------------------
  76. void CBaseTempEntity::Test( const Vector& current_origin, const QAngle& current_angles )
  77. {
  78. Vector origin, forward;
  79. Msg( "%s\n", m_pszName );
  80. AngleVectors( current_angles, &forward );
  81. VectorMA( current_origin, 20, forward, origin );
  82. CBroadcastRecipientFilter filter;
  83. Create( filter, 0.0 );
  84. }
  85. //-----------------------------------------------------------------------------
  86. // Purpose: Called at startup to allow temp entities to precache any models/sounds that they need
  87. //-----------------------------------------------------------------------------
  88. void CBaseTempEntity::PrecacheTempEnts( void )
  89. {
  90. CBaseTempEntity *te = GetList();
  91. while ( te )
  92. {
  93. te->Precache();
  94. te = te->GetNext();
  95. }
  96. }
  97. void CBaseTempEntity::Create( IRecipientFilter& filter, float delay )
  98. {
  99. // temp entities can't be part of the signon message, use real entities instead
  100. // temp entities *can* be reliable, necessarily, due to particles.
  101. Assert( !filter.IsInitMessage() );
  102. Assert( delay >= -1 && delay <= 1); // 1 second max delay
  103. engine->PlaybackTempEntity( filter, delay,
  104. (void *)this, GetServerClass()->m_pTable, GetServerClass()->m_ClassID );
  105. }