本文整理汇总了C++中unit::clone方法的典型用法代码示例。如果您正苦于以下问题:C++ unit::clone方法的具体用法?C++ unit::clone怎么用?C++ unit::clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unit
的用法示例。
在下文中一共展示了unit::clone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_amla_unit
/**
* Returns the AMLA-advanced version of a unit (with traits and items retained).
*/
unit_ptr get_amla_unit(const unit &u, const config &mod_option)
{
unit_ptr amla_unit = u.clone();
amla_unit->set_experience(amla_unit->experience_overflow());
amla_unit->add_modification("advancement", mod_option);
return amla_unit;
}
示例2: add
unit_map::umap_retval_pair_t unit_map::add(const map_location& l, const unit& u)
{
self_check();
// TODO: should this take a shared pointer to a unit rather than make a copy?
unit_ptr p = u.clone();
p->set_location(l);
unit_map::umap_retval_pair_t res(insert(p));
if(res.second == false) {
p.reset();
}
return res;
}
示例3: helper_place_unit
void helper_place_unit(const unit& u, const map_location& loc){
unit_ptr new_unit = u.clone();
new_unit->set_movement(0, true);
new_unit->set_attacks(0);
new_unit->heal_fully();
new_unit->set_location(loc);
unit_map::unit_iterator new_unit_itor;
bool success = false;
std::tie(new_unit_itor, success) = resources::gameboard->units().insert(new_unit);
assert(success);
if(resources::gameboard->map().is_village(loc)){
helper_check_village(loc, new_unit_itor->side());
}
}
示例4: get_advanced_unit
unit_ptr get_advanced_unit(const unit &u, const std::string& advance_to)
{
const unit_type *new_type = unit_types.find(advance_to);
if (!new_type) {
throw game::game_error("Could not find the unit being advanced"
" to: " + advance_to);
}
unit_ptr new_unit = u.clone();
new_unit->set_experience(new_unit->experience_overflow());
new_unit->advance_to(*new_type);
new_unit->heal_fully();
new_unit->set_state(unit::STATE_POISONED, false);
new_unit->set_state(unit::STATE_SLOWED, false);
new_unit->set_state(unit::STATE_PETRIFIED, false);
new_unit->set_user_end_turn(false);
new_unit->set_hidden(false);
return new_unit;
}
示例5:
temporary_unit_placer::temporary_unit_placer(game_board& b, const map_location& loc, unit& u)
: m_(b.units_), loc_(loc), temp_(m_.extract(loc))
{
u.clone();
m_.add(loc, u);
}