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.

68 lines
1.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // TF Entity Spawner
  4. //
  5. //=============================================================================
  6. #ifndef TF_ENTITY_SPAWNER_H
  7. #define TF_ENTITY_SPAWNER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. class CEntitySpawnPoint;
  12. class CEntitySpawnManager;
  13. class CEntitySpawnPoint : public CServerOnlyPointEntity, public IEntityListener
  14. {
  15. public:
  16. DECLARE_CLASS( CEntitySpawnPoint, CServerOnlyPointEntity );
  17. DECLARE_DATADESC();
  18. CEntitySpawnPoint() {}
  19. virtual void Spawn( void );
  20. virtual void UpdateOnRemove( void );
  21. bool IsUsed( void ) { return (m_hMyEntity.Get() != NULL); }
  22. void SetEntity( CBaseEntity* pEnt ) { m_hMyEntity = pEnt; }
  23. void RespawnNotifyThink( void );
  24. virtual void OnEntityDeleted( CBaseEntity* pEntity );
  25. private:
  26. string_t m_iszSpawnManagerName;
  27. float m_flNodeFree;
  28. CHandle< CEntitySpawnManager > m_hSpawnManager;
  29. CHandle< CBaseEntity > m_hMyEntity;
  30. };
  31. class CEntitySpawnManager : public CLogicalEntity
  32. {
  33. public:
  34. DECLARE_CLASS( CEntitySpawnManager, CLogicalEntity );
  35. DECLARE_DATADESC();
  36. CEntitySpawnManager() {}
  37. virtual void Spawn( void );
  38. void RegisterSpawnPoint( CEntitySpawnPoint* pNewPoint );
  39. virtual void Activate( void );
  40. void SpawnAllEntities( void );
  41. bool SpawnEntity( void );
  42. int GetRespawnTime( void ) { return m_iRespawnTime; }
  43. private:
  44. int GetRandomUnusedIndex( void );
  45. bool SpawnEntityAt( int iIndex );
  46. private:
  47. string_t m_iszEntityName;
  48. int m_iEntityCount;
  49. int m_iRespawnTime;
  50. bool m_bDropToGround;
  51. bool m_bRandomRotation;
  52. int m_iMaxSpawnedEntities;
  53. CUtlVector< CHandle< CEntitySpawnPoint > > m_SpawnPoints;
  54. };
  55. #endif //TF_ENTITY_SPAWNER_H