Beispiel #1
0
/**
 * Saves the soldier to a YAML file.
 * @param out YAML emitter.
 */
void BattleUnit::save(YAML::Emitter &out) const
{
	out << YAML::BeginMap;

	out << YAML::Key << "id" << YAML::Value << _id;
	out << YAML::Key << "faction" << YAML::Value << _faction;
	Soldier *soldier = dynamic_cast<Soldier*>(this->getUnit());
	if (soldier != 0)
	{
		out << YAML::Key << "soldierId" << YAML::Value << soldier->getId();
	}
	else
	{
		out << YAML::Key << "soldierId" << YAML::Value << -1;
		out << YAML::Key << "genUnitType" << YAML::Value << ((GenUnit*)_unit)->getRules()->getType();
		out << YAML::Key << "genUnitArmor" << YAML::Value << ((GenUnit*)_unit)->getRules()->getArmor();
	}
	out << YAML::Key << "name" << YAML::Value << Language::wstrToUtf8(_unit->getName(0));
	out << YAML::Key << "status" << YAML::Value << _status;
	out << YAML::Key << "position" << YAML::Value << YAML::Flow;
	out << YAML::BeginSeq << _pos.x << _pos.y << _pos.z << YAML::EndSeq;
	out << YAML::Key << "direction" << YAML::Value << _direction;
	out << YAML::Key << "directionTurret" << YAML::Value << _directionTurret;
	out << YAML::Key << "tu" << YAML::Value << _tu;
	out << YAML::Key << "health" << YAML::Value << _health;
	out << YAML::Key << "energy" << YAML::Value << _energy;
	out << YAML::Key << "morale" << YAML::Value << _morale;
	out << YAML::Key << "kneeled" << YAML::Value << _kneeled;
	out << YAML::Key << "armor" << YAML::Value;
	out << YAML::Flow << YAML::BeginSeq;
	for (int i=0; i < 5; i++) out << _armor[i];
	out << YAML::EndSeq;
	out << YAML::Key << "fatalWounds" << YAML::Value;
	out << YAML::Flow << YAML::BeginSeq;
	for (int i=0; i < 6; i++) out << _fatalWounds[i];
	out << YAML::EndSeq;
	out << YAML::Key << "fire" << YAML::Value << _fire;
	out << YAML::Key << "expBravery" << YAML::Value << _expBravery;
	out << YAML::Key << "expReactions" << YAML::Value << _expReactions;
	out << YAML::Key << "expFiring" << YAML::Value << _expFiring;
	out << YAML::Key << "expThrowing" << YAML::Value << _expThrowing;
	out << YAML::Key << "expPsiSkill" << YAML::Value << _expPsiSkill;
	out << YAML::Key << "expMelee" << YAML::Value << _expMelee;
	out << YAML::Key << "turretType" << YAML::Value << _turretType;

	if (getCurrentAIState())
	{
		out << YAML::Key << "AI" << YAML::Value;
		getCurrentAIState()->save(out);
	}

	out << YAML::EndMap;
}
Beispiel #2
0
/**
 * Saves the soldier to a YAML file.
 * @param out YAML emitter.
 */
void BattleUnit::save(YAML::Emitter &out) const
{
	out << YAML::BeginMap;

	out << YAML::Key << "id" << YAML::Value << _id;
	out << YAML::Key << "faction" << YAML::Value << _faction;
	out << YAML::Key << "soldierId" << YAML::Value << _id;
	out << YAML::Key << "genUnitType" << YAML::Value << _type;
	out << YAML::Key << "genUnitArmor" << YAML::Value << _armor->getType();
	out << YAML::Key << "name" << YAML::Value << Language::wstrToUtf8(getName(0));
	out << YAML::Key << "status" << YAML::Value << _status;
	out << YAML::Key << "position" << YAML::Value << _pos;
	out << YAML::Key << "direction" << YAML::Value << _direction;
	out << YAML::Key << "directionTurret" << YAML::Value << _directionTurret;
	out << YAML::Key << "tu" << YAML::Value << _tu;
	out << YAML::Key << "health" << YAML::Value << _health;
	out << YAML::Key << "stunlevel" << YAML::Value << _stunlevel;
	out << YAML::Key << "energy" << YAML::Value << _energy;
	out << YAML::Key << "morale" << YAML::Value << _morale;
	out << YAML::Key << "kneeled" << YAML::Value << _kneeled;
	out << YAML::Key << "floating" << YAML::Value << _floating;
	out << YAML::Key << "armor" << YAML::Value;
	out << YAML::Flow << YAML::BeginSeq;
	for (int i=0; i < 5; i++) out << _currentArmor[i];
	out << YAML::EndSeq;
	out << YAML::Key << "fatalWounds" << YAML::Value;
	out << YAML::Flow << YAML::BeginSeq;
	for (int i=0; i < 6; i++) out << _fatalWounds[i];
	out << YAML::EndSeq;
	out << YAML::Key << "fire" << YAML::Value << _fire;
	out << YAML::Key << "expBravery" << YAML::Value << _expBravery;
	out << YAML::Key << "expReactions" << YAML::Value << _expReactions;
	out << YAML::Key << "expFiring" << YAML::Value << _expFiring;
	out << YAML::Key << "expThrowing" << YAML::Value << _expThrowing;
	out << YAML::Key << "expPsiSkill" << YAML::Value << _expPsiSkill;
	out << YAML::Key << "expMelee" << YAML::Value << _expMelee;
	out << YAML::Key << "turretType" << YAML::Value << _turretType;
	out << YAML::Key << "visible" << YAML::Value << _visible;

	if (getCurrentAIState())
	{
		out << YAML::Key << "AI" << YAML::Value;
		getCurrentAIState()->save(out);
	}
	out << YAML::Key << "killedBy" << YAML::Value << _killedBy;

	out << YAML::EndMap;
}