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.

97 lines
2.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "fx_explosion.h"
  9. #include "tempentity.h"
  10. #include "c_tracer.h"
  11. #include "env_headcrabcanister_shared.h"
  12. #include "baseparticleentity.h"
  13. // memdbgon must be the last include file in a .cpp file!!!
  14. #include "tier0/memdbgon.h"
  15. //-----------------------------------------------------------------------------
  16. // Headcrab canister Class (Client-side only!)
  17. //-----------------------------------------------------------------------------
  18. class C_EnvHeadcrabCanister : public C_BaseAnimating
  19. {
  20. DECLARE_CLASS( C_EnvHeadcrabCanister, C_BaseAnimating );
  21. DECLARE_CLIENTCLASS();
  22. public:
  23. //-------------------------------------------------------------------------
  24. // Initialization/Destruction
  25. //-------------------------------------------------------------------------
  26. C_EnvHeadcrabCanister();
  27. ~C_EnvHeadcrabCanister();
  28. virtual void OnDataChanged( DataUpdateType_t updateType );
  29. virtual void ClientThink();
  30. private:
  31. C_EnvHeadcrabCanister( const C_EnvHeadcrabCanister & );
  32. CEnvHeadcrabCanisterShared m_Shared;
  33. CNetworkVar( bool, m_bLanded );
  34. };
  35. EXTERN_RECV_TABLE(DT_EnvHeadcrabCanisterShared);
  36. IMPLEMENT_CLIENTCLASS_DT( C_EnvHeadcrabCanister, DT_EnvHeadcrabCanister, CEnvHeadcrabCanister )
  37. RecvPropDataTable( RECVINFO_DT( m_Shared ), 0, &REFERENCE_RECV_TABLE(DT_EnvHeadcrabCanisterShared) ),
  38. RecvPropBool( RECVINFO( m_bLanded ) ),
  39. END_RECV_TABLE()
  40. //-----------------------------------------------------------------------------
  41. // Constructor
  42. //-----------------------------------------------------------------------------
  43. C_EnvHeadcrabCanister::C_EnvHeadcrabCanister()
  44. {
  45. }
  46. //-----------------------------------------------------------------------------
  47. // Destructor
  48. //-----------------------------------------------------------------------------
  49. C_EnvHeadcrabCanister::~C_EnvHeadcrabCanister()
  50. {
  51. }
  52. //-----------------------------------------------------------------------------
  53. // On data update
  54. //-----------------------------------------------------------------------------
  55. void C_EnvHeadcrabCanister::OnDataChanged( DataUpdateType_t updateType )
  56. {
  57. BaseClass::OnDataChanged( updateType );
  58. if ( updateType == DATA_UPDATE_CREATED )
  59. {
  60. SetNextClientThink( CLIENT_THINK_ALWAYS );
  61. }
  62. // Stop client-side simulation on landing
  63. if ( m_bLanded )
  64. {
  65. SetNextClientThink( CLIENT_THINK_NEVER );
  66. }
  67. }
  68. //-----------------------------------------------------------------------------
  69. // Compute position
  70. //-----------------------------------------------------------------------------
  71. void C_EnvHeadcrabCanister::ClientThink()
  72. {
  73. Vector vecEndPosition;
  74. QAngle vecEndAngles;
  75. m_Shared.GetPositionAtTime( gpGlobals->curtime, vecEndPosition, vecEndAngles );
  76. SetAbsOrigin( vecEndPosition );
  77. SetAbsAngles( vecEndAngles );
  78. }