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>() );
  }
}
예제 #2
0
void Forum::deliverService()
{
  if( numberWorkers() > 0 && walkers().size() == 0 )
  {
    TaxCollectorPtr walker = TaxCollector::create( _city() );
    walker->send2City( this, ServiceWalker::goServiceMaximum|ServiceWalker::anywayWhenFailed );

    addWalker( walker.object() );
  }
}
예제 #3
0
void ActorColony::deliverTrainee()
{
  if( haveWalkers() )
    return;

  auto trainee = Walker::create<TraineeWalker>( _city(), walker::actor );
  trainee->send2City( this );

  addWalker( trainee );
}
예제 #4
0
void ServiceBuilding::deliverService()
{
  // make a service walker and send him to his wandering
  ServiceWalkerPtr serviceman = ServiceWalker::create( _getCity(), getService() );
  serviceman->setMaxDistance( getWalkerDistance() );
  serviceman->send2City( BuildingPtr( this ) );

  if( !serviceman->isDeleted() )
  {
    addWalker( serviceman.as<Walker>() );
  }
}
예제 #5
0
void Forum::deliverService()
{
  if( getWorkers() > 0 && getWalkerList().size() == 0 )
  {
    TaxCollectorPtr walker = TaxCollector::create( _getCity() );
    walker->send2City( this );

    if( !walker->isDeleted() )
    {
      addWalker( walker.as<Walker>() );
    }
  }
}
예제 #6
0
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>() );
    }
  }
}
예제 #7
0
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;
      }
    }
  }   
}
예제 #8
0
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 );
    }
  }
}