本文整理汇总了C++中unit::write方法的典型用法代码示例。如果您正苦于以下问题:C++ unit::write方法的具体用法?C++ unit::write怎么用?C++ unit::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unit
的用法示例。
在下文中一共展示了unit::write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: internal_matches_filter
//.........这里部分代码省略.........
if (!vcfg["recall_cost"].blank() && vcfg["recall_cost"].to_int(-1) != u.recall_cost()) {
return false;
}
if (!vcfg["level"].blank() && vcfg["level"].to_int(-1) != u.level()) {
return false;
}
if (!vcfg["defense"].blank() && vcfg["defense"].to_int(-1) != u.defense_modifier(fc_.get_disp_context().map().get_terrain(loc))) {
return false;
}
if (!vcfg["movement_cost"].blank() && vcfg["movement_cost"].to_int(-1) != u.movement_cost(fc_.get_disp_context().map().get_terrain(loc))) {
return false;
}
// Now start with the new WML based comparison.
// If a key is in the unit and in the filter, they should match
// filter only => not for us
// unit only => not filtered
config unit_cfg; // No point in serializing the unit once for each [filter_wml]!
for (const vconfig& wmlcfg : vcfg.get_children("filter_wml")) {
config fwml = wmlcfg.get_parsed_config();
/* Check if the filter only cares about variables.
If so, no need to serialize the whole unit. */
config::all_children_itors ci = fwml.all_children_range();
if (fwml.all_children_count() == 1 &&
fwml.attribute_count() == 1 &&
ci.front().key == "variables") {
if (!u.variables().matches(ci.front().cfg))
return false;
} else {
if (unit_cfg.empty())
u.write(unit_cfg);
if (!unit_cfg.matches(fwml))
return false;
}
}
for (const vconfig& vision : vcfg.get_children("filter_vision")) {
std::set<int> viewers;
// Use standard side filter
side_filter ssf(vision, &fc_);
std::vector<int> sides = ssf.get_teams();
viewers.insert(sides.begin(), sides.end());
bool found = false;
for (const int viewer : viewers) {
bool fogged = fc_.get_disp_context().teams()[viewer - 1].fogged(loc);
bool hiding = u.invisible(loc, fc_.get_disp_context());
bool unit_hidden = fogged || hiding;
if (vision["visible"].to_bool(true) != unit_hidden) {
found = true;
break;
}
}
if (!found) {return false;}
}
if (vcfg.has_child("filter_adjacent")) {
const unit_map& units = fc_.get_disp_context().units();
map_location adjacent[6];
get_adjacent_tiles(loc, adjacent);
for (const vconfig& adj_cfg : vcfg.get_children("filter_adjacent")) {
示例2:
BOOST_FOREACH(unit& u, recall_list_){
config& new_unit = side_cfg.add_child("unit");
u.write(new_unit);
}