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.

85 lines
3.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: DOD's objective resource, transmits all objective states to players
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef DOD_OBJECTIVE_RESOURCE_H
  8. #define DOD_OBJECTIVE_RESOURCE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "dod_shareddefs.h"
  13. class CDODObjectiveResource : public CBaseEntity
  14. {
  15. DECLARE_CLASS( CDODObjectiveResource, CBaseEntity );
  16. public:
  17. DECLARE_SERVERCLASS();
  18. DECLARE_DATADESC();
  19. virtual void Spawn( void );
  20. virtual int UpdateTransmitState(void);
  21. void ResetControlPoints( void );
  22. // Data functions, called to set up the state at the beginning of a round
  23. void SetNumControlPoints( int num );
  24. void SetCPIcons( int index, int iAlliesIcon, int iAxisIcon, int iNeutralIcon, int iTimerCapIcon, int iBombedIcon );
  25. void SetCPPosition( int index, const Vector& vPosition );
  26. void SetCPVisible( int index, bool bVisible );
  27. void SetCPRequiredCappers( int index, int iReqAllies, int iReqAxis );
  28. void SetCPCapTime( int index, float flAlliesCapTime, float flAxisCapTime );
  29. // State functions, called many times
  30. void SetNumPlayers( int index, int team, int iNumPlayers );
  31. void StartCap( int index, int team );
  32. void SetOwningTeam( int index, int team );
  33. void SetCappingTeam( int index, int team );
  34. void SetBombPlanted( int index, bool bPlanted );
  35. void SetBombsRequired( int index, int iBombsRequired );
  36. void SetBombsRemaining( int index, int iBombsRemaining );
  37. void SetBombBeingDefused( int index, bool bBeingDefused );
  38. void AssertValidIndex( int index )
  39. {
  40. Assert( 0 <= index && index <= MAX_CONTROL_POINTS && index < m_iNumControlPoints );
  41. }
  42. private:
  43. CNetworkVar( int, m_iNumControlPoints );
  44. // data variables
  45. CNetworkArray( Vector, m_vCPPositions, MAX_CONTROL_POINTS );
  46. CNetworkArray( int, m_bCPIsVisible, MAX_CONTROL_POINTS );
  47. CNetworkArray( int, m_iAlliesIcons, MAX_CONTROL_POINTS );
  48. CNetworkArray( int, m_iAxisIcons, MAX_CONTROL_POINTS );
  49. CNetworkArray( int, m_iNeutralIcons, MAX_CONTROL_POINTS );
  50. CNetworkArray( int, m_iTimerCapIcons, MAX_CONTROL_POINTS );
  51. CNetworkArray( int, m_iBombedIcons, MAX_CONTROL_POINTS );
  52. CNetworkArray( int, m_iAlliesReqCappers,MAX_CONTROL_POINTS );
  53. CNetworkArray( int, m_iAxisReqCappers, MAX_CONTROL_POINTS );
  54. CNetworkArray( float, m_flAlliesCapTime, MAX_CONTROL_POINTS );
  55. CNetworkArray( float, m_flAxisCapTime, MAX_CONTROL_POINTS );
  56. CNetworkArray( int, m_bBombPlanted, MAX_CONTROL_POINTS );
  57. CNetworkArray( int, m_iBombsRequired, MAX_CONTROL_POINTS );
  58. CNetworkArray( int, m_iBombsRemaining, MAX_CONTROL_POINTS );
  59. CNetworkArray( int, m_bBombBeingDefused,MAX_CONTROL_POINTS );
  60. // state variables
  61. // change when players enter/exit an area
  62. CNetworkArray( int, m_iNumAllies, MAX_CONTROL_POINTS );
  63. CNetworkArray( int, m_iNumAxis, MAX_CONTROL_POINTS );
  64. // changes when a cap starts. start and end times are calculated on client
  65. CNetworkArray( int, m_iCappingTeam, MAX_CONTROL_POINTS );
  66. // changes when a point is successfully captured
  67. CNetworkArray( int, m_iOwner, MAX_CONTROL_POINTS );
  68. };
  69. extern CDODObjectiveResource *g_pObjectiveResource;
  70. #endif //DOD_OBJECTIVE_RESOURCE_H