void BuildingPrefecture::deliverService() { if( getWorkers() > 0 && getWalkerList().size() == 0 ) { bool fireDetect = _fireDetect.getI() >= 0; WalkerPrefectPtr walker = WalkerPrefect::create( Scenario::instance().getCity() ); walker->setMaxDistance( 26 ); //bool patrol = true; if( fireDetect ) { PathWay pathway; TilePos startPos = _accessRoads.front()->getIJ(); bool pathFounded = Pathfinder::getInstance().getPath( startPos, _fireDetect, pathway, false, Size( 0 ) ); //patrol = !pathFounded; if( pathFounded ) { walker->setPathWay( pathway ); walker->setIJ( pathway.getOrigin().getIJ() ); } _fireDetect = TilePos( -1, -1 ); } walker->send2City( BuildingPrefecturePtr( this ), fireDetect ? 200 : 0 ); addWalker( walker.as<Walker>() ); } }
void BuildingEngineer::deliverService() { if( getWorkers() > 0 && getWalkerList().size() == 0 ) { ServiceBuilding::deliverService(); } }
void MDistor::init() { getWorkers(); cout<<"MDistor init creating checkSize thread"<<endl; //sizeChecker = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&MDistor::checkSize, this))); }
void Forum::deliverService() { if( getWorkers() > 0 && getWalkerList().size() == 0 ) { TaxCollectorPtr walker = TaxCollector::create( _getCity() ); walker->send2City( this ); if( !walker->isDeleted() ) { addWalker( walker.as<Walker>() ); } } }
bool Factory::mayWork() const { if( getWorkers() == 0 || !_d->isActive ) return false; GoodStock& inStock = const_cast< Factory* >( this )->getInGood(); if( inStock._goodType == G_NONE ) return true; if( inStock._currentQty > 0 || _d->produceGood ) return true; return false; }
void BuildingEngineer::timeStep(const unsigned long time) { bool mayAnimate = getWorkers() > 0; if( mayAnimate && _getAnimation().isStopped() ) { _getAnimation().start(); } if( !mayAnimate && _getAnimation().isRunning() ) { _getAnimation().stop(); } ServiceBuilding::timeStep( time ); }
void MarbleQuarry::timeStep( const unsigned long time ) { bool mayAnimate = getWorkers() > 0; if( mayAnimate && _getAnimation().isStopped() ) { _getAnimation().start(); } if( !mayAnimate && _getAnimation().isRunning() ) { _getAnimation().stop(); } Factory::timeStep( time ); }
void FactoryClay::timeStep( const unsigned long time ) { bool mayAnimate = getWorkers() > 0; if( mayAnimate && _animation.isStopped() ) { _animation.start(); } if( !mayAnimate && _animation.isRunning() ) { _animation.stop(); } Factory::timeStep( time ); }
void Market::deliverService() { if( getWorkers() > 0 && _getWalkerList().size() == 0 ) { // the marketBuyer is ready to buy something! MarketBuyerPtr buyer = MarketBuyer::create( MarketPtr( this ) ); buyer->send2City(); if( !buyer->isDeleted() ) { _addWalker( buyer.as<Walker>() ); } else if( _d->isAnyGoodStored() ) { ServiceBuilding::deliverService(); } } }
void Factory::timeStep(const unsigned long time) { Building::timeStep(time); GoodStock &inStock = getInGood(); float workersRatio = float(getWorkers()) / float(getMaxWorkers()); // work drops if not enough workers // 1080: number of seconds in a year, 0.67: number of timeSteps per second float work = 100.f / 1080.f / 0.67f * _d->productionRate * workersRatio * workersRatio; // work is proportionnal to time and factory speed if (inStock._goodType != G_NONE && inStock._currentQty == 0) { // cannot work, no input material! work = 0.0; } if( _d->progress > 100.0 ) { if (inStock._goodType != G_NONE) { // the input good is consumed inStock._currentQty -= 100; } _d->removeIdlePushers(); deliverGood(); } else { _d->progress += work; _animation.update( time ); Picture *pic = _animation.getCurrentPicture(); if (pic != NULL) { // animation of the working factory int level = _fgPictures.size()-1; _fgPictures[level] = _animation.getCurrentPicture(); } } }
void GTUtilsWorkflowDesigner::addAlgorithm(HI::GUITestOpStatus &os, QString algName, bool exactMatch, bool useDragAndDrop){ expandTabs(os); QTabWidget* tabs = qobject_cast<QTabWidget*>(GTWidget::findWidget(os,"tabs")); GT_CHECK(tabs!=NULL, "tabs widget not found"); GTTabWidget::setCurrentIndex(os,tabs,0); GTGlobals::sleep(500); QTreeWidgetItem *alg = findTreeItem(os, algName, algoriths, exactMatch); GTGlobals::sleep(100); GT_CHECK(alg!=NULL,"algorithm is NULL"); selectAlgorithm(os,alg); QWidget* w = GTWidget::findWidget(os,"sceneView"); int workerNum = getWorkers(os).size(); QPoint p(w->rect().topLeft() + QPoint(100+300*(workerNum-(workerNum/2)*2),100 + 200*(workerNum/2)));//shifting workers position if(useDragAndDrop){ GTMouseDriver::dragAndDrop(os, GTMouseDriver::getMousePosition(), w->mapToGlobal(p)); }else{ GTWidget::click(os, w,Qt::LeftButton, p); } GTGlobals::sleep(1000); }
void Factory::timeStep(const unsigned long time) { WorkingBuilding::timeStep(time); //try get good from storage building for us if( time % 22 == 1 && getWorkers() > 0 && getWalkerList().size() == 0 ) { receiveGood(); deliverGood(); } //start/stop animation when workers found bool mayAnimate = mayWork(); if( mayAnimate && _getAnimation().isStopped() ) { _getAnimation().start(); } if( !mayAnimate && _getAnimation().isRunning() ) { _getAnimation().stop(); } //no workers or no good in stock... stop animate if( !mayAnimate ) { return; } if( _d->progress >= 100.0 ) { _d->produceGood = false; if( _d->goodStore.getCurrentQty( _d->outGoodType ) < _d->goodStore.getMaxQty( _d->outGoodType ) ) { _d->progress -= 100.f; //gcc fix for temporaly ref object GoodStock tmpStock( _d->outGoodType, 100, 100 ); _d->goodStore.store( tmpStock, 100 ); } } else { //ok... factory is work, produce goods float workersRatio = float(getWorkers()) / float(getMaxWorkers()); // work drops if not enough workers // 1080: number of seconds in a year, 0.67: number of timeSteps per second float work = 100.f / 1080.f / 0.67f * _d->productionRate * workersRatio * workersRatio; // work is proportional to time and factory speed if( _d->produceGood ) { _d->progress += work; _getAnimation().update( time ); const Picture& pic = _getAnimation().getCurrentPicture(); if( pic.isValid() ) { // animation of the working factory int level = _fgPictures.size()-1; _fgPictures[level] = _getAnimation().getCurrentPicture(); } } } if( !_d->produceGood ) { if( _d->inGoodType == G_NONE ) //raw material { _d->produceGood = true; } else if( _d->goodStore.getCurrentQty( _d->inGoodType ) >= 100 && _d->goodStore.getCurrentQty( _d->outGoodType ) < 100 ) { _d->produceGood = true; //gcc fix temporaly ref object error GoodStock tmpStock( _d->inGoodType, 100, 0 ); _d->goodStore.retrieve( tmpStock, 100 ); } } }
int BuildingPrefecture::getServiceDelay() const { float koeff = ( getWorkers() > 0 ) ? (float)getMaxWorkers() / (float)getWorkers() : 1.f; return (int)(ServiceBuilding::getServiceDelay() * koeff); }