void Factory::deliverGood() { // make a cart pusher and send him away StringHelper::debug( 0xff, "Good is ready!!!" ); if( _mayDeliverGood() ) { GoodStock stock(_outGoodType, 100, 100); CartPusherPtr walker = CartPusher::create( BuildingPtr( this ), stock ); walker->send2City(); _d->progress -= 100.f; if( !walker->isDeleted() ) _addWalker( walker.as<Walker>() ); } }
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::deliverGood() { // make a cart pusher and send him away int qty = _d->goodStore.getCurrentQty( _d->outGoodType ); if( _mayDeliverGood() && qty >= 100 ) { CartPusherPtr walker = CartPusher::create( Scenario::instance().getCity() ); GoodStock pusherStock( _d->outGoodType, qty, 0 ); _d->goodStore.retrieve( pusherStock, math::clamp( qty, 0, 400 ) ); walker->send2City( BuildingPtr( this ), pusherStock ); //success to send cartpusher if( !walker->isDeleted() ) { addWalker( walker.as<Walker>() ); } else { _d->goodStore.store( walker->getStock(), walker->getStock()._currentQty ); } } }