本文整理汇总了C++中Craft::load方法的典型用法代码示例。如果您正苦于以下问题:C++ Craft::load方法的具体用法?C++ Craft::load怎么用?C++ Craft::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Craft
的用法示例。
在下文中一共展示了Craft::load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
/**
* Loads the base from a YAML file.
* @param node YAML node.
* @param save Pointer to saved game.
*/
void Base::load(const YAML::Node &node, SavedGame *save, bool newGame, bool newBattleGame)
{
Target::load(node);
_name = Language::utf8ToWstr(node["name"].as<std::string>(""));
if (!newGame || !Options::getBool("customInitialBase") || newBattleGame)
{
for (YAML::const_iterator i = node["facilities"].begin(); i != node["facilities"].end(); ++i)
{
std::string type = (*i)["type"].as<std::string>();
BaseFacility *f = new BaseFacility(_rule->getBaseFacility(type), this);
f->load(*i);
_facilities.push_back(f);
}
}
for (YAML::const_iterator i = node["crafts"].begin(); i != node["crafts"].end(); ++i)
{
std::string type = (*i)["type"].as<std::string>();
Craft *c = new Craft(_rule->getCraft(type), this);
c->load(*i, _rule, save);
_crafts.push_back(c);
}
for (YAML::const_iterator i = node["soldiers"].begin(); i != node["soldiers"].end(); ++i)
{
Soldier *s = new Soldier(_rule->getSoldier("XCOM"), _rule->getArmor("STR_NONE_UC"));
s->load(*i, _rule);
if (const YAML::Node &craft = (*i)["craft"])
{
std::string type = craft["type"].as<std::string>();
int id = craft["id"].as<int>();
for (std::vector<Craft*>::iterator j = _crafts.begin(); j != _crafts.end(); ++j)
{
if ((*j)->getRules()->getType() == type && (*j)->getId() == id)
{
s->setCraft(*j);
break;
}
}
}
else
{
s->setCraft(0);
}
_soldiers.push_back(s);
}
_items->load(node["items"]);
// Some old saves have bad items, better get rid of them to avoid further bugs
for (std::map<std::string, int>::iterator i = _items->getContents()->begin(); i != _items->getContents()->end();)
{
if (std::find(_rule->getItemsList().begin(), _rule->getItemsList().end(), i->first) == _rule->getItemsList().end())
{
_items->getContents()->erase(i++);
}
else
{
++i;
}
}
_scientists = node["scientists"].as<int>(_scientists);
_engineers = node["engineers"].as<int>(_engineers);
_inBattlescape = node["inBattlescape"].as<bool>(_inBattlescape);
for (YAML::const_iterator i = node["transfers"].begin(); i != node["transfers"].end(); ++i)
{
int hours = (*i)["hours"].as<int>();
Transfer *t = new Transfer(hours);
t->load(*i, this, _rule);
_transfers.push_back(t);
}
for (YAML::const_iterator i = node["research"].begin(); i != node["research"].end(); ++i)
{
std::string research = (*i)["project"].as<std::string>();
ResearchProject *r = new ResearchProject(_rule->getResearch(research));
r->load(*i);
_research.push_back(r);
}
for (YAML::const_iterator i = node["productions"].begin(); i != node["productions"].end(); ++i)
{
std::string item = (*i)["item"].as<std::string>();
Production *p = new Production(_rule->getManufacture(item), 0);
p->load(*i);
_productions.push_back(p);
}
_retaliationTarget = node["retaliationTarget"].as<bool>(_retaliationTarget);
}