当前位置: 首页>>代码示例>>C++>>正文


C++ HousePtr::getNbHabitants方法代码示例

本文整理汇总了C++中HousePtr::getNbHabitants方法的典型用法代码示例。如果您正苦于以下问题:C++ HousePtr::getNbHabitants方法的具体用法?C++ HousePtr::getNbHabitants怎么用?C++ HousePtr::getNbHabitants使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HousePtr的用法示例。


在下文中一共展示了HousePtr::getNbHabitants方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: create

 GuiInfoBox* create( Widget* parent, const Tile& tile )
 {
   HousePtr house = tile.getTerrain().getOverlay().as<House>();
   if( house->getNbHabitants() > 0 )
   {
     return new InfoBoxHouse( parent, tile );
   }
   else
   {
     return new InfoBoxFreeHouse( parent, tile );
   }
 }
开发者ID:Rovanion,项目名称:opencaesar3,代码行数:12,代码来源:oc3_infoboxmanager.cpp

示例2: onMidTile

void TaxCollector::onMidTile()
{
  ServiceWalker::onMidTile();

  ReachedBuildings buildings = getReachedBuildings( getIJ() );
  for( ReachedBuildings::iterator it=buildings.begin(); it != buildings.end(); it++ )
  {
    HousePtr house = (*it).as<House>();
    if( house.isValid() )
    {
      int money = house->collectTaxes();
      _d->money += money;
      _d->peoplesReached += money > 0 ? house->getNbHabitants() : 0;
    }
  }
}
开发者ID:akuskis,项目名称:opencaesar3,代码行数:16,代码来源:oc3_walker_taxcollector.cpp

示例3: update

void CityServiceEmigrant::update( const unsigned int time )
{
  if( time % 44 != 1 )
    return;
  
  unsigned int vacantPop=0;

  LandOverlays houses = _d->city->getBuildingList(B_HOUSE);
  for( LandOverlays::iterator itHouse = houses.begin(); itHouse != houses.end(); ++itHouse )
  {
    HousePtr house = (*itHouse).as<House>();
    if( house.isValid() && house->getAccessRoads().size() > 0 )
    {
      vacantPop += math::clamp( house->getMaxHabitants() - house->getNbHabitants(), 0, 0xff );
    }
  }

  if( vacantPop == 0 )
  {
    return;
  }

  Walkers walkers = _d->city->getWalkerList( WT_EMIGRANT );

  if( vacantPop <= walkers.size() * 5 )
  {
    return;
  }

  Tile& roadTile = _d->city->getTilemap().at( _d->city->getRoadEntry() );

  EmigrantPtr emigrant = Emigrant::create( _d->city );

  if( emigrant.isValid() )
  {
    emigrant->send2City( roadTile );
  }
}
开发者ID:akuskis,项目名称:opencaesar3,代码行数:38,代码来源:oc3_cityservice_emigrant.cpp

示例4: getTile

void House::_tryUpdate_1_to_11_lvl( int level4grow, int startSmallPic, int startBigPic, const char desirability )
{       
  if( getSize() == 1 )
  {
    Tilemap& tmap = _getCity()->getTilemap();
    TilemapTiles area = tmap.getFilledRectangle( getTile().getIJ(), Size(2) );
    bool mayGrow = true;

    foreach( Tile* tile, area )
    {
      if( tile == NULL )
      {
        mayGrow = false;   //some broken, can't grow
        break;
      }

      HousePtr house = tile->getOverlay().as<House>();
      if( house != NULL && house->getLevelSpec().getHouseLevel() == level4grow )
      {
        if( house->getSize().getWidth() > 1 )  //bigger house near, can't grow
        {
          mayGrow = false;
          break;
        }            
      }
      else
      {
        mayGrow = false; //no house near, can't grow
        break;
      }
    }

    if( mayGrow )
    {
      int sumHabitants = getNbHabitants();
      int sumFreeWorkers = _d->freeWorkersCount;
      TilemapTiles::iterator delIt=area.begin();
      HousePtr selfHouse = (*delIt)->getOverlay().as<House>();

      delIt++; //don't remove himself
      for( ; delIt != area.end(); delIt++ )
      {
        HousePtr house = (*delIt)->getOverlay().as<House>();
        if( house.isValid() )
        {
          house->deleteLater();
          house->_d->currentHabitants = 0;

          sumHabitants += house->getNbHabitants();
          sumFreeWorkers += house->_d->freeWorkersCount;

          selfHouse->getGoodStore().storeAll( house->getGoodStore() );
        }
      }

      _d->currentHabitants = sumHabitants;
      _d->freeWorkersCount = sumFreeWorkers;
      _d->houseLevelSpec = HouseSpecHelper::getInstance().getHouseLevelSpec(_d->houseLevel);
      _d->nextHouseLevelSpec = _d->houseLevelSpec.next();

      _update();
      _updateDesirabilityInfluence( Construction::duNegative );
      setSize( getSize() + Size(1) );
      build( _getCity(), getTile().getIJ() );
    }
  }
开发者ID:hellium,项目名称:opencaesar3,代码行数:66,代码来源:oc3_building_house.cpp

示例5: getTile

void House::_tryUpdate_1_to_11_lvl( int level4grow, int startSmallPic, int startBigPic, const char desirability )
{       
  if( getSize() == 1 )
  {
    CityPtr city = Scenario::instance().getCity();
    Tilemap& tmap = city->getTilemap();
    PtrTilesList tiles = tmap.getFilledRectangle( getTile().getIJ(), Size(2) );   
    bool mayGrow = true;

    for( PtrTilesList::iterator it=tiles.begin(); it != tiles.end(); it++ )
    {
      if( *it == NULL )
      {
        mayGrow = false;   //some broken, can't grow
        break;
      }

      HousePtr house = (*it)->getTerrain().getOverlay().as<House>();
      if( house != NULL && house->getLevelSpec().getHouseLevel() == level4grow )
      {
        if( house->getSize().getWidth() > 1 )  //bigger house near, can't grow
        {
          mayGrow = false;
          break;
        }            
      }
      else
      {
        mayGrow = false; //no house near, can't grow
        break;
      }
    }

    if( mayGrow )
    {
      int sumHabitants = getNbHabitants();
      int sumFreeWorkers = _d->freeWorkersCount;
      PtrTilesList::iterator delIt=tiles.begin();
      delIt++; //don't remove himself
      for( ; delIt != tiles.end(); delIt++ )
      {
        HousePtr house = (*delIt)->getTerrain().getOverlay().as<House>();
        if( house.isValid() )
        {
          house->deleteLater();
          house->_d->currentHabitants = 0;
          sumHabitants += house->getNbHabitants();
          sumFreeWorkers += house->_d->freeWorkersCount;
        }
      }

      _d->currentHabitants = sumHabitants;
      _d->freeWorkersCount = sumFreeWorkers;
      _d->houseLevelSpec = HouseSpecHelper::getInstance().getHouseLevelSpec(_d->houseLevel);
      _d->nextHouseLevelSpec = _d->houseLevelSpec.next();

      _update();
      _updateDesirabilityInfluence( Construction::duNegative );
      setSize( getSize() + Size(1) );
      build( getTile().getIJ() );      
    }
  }

  _updateDesirabilityInfluence( Construction::duNegative );
  _d->desirability = desirability;       
  _updateDesirabilityInfluence( Construction::duPositive );

  bool bigSize = getSize().getWidth() > 1;
  _d->houseId = bigSize ? startBigPic : startSmallPic; 
  _d->picIdOffset = bigSize ? 0 : ( (rand() % 10 > 6) ? 1 : 0 );
}
开发者ID:akuskis,项目名称:opencaesar3,代码行数:71,代码来源:oc3_house.cpp


注:本文中的HousePtr::getNbHabitants方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。