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.

75 lines
2.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. // NextBot paths that go through this entity must fulfill the given prerequisites to pass
  3. // Michael Booth, August 2009
  4. #include "cbase.h"
  5. #include "func_nav_prerequisite.h"
  6. #include "ndebugoverlay.h"
  7. #include "modelentities.h"
  8. // memdbgon must be the last include file in a .cpp file!!!
  9. #include "tier0/memdbgon.h"
  10. LINK_ENTITY_TO_CLASS( func_nav_prerequisite, CFuncNavPrerequisite );
  11. BEGIN_DATADESC( CFuncNavPrerequisite )
  12. DEFINE_KEYFIELD( m_task, FIELD_INTEGER, "Task" ),
  13. DEFINE_KEYFIELD( m_taskEntityName, FIELD_STRING, "Entity" ),
  14. DEFINE_KEYFIELD( m_taskValue, FIELD_FLOAT, "Value" ),
  15. DEFINE_KEYFIELD( m_isDisabled, FIELD_BOOLEAN, "StartDisabled" ),
  16. DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ),
  17. DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ),
  18. END_DATADESC()
  19. IMPLEMENT_AUTO_LIST( IFuncNavPrerequisiteAutoList );
  20. //-----------------------------------------------------------------------------
  21. CFuncNavPrerequisite::CFuncNavPrerequisite()
  22. {
  23. m_task = TASK_NONE;
  24. m_hTaskEntity = NULL;
  25. }
  26. //-----------------------------------------------------------------------------
  27. void CFuncNavPrerequisite::Spawn( void )
  28. {
  29. AddSpawnFlags( SF_TRIGGER_ALLOW_CLIENTS );
  30. BaseClass::Spawn();
  31. InitTrigger();
  32. }
  33. //-----------------------------------------------------------------------------
  34. bool CFuncNavPrerequisite::IsTask( TaskType task ) const
  35. {
  36. return task == m_task ? true : false;
  37. }
  38. //-----------------------------------------------------------------------------
  39. CBaseEntity *CFuncNavPrerequisite::GetTaskEntity( void )
  40. {
  41. if ( m_hTaskEntity == NULL )
  42. {
  43. m_hTaskEntity = gEntList.FindEntityByName( NULL, m_taskEntityName );
  44. }
  45. return m_hTaskEntity;
  46. }
  47. //--------------------------------------------------------------------------------------------------------
  48. void CFuncNavPrerequisite::InputEnable( inputdata_t &inputdata )
  49. {
  50. m_isDisabled = false;
  51. }
  52. //--------------------------------------------------------------------------------------------------------
  53. void CFuncNavPrerequisite::InputDisable( inputdata_t &inputdata )
  54. {
  55. m_isDisabled = true;
  56. }