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.

130 lines
5.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef PHYSPROPCLIENTSIDE_H
  7. #define PHYSPROPCLIENTSIDE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "c_breakableprop.h"
  12. #include "props_shared.h"
  13. class C_PhysPropClientside : public C_BreakableProp, public IBreakableWithPropData, public IMultiplayerPhysics
  14. {
  15. public:
  16. DECLARE_CLASS( C_PhysPropClientside, C_BreakableProp );
  17. C_PhysPropClientside();
  18. virtual ~C_PhysPropClientside();
  19. bool Initialize();
  20. void Spawn();
  21. int ParsePropData( void );
  22. virtual bool IsDormant( void ) { return false; } // we could add a PVS check here
  23. virtual void ClientThink( void );
  24. virtual CollideType_t GetCollideType( void ) { return ENTITY_SHOULD_RESPOND; }
  25. virtual void StartTouch( C_BaseEntity *pOther );
  26. virtual void HitSurface( C_BaseEntity *pOther );
  27. virtual void ImpactTrace( trace_t *pTrace, int iDamageType, char *pCustomImpactName );
  28. virtual bool IsClientCreated( void ) const { return true; }
  29. virtual int GetMultiplayerPhysicsMode() { return m_iPhysicsMode; }
  30. virtual float GetMass();
  31. virtual bool IsAsleep();
  32. virtual bool KeyValue( const char *szKeyName, const char *szValue );
  33. virtual void OnTakeDamage( int iDamage ); // very simple version
  34. virtual void Break();
  35. virtual void Clone( Vector &velocity );
  36. virtual void StartFadeOut( float fTime );
  37. virtual void SetHealth(int iHealth) { m_iHealth = iHealth; }
  38. virtual int GetHealth() const { return m_iHealth; }
  39. int GetNumBreakableChunks( void ) { return m_iNumBreakableChunks; }
  40. // IBreakableWithPropData interface:
  41. public:
  42. // IBreakableWithPropData
  43. void SetDmgModBullet( float flDmgMod ) { m_flDmgModBullet = flDmgMod; }
  44. void SetDmgModClub( float flDmgMod ) { m_flDmgModClub = flDmgMod; }
  45. void SetDmgModExplosive( float flDmgMod ) { m_flDmgModExplosive = flDmgMod; }
  46. void SetDmgModFire( float flDmgMod ) { m_flDmgModFire = flDmgMod; }
  47. float GetDmgModBullet( void ) { return m_flDmgModBullet; }
  48. float GetDmgModClub( void ) { return m_flDmgModClub; }
  49. float GetDmgModExplosive( void ) { return m_flDmgModExplosive; }
  50. float GetDmgModFire( void ) { return m_flDmgModFire; }
  51. void SetExplosiveRadius( float flRadius ) { m_explodeRadius = flRadius; }
  52. void SetExplosiveDamage( float flDamage ) { m_explodeDamage = flDamage; }
  53. float GetExplosiveRadius( void ) { return m_explodeRadius; }
  54. float GetExplosiveDamage( void ) { return m_explodeDamage; }
  55. void SetPhysicsDamageTable( string_t iszTableName ) { m_iszPhysicsDamageTableName = iszTableName; }
  56. string_t GetPhysicsDamageTable( void ) { return m_iszPhysicsDamageTableName; }
  57. void SetBreakableModel( string_t iszModel ) { m_iszBreakableModel = iszModel; }
  58. string_t GetBreakableModel( void ) { return m_iszBreakableModel; }
  59. void SetBreakableSkin( int iSkin ) { m_iBreakableSkin = iSkin; }
  60. int GetBreakableSkin( void ) { return m_iBreakableSkin; }
  61. void SetBreakableCount( int iCount ) { m_iBreakableCount = iCount; }
  62. int GetBreakableCount( void ) { return m_iBreakableCount; }
  63. void SetMaxBreakableSize( int iSize ) { m_iMaxBreakableSize = iSize; }
  64. int GetMaxBreakableSize( void ) { return m_iMaxBreakableSize; }
  65. void SetPropDataBlocksLOS( bool bBlocksLOS ) { m_bBlockLOSSetByPropData = true; SetBlocksLOS( bBlocksLOS ); }
  66. void SetPropDataIsAIWalkable( bool b ) { m_bIsWalkableSetByPropData = true; SetAIWalkable( b ); }
  67. void SetBasePropData( string_t iszBase ) { m_iszBasePropData = iszBase; }
  68. string_t GetBasePropData( void ) { return m_iszBasePropData; }
  69. void SetInteraction( propdata_interactions_t Interaction ) { m_iInteractions |= (1 << Interaction); }
  70. bool HasInteraction( propdata_interactions_t Interaction ) { return ( m_iInteractions & (1 << Interaction) ) != 0; }
  71. void SetPhysicsMode(int iMode);
  72. int GetPhysicsMode() { return m_iPhysicsMode; }
  73. void SetMultiplayerBreakMode( mp_break_t mode ) {}
  74. mp_break_t GetMultiplayerBreakMode( void ) const { return MULTIPLAYER_BREAK_DEFAULT; }
  75. // static management fucntions:
  76. static void RecreateAll(); // recreate all clientside props in map
  77. static void DestroyAll(); // clear all clientside created phys props
  78. static C_PhysPropClientside *CreateNew(bool bForce = false);
  79. protected:
  80. static void ParseAllEntities(const char *pMapData);
  81. static const char *ParseEntity( const char *pEntData );
  82. public:
  83. int m_iPhysicsMode; // should always be PHYSICS_MULTIPLAYER_CLIENTSIDE
  84. float m_flTouchDelta; // Amount of time that must pass before another touch function can be called
  85. float m_fDeathTime; // Point at which this object self destructs.
  86. // The default of -1 indicates the object shouldn't destruct.
  87. // properties from serverclass CPhysicsProp
  88. float m_impactEnergyScale;
  89. int m_spawnflags;
  90. float m_inertiaScale;
  91. protected:
  92. // Prop data storage
  93. float m_flDmgModBullet;
  94. float m_flDmgModClub;
  95. float m_flDmgModExplosive;
  96. float m_flDmgModFire;
  97. string_t m_iszPhysicsDamageTableName;
  98. string_t m_iszBreakableModel;
  99. int m_iBreakableSkin;
  100. int m_iBreakableCount;
  101. int m_iMaxBreakableSize;
  102. string_t m_iszBasePropData;
  103. int m_iInteractions;
  104. // Count of how many pieces we'll break into, custom or generic
  105. int m_iNumBreakableChunks;
  106. float m_explodeDamage;
  107. float m_explodeRadius;
  108. bool m_bBlockLOSSetByPropData;
  109. bool m_bIsWalkableSetByPropData;
  110. };
  111. #endif // PHYSPROPCLIENTSIDE_H