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.

76 lines
3.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Tracker for War Data on a player
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_SPYENGY_WARTRACKER_H
  8. #define TF_SPYENGY_WARTRACKER_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tf_wardata.h"
  13. #include "shared_object_tracker.h"
  14. class CTFplayer;
  15. //---------------------------------------------------------------------
  16. // Purpose: Tracks kills between Team Engineer and Team Spy in the 2014
  17. // war. Players are considered Team Engineer if they are wearing
  18. // the special Engy Hat or are unallied and playing as Engy.
  19. // Visa versa, players are considered to be on Team Spy if they
  20. // are wearing the special Spy Hat or are unallied and playing
  21. // as Spy.
  22. //---------------------------------------------------------------------
  23. class CTFWarTracker : public CBaseSOTracker, public CGameEventListener
  24. {
  25. DECLARE_CLASS( CTFWarTracker, CBaseSOTracker )
  26. public:
  27. CTFWarTracker( const CSharedObject* pItem, CSteamID SteamIDOwner, CSOTrackerManager* pManager );
  28. virtual void FireGameEvent( IGameEvent *pEvent ) OVERRIDE;
  29. virtual void CommitChangesToDB() OVERRIDE;
  30. virtual void OnUpdate() OVERRIDE {}
  31. virtual void OnRemove() OVERRIDE {}
  32. private:
  33. static const int m_kPointsPerKill = 5;
  34. static const int m_kBonusPointsPerKill = 2;
  35. CGCMsgGC_War_IndividualUpdate m_ProtoData;
  36. };
  37. //---------------------------------------------------------------------
  38. // Purpose: Contains all the trackers for wars for each player. Tells
  39. // individual trackers to update the GC every m_kflThinkInterval
  40. // seconds, defined below.
  41. //---------------------------------------------------------------------
  42. class CTFWarTrackerManager : public CSOTrackerManager
  43. {
  44. DECLARE_CLASS( CTFWarTrackerManager, CSOTrackerManager )
  45. public:
  46. CTFWarTrackerManager();
  47. virtual SOTrackerMap_t::KeyType_t GetKeyForObjectTracker( const CSharedObject* pItem, CSteamID steamIDOwner ) OVERRIDE;
  48. private:
  49. #ifdef GAME_DLL
  50. void SendMessageForCommit( const ::google::protobuf::Message* pProtoMessage ) const;
  51. #endif
  52. virtual int GetType() const OVERRIDE { return CWarData::k_nTypeID; }
  53. virtual const char* GetName() const { return "WarTrackerManager"; }
  54. virtual CFmtStr GetDebugObjectDescription( const CSharedObject* pItem ) const;
  55. virtual CBaseSOTracker* AllocateNewTracker( const CSharedObject* pItem, CSteamID steamIDOwner, CSOTrackerManager* pManager ) const OVERRIDE;
  56. virtual ::google::protobuf::Message* AllocateNewProtoMessage() const OVERRIDE;
  57. virtual void OnCommitRecieved( const ::google::protobuf::Message* pProtoMsg ) OVERRIDE;
  58. virtual bool ShouldTrackObject( const CSteamID & steamIDOwner, const CSharedObject *pObject ) const OVERRIDE;
  59. virtual int CompareRecords( const ::google::protobuf::Message* pNewProtoMsg, const ::google::protobuf::Message* pExistingProtoMsg ) const OVERRIDE;
  60. };
  61. CTFWarTrackerManager* GetWarTrackerManager();
  62. #endif // TF_SPYENGY_WARTRACKER_H