Counter Strike : Global Offensive Source Code
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.

107 lines
3.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef ICLIENTNETWORKABLE_H
  8. #define ICLIENTNETWORKABLE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "iclientunknown.h"
  13. #include "tier1/bitbuf.h"
  14. class IClientEntity;
  15. class ClientClass;
  16. enum ShouldTransmitState_t
  17. {
  18. SHOULDTRANSMIT_START=0, // The entity is starting to be transmitted (maybe it entered the PVS).
  19. SHOULDTRANSMIT_END // Called when the entity isn't being transmitted by the server.
  20. // This signals a good time to hide the entity until next time
  21. // the server wants to transmit its state.
  22. };
  23. // NOTE: All of these are commented out; NotifyShouldTransmit actually
  24. // has all these in them. Left it as an enum in case we want to go back though
  25. enum DataUpdateType_t
  26. {
  27. DATA_UPDATE_CREATED = 0, // indicates it was created +and+ entered the pvs
  28. // DATA_UPDATE_ENTERED_PVS,
  29. DATA_UPDATE_DATATABLE_CHANGED,
  30. // DATA_UPDATE_LEFT_PVS,
  31. // DATA_UPDATE_DESTROYED, // FIXME: Could enable this, but it's a little worrying
  32. // since it changes a bunch of existing code
  33. DATA_UPDATE_POST_UPDATE,
  34. };
  35. abstract_class IClientNetworkable
  36. {
  37. public:
  38. // Gets at the containing class...
  39. virtual IClientUnknown* GetIClientUnknown() = 0;
  40. // Called by the engine when the server deletes the entity.
  41. virtual void Release() = 0;
  42. // Supplied automatically by the IMPLEMENT_CLIENTCLASS macros.
  43. virtual ClientClass* GetClientClass() = 0;
  44. // This tells the entity what the server says for ShouldTransmit on this entity.
  45. // Note: This used to be EntityEnteredPVS/EntityRemainedInPVS/EntityLeftPVS.
  46. virtual void NotifyShouldTransmit( ShouldTransmitState_t state ) = 0;
  47. //
  48. // NOTE FOR ENTITY WRITERS:
  49. //
  50. // In 90% of the cases, you should hook OnPreDataChanged/OnDataChanged instead of
  51. // PreDataUpdate/PostDataUpdate.
  52. //
  53. // The DataChanged events are only called once per frame whereas Pre/PostDataUpdate
  54. // are called once per packet (and sometimes multiple times per frame).
  55. //
  56. // OnDataChanged is called during simulation where entity origins are correct and
  57. // attachments can be used. whereas PostDataUpdate is called while parsing packets
  58. // so attachments and other entity origins may not be valid yet.
  59. //
  60. virtual void OnPreDataChanged( DataUpdateType_t updateType ) = 0;
  61. virtual void OnDataChanged( DataUpdateType_t updateType ) = 0;
  62. // Called when data is being updated across the network.
  63. // Only low-level entities should need to know about these.
  64. virtual void PreDataUpdate( DataUpdateType_t updateType ) = 0;
  65. virtual void PostDataUpdate( DataUpdateType_t updateType ) = 0;
  66. virtual void OnDataUnchangedInPVS() = 0;
  67. // Objects become dormant on the client if they leave the PVS on the server.
  68. virtual bool IsDormant( void ) const = 0;
  69. // Ent Index is the server handle used to reference this entity.
  70. // If the index is < 0, that indicates the entity is not known to the server
  71. virtual int entindex( void ) const = 0;
  72. // Server to client entity message received
  73. virtual void ReceiveMessage( int classID, bf_read &msg ) = 0;
  74. // Get the base pointer to the networked data that GetClientClass->m_pRecvTable starts at.
  75. // (This is usually just the "this" pointer).
  76. virtual void* GetDataTableBasePtr() = 0;
  77. // Tells the entity that it's about to be destroyed due to the client receiving
  78. // an uncompressed update that's caused it to destroy all entities & recreate them.
  79. virtual void SetDestroyedOnRecreateEntities( void ) = 0;
  80. };
  81. #endif // ICLIENTNETWORKABLE_H