本文整理汇总了C++中Craft::setStatus方法的典型用法代码示例。如果您正苦于以下问题:C++ Craft::setStatus方法的具体用法?C++ Craft::setStatus怎么用?C++ Craft::setStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Craft
的用法示例。
在下文中一共展示了Craft::setStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: step
productionProgress_e Production::step(Base * b, SavedGame * g, const Mod *m, Language *lang)
{
int done = getAmountProduced();
_timeSpent += _engineers;
if (done < getAmountProduced())
{
int produced;
if (!getInfiniteAmount())
{
produced = std::min(getAmountProduced(), _amount) - done; // std::min is required because we don't want to overproduce
}
else
{
produced = getAmountProduced() - done;
}
int count = 0;
do
{
for (std::map<std::string,int>::const_iterator i = _rules->getProducedItems().begin(); i != _rules->getProducedItems().end(); ++i)
{
if (_rules->getCategory() == "STR_CRAFT")
{
Craft *craft = new Craft(m->getCraft(i->first, true), b, g->getId(i->first));
craft->setStatus("STR_REFUELLING");
b->getCrafts()->push_back(craft);
break;
}
else if (_rules->getCategory() == "STR_VEHICLE")
{
Soldier *soldier = m->genSoldier(g, i->first);
b->getSoldiers()->push_back(soldier);
break;
}
else
{
if (m->getItem(i->first, true)->getBattleType() == BT_NONE)
{
for (std::vector<Craft*>::iterator c = b->getCrafts()->begin(); c != b->getCrafts()->end(); ++c)
{
(*c)->reuseItem(i->first);
}
}
if (getSellItems())
g->setFunds(g->getFunds() + (m->getItem(i->first, true)->getSellCost() * i->second));
else
b->getStorageItems()->addItem(i->first, i->second);
}
}
// Spawn persons (soldiers, engineers, scientists, ...)
const std::string &spawnedPersonType = _rules->getSpawnedPersonType();
if (spawnedPersonType != "")
{
if (spawnedPersonType == "STR_SCIENTIST")
{
Transfer *t = new Transfer(24);
t->setScientists(1);
b->getTransfers()->push_back(t);
}
else if (spawnedPersonType == "STR_ENGINEER")
{
Transfer *t = new Transfer(24);
t->setEngineers(1);
b->getTransfers()->push_back(t);
}
else
{
RuleSoldier *rule = m->getSoldier(spawnedPersonType);
if (rule != 0)
{
Transfer *t = new Transfer(24);
Soldier *s = m->genSoldier(g, rule->getType());
if (_rules->getSpawnedPersonName() != "")
{
s->setName(lang->getString(_rules->getSpawnedPersonName()));
}
t->setSoldier(s);
b->getTransfers()->push_back(t);
}
}
}
count++;
if (count < produced)
{
// We need to ensure that player has enough cash/item to produce a new unit
if (!haveEnoughMoneyForOneMoreUnit(g)) return PROGRESS_NOT_ENOUGH_MONEY;
if (!haveEnoughMaterialsForOneMoreUnit(b, m)) return PROGRESS_NOT_ENOUGH_MATERIALS;
startItem(b, g, m);
}
}
while (count < produced);
}
if (getAmountProduced() >= _amount && !getInfiniteAmount()) return PROGRESS_COMPLETE;
if (done < getAmountProduced())
{
// We need to ensure that player has enough cash/item to produce a new unit
if (!haveEnoughMoneyForOneMoreUnit(g)) return PROGRESS_NOT_ENOUGH_MONEY;
if (!haveEnoughLivingSpaceForOneMoreUnit(b)) return PROGRESS_NOT_ENOUGH_LIVING_SPACE;
if (!haveEnoughMaterialsForOneMoreUnit(b, m)) return PROGRESS_NOT_ENOUGH_MATERIALS;
startItem(b, g, m);
//.........这里部分代码省略.........
示例2: step
productionProgress_e Production::step(Base * b, SavedGame * g, const Ruleset *r)
{
int done = getAmountProduced();
_timeSpent += _engineers;
if (!Options::canManufactureMoreItemsPerHour && done < getAmountProduced())
{
// enforce pre-TFTD manufacturing rules: extra hours are wasted
_timeSpent = (done + 1) * _rules->getManufactureTime();
}
if (done < getAmountProduced())
{
int produced;
if (!getInfiniteAmount())
{
produced = std::min(getAmountProduced(), _amount) - done; // std::min is required because we don't want to overproduce
}
else
{
produced = getAmountProduced() - done;
}
int count = 0;
do
{
for (std::map<std::string,int>::const_iterator i = _rules->getProducedItems().begin(); i != _rules->getProducedItems().end(); ++i)
{
if (_rules->getCategory() == "STR_CRAFT")
{
Craft *craft = new Craft(r->getCraft(i->first), b, g->getId(i->first));
craft->setStatus("STR_REFUELLING");
b->getCrafts()->push_back(craft);
break;
}
else
{
// Check if it's ammo to reload a craft
if (r->getItem(i->first)->getBattleType() == BT_NONE)
{
for (std::vector<Craft*>::iterator c = b->getCrafts()->begin(); c != b->getCrafts()->end(); ++c)
{
if ((*c)->getStatus() != "STR_READY")
continue;
for (std::vector<CraftWeapon*>::iterator w = (*c)->getWeapons()->begin(); w != (*c)->getWeapons()->end(); ++w)
{
if ((*w) != 0 && (*w)->getRules()->getClipItem() == i->first && (*w)->getAmmo() < (*w)->getRules()->getAmmoMax())
{
(*w)->setRearming(true);
(*c)->setStatus("STR_REARMING");
}
}
}
}
// Check if it's fuel to refuel a craft
if (r->getItem(i->first)->getBattleType() == BT_NONE)
{
for (std::vector<Craft*>::iterator c = b->getCrafts()->begin(); c != b->getCrafts()->end(); ++c)
{
if ((*c)->getStatus() != "STR_READY")
continue;
if ((*c)->getRules()->getRefuelItem() == i->first && 100 > (*c)->getFuelPercentage())
(*c)->setStatus("STR_REFUELLING");
}
}
if (getSellItems())
g->setFunds(g->getFunds() + (r->getItem(i->first)->getSellCost() * i->second));
else
b->getItems()->addItem(i->first, i->second);
}
}
count++;
if (count < produced)
{
// We need to ensure that player has enough cash/item to produce a new unit
if (!haveEnoughMoneyForOneMoreUnit(g)) return PROGRESS_NOT_ENOUGH_MONEY;
if (!haveEnoughMaterialsForOneMoreUnit(b)) return PROGRESS_NOT_ENOUGH_MATERIALS;
startItem(b,g);
}
}
while (count < produced);
}
if (getAmountProduced() >= _amount && !getInfiniteAmount()) return PROGRESS_COMPLETE;
if (done < getAmountProduced())
{
// We need to ensure that player has enough cash/item to produce a new unit
if (!haveEnoughMoneyForOneMoreUnit(g)) return PROGRESS_NOT_ENOUGH_MONEY;
if (!haveEnoughMaterialsForOneMoreUnit(b)) return PROGRESS_NOT_ENOUGH_MATERIALS;
startItem(b,g);
}
return PROGRESS_NOT_COMPLETE;
}
示例3: step
productionProgress_e Production::step(Base * b, SavedGame * g, const Mod *m)
{
int done = getAmountProduced();
_timeSpent += _engineers;
if (done < getAmountProduced())
{
int produced;
if (!getInfiniteAmount())
{
produced = std::min(getAmountProduced(), _amount) - done; // std::min is required because we don't want to overproduce
}
else
{
produced = getAmountProduced() - done;
}
int count = 0;
do
{
for (std::map<std::string,int>::const_iterator i = _rules->getProducedItems().begin(); i != _rules->getProducedItems().end(); ++i)
{
if (_rules->getCategory() == "STR_CRAFT")
{
Craft *craft = new Craft(m->getCraft(i->first, true), b, g->getId(i->first));
craft->setStatus("STR_REFUELLING");
b->getCrafts()->push_back(craft);
break;
}
else
{
if (m->getItem(i->first, true)->getBattleType() == BT_NONE)
{
for (std::vector<Craft*>::iterator c = b->getCrafts()->begin(); c != b->getCrafts()->end(); ++c)
{
(*c)->reuseItem(i->first);
}
}
if (getSellItems())
g->setFunds(g->getFunds() + (m->getItem(i->first, true)->getSellCost() * i->second));
else
b->getStorageItems()->addItem(i->first, i->second);
}
}
count++;
if (count < produced)
{
// We need to ensure that player has enough cash/item to produce a new unit
if (!haveEnoughMoneyForOneMoreUnit(g)) return PROGRESS_NOT_ENOUGH_MONEY;
if (!haveEnoughMaterialsForOneMoreUnit(b, m)) return PROGRESS_NOT_ENOUGH_MATERIALS;
startItem(b, g, m);
}
}
while (count < produced);
}
if (getAmountProduced() >= _amount && !getInfiniteAmount()) return PROGRESS_COMPLETE;
if (done < getAmountProduced())
{
// We need to ensure that player has enough cash/item to produce a new unit
if (!haveEnoughMoneyForOneMoreUnit(g)) return PROGRESS_NOT_ENOUGH_MONEY;
if (!haveEnoughMaterialsForOneMoreUnit(b, m)) return PROGRESS_NOT_ENOUGH_MATERIALS;
startItem(b, g, m);
}
return PROGRESS_NOT_COMPLETE;
}
示例4: step
productionProgress_e Production::step(Base * b, SavedGame * g, const Ruleset *r)
{
int done = getAmountProduced ();
_timeSpent += _engineers;
if (done < getAmountProduced ())
{
bool allowAutoSellProduction = Options::getBool("allowAutoSellProduction");
bool canManufactureMoreItemsPerHour = Options::getBool("canManufactureMoreItemsPerHour");
int produced = std::min(getAmountProduced(), _amount) - done; // std::min is required because we don't want to overproduce
int count = 0;
do
{
if (_rules->getCategory() == "STR_CRAFT")
{
Craft *craft = new Craft(r->getCraft(_rules->getName()), b, g->getId(_rules->getName()));
craft->setStatus("STR_REFUELLING");
b->getCrafts()->push_back(craft);
}
else
{
// Check if it's ammo to reload a craft
if (r->getItem(_rules->getName())->getBattleType() == BT_NONE)
{
for (std::vector<Craft*>::iterator c = b->getCrafts()->begin(); c != b->getCrafts()->end(); ++c)
{
if ((*c)->getStatus() != "STR_READY")
continue;
for (std::vector<CraftWeapon*>::iterator w = (*c)->getWeapons()->begin(); w != (*c)->getWeapons()->end(); ++w)
{
if ((*w) != 0 && (*w)->getRules()->getClipItem() == _rules->getName() && (*w)->getAmmo() < (*w)->getRules()->getAmmoMax())
{
(*w)->setRearming(true);
(*c)->setStatus("STR_REARMING");
}
}
}
}
if (allowAutoSellProduction && getAmountTotal() == std::numeric_limits<int>::max())
g->setFunds(g->getFunds() + r->getItem(_rules->getName())->getSellCost());
else
b->getItems()->addItem(_rules->getName(), 1);
}
if (!canManufactureMoreItemsPerHour) break;
count++;
if (count < produced)
{
// We need to ensure that player has enough cash/item to produce a new unit
if (!haveEnoughMoneyForOneMoreUnit(g)) return PROGRESS_NOT_ENOUGH_MONEY;
if (!haveEnoughMaterialsForOneMoreUnit(b)) return PROGRESS_NOT_ENOUGH_MATERIALS;
startItem(b,g);
}
}
while (count < produced);
}
if (getAmountProduced () >= _amount) return PROGRESS_COMPLETE;
if (done < getAmountProduced ())
{
// We need to ensure that player has enough cash/item to produce a new unit
if (!haveEnoughMoneyForOneMoreUnit(g)) return PROGRESS_NOT_ENOUGH_MONEY;
if (!haveEnoughMaterialsForOneMoreUnit(b)) return PROGRESS_NOT_ENOUGH_MATERIALS;
startItem(b,g);
}
return PROGRESS_NOT_COMPLETE;
}