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.

64 lines
2.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef PASSTIME_BALLCONTROLLER_H
  8. #define PASSTIME_BALLCONTROLLER_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "util_shared.h"
  13. class CPasstimeBall;
  14. class CTFPlayer;
  15. struct gamevcollisionevent_t;
  16. //-----------------------------------------------------------------------------
  17. class CPasstimeBallController : public TAutoList< CPasstimeBallController >
  18. {
  19. public:
  20. // ApplyTo returns the number of controllers that were applied.
  21. // BallCollision happens from vphysics callbacks.
  22. // BallPickedUp happens after player gets ball, but before ball
  23. // is removed from world.
  24. static int ApplyTo( CPasstimeBall *pBall );
  25. static int DisableOn( const CPasstimeBall *pBall );
  26. static void BallCollision( CPasstimeBall *pBall, int iCollisionIndex, gamevcollisionevent_t *pEvent );
  27. static void BallPickedUp( CPasstimeBall *pBall, CTFPlayer *pCatcher );
  28. static void BallDamaged( CPasstimeBall *pBall );
  29. static void BallSpawned( CPasstimeBall *pBall );
  30. explicit CPasstimeBallController( int priority );
  31. virtual ~CPasstimeBallController() {}
  32. void SetIsEnabled( bool is );
  33. bool IsEnabled() const;
  34. int GetPriority() const;
  35. protected:
  36. virtual bool Apply( CPasstimeBall *pBall ) = 0;
  37. virtual bool IsActive() const = 0;
  38. virtual void OnBallCollision( CPasstimeBall *pBall, int iCollisionIndex, gamevcollisionevent_t *pEvent ) {}
  39. virtual void OnBallPickedUp( CPasstimeBall *pBall, CTFPlayer *pCatcher ) {}
  40. virtual void OnBallDamaged( CPasstimeBall *pBall ) {}
  41. virtual void OnBallSpawned( CPasstimeBall *pBall ) {}
  42. virtual void OnEnabled() {}
  43. virtual void OnDisabled() {}
  44. private:
  45. bool m_bEnabled;
  46. int m_iPriority; // higher priority comes first, must be > INT_MIN
  47. // noncopyable
  48. CPasstimeBallController( const CPasstimeBallController & ) = delete;
  49. CPasstimeBallController( CPasstimeBallController && ) = delete;
  50. CPasstimeBallController &operator=( const CPasstimeBallController & ) = delete;
  51. CPasstimeBallController &operator=( CPasstimeBallController && ) = delete;
  52. };
  53. #endif // PASSTIME_BALLCONTROLLER_H