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.

76 lines
2.0 KiB

  1. //========= Copyright � 1996-2008, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Definition of the info_remarkable entity.
  4. // This entity is a quick and dirty hack to provide writers
  5. // with some kind of object that characters can remark upon.
  6. // It is not performant, because it relies upon each character
  7. // polling over each of these for visibility. A better approach
  8. // will be an object that is notified by the engine when it is within
  9. // a character's view.
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #include "cbase.h"
  14. #include "inforemarkable.h"
  15. // memdbgon must be the last include file in a .cpp file!!!
  16. #include "tier0/memdbgon.h"
  17. /// A global list of entities that can be remarked upon.
  18. /// @todo This is an awful, brute force solution. Fix it.
  19. class CRemarkableEntityList : public CAutoGameSystem
  20. {
  21. public:
  22. CRemarkableEntityList( char const *name ) : CAutoGameSystem( name )
  23. {}
  24. virtual void LevelShutdownPostEntity()
  25. {
  26. m_list.Purge();
  27. }
  28. void AddEntity( CInfoRemarkable *pItem )
  29. {
  30. m_list.AddToTail( pItem );
  31. }
  32. void RemoveEntity( CInfoRemarkable *pItem )
  33. {
  34. m_list.FindAndRemove( pItem );
  35. }
  36. CUtlLinkedList< CInfoRemarkable * > m_list;
  37. };
  38. CRemarkableEntityList g_RemarkableList( "CRemarkableEntityList" );
  39. CUtlLinkedList< CInfoRemarkable * > *CInfoRemarkable::GetListOfAllThatIsRemarkable( void )
  40. {
  41. return &g_RemarkableList.m_list;
  42. }
  43. CInfoRemarkable::~CInfoRemarkable()
  44. {
  45. g_RemarkableList.RemoveEntity( this );
  46. }
  47. void CInfoRemarkable::Spawn( void )
  48. {
  49. g_RemarkableList.AddEntity(this);
  50. m_iTimesRemarkedUpon = 0;
  51. }
  52. //--------------------------------------------------------------------------------------------------------
  53. LINK_ENTITY_TO_CLASS( info_remarkable, CInfoRemarkable );
  54. //--------------------------------------------------------------------------------------------------------
  55. BEGIN_DATADESC( CInfoRemarkable )
  56. DEFINE_KEYFIELD( m_szRemarkContext, FIELD_STRING, "contextsubject" ),
  57. END_DATADESC()