void ArrivalPaxLandsideBehavior::ProcessPickCarryOnFromVehicle( const ElapsedTime& eEventTime ) { //pick up carry ons // move to destination LandsideResourceInSim *pDestResource = NULL; LandsideVehicleInSim* pVehicle = m_pPerson->getEngine()->GetLandsideSimulation()->FindPaxVehicle(m_pPerson->getID()); if(pVehicle) { setVehicle(pVehicle); pDestResource = pVehicle->getLastState().getLandsideRes(); } if(pDestResource == NULL) { ASSERT(FALSE); terminate(eEventTime); return; } //destination is parking lot setDestResource(pDestResource); setState(MoveToFacility); GenerateEvent(eEventTime + ElapsedTime(2L)); }
SteeringForce::SteeringForce(Vehicle* ve):m_iFlags(0),m_dWanderDistance(WanderDist),m_dWanderJitter(WanderJitterPerSec),m_dWanderRadius(WanderRad),m_WaypointSeekdistSq(WaypointSeekDist*WaypointSeekDist) { setVehicle(ve); m_vWanderTaget = Vec2(0, m_dWanderRadius); }
void Character::controller(int walkState, int turnState) { b2Vec2 desiredVelocity; b2Vec2 vel = m_Body->GetLinearVelocity(); b2Vec2 direction ; PlayerState State = STEADY; float desiredAngle = m_Body->GetAngle(); if (walkState == FOWARD) { State = WALK; direction = m_Body->GetWorldVector(b2Vec2(0,1.f)); } if (walkState == BACKWARD) { State = WALK; direction = m_Body->GetWorldVector(b2Vec2(0,-1.f)); } if (turnState == TURNLEFT) desiredAngle += -5.f * DEGTORAD; if (turnState == TURNRIGHT) desiredAngle += 5.f * DEGTORAD; runState(State); m_AniSprite->Update(); draw(); desiredVelocity = m_Body->GetWorldVector(direction); m_Body->ApplyLinearImpulse(direction , m_Body->GetWorldCenter()); m_Body->ApplyLinearImpulse(-0.1 * m_Body->GetMass() * m_Body->GetLinearVelocity(), m_Body->GetWorldCenter()); float nextAngle = m_Body->GetAngle() + m_Body->GetAngularVelocity()/ 60; //sf::Vector2i targetPos = sf::Mouse::getPosition(*m_Window) - sf::Vector2i(m_Window->getSize().x/2, m_Window->getSize().y/2); //float desiredAngle = atan2f(-targetPos.x, targetPos.y); float totalRotation = desiredAngle - nextAngle; while (totalRotation < -180 * DEGTORAD) totalRotation+=360 * DEGTORAD; while (totalRotation > 180 * DEGTORAD) totalRotation-=360 * DEGTORAD; float desiredAngularVelocity = totalRotation * 60; m_Body->ApplyAngularImpulse(m_Body->GetInertia() * desiredAngularVelocity); if (sf::Keyboard::isKeyPressed(sf::Keyboard::F)) { keyTemp++; if (keyTemp == 1) driveHandler(); //Make Sure driveHandler() only called once } else { keyTemp = 0; } if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) { new Bullet(m_Body->GetWorld(), m_Body->GetWorldPoint(b2Vec2(0,1)) , getNormal()); } for (unsigned int i = 0; i < VehicleCache.size(); i++) { setVehicle(VehicleCache[i]); } VehicleCache.clear(); }
void MSContainer::MSContainerStage_Driving::proceed(MSNet* net, MSTransportable* container, SUMOTime now, Stage* previous) { if (previous->getDestinationStop() != 0) { // the arrival stop may have an access point myWaitingEdge = &previous->getDestinationStop()->getLane().getEdge(); } else { myWaitingEdge = previous->getEdge(); } myWaitingPos = previous->getEdgePos(now); myWaitingSince = now; SUMOVehicle* availableVehicle = net->getVehicleControl().getWaitingVehicle(myWaitingEdge, myLines, myWaitingPos, container->getID()); if (availableVehicle != 0 && availableVehicle->getParameter().departProcedure == DEPART_CONTAINER_TRIGGERED && !availableVehicle->hasDeparted()) { setVehicle(availableVehicle); myVehicle->addContainer(container); net->getInsertionControl().add(myVehicle); net->getVehicleControl().removeWaiting(myWaitingEdge, myVehicle); net->getVehicleControl().unregisterOneWaiting(false); } else { net->getContainerControl().addWaiting(myWaitingEdge, container); myWaitingEdge->addContainer(container); } }
void ArrivalPaxLandsideBehavior::processEntryLandisde( const ElapsedTime& eEventTime ) { if(!m_pPerson) return; InitializeBehavior(); SetEnterLandsideLocation(location); if(simEngineConfig()->isSimTerminalMode()) { //WriteLogEntry(t); Processor* pProc= m_pPerson->getTerminalBehavior()->getLastTerminalProc(); ASSERT(pProc); if(pProc)//find { CString strProcName = pProc->getIDName(); CFacilityBehaviorsInSim *pFacilityBehavior = m_pPerson->getEngine()->GetLandsideSimulation()->getFacilityBehaviors(); LandsideResourceInSim* pLandsideLinkageObject = pFacilityBehavior->GetLandsideTerminalLinkage(*pProc->getID()); if(pLandsideLinkageObject) { //it could be curbside, bus station ... pLandsideLinkageObject->PassengerMoveInto(this, eEventTime); return; } else //the last processor is not link to any { //check parking spot LandsideResourceInSim *pDestResource = NULL; LandsideVehicleInSim* pVehicle = m_pPerson->getEngine()->GetLandsideSimulation()->FindPaxVehicle(m_pPerson->getID()); if(pVehicle) { setVehicle(pVehicle); } else //vehicle not entry simulation? { //LandsideSimErrorShown::PaxSimWarning(m_pPerson,_T("Pick Vehicle is not entry simulation yet"),_T("Pax Runtime Error"),eEventTime); terminate(eEventTime); return; } if(LandsideResourceInSim* pDestResource = pVehicle->getLastState().getLandsideRes() ) { setResource(pDestResource); //destination is parking lot setDestResource(pDestResource); setState(MoveToFacility); GenerateEvent(eEventTime + ElapsedTime(2L)); //@CodeWarn ?2sec what for return; } else { LandsideSimErrorShown::PaxSimWarning(m_pPerson,_T("Pax vehicle is not in any resource"),_T("Pax Runtime Error"),eEventTime); terminate(eEventTime); return; } } } else //no proc? { LandsideSimErrorShown::PaxSimWarning(m_pPerson,_T("No Last Processor"),_T("Pax Runtime Error"),eEventTime); terminate(eEventTime); return; } } else { if(!m_pVehicle) { LandsideVehicleInSim* pVehicle = m_pPerson->getEngine()->GetLandsideSimulation()->FindPaxVehicle(m_pPerson->getID()); if(pVehicle) { setVehicle(pVehicle); } else { ASSERT(FALSE); terminate(eEventTime); return; } } UpdateEntryTime(eEventTime); //get on to the vehicle straight CPoint2008 pos= m_pVehicle->getOffVehiclePos( CPoint2008(getPoint()) ); LandsideResourceInSim* pRes= m_pVehicle->getState(eEventTime).getLandsideRes(); setResource(pRes); setLocation(pos); setDestination(pos); WriteLogEntry(eEventTime); m_pPerson->setState(MoveToVehicle); GenerateEvent(eEventTime); } }