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.

81 lines
2.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. // func_passtime_goal - based on func_capture_zone
  8. #ifndef FUNC_PASSTIME_GOAL_H
  9. #define FUNC_PASSTIME_GOAL_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "triggers.h"
  14. class CPasstimeBall;
  15. //-----------------------------------------------------------------------------
  16. // This class is to get around the fact that DEFINE_FUNCTION doesn't like multiple inheritance
  17. // TODO: make AutoList work without inheritance
  18. class CFuncPasstimeGoalShim : public CBaseTrigger
  19. {
  20. public:
  21. virtual void StartTouch(CBaseEntity *pOther) OVERRIDE { CBaseTrigger::StartTouch(pOther); ShimStartTouch(pOther); }
  22. virtual void EndTouch(CBaseEntity *pOther) OVERRIDE { CBaseTrigger::EndTouch(pOther); ShimEndTouch(pOther); }
  23. private:
  24. virtual void ShimStartTouch( CBaseEntity* pOther ) = 0;
  25. virtual void ShimEndTouch( CBaseEntity* pOther ) = 0;
  26. };
  27. //-----------------------------------------------------------------------------
  28. class CFuncPasstimeGoal : public CFuncPasstimeGoalShim, public TAutoList< CFuncPasstimeGoal >
  29. {
  30. public:
  31. DECLARE_CLASS( CFuncPasstimeGoal, CFuncPasstimeGoalShim );
  32. DECLARE_SERVERCLASS();
  33. DECLARE_DATADESC();
  34. CFuncPasstimeGoal();
  35. virtual void Spawn() OVERRIDE;
  36. virtual int UpdateTransmitState() OVERRIDE;
  37. void OnScore( int team );
  38. int Points() const { return m_iPoints; }
  39. bool IsDisabled() const { return m_bTriggerDisabled; }
  40. enum SpawnFlags
  41. {
  42. WIN_ON_SCORE = 1,
  43. DISABLE_BALL_SCORE = 2,
  44. ENABLE_PLAYER_SCORE = 4,
  45. TYPE_TOWER_GOAL = 8,
  46. };
  47. // FIXME: this is copypasta with c_func_passtime_goal
  48. enum GoalType
  49. {
  50. TYPE_HOOP,
  51. TYPE_ENDZONE,
  52. TYPE_TOWER,
  53. };
  54. bool BWinOnScore() const { return (GetSpawnFlags() & (CFuncPasstimeGoal::WIN_ON_SCORE << 24)) != 0; }
  55. bool BDisableBallScore() const { return (GetSpawnFlags() & (CFuncPasstimeGoal::DISABLE_BALL_SCORE << 24)) != 0; }
  56. bool BEnablePlayerScore() const { return (GetSpawnFlags() & (CFuncPasstimeGoal::ENABLE_PLAYER_SCORE << 24)) != 0; }
  57. bool BTowerGoal() const { return (GetSpawnFlags() & (CFuncPasstimeGoal::TYPE_TOWER_GOAL << 24)) != 0; }
  58. private:
  59. virtual void ShimStartTouch( CBaseEntity *pOther ) OVERRIDE;
  60. virtual void ShimEndTouch( CBaseEntity *pOther ) OVERRIDE;
  61. bool CanTouchMe( CBaseEntity *pOther );
  62. void GoalThink();
  63. COutputEvent m_onScoreBlu;
  64. COutputEvent m_onScoreRed;
  65. int m_iPoints;
  66. CNetworkVar( bool, m_bTriggerDisabled );
  67. CNetworkVar( int, m_iGoalType );
  68. };
  69. #endif // FUNC_PASSTIME_GOAL_H