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


C++ unit::clone方法代码示例

本文整理汇总了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;
}
开发者ID:Pentarctagon,项目名称:wesnoth,代码行数:10,代码来源:advancement.cpp

示例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;
}
开发者ID:GregoryLundberg,项目名称:wesnoth,代码行数:15,代码来源:map.cpp

示例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());
	}
}
开发者ID:GregoryLundberg,项目名称:wesnoth,代码行数:17,代码来源:simulated_actions.cpp

示例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;
}
开发者ID:Pentarctagon,项目名称:wesnoth,代码行数:18,代码来源:advancement.cpp

示例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);
}
开发者ID:aquileia,项目名称:wesnoth,代码行数:6,代码来源:game_board.cpp


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