コード例 #1
0
ファイル: types.cpp プロジェクト: PoignardAzur/wesnoth
/**
 * Performs a build of this to the indicated stage.
 */
void unit_type::build(BUILD_STATUS status, const movement_type_map &movement_types,
                      const race_map &races, const config::const_child_itors &traits)
{
	DBG_UT << "Building unit type " << log_id() << ", level " << status << '\n';

	switch (status) {
	case NOT_BUILT:
		// Already done in the constructor.
		return;

	case CREATED:
		// Build the basic data.
		build_created(movement_types, races, traits);
		return;

	case VARIATIONS: // Implemented as part of HELP_INDEXED
	case HELP_INDEXED:
		// Build the data needed to feed the help index.
		build_help_index(movement_types, races, traits);
		return;

	case FULL:
		build_full(movement_types, races, traits);
		return;

	default:
		ERR_UT << "Build of unit_type to unrecognized status (" << status << ") requested." << std::endl;
		// Build as much as possible.
		build_full(movement_types, races, traits);
		return;
	}
}
コード例 #2
0
ファイル: types.cpp プロジェクト: ArtBears/wesnoth
/**
 * Load data into an empty unit_type (build to FULL).
 */
void unit_type::build_full(const movement_type_map &mv_types,
	const race_map &races, const config::const_child_itors &traits)
{
	// Don't build twice.
	if ( FULL <= build_status_ )
		return;
	// Make sure we are built to the preceding build level.
	build_help_index(mv_types, races, traits);

	for (int i = 0; i < 2; ++i) {
		if (gender_types_[i])
			gender_types_[i]->build_full(mv_types, races, traits);
	}

	if ( race_ != &unit_race::null_race )
	{
		if (!race_->uses_global_traits()) {
			possible_traits_.clear();
		}
		if ( cfg_["ignore_race_traits"].to_bool() ) {
			possible_traits_.clear();
		} else {
			for (const config &t : race_->additional_traits())
			{
				if (alignment_ != unit_type::ALIGNMENT::NEUTRAL || t["id"] != "fearless")
					possible_traits_.add_child("trait", t);
			}
		}
		if (undead_variation_.empty()) {
			undead_variation_ = race_->undead_variation();
		}
	}

	// Insert any traits that are just for this unit type
	for (const config &trait : cfg_.child_range("trait"))
	{
		possible_traits_.add_child("trait", trait);
	}

	zoc_ = cfg_["zoc"].to_bool(level_ > 0);

	const config::attribute_value & alpha_blend = cfg_["alpha"];
	if(alpha_blend.empty() == false) {
		alpha_ = ftofxp(alpha_blend.to_double());
	}

	game_config::add_color_info(cfg_);

	hp_bar_scaling_ = cfg_["hp_bar_scaling"].to_double(game_config::hp_bar_scaling);
	xp_bar_scaling_ = cfg_["xp_bar_scaling"].to_double(game_config::xp_bar_scaling);

	// Propagate the build to the variations.
	for (variations_map::value_type & variation : variations_) {
		variation.second->build_full(mv_types, races, traits);
	}

	// Deprecation messages, only seen when unit is parsed for the first time.

	build_status_ = FULL;
}
コード例 #3
0
ファイル: types.cpp プロジェクト: PoignardAzur/wesnoth
/**
 * Load data into an empty unit_type (build to FULL).
 */
void unit_type::build_full(const movement_type_map &mv_types,
	const race_map &races, const config::const_child_itors &traits)
{
	// Don't build twice.
	if ( FULL <= build_status_ )
		return;
	// Make sure we are built to the preceding build level.
	build_help_index(mv_types, races, traits);

	for (int i = 0; i < 2; ++i) {
		if (gender_types_[i])
			gender_types_[i]->build_full(mv_types, races, traits);
	}

	if ( race_ != &unit_race::null_race )
	{
		if (undead_variation_.empty()) {
			undead_variation_ = race_->undead_variation();
		}
	}

	zoc_ = cfg_["zoc"].to_bool(level_ > 0);

	const config::attribute_value & alpha_blend = cfg_["alpha"];
	if(alpha_blend.empty() == false) {
		alpha_ = ftofxp(alpha_blend.to_double());
	}

	game_config::add_color_info(cfg_);

	hp_bar_scaling_ = cfg_["hp_bar_scaling"].to_double(game_config::hp_bar_scaling);
	xp_bar_scaling_ = cfg_["xp_bar_scaling"].to_double(game_config::xp_bar_scaling);

	// Propagate the build to the variations.
	for (variations_map::value_type & variation : variations_) {
		variation.second->build_full(mv_types, races, traits);
	}

	// Deprecation messages, only seen when unit is parsed for the first time.

	build_status_ = FULL;
}