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.

81 lines
2.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef MAPENTITIES_H
  8. #define MAPENTITIES_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "mapentities_shared.h"
  13. class CPointTemplate;
  14. // This class provides hooks into the map-entity loading process that allows CS to do some tricks
  15. // when restarting the round. The main trick it tries to do is recreate all
  16. abstract_class IMapEntityFilter
  17. {
  18. public:
  19. virtual bool ShouldCreateEntity( const char *pClassname ) = 0;
  20. virtual CBaseEntity* CreateNextEntity( const char *pClassname ) = 0;
  21. };
  22. // Use the filter so you can prevent certain entities from being created out of the map.
  23. // CSPort does this when restarting rounds. It wants to reload most entities from the map, but certain
  24. // entities like the world entity need to be left intact.
  25. void MapEntity_ParseAllEntities( const char *pMapData, IMapEntityFilter *pFilter=NULL, bool bActivateEntities=false );
  26. const char *MapEntity_ParseEntity( CBaseEntity *&pEntity, const char *pEntData, IMapEntityFilter *pFilter );
  27. void MapEntity_PrecacheEntity( const char *pEntData, int &nStringSize );
  28. //-----------------------------------------------------------------------------
  29. // Hierarchical spawn
  30. //-----------------------------------------------------------------------------
  31. struct HierarchicalSpawn_t
  32. {
  33. CBaseEntity *m_pEntity;
  34. int m_nDepth;
  35. CBaseEntity *m_pDeferredParent; // attachment parents can't be set until the parents are spawned
  36. const char *m_pDeferredParentAttachment; // so defer setting them up until the second pass
  37. };
  38. struct HierarchicalSpawnMapData_t
  39. {
  40. const char *m_pMapData;
  41. int m_iMapDataLength;
  42. };
  43. // Shared by mapentities.cpp and Foundry for spawning entities.
  44. class CMapEntitySpawner
  45. {
  46. public:
  47. CMapEntitySpawner();
  48. ~CMapEntitySpawner();
  49. void AddEntity( CBaseEntity *pEntity, const char *pMapData, int iMapDataLength );
  50. void HandleTemplates();
  51. void SpawnAndActivate( bool bActivateEntities );
  52. void PurgeRemovedEntities();
  53. public:
  54. bool m_bFoundryMode;
  55. private:
  56. HierarchicalSpawnMapData_t *m_pSpawnMapData;
  57. HierarchicalSpawn_t *m_pSpawnList;
  58. CUtlVector< CPointTemplate* > m_PointTemplates;
  59. int m_nEntities;
  60. };
  61. void SpawnHierarchicalList( int nEntities, HierarchicalSpawn_t *pSpawnList, bool bActivateEntities );
  62. void MapEntity_ParseAllEntites_SpawnTemplates( CPointTemplate **pTemplates, int iTemplateCount, CBaseEntity **pSpawnedEntities, HierarchicalSpawnMapData_t *pSpawnMapData, int iSpawnedEntityCount );
  63. #endif // MAPENTITIES_H