Added commentary node return speed scale

This commit is contained in:
Blixibon 2021-07-26 13:06:20 -05:00
parent 7fde10fef6
commit 632bd3d0ba

View File

@ -79,6 +79,7 @@ public:
#ifdef MAPBASE #ifdef MAPBASE
m_flViewTargetSpeedScale = 1.0f; m_flViewTargetSpeedScale = 1.0f;
m_flViewPositionSpeedScale = 1.0f; m_flViewPositionSpeedScale = 1.0f;
m_flReturnSpeedScale = 0.0f;
m_flPanelScale = 1.0f; m_flPanelScale = 1.0f;
m_flPanelX = -1.0f; m_flPanelX = -1.0f;
m_flPanelY = -1.0f; m_flPanelY = -1.0f;
@ -133,6 +134,7 @@ private:
#ifdef MAPBASE #ifdef MAPBASE
float m_flViewTargetSpeedScale; float m_flViewTargetSpeedScale;
float m_flViewPositionSpeedScale; float m_flViewPositionSpeedScale;
float m_flReturnSpeedScale;
#endif #endif
bool m_bPreventMovement; bool m_bPreventMovement;
bool m_bUnderCrosshair; bool m_bUnderCrosshair;
@ -191,6 +193,7 @@ BEGIN_DATADESC( CPointCommentaryNode )
#ifdef MAPBASE #ifdef MAPBASE
DEFINE_KEYFIELD( m_flViewTargetSpeedScale, FIELD_FLOAT, "viewtarget_speed" ), DEFINE_KEYFIELD( m_flViewTargetSpeedScale, FIELD_FLOAT, "viewtarget_speed" ),
DEFINE_KEYFIELD( m_flViewPositionSpeedScale, FIELD_FLOAT, "viewposition_speed" ), DEFINE_KEYFIELD( m_flViewPositionSpeedScale, FIELD_FLOAT, "viewposition_speed" ),
DEFINE_KEYFIELD( m_flReturnSpeedScale, FIELD_FLOAT, "return_speed" ),
DEFINE_KEYFIELD( m_iCommentaryType, FIELD_INTEGER, "type" ), DEFINE_KEYFIELD( m_iCommentaryType, FIELD_INTEGER, "type" ),
DEFINE_KEYFIELD( m_flPanelScale, FIELD_FLOAT, "panelscale" ), DEFINE_KEYFIELD( m_flPanelScale, FIELD_FLOAT, "panelscale" ),
DEFINE_KEYFIELD( m_flPanelX, FIELD_FLOAT, "x" ), DEFINE_KEYFIELD( m_flPanelX, FIELD_FLOAT, "x" ),
@ -939,7 +942,7 @@ void CPointCommentaryNode::Spawn( void )
break; break;
case COMMENTARY_TYPE_IMAGE: case COMMENTARY_TYPE_IMAGE:
szModel = "models/extras/info_image.mdl"; // TODO szModel = "models/extras/info_image.mdl";
break; break;
default: default:
@ -960,6 +963,12 @@ void CPointCommentaryNode::Spawn( void )
AddSolidFlags( FSOLID_CUSTOMRAYTEST | FSOLID_CUSTOMBOXTEST ); AddSolidFlags( FSOLID_CUSTOMRAYTEST | FSOLID_CUSTOMBOXTEST );
AddEffects( EF_NOSHADOW ); AddEffects( EF_NOSHADOW );
#ifdef MAPBASE
// Default to view position speed scale (which in turn defaults to 1.0)
if (m_flReturnSpeedScale == 0.0f)
m_flReturnSpeedScale = m_flViewPositionSpeedScale;
#endif
// Setup for animation // Setup for animation
ResetSequence( LookupSequence("idle") ); ResetSequence( LookupSequence("idle") );
SetThink( &CPointCommentaryNode::SpinThink ); SetThink( &CPointCommentaryNode::SpinThink );
@ -1342,8 +1351,8 @@ void CPointCommentaryNode::UpdateViewPostThink( void )
// Blend back to the player's position over time. // Blend back to the player's position over time.
float flCurTime = (gpGlobals->curtime - m_flFinishedTime); float flCurTime = (gpGlobals->curtime - m_flFinishedTime);
#ifdef MAPBASE #ifdef MAPBASE
if (m_flViewPositionSpeedScale != 1.0f) if (m_flReturnSpeedScale != 1.0f)
flCurTime *= m_flViewPositionSpeedScale; flCurTime *= m_flReturnSpeedScale;
#endif #endif
float flTimeToBlend = MIN( 2.0, m_flFinishedTime - m_flStartTime ); float flTimeToBlend = MIN( 2.0, m_flFinishedTime - m_flStartTime );
float flBlendPerc = 1.0f - clamp( flCurTime / flTimeToBlend, 0.f, 1.f ); float flBlendPerc = 1.0f - clamp( flCurTime / flTimeToBlend, 0.f, 1.f );