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
3.0 KiB

  1. // NextBotAttentionInterface.h
  2. // Manage what this bot pays attention to
  3. // Author: Michael Booth, April 2007
  4. // Copyright (c) 2007 Turtle Rock Studios, Inc. - All Rights Reserved
  5. #ifndef _NEXT_BOT_ATTENTION_INTERFACE_H_
  6. #define _NEXT_BOT_ATTENTION_INTERFACE_H_
  7. #include "NextBotComponentInterface.h"
  8. class INextBot;
  9. class IBody;
  10. //----------------------------------------------------------------------------------------------------------------
  11. /**
  12. * The interface for managing what a bot pays attention to.
  13. * Vision determines what see see and notice -> Attention determines which of those things we look at -> Low level head/aiming simulation actually moves our head/eyes
  14. */
  15. class IAttention : public INextBotComponent
  16. {
  17. public:
  18. IAttention( INextBot *bot ) : INextBotComponent( bot ) { }
  19. virtual ~IAttention() { }
  20. virtual void Reset( void ) { } // reset to initial state
  21. virtual void Update( void ) { } // update internal state
  22. enum SignificanceLevel
  23. {
  24. BORING, // background noise
  25. INTERESTING, // notably interesting
  26. COMPELLING, // very hard to pay attention to anything else
  27. IRRESISTIBLE, // can't look away
  28. };
  29. // override these to control the significance of entities in a context-specific way
  30. virtual int CompareSignificance( const CBaseEntity *a, const CBaseEntity *b ) const; // returns <0 if a < b, 0 if a==b, or >0 if a>b
  31. // bring things to our attention
  32. virtual void AttendTo( CBaseEntity *what, const char *reason = NULL );
  33. virtual void AttendTo( const Vector &where, SignificanceLevel significance, const char *reason = NULL );
  34. // remove things from our attention
  35. virtual void Disregard( CBaseEntity *what, const char *reason = NULL );
  36. virtual bool IsAwareOf( CBaseEntity *what ) const; // return true if given object is in our attending set
  37. virtual float GetAwareDuration( CBaseEntity *what ) const; // return how long we've been aware of this entity
  38. // INextBotEventResponder ------------------------------------------------------------------
  39. virtual void OnInjured( const CTakeDamageInfo &info ); // when bot is damaged by something
  40. virtual void OnContact( CBaseEntity *other, CGameTrace *result = NULL ); // invoked when bot touches 'other'
  41. virtual void OnSight( CBaseEntity *subject ); // when subject initially enters bot's visual awareness
  42. virtual void OnLostSight( CBaseEntity *subject ); // when subject leaves enters bot's visual awareness
  43. virtual void OnSound( CBaseEntity *source, const CSoundParameters &params ); // when an entity emits a sound
  44. private:
  45. IBody *m_body; // to access head aiming
  46. struct PointOfInterest
  47. {
  48. enum { ENTITY, POSITION } m_type;
  49. CHandle< CBaseEntity > m_entity;
  50. Vector m_position;
  51. IntervalTimer m_duration; // how long has this PoI been in our attention set
  52. };
  53. CUtlVector< PointOfInterest > m_attentionSet; // the set of things we are attending to
  54. };
  55. inline int IAttention::CompareSignificance( const CBaseEntity *a, const CBaseEntity *b ) const
  56. {
  57. return 0;
  58. }
  59. #endif // _NEXT_BOT_ATTENTION_INTERFACE_H_