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


C++ Propagator::init方法代码示例

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


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

示例1: computeWalkerPath

void TraineeWalker::computeWalkerPath()
{
  _maxNeed = 0;  // need of this trainee in buildings
  Propagator pathPropagator;
  pathPropagator.init( *_originBuilding.object() );
  pathPropagator.propagate(_maxDistance);

  for (std::list<BuildingType>::iterator itType = _buildingNeed.begin(); itType != _buildingNeed.end(); ++itType)
  {
    BuildingType buildingType = *itType;
    checkDestination(buildingType, pathPropagator);
  }

  if( _destinationBuilding != NULL )
  {
    // some building needs that trainee!
    // std::cout << "trainee sent!" << std::endl;
    PathWay pathWay;
    pathPropagator.getPath( _destinationBuilding, pathWay);
    setPathWay( pathWay );
    setIJ( _pathWay.getOrigin().getIJ() );
  }
  else
  {
    // nobody needs him...
    // std::cout << "trainee suicide!" << std::endl;
    deleteLater();
  }
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:29,代码来源:oc3_traineewalker.cpp

示例2: computeWalkerPath

void TraineeWalker::computeWalkerPath()
{
   _maxNeed = 0;  // need of this trainee in buildings
   Propagator pathPropagator;
   pathPropagator.init(*_originBuilding);
   pathPropagator.propagate(_maxDistance);

   for (std::list<BuildingType>::iterator itType = _buildingNeed.begin(); itType != _buildingNeed.end(); ++itType)
   {
      BuildingType buildingType = *itType;
      checkDestination(buildingType, pathPropagator);
   }

   if (_destinationBuilding != NULL)
   {
      // some building needs that trainee!
      // std::cout << "trainee sent!" << std::endl;
      PathWay pathWay;
      pathPropagator.getPath(*_destinationBuilding, pathWay);
      setPathWay(pathWay);
      setIJ(_pathWay.getOrigin().getI(), _pathWay.getOrigin().getJ());
      Scenario::instance().getCity().getWalkerList().push_back(this);
      _destinationBuilding->reserveTrainee(_traineeType);
   }
   else
   {
      // nobody needs him...
      // std::cout << "trainee suicide!" << std::endl;
      _isDeleted = true;
   }

}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例3: assignPath

void Emigrant::assignPath( const Road& startPoint )
{
	std::list<PathWay> pathWayList;

	std::list<LandOverlay*> houses = Scenario::instance().getCity().getBuildingList(B_HOUSE);
	House* blankHouse = 0;
	for( std::list<LandOverlay*>::iterator itHouse = houses.begin(); itHouse != houses.end(); ++itHouse )
	{
		if( House* house = dynamic_cast<House*>(*itHouse) )
		{
			if( house->getNbHabitants() < house->getMaxHabitants() )
			{
				blankHouse = house;
				_d->destination = house->getTile().getIJ();
				break;
			}
		}
	}

	Propagator pathfinder;
	PathWay pathWay;
	pathfinder.init( const_cast< Road& >( startPoint ) );
	bool findPath = pathfinder.getPath( *blankHouse, pathWay );
	if( findPath )
	{
		setPathWay( pathWay );
		setIJ(_pathWay.getOrigin().getI(), _pathWay.getOrigin().getJ());   
	}
}
开发者ID:pufik6666,项目名称:opencaesar3,代码行数:29,代码来源:oc3_emigrant.cpp

示例4:

void Roads::Impl::updateRoadsAround( Propagator& propagator, UpdateInfo info )
{
  propagator.init( info.first );
  PathwayList pathWayList = propagator.getWays( info.second );

  for( auto& path : pathWayList )
  {
    RoadList roads = path->allTiles().overlays<Road>();
    for( auto road : roads )
      road->appendPaved( paved.increase );
  }
}
开发者ID:dalerank,项目名称:caesaria-game,代码行数:12,代码来源:cityservice_roads.cpp

示例5:

void Roads::Impl::updateRoadsAround( Propagator& propagator, UpdateInfo info )
{
  propagator.init( info.first );
  PathwayList pathWayList = propagator.getWays( info.second );

  for( auto&& path : pathWayList )
  {
    const TilesArray& tiles = path->allTiles();
    for( auto tile : tiles )
    {
      RoadPtr road = tile->overlay().as<Road>();
      if( road.isValid() )
      {
        road->appendPaved( defaultIncreasePaved );
      }
    }
  }
}
开发者ID:binakot,项目名称:caesaria-game,代码行数:18,代码来源:cityservice_roads.cpp

示例6: computeWalkerDestination

void CartPusher::computeWalkerDestination()
{
   // get the list of buildings within reach
   PathWay pathWay;
   Propagator pathPropagator;
   _d->consumerBuilding = 0;
   pathPropagator.init( *_d->producerBuilding.object() );
   pathPropagator.propagate(_d->maxDistance);

   BuildingPtr destBuilding;
   if (destBuilding == NULL)
   {
      // try send that good to a factory
      destBuilding = getWalkerDestination_factory(pathPropagator, pathWay);
   }

   if (destBuilding == NULL)
   {
      // try send that good to a granary
      destBuilding = getWalkerDestination_granary(pathPropagator, pathWay);
   }

   if (destBuilding == NULL)
   {
      // try send that good to a warehouse
      destBuilding = getWalkerDestination_warehouse( pathPropagator, pathWay );
   }

   if( destBuilding != NULL)
   {
      //_isDeleted = true;  // no destination!
     setConsumerBuilding( destBuilding );
     setPathWay( pathWay );
     setIJ( _pathWay.getOrigin().getIJ() );
     setSpeed( 1 );
   }
   else
   {
     _action._direction = D_NORTH;
     setSpeed( 0 );
     setIJ( _d->producerBuilding->getAccessRoads().front()->getIJ() );
     walk();
   }
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:44,代码来源:oc3_walker_cart_pusher.cpp

示例7: assignPath

void Immigrant::assignPath( const Building& home )
{
    City& city = Scenario::instance().getCity();
    Tile& exitTile = city.getTilemap().at( city.getRoadExitI(), city.getRoadExitJ() );

    Road* exitRoad = dynamic_cast< Road* >( exitTile.get_terrain().getOverlay() );
    if( exitRoad )
    {
        Propagator pathfinder;
	    PathWay pathWay;
        pathfinder.init( const_cast< Building& >( home ) );
        bool findPath = pathfinder.getPath( *exitRoad, pathWay );
	    if( findPath )
	    {
		    setPathWay( pathWay );
		    setIJ(_pathWay.getOrigin().getI(), _pathWay.getOrigin().getJ());   
	    }
    }
    else
        _isDeleted = true;
}
开发者ID:,项目名称:,代码行数:21,代码来源:


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