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/server/portal/env_lightrail_endpoint.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/server/portal/env_lightrail_endpoint.cpp')
| -rw-r--r-- | game/server/portal/env_lightrail_endpoint.cpp | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/game/server/portal/env_lightrail_endpoint.cpp b/game/server/portal/env_lightrail_endpoint.cpp new file mode 100644 index 0000000..7b35131 --- /dev/null +++ b/game/server/portal/env_lightrail_endpoint.cpp @@ -0,0 +1,190 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#include "cbase.h" +#include "env_lightrail_endpoint_shared.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +LINK_ENTITY_TO_CLASS( env_lightrail_endpoint, CEnv_Lightrail_Endpoint ); + +BEGIN_DATADESC( CEnv_Lightrail_Endpoint ) + DEFINE_KEYFIELD( m_flSmallScale, FIELD_FLOAT, "small_fx_scale" ), + DEFINE_KEYFIELD( m_flLargeScale, FIELD_FLOAT, "large_fx_scale" ), + DEFINE_FIELD( m_nState, FIELD_INTEGER ), + DEFINE_FIELD( m_flDuration, FIELD_FLOAT ), + DEFINE_FIELD( m_flStartTime, FIELD_TIME ), + + DEFINE_INPUTFUNC( FIELD_FLOAT, "StartCharge", InputStartCharge ), + DEFINE_INPUTFUNC( FIELD_VOID, "StartSmallFX", InputStartSmallFX ), + DEFINE_INPUTFUNC( FIELD_VOID, "StartLargeFX", InputStartLargeFX ), + DEFINE_INPUTFUNC( FIELD_FLOAT, "Stop", InputStop ), +END_DATADESC() + +IMPLEMENT_SERVERCLASS_ST( CEnv_Lightrail_Endpoint, DT_Env_Lightrail_Endpoint ) + SendPropFloat( SENDINFO(m_flSmallScale), 0, SPROP_NOSCALE), + SendPropFloat( SENDINFO(m_flLargeScale), 0, SPROP_NOSCALE), + SendPropInt( SENDINFO(m_nState), 8, SPROP_UNSIGNED), + SendPropFloat( SENDINFO(m_flDuration), 0, SPROP_NOSCALE), + SendPropFloat( SENDINFO(m_flStartTime), 0, SPROP_NOSCALE), + SendPropInt( SENDINFO(m_spawnflags), 0, SPROP_UNSIGNED), +END_SEND_TABLE() + + +//----------------------------------------------------------------------------- +// Precache: +//----------------------------------------------------------------------------- +void CEnv_Lightrail_Endpoint::Precache() +{ + BaseClass::Precache(); + PrecacheMaterial( "effects/light_rail_endpoint" ); //Sprite used for the effects +} + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CEnv_Lightrail_Endpoint::Spawn( void ) +{ + Precache(); + + UTIL_SetSize( this, Vector( -8, -8, -8 ), Vector( 8, 8, 8 ) ); + + // See if we start active + if ( HasSpawnFlags( SF_ENDPOINT_START_SMALLFX ) ) + { + m_nState = (int)ENDPOINT_STATE_LARGEFX; //THIS NEEDS TO BE CHANGED TO SMALL FX STATE + m_flStartTime = gpGlobals->curtime; + } + + // No model but we still need to force this! + AddEFlags( EFL_FORCE_CHECK_TRANSMIT ); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : flWarmUpTime - +//----------------------------------------------------------------------------- +void CEnv_Lightrail_Endpoint::StartCharge( float flWarmUpTime ) +{ + m_nState = (int)ENDPOINT_STATE_CHARGING; + m_flDuration = flWarmUpTime; + m_flStartTime = gpGlobals->curtime; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CEnv_Lightrail_Endpoint::StartLargeFX( void ) +{ + m_nState = (int)ENDPOINT_STATE_LARGEFX; + m_flStartTime = gpGlobals->curtime; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CEnv_Lightrail_Endpoint::StartSmallFX( void ) +{ + m_nState = (int)ENDPOINT_STATE_SMALLFX; + m_flStartTime = gpGlobals->curtime; +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : flCoolDownTime - +//----------------------------------------------------------------------------- +void CEnv_Lightrail_Endpoint::StopLargeFX( float flCoolDownTime ) +{ + m_nState = (int)ENDPOINT_STATE_OFF; + m_flDuration = flCoolDownTime; + m_flStartTime = gpGlobals->curtime; +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : flCoolDownTime - +//----------------------------------------------------------------------------- +void CEnv_Lightrail_Endpoint::StopSmallFX( float flCoolDownTime ) +{ + m_nState = (int)ENDPOINT_STATE_OFF; + m_flDuration = flCoolDownTime; + m_flStartTime = gpGlobals->curtime; +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CEnv_Lightrail_Endpoint::InputStartCharge( inputdata_t &inputdata ) +{ + StartCharge( inputdata.value.Float() ); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CEnv_Lightrail_Endpoint::InputStartLargeFX( inputdata_t &inputdata ) +{ + StartLargeFX(); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CEnv_Lightrail_Endpoint::InputStartSmallFX( inputdata_t &inputdata ) +{ + StartSmallFX(); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : &inputdata - +//----------------------------------------------------------------------------- +void CEnv_Lightrail_Endpoint::InputStop( inputdata_t &inputdata ) +{ + StopLargeFX( inputdata.value.Float() ); +} + +CBaseViewModel *IsViewModelMoveParent_( CBaseEntity *pEffect ) +{ + if ( pEffect->GetMoveParent() ) + { + CBaseViewModel *pViewModel = dynamic_cast<CBaseViewModel *>( pEffect->GetMoveParent() ); + + if ( pViewModel ) + { + return pViewModel; + } + } + + return NULL; +} + +int CEnv_Lightrail_Endpoint::UpdateTransmitState( void ) +{ + if ( IsViewModelMoveParent_( this ) ) + { + return SetTransmitState( FL_EDICT_FULLCHECK ); + } + + return BaseClass::UpdateTransmitState(); +} + +int CEnv_Lightrail_Endpoint::ShouldTransmit( const CCheckTransmitInfo *pInfo ) +{ + CBaseViewModel *pViewModel = IsViewModelMoveParent_( this ); + + if ( pViewModel ) + { + return pViewModel->ShouldTransmit( pInfo ); + } + + return BaseClass::ShouldTransmit( pInfo ); +} |