void Factory::receiveGood() { GoodStock& stock = getInGood(); //send cart supplier if stock not full if( _mayDeliverGood() && stock._currentQty < stock._maxQty ) { CartSupplierPtr walker = CartSupplier::create( Scenario::instance().getCity() ); walker->send2City( this, stock._goodType, stock._maxQty - stock._currentQty ); if( !walker->isDeleted() ) { addWalker( walker.as<Walker>() ); } } }
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(); } } }