void BuildingEngineer::deliverService() { if( getWorkers() > 0 && getWalkerList().size() == 0 ) { ServiceBuilding::deliverService(); } }
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 Forum::deliverService() { if( getWorkers() > 0 && getWalkerList().size() == 0 ) { TaxCollectorPtr walker = TaxCollector::create( _getCity() ); walker->send2City( this ); if( !walker->isDeleted() ) { addWalker( walker.as<Walker>() ); } } }
void Forum::timeStep( const unsigned long time ) { WalkerList walkers = getWalkerList(); foreach( WalkerPtr walker, walkers ) { if( walker->isDeleted() ) { TaxCollectorPtr collector = walker.as< TaxCollector >(); if( collector.isValid() ) { _d->taxInThisMonth += collector->getMoney(); _d->citizensReached += collector->getCitizensReachedCount(); } } } Building::timeStep( time ); }
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 ); } } }
bool Factory::_mayDeliverGood() const { return ( getAccessRoads().size() > 0 ) && ( getWalkerList().size() == 0 ); }