//----------------------------------------------------------------------------- // Purpose: Stop placement when holstering //----------------------------------------------------------------------------- bool CTFWeaponBuilder::Holster( CBaseCombatWeapon *pSwitchingTo ) { if ( m_iBuildState == BS_PLACING || m_iBuildState == BS_PLACING_INVALID ) { SetCurrentState( BS_IDLE ); } StopPlacement(); return BaseClass::Holster(pSwitchingTo); }
//----------------------------------------------------------------------------- // Purpose: Stop placement when holstering //----------------------------------------------------------------------------- bool CTFWeaponBuilder::Holster( CBaseCombatWeapon *pSwitchingTo ) { if ( GetOwner() && ToTFPlayer(GetOwner()) && ToTFPlayer(GetOwner())->m_Shared.IsCarryingObject() ) return false; if ( m_iBuildState == BS_PLACING || m_iBuildState == BS_PLACING_INVALID ) { SetCurrentState( BS_IDLE ); } StopPlacement(); return BaseClass::Holster(pSwitchingTo); }
//----------------------------------------------------------------------------- // Purpose: Start placing the object //----------------------------------------------------------------------------- void CTFWeaponBuilder::StartPlacement( void ) { StopPlacement(); // Create the slab m_hObjectBeingBuilt = (CBaseObject*)CreateEntityByName( GetObjectInfo( m_iObjectType )->m_pClassName ); if ( m_hObjectBeingBuilt ) { m_hObjectBeingBuilt->Spawn(); m_hObjectBeingBuilt->StartPlacement( ToTFPlayer( GetOwner() ) ); // Stomp this here in the same frame we make the object, so prevent clientside warnings that it's under attack m_hObjectBeingBuilt->m_iHealth = OBJECT_CONSTRUCTION_STARTINGHEALTH; } }
//----------------------------------------------------------------------------- // Purpose: Stop placement when holstering //----------------------------------------------------------------------------- bool CTFWeaponBuilder::Holster( CBaseCombatWeapon *pSwitchingTo ) { if ( m_iBuildState == BS_PLACING || m_iBuildState == BS_PLACING_INVALID ) { SetCurrentState( BS_IDLE ); } StopPlacement(); // Make sure hauling status is cleared. CTFPlayer *pOwner = GetTFPlayerOwner(); if ( pOwner && pOwner->m_Shared.IsCarryingObject() ) { pOwner->m_Shared.SetCarriedObject( NULL ); } return BaseClass::Holster(pSwitchingTo); }
//----------------------------------------------------------------------------- // Purpose: Set the builder to the specified state //----------------------------------------------------------------------------- void CWeaponBuilder::SetCurrentState( int iState ) { // Check the current build state... we may need to shut some stuff down... switch(m_iBuildState) { case BS_PLACING: case BS_PLACING_INVALID: { if ((iState != BS_PLACING) && (iState != BS_PLACING_INVALID) && (iState != BS_BUILDING)) { StopPlacement(); WeaponSound( SPECIAL1 ); } } break; } m_iBuildState = iState; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFWeaponBuilder::ItemPostFrame( void ) { CTFPlayer *pOwner = ToTFPlayer( GetOwner() ); if ( !pOwner ) return; // If we're building, and our team has lost, stop placing the object if ( m_hObjectBeingBuilt.Get() && TFGameRules()->State_Get() == GR_STATE_TEAM_WIN && pOwner->GetTeamNumber() != TFGameRules()->GetWinningTeam() ) { StopPlacement(); return; } // Check that I still have enough resources to build this item if ( pOwner->CanBuild( m_iObjectType ) != CB_CAN_BUILD ) { SwitchOwnersWeaponToLast(); } if (( pOwner->m_nButtons & IN_ATTACK ) && (m_flNextPrimaryAttack <= gpGlobals->curtime) ) { PrimaryAttack(); } if ( pOwner->m_nButtons & IN_ATTACK2 ) { if ( m_flNextSecondaryAttack <= gpGlobals->curtime ) { SecondaryAttack(); } } else { m_bInAttack2 = false; } WeaponIdle(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- CTFWeaponBuilder::~CTFWeaponBuilder() { StopPlacement(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFWeaponBuilder::WeaponReset( void ) { BaseClass::WeaponReset(); StopPlacement(); }