本文整理汇总了C++中MapBlock::load方法的典型用法代码示例。如果您正苦于以下问题:C++ MapBlock::load方法的具体用法?C++ MapBlock::load怎么用?C++ MapBlock::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapBlock
的用法示例。
在下文中一共展示了MapBlock::load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
/**
* Loads the terrain from a YAML file.
* @param node YAML node.
* @param mod Mod for the terrain.
*/
void RuleTerrain::load(const YAML::Node &node, Mod *mod)
{
if (const YAML::Node &map = node["mapDataSets"])
{
_mapDataSets.clear();
for (YAML::const_iterator i = map.begin(); i != map.end(); ++i)
{
_mapDataSets.push_back(mod->getMapDataSet(i->as<std::string>()));
}
}
if (const YAML::Node &map = node["mapBlocks"])
{
_mapBlocks.clear();
for (YAML::const_iterator i = map.begin(); i != map.end(); ++i)
{
MapBlock *mapBlock = new MapBlock((*i)["name"].as<std::string>());
mapBlock->load(*i);
_mapBlocks.push_back(mapBlock);
}
}
_name = node["name"].as<std::string>(_name);
if (const YAML::Node &civs = node["civilianTypes"])
{
_civilianTypes = civs.as<std::vector<std::string> >(_civilianTypes);
}
else
{
_civilianTypes.push_back("MALE_CIVILIAN");
_civilianTypes.push_back("FEMALE_CIVILIAN");
}
for (YAML::const_iterator i = node["music"].begin(); i != node["music"].end(); ++i)
{
_music.push_back((*i).as<std::string>(""));
}
if (node["depth"])
{
_minDepth = node["depth"][0].as<int>(_minDepth);
_maxDepth = node["depth"][1].as<int>(_maxDepth);
}
if (node["ambience"])
{
_ambience = mod->getSoundOffset(node["ambience"].as<int>(_ambience), "BATTLE.CAT");
}
_ambientVolume = node["ambientVolume"].as<double>(_ambientVolume);
_script = node["script"].as<std::string>(_script);
}
示例2: load
/**
* Loads the terrain from a YAML file.
* @param node YAML node.
* @param ruleset Ruleset for the terrain.
*/
void RuleTerrain::load(const YAML::Node &node, Ruleset *ruleset)
{
if (const YAML::Node &map = node["mapDataSets"])
{
_mapDataSets.clear();
for (YAML::const_iterator i = map.begin(); i != map.end(); ++i)
{
_mapDataSets.push_back(ruleset->getMapDataSet(i->as<std::string>()));
}
}
if (const YAML::Node &map = node["mapBlocks"])
{
_mapBlocks.clear();
for (YAML::const_iterator i = map.begin(); i != map.end(); ++i)
{
MapBlock *map = new MapBlock((*i)["name"].as<std::string>(), 0, 0, MT_DEFAULT);
map->load(*i);
_mapBlocks.push_back(map);
}
}
_name = node["name"].as<std::string>(_name);
_largeBlockLimit = node["largeBlockLimit"].as<int>(_largeBlockLimit);
_textures = node["textures"].as< std::vector<int> >(_textures);
_hemisphere = node["hemisphere"].as<int>(_hemisphere);
_roadTypeOdds = node["roadTypeOdds"].as< std::vector<int> >(_roadTypeOdds);
if (const YAML::Node &civs = node["civilianTypes"])
{
_civilianTypes = civs.as<std::vector<std::string> >(_civilianTypes);
}
else
{
_civilianTypes.push_back("MALE_CIVILIAN");
_civilianTypes.push_back("FEMALE_CIVILIAN");
}
_minDepth = node["minDepth"].as<int>(_minDepth);
_maxDepth = node["maxDepth"].as<int>(_maxDepth);
}