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.

152 lines
5.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_PASSTIME_LOGIC_H
  8. #define TF_PASSTIME_LOGIC_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "baseentity.h"
  13. #include "tf_passtime_ball.h"
  14. #include "GameEventListener.h"
  15. //-----------------------------------------------------------------------------
  16. class CTFPlayer;
  17. class CTFPasstimeBall;
  18. class CPasstimeBallSpawn;
  19. class CFuncPasstimeGoal;
  20. class CCountdownAnnouncer;
  21. class CTrackPath;
  22. struct SetSectionParams;
  23. enum HudNotification_t;
  24. //-----------------------------------------------------------------------------
  25. class CTFPasstimeLogic : public CPointEntity, public CGameEventListener
  26. {
  27. public:
  28. DECLARE_CLASS( CTFPasstimeLogic, CBaseEntity );
  29. DECLARE_SERVERCLASS();
  30. DECLARE_DATADESC();
  31. CTFPasstimeLogic();
  32. virtual ~CTFPasstimeLogic();
  33. virtual void Spawn() OVERRIDE;
  34. virtual void Precache() OVERRIDE;
  35. virtual int UpdateTransmitState() OVERRIDE;
  36. virtual void FireGameEvent( IGameEvent *pEvent ) OVERRIDE;
  37. void LaunchBall( CTFPlayer *pPlayer, const Vector &pos, const Vector &vel );
  38. void EjectBall( CTFPlayer *pPlayer, CTFPlayer *pAttacker );
  39. bool BCanPlayerPickUpBall( CTFPlayer *pPlayer, HudNotification_t *pReason = 0 ) const;
  40. CPasstimeBall *GetBall() const;
  41. void OnBallCarrierDamaged( CTFPlayer *pPlayer, CTFPlayer *pAttacker, const CTakeDamageInfo& info );
  42. void OnBallCarrierMeleeHit( CTFPlayer *pPlayer, CTFPlayer *pAttacker );
  43. void OnPlayerTouchBall( CTFPlayer *pPlayer, CPasstimeBall *pBall );
  44. void OnEnterGoal( CPasstimeBall *pBall, CFuncPasstimeGoal *pGoal );
  45. void OnEnterGoal( CTFPlayer *pPlayer, CFuncPasstimeGoal *pGoal );
  46. void OnExitGoal( CPasstimeBall *pBall, CFuncPasstimeGoal *pGoal );
  47. void OnStayInGoal( CTFPlayer *pPlayer, CFuncPasstimeGoal *pGoal );
  48. bool OnBallCollision( CPasstimeBall *pBall, int index, gamevcollisionevent_t *pEvent );
  49. float GetLastHeldTime( CTFPlayer* pPlayer );
  50. float GetLastPassTime( CTFPlayer* pPlayer );
  51. void SetLastPassTime( CTFPlayer* pPlayer );
  52. void RespawnBall();
  53. float GetMaxPassRange() const { return m_flMaxPassRange; }
  54. CTFPlayer *GetBallCarrier() const;
  55. float GetPackSpeed( CTFPlayer *pPlayer ) const;
  56. static void AddCondToTeam( ETFCond eCond, int iTeam, float flTime );
  57. private:
  58. void PostSpawn();
  59. void InputSetSection( inputdata_t &input );
  60. bool ParseSetSection( const char *pStr, SetSectionParams &s ) const;
  61. void InputSpawnBall( inputdata_t &input );
  62. void InputTimeUp( inputdata_t &input );
  63. void InputSpeedBoostUsed( inputdata_t &input );
  64. void InputJumpPadUsed( inputdata_t &input );
  65. void StopAskForBallEffects();
  66. void OnBallGet();
  67. void Score( CTFPlayer *pPlayer, CFuncPasstimeGoal *pGoal );
  68. void Score( CPasstimeBall *pBall, CFuncPasstimeGoal *pGoal );
  69. void Score( CTFPlayer *pPlayer, int iTeam, int iPoints, bool iForceWin );
  70. void SpawnBallAtRandomSpawnerThink();
  71. void SpawnBallAtRandomSpawner();
  72. void SpawnBallAtSpawner( CPasstimeBallSpawn *pSpawner );
  73. void MoveBallToSpawner();
  74. void StealBall( CTFPlayer *pFrom, CTFPlayer *pTo );
  75. void ThinkExpiredTimer();
  76. void EndRoundExpiredTimer();
  77. void CrowdReactionSound( int iTeam );
  78. void OneSecStatsUpdateThink();
  79. void BallHistSampleThink();
  80. void BallPower_PowerThink();
  81. void BallPower_PackThink();
  82. void BallPower_PackHealThink();
  83. float CalcProgressFrac() const;
  84. bool AddBallPower( int iPower );
  85. void ClearBallPower();
  86. bool ShouldEndOvertime() const;
  87. void ReplicatePackMemberBits();
  88. CUtlVector< std::pair<CTFPlayer*, float> > m_ballLastPassTimes;
  89. CUtlVector< std::pair<CTFPlayer*, float> > m_ballLastHeldTimes;
  90. CCountdownAnnouncer *m_pRespawnCountdown;
  91. int m_iBallSpawnCountdownSec;
  92. float m_flNextCrowdReactionTime;
  93. uint64 m_nPackMemberBits;
  94. uint64 m_nPrevPackMemberBits;
  95. // outputs
  96. COutputEvent m_onBallFree;
  97. COutputEvent m_onBallGetRed;
  98. COutputEvent m_onBallGetBlu;
  99. COutputEvent m_onBallGetAny;
  100. COutputEvent m_onBallRemoved;
  101. COutputEvent m_onScoreRed;
  102. COutputEvent m_onScoreBlu;
  103. COutputEvent m_onScoreAny;
  104. COutputEvent m_onBallPowerUp;
  105. COutputEvent m_onBallPowerDown;
  106. // secret room stuff
  107. void SecretRoom_Spawn();
  108. void statica( inputdata_t &input ); // SecretRoom_InputStartTouchPlayerSlot
  109. void staticb( inputdata_t &input ); // SecretRoom_InputEndTouchPlayerSlot
  110. void staticc( inputdata_t &input ); // SecretRoom_InputPlugDamaged
  111. void InputRoomTriggerOnTouch( inputdata_t &input );
  112. void SecretRoom_UpdateTv( int iNumSlotsFilled );
  113. void SecretRoom_Solve();
  114. int SecretRoom_CountSlottedPlayers() const;
  115. CTFPlayer **SecretRoom_GetPlayerSlotInfoForTrigger( const char *pTriggerName, int *piExpectedClass, int *piExpectedTeam );
  116. CBaseEntity *m_SecretRoom_pTv;
  117. CSoundPatch* m_SecretRoom_pTvSound;
  118. enum class SecretRoomState { None, Open, Solved } m_SecretRoom_state;
  119. CTFPlayer *m_SecretRoom_slottedPlayers[9];
  120. CUtlVector<CSteamID> m_SecretRoom_playersThatTouchedRoom;
  121. // netvars
  122. CNetworkHandle( CPasstimeBall, m_hBall );
  123. CNetworkArray( Vector, m_trackPoints, 16 );
  124. CNetworkVar( int, m_iNumSections );
  125. CNetworkVar( int, m_iCurrentSection );
  126. CNetworkVar( float, m_flMaxPassRange );
  127. CNetworkVar( int, m_iBallPower );
  128. CNetworkVar( float, m_flPackSpeed );
  129. CNetworkArray( int, m_bPlayerIsPackMember, MAX_PLAYERS + 1 ); // +1 for easy entity index
  130. };
  131. //-----------------------------------------------------------------------------
  132. extern CTFPasstimeLogic *g_pPasstimeLogic;
  133. #endif // TF_PASSTIME_LOGIC_H