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 Granary::_tryDevastateGranary() { //if granary in devastation mode need try send cart pusher with goods to other granary/warehouse/factory for( int goodType=Good::wheat; goodType <= Good::vegetable; goodType++ ) { int goodQty = math::clamp( goodQty, 0, 400); if( goodQty > 0 ) { GoodStock stock( (Good::Type)goodType, goodQty, goodQty); CartPusherPtr walker = CartPusher::create( _getCity() ); walker->send2City( BuildingPtr( this ), stock ); if( !walker->isDeleted() ) { stock._currentQty = 0; _d->goodStore.retrieve( stock, goodQty );//setCurrentQty( (GoodType)goodType, goodQtyMax - goodQty ); addWalker( walker.as<Walker>() ); break; } } } }
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 ); } } }