diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/tf/c_playerrelativemodel.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/client/tf/c_playerrelativemodel.cpp')
| -rw-r--r-- | game/client/tf/c_playerrelativemodel.cpp | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/game/client/tf/c_playerrelativemodel.cpp b/game/client/tf/c_playerrelativemodel.cpp new file mode 100644 index 0000000..87efdd0 --- /dev/null +++ b/game/client/tf/c_playerrelativemodel.cpp @@ -0,0 +1,164 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: A clientside, visual only model that's positioned relative to players +// +//============================================================================= + +#include "cbase.h" +#include "c_playerrelativemodel.h" + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +C_PlayerRelativeModel *C_PlayerRelativeModel::Create( const char *pszModelName, C_BaseEntity *pParent, Vector vecOffset, QAngle angleOffset, float flAnimSpeed, float flLifetime, int iFlags ) +{ + C_PlayerRelativeModel *pFlash = new C_PlayerRelativeModel; + if ( !pFlash ) + return NULL; + + if ( !pFlash->Initialize( pszModelName, pParent, vecOffset, angleOffset, flAnimSpeed, flLifetime, iFlags ) ) + return NULL; + + return pFlash; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool C_PlayerRelativeModel::Initialize( const char *pszModelName, C_BaseEntity *pParent, Vector vecOffset, QAngle angleOffset, float flAnimSpeed, float flLifetime, int iFlags ) +{ + AddEffects( EF_NORECEIVESHADOW | EF_NOSHADOW ); + if ( InitializeAsClientEntity( pszModelName, RENDER_GROUP_OPAQUE_ENTITY ) == false ) + { + Release(); + return false; + } + + m_vecOffsetPos = vecOffset; + m_angleOffset = angleOffset; + + SetParent( pParent, 0 ); + SetLocalOrigin( vec3_origin ); + SetLocalAngles( vec3_angle ); + + AddSolidFlags( FSOLID_NOT_SOLID ); + + SetLifetime( flLifetime ); + SetNextClientThink( CLIENT_THINK_ALWAYS ); + + SetCycle( 0 ); + + m_qOffsetRotation = vec3_angle; + m_flAnimSpeed = flAnimSpeed; + + m_iFlags = iFlags; + return true; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void C_PlayerRelativeModel::SetLifetime( float flLifetime ) +{ + if ( flLifetime == PRM_PERMANENT ) + { + m_flExpiresAt = PRM_PERMANENT; + } + else + { + // Expire when the lifetime is up + m_flExpiresAt = gpGlobals->curtime + flLifetime; + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void C_PlayerRelativeModel::ClientThink( void ) +{ + if ( !GetMoveParent() || (m_flExpiresAt != PRM_PERMANENT && gpGlobals->curtime > m_flExpiresAt) ) + { + Release(); + return; + } + + // Animate + C_BaseEntity *pParent = GetMoveParent(); + + Vector out(0, 0, 0); + if ( m_iFlags & PRM_SPIN_Z ) + { + m_qOffsetRotation += QAngle(0, gpGlobals->frametime * m_flAnimSpeed, 0); + VectorRotate( m_vecOffsetPos, m_qOffsetRotation, out ); + } + + SetAbsOrigin( pParent->GetAbsOrigin() + out ); + SetAbsAngles( m_qOffsetRotation + m_angleOffset ); +} + +//----------------------------------------------------------------------------- +// C_MerasmusBombEffect +//----------------------------------------------------------------------------- +C_MerasmusBombEffect *C_MerasmusBombEffect::Create( const char *pszModelName, C_TFPlayer *pParent, Vector vecOffset, QAngle angleOffset, float flAnimSpeed, float flLifetime, int iFlags ) +{ + C_MerasmusBombEffect *pFlash = new C_MerasmusBombEffect; + if ( !pFlash ) + return NULL; + + if ( !pFlash->Initialize( pszModelName, pParent, vecOffset, angleOffset, flAnimSpeed, flLifetime, iFlags ) ) + return NULL; + + return pFlash; +} + +//----------------------------------------------------------------------------- +bool C_MerasmusBombEffect::Initialize( const char *pszModelName, C_TFPlayer *pParent, Vector vecOffset, QAngle angleOffset, float flAnimSpeed, float flLifetime, int iFlags ) +{ + if ( !BaseClass::Initialize(pszModelName, pParent, vecOffset, angleOffset, flAnimSpeed, flLifetime, iFlags ) ) + return false; + + // Create a particle effect + const char *pszEffectName = "bombonomicon_spell_trail"; + + if ( m_pBombonomiconBeam ) + { + m_pBombonomiconBeam->StopEmission(); + m_pBombonomiconBeam = NULL; + } + + if ( m_pBombonomiconEffect ) + { + m_pBombonomiconEffect->StopEmission(); + m_pBombonomiconEffect = NULL; + } + + m_pBombonomiconBeam = ParticleProp()->Create( pszEffectName, PATTACH_ABSORIGIN_FOLLOW, INVALID_PARTICLE_ATTACHMENT, Vector(0,0,-10) ); + if ( m_pBombonomiconBeam ) + { + ParticleProp()->AddControlPoint( m_pBombonomiconBeam, 1, pParent, PATTACH_POINT_FOLLOW, "head", Vector(0,0,0) ); + } + + return true; +} + + +//----------------------------------------------------------------------------- +void C_MerasmusBombEffect::ClientThink( void ) +{ + if ( !GetMoveParent() || (m_flExpiresAt != PRM_PERMANENT && gpGlobals->curtime > m_flExpiresAt) ) + { + if ( m_pBombonomiconBeam ) + { + m_pBombonomiconBeam->StopEmission(); + m_pBombonomiconBeam = NULL; + } + + if ( m_pBombonomiconEffect ) + { + m_pBombonomiconEffect->StopEmission(); + m_pBombonomiconEffect = NULL; + } + } + + BaseClass::ClientThink(); +}
\ No newline at end of file |