void CVTOLVehicleManager::LockSeats(IVehicle* pVehicle, bool lock) { EVehicleSeatLockStatus newStatus = lock ? eVSLS_LockedForPlayers : eVSLS_Unlocked; const int numSeats = pVehicle->GetSeatCount(); for(int i = 1; i <= numSeats; ++i) { IVehicleSeat* pSeat = pVehicle->GetSeatById(i); if(pSeat && pSeat->GetLockedStatus() != eVSLS_Locked) { pSeat->SetLocked(newStatus); } } }
virtual void ProcessEvent(EFlowEvent flowEvent, SActivationInfo* pActivationInfo) { if (flowEvent == eFE_Activate && IsPortActive(pActivationInfo, EIP_StartDriving)) { IEntity* pEntity = pActivationInfo->pEntity; if(!pEntity) return; IVehicle* pVehicle; pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle( pEntity->GetId() ); if(!pVehicle || pVehicle->IsDestroyed()) { return; } IVehicleMovement* pMovement = pVehicle->GetMovement(); if (!pMovement) return; CVehicleMovementBase* pMovementBase = StaticCast_CVehicleMovementBase(pMovement); if (!pMovementBase) return; IActor* pPlayer = g_pGame->GetIGameFramework()->GetClientActor(); if (!pPlayer) return; const EntityId localPlayer = pPlayer->GetEntityId(); if (pVehicle->GetSeatCount() == 0) // Don't need to remotely enter { pMovement->StartDriving(localPlayer); } else { pVehicle->EvictAllPassengers(); IVehicleSeat* pSeat = pVehicle->GetSeatById(1); if (pSeat) { // Can't use remote entering to control otherwise if vehicle blows up, player dies //pSeat->EnterRemotely(localPlayer); pMovement->StartDriving(localPlayer); m_prevSeatLockStatus = pSeat->GetLockedStatus(); pSeat->SetLocked(eVSLS_Locked); } } m_fDuration = GetPortFloat(pActivationInfo, EIP_Time); m_fSpeed = GetPortFloat(pActivationInfo, EIP_Speed); m_actInfo = *pActivationInfo; m_entityId = pEntity->GetId(); SetActive(true); } else if (flowEvent == eFE_Update) { if (!m_bActive) { if (m_bNeedsCleanup) { Cleanup(); } return; } IEntity* pEntity = pActivationInfo->pEntity; if(!pEntity) { SetActive(false); return; } IVehicle* pVehicle; pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle( pEntity->GetId() ); if(!pVehicle || pVehicle->IsDestroyed()) { SetActive(false); return; } const float curTime = gEnv->pTimer->GetFrameStartTime().GetSeconds(); if ((curTime - m_fStartedTime) >= m_fDuration) { SetActive(false); ActivateOutput(pActivationInfo, EOP_TimeComplete, true); } else // Update every frame { IVehicleMovement* pMovement = pVehicle->GetMovement(); if (pMovement) { // prevent full pedal being kept pressed, but give it a bit pMovement->OnAction(eVAI_MoveForward, eAAM_OnPress, 1.0f); } } } }