aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/client/c_gib.cpp
diff options
context:
space:
mode:
authorJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
committerJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
commit39ed87570bdb2f86969d4be821c94b722dc71179 (patch)
treeabc53757f75f40c80278e87650ea92808274aa59 /mp/src/game/client/c_gib.cpp
downloadsource-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz
source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/game/client/c_gib.cpp')
-rw-r--r--mp/src/game/client/c_gib.cpp133
1 files changed, 133 insertions, 0 deletions
diff --git a/mp/src/game/client/c_gib.cpp b/mp/src/game/client/c_gib.cpp
new file mode 100644
index 00000000..3da83295
--- /dev/null
+++ b/mp/src/game/client/c_gib.cpp
@@ -0,0 +1,133 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================//
+
+#include "cbase.h"
+#include "vcollide_parse.h"
+#include "c_gib.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+//NOTENOTE: This is not yet coupled with the server-side implementation of CGib
+// This is only a client-side version of gibs at the moment
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+C_Gib::~C_Gib( void )
+{
+ VPhysicsDestroyObject();
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : *pszModelName -
+// vecOrigin -
+// vecForceDir -
+// vecAngularImp -
+// Output : Returns true on success, false on failure.
+//-----------------------------------------------------------------------------
+C_Gib *C_Gib::CreateClientsideGib( const char *pszModelName, Vector vecOrigin, Vector vecForceDir, AngularImpulse vecAngularImp, float flLifetime )
+{
+ C_Gib *pGib = new C_Gib;
+
+ if ( pGib == NULL )
+ return NULL;
+
+ if ( pGib->InitializeGib( pszModelName, vecOrigin, vecForceDir, vecAngularImp, flLifetime ) == false )
+ return NULL;
+
+ return pGib;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : *pszModelName -
+// vecOrigin -
+// vecForceDir -
+// vecAngularImp -
+// Output : Returns true on success, false on failure.
+//-----------------------------------------------------------------------------
+bool C_Gib::InitializeGib( const char *pszModelName, Vector vecOrigin, Vector vecForceDir, AngularImpulse vecAngularImp, float flLifetime )
+{
+ if ( InitializeAsClientEntity( pszModelName, RENDER_GROUP_OPAQUE_ENTITY ) == false )
+ {
+ Release();
+ return false;
+ }
+
+ SetAbsOrigin( vecOrigin );
+ SetCollisionGroup( COLLISION_GROUP_DEBRIS );
+
+ solid_t tmpSolid;
+ PhysModelParseSolid( tmpSolid, this, GetModelIndex() );
+
+ m_pPhysicsObject = VPhysicsInitNormal( SOLID_VPHYSICS, 0, false, &tmpSolid );
+
+ if ( m_pPhysicsObject )
+ {
+ float flForce = m_pPhysicsObject->GetMass();
+ vecForceDir *= flForce;
+
+ m_pPhysicsObject->ApplyForceOffset( vecForceDir, GetAbsOrigin() );
+ m_pPhysicsObject->SetCallbackFlags( m_pPhysicsObject->GetCallbackFlags() | CALLBACK_GLOBAL_TOUCH | CALLBACK_GLOBAL_TOUCH_STATIC );
+ }
+ else
+ {
+ // failed to create a physics object
+ Release();
+ return false;
+ }
+
+ SetNextClientThink( gpGlobals->curtime + flLifetime );
+
+ return true;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void C_Gib::ClientThink( void )
+{
+ SetRenderMode( kRenderTransAlpha );
+ m_nRenderFX = kRenderFxFadeFast;
+
+ if ( m_clrRender->a == 0 )
+ {
+#ifdef HL2_CLIENT_DLL
+ s_AntlionGibManager.RemoveGib( this );
+#endif
+ Release();
+ return;
+ }
+
+ SetNextClientThink( gpGlobals->curtime + 1.0f );
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : *pOther -
+//-----------------------------------------------------------------------------
+void C_Gib::StartTouch( C_BaseEntity *pOther )
+{
+ // Limit the amount of times we can bounce
+ if ( m_flTouchDelta < gpGlobals->curtime )
+ {
+ HitSurface( pOther );
+ m_flTouchDelta = gpGlobals->curtime + 0.1f;
+ }
+
+ BaseClass::StartTouch( pOther );
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : *pOther -
+//-----------------------------------------------------------------------------
+void C_Gib::HitSurface( C_BaseEntity *pOther )
+{
+ //TODO: Implement splatter or effects in child versions
+}