//------------------------------------------------------------------------------ // Purpose : //------------------------------------------------------------------------------ void CGameUI::InputActivate( inputdata_t &inputdata ) { // If already in use, ignore activatation by others if (( m_player.Get() != NULL ) && ( m_player.Get() != inputdata.pActivator )) { return; } if ( inputdata.pActivator && inputdata.pActivator->IsPlayer() ) { m_player = (CBasePlayer *)inputdata.pActivator; m_playerOn.FireOutput( inputdata.pActivator, this, 0 ); // Turn the hud off SetNextThink( gpGlobals->curtime ); // Disable player motion if (FBitSet(m_spawnflags, SF_GAMEUI_FREEZE_PLAYER)) { m_player->AddFlag( FL_ATCONTROLS ); } if (FBitSet(m_spawnflags, SF_GAMEUI_HIDE_WEAPON)) { m_player->m_Local.m_iHideHUD |= HIDEHUD_WEAPONS; if ( m_player->GetActiveWeapon() ) { m_hSaveWeapon = m_player->GetActiveWeapon(); m_player->GetActiveWeapon()->Holster(); m_player->ClearActiveWeapon(); m_player->HideViewModels(); } } } m_bForceUpdate = true; }
//------------------------------------------------------------------------------ // Purpose : //------------------------------------------------------------------------------ void CGameUI::InputActivate( inputdata_t &inputdata ) { CBasePlayer *pPlayer; // Determine if we're specifying this as an override parameter if ( inputdata.value.StringID() != NULL_STRING ) { CBaseEntity *pEntity = gEntList.FindEntityByName( NULL, inputdata.value.String(), this, inputdata.pActivator, inputdata.pCaller ); if ( pEntity == NULL || pEntity->IsPlayer() == false ) { Warning( "%s InputActivate: entity %s not found or is not a player!\n", STRING(GetEntityName()), inputdata.value.String() ); return; } pPlayer = ToBasePlayer( pEntity ); } else { // Otherwise try to use the activator if ( inputdata.pActivator == NULL || inputdata.pActivator->IsPlayer() == false ) { Warning( "%s InputActivate: invalid or missing !activator!\n", STRING(GetEntityName()), inputdata.value.String() ); return; } pPlayer = ToBasePlayer( inputdata.pActivator ); } // If another player is already using these controls3, ignore this activation if ( m_player.Get() != NULL && pPlayer != m_player.Get() ) { // TODO: We could allow this by calling Deactivate() at this point and continuing on -- jdw return; } // Setup our internal data m_player = pPlayer; m_playerOn.FireOutput( pPlayer, this, 0 ); // Turn the hud off SetNextThink( gpGlobals->curtime ); // Disable player's motion if ( FBitSet( m_spawnflags, SF_GAMEUI_FREEZE_PLAYER ) ) { m_player->AddFlag( FL_ATCONTROLS ); } // Store off and hide the currently held weapon if ( FBitSet( m_spawnflags, SF_GAMEUI_HIDE_WEAPON ) ) { m_player->m_Local.m_iHideHUD |= HIDEHUD_WEAPONSELECTION; if ( m_player->GetActiveWeapon() ) { m_hSaveWeapon = m_player->GetActiveWeapon(); m_player->GetActiveWeapon()->Holster(); m_player->ClearActiveWeapon(); m_player->HideViewModels(); } } // We must update our state m_bForceUpdate = true; }