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.

92 lines
2.5 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "model_types.h"
  8. #include "vcollide.h"
  9. #include "vcollide_parse.h"
  10. #include "solidsetdefaults.h"
  11. #include "bone_setup.h"
  12. #include "engine/ivmodelinfo.h"
  13. #include "physics.h"
  14. #include "c_breakableprop.h"
  15. #include "view.h"
  16. // memdbgon must be the last include file in a .cpp file!!!
  17. #include "tier0/memdbgon.h"
  18. void RecvProxy_UnmodifiedQAngles( const CRecvProxyData *pData, void *pStruct, void *pOut )
  19. {
  20. const float *v = pData->m_Value.m_Vector;
  21. ((float*)pOut)[0] = v[0];
  22. ((float*)pOut)[1] = v[1];
  23. ((float*)pOut)[2] = v[2];
  24. }
  25. IMPLEMENT_CLIENTCLASS_DT(C_BreakableProp, DT_BreakableProp, CBreakableProp)
  26. RecvPropQAngles( RECVINFO( m_qPreferredPlayerCarryAngles ), 0, RecvProxy_UnmodifiedQAngles ),
  27. RecvPropBool( RECVINFO( m_bClientPhysics ) ),
  28. END_RECV_TABLE()
  29. //-----------------------------------------------------------------------------
  30. // Purpose:
  31. //-----------------------------------------------------------------------------
  32. C_BreakableProp::C_BreakableProp( void )
  33. {
  34. m_takedamage = DAMAGE_YES;
  35. }
  36. //-----------------------------------------------------------------------------
  37. // Copy fade from another breakable prop
  38. //-----------------------------------------------------------------------------
  39. void C_BreakableProp::CopyFadeFrom( C_BreakableProp *pSource )
  40. {
  41. SetGlobalFadeScale( pSource->GetGlobalFadeScale() );
  42. SetDistanceFade( pSource->GetMinFadeDist(), pSource->GetMaxFadeDist() );
  43. }
  44. void C_BreakableProp::OnDataChanged( DataUpdateType_t type )
  45. {
  46. BaseClass::OnDataChanged( type );
  47. if ( m_bClientPhysics )
  48. {
  49. bool bCreate = (type == DATA_UPDATE_CREATED) ? true : false;
  50. VPhysicsShadowDataChanged(bCreate, this);
  51. }
  52. }
  53. //IPlayerPickupVPhysics
  54. bool C_BreakableProp::HasPreferredCarryAnglesForPlayer( CBasePlayer *pPlayer )
  55. {
  56. return (m_qPreferredPlayerCarryAngles.x < FLT_MAX);
  57. }
  58. QAngle C_BreakableProp::PreferredCarryAngles( void )
  59. {
  60. return (m_qPreferredPlayerCarryAngles.x < FLT_MAX) ? m_qPreferredPlayerCarryAngles : vec3_angle;
  61. }
  62. bool C_BreakableProp::ShouldPredict( void )
  63. {
  64. #ifdef PORTAL
  65. C_BasePlayer *pPredOwner = GetPlayerHoldingEntity( this );
  66. return (pPredOwner && pPredOwner->IsLocalPlayer()) ? true : BaseClass::ShouldPredict();
  67. #else
  68. return false;
  69. #endif
  70. }
  71. C_BasePlayer *C_BreakableProp::GetPredictionOwner( void )
  72. {
  73. #ifdef PORTAL
  74. return GetPlayerHoldingEntity( this );
  75. #else
  76. return NULL;
  77. #endif
  78. }