// BUGBUG: This design causes a latentcy. When the button is retriggered, the first impulse // will send the target in the wrong direction because the parameter is calculated based on the // current, not future position. void CMomentaryRotButton::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { pev->ideal_yaw = CBaseToggle::AxisDelta( pev->spawnflags, pev->angles, m_start ) / m_flMoveDistance; UpdateAllButtons( pev->ideal_yaw, 1 ); UpdateTarget( pev->ideal_yaw ); }
void CMomentaryRotButton :: ButtonUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if( IsLockedByMaster( pActivator )) return; // always update target for direct use m_bUpdateTarget = true; if( useType == USE_SET ) { if( pActivator->IsPlayer( )) { CBasePlayer *pPlayer = (CBasePlayer *)pActivator; if( pPlayer->m_afPhysicsFlags & PFLAG_USING ) UpdateAllButtons(); else SetPosition( value ); // just targetting "from player" indirect } else SetPosition( value ); // not from player } else if( useType == USE_RESET ) { // stop moving immediately UseMoveDone(); } }
void CMomentaryRotButton::Return( void ) { float value = CBaseToggle::AxisDelta( pev->spawnflags, pev->angles, m_start ) / m_flMoveDistance; UpdateAllButtons( value, 0 ); // This will end up calling UpdateSelfReturn() n times, but it still works right if ( value > 0 ) UpdateTarget( value ); }
void CMomentaryRotButton::Return(void) { float value = CBaseToggle::AxisDelta(pev->spawnflags, pev->angles, m_start) / m_flMoveDistance; UpdateAllButtons(value, 0); if (value > 0) { if (!FStringNull(pev->target)) UpdateTarget(value); } }
// BUGBUG: This design causes a latentcy. When the button is retriggered, the first impulse // will send the target in the wrong direction because the parameter is calculated based on the // current, not future position. void CMomentaryRotButton::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { pev->ideal_yaw = CBaseToggle::AxisDelta(pev->spawnflags, pev->angles, m_start) / m_flMoveDistance; UpdateAllButtons(pev->ideal_yaw, 1); // Calculate destination angle and use it to predict value, this prevents sending target in wrong direction on retriggering Vector dest = pev->angles + pev->avelocity * (pev->nextthink - pev->ltime); float value1 = CBaseToggle::AxisDelta(pev->spawnflags, dest, m_start) / m_flMoveDistance; UpdateTarget(value1); }