本文整理汇总了C++中BaseFacility类的典型用法代码示例。如果您正苦于以下问题:C++ BaseFacility类的具体用法?C++ BaseFacility怎么用?C++ BaseFacility使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseFacility类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: viewClick
/**
* Processes clicking on facilities.
* @param action Pointer to an action.
*/
void BasescapeState::viewClick(Action *action)
{
BaseFacility *fac = _view->getSelectedFacility();
if (fac != 0)
{
// Pre-calculate values to ensure base stays connected
int x = -1, y = -1, squares = 0;
for (std::vector<BaseFacility*>::iterator i = _base->getFacilities()->begin(); i != _base->getFacilities()->end(); i++)
{
if ((*i)->getRules()->getLift())
{
x = (*i)->getX();
y = (*i)->getY();
}
squares += (*i)->getRules()->getSize() * (*i)->getRules()->getSize();
}
squares -= fac->getRules()->getSize() * fac->getRules()->getSize();
// Is facility in use?
if (fac->inUse())
{
_game->pushState(new BasescapeErrorState(_game, "STR_FACILITY_IN_USE"));
}
// Would base become disconnected? (ocuppied squares connected to Access Lift < total squares occupied by base)
else if (_view->countConnected(x, y, 0, fac) < squares)
{
_game->pushState(new BasescapeErrorState(_game, "STR_CANNOT_DISMANTLE_FACILITY"));
}
else
{
_game->pushState(new DismantleFacilityState(_game, _base, fac));
}
}
}
示例2: ErrorMessageState
/**
* Processes clicking on facilities.
* @param action Pointer to an action.
*/
void PlaceFacilityState::viewClick(Action *)
{
if (!_view->isPlaceable(_rule))
{
_game->pushState(new ErrorMessageState(tr("STR_CANNOT_BUILD_HERE"), _palette, _game->getRuleset()->getInterface("placeFacility")->getElement("errorMessage")->color, "BACK01.SCR", _game->getRuleset()->getInterface("placeFacility")->getElement("errorPalette")->color));
}
else if (_game->getSavedGame()->getFunds() < _rule->getBuildCost())
{
_game->popState();
_game->pushState(new ErrorMessageState(tr("STR_NOT_ENOUGH_MONEY"), _palette, _game->getRuleset()->getInterface("placeFacility")->getElement("errorMessage")->color, "BACK01.SCR", _game->getRuleset()->getInterface("placeFacility")->getElement("errorPalette")->color));
}
else
{
BaseFacility *fac = new BaseFacility(_rule, _base);
fac->setX(_view->getGridX());
fac->setY(_view->getGridY());
fac->setBuildTime(_rule->getBuildTime());
_base->getFacilities()->push_back(fac);
if (Options::allowBuildingQueue)
{
if (_view->isQueuedBuilding(_rule)) fac->setBuildTime(std::numeric_limits<int>::max());
_view->reCalcQueuedBuildings();
}
_game->getSavedGame()->setFunds(_game->getSavedGame()->getFunds() - _rule->getBuildCost());
_game->popState();
}
}
示例3: BaseFacility
/**
* Processes clicking on facilities.
* @param action Pointer to an action.
*/
void PlaceLiftState::viewClick(Action *action)
{
BaseFacility *fac = new BaseFacility(_game->getRuleset()->getBaseFacility("STR_ACCESS_LIFT"), _base, _view->getGridX(), _view->getGridY());
fac->setBuildTime(0);
_base->getFacilities()->push_back(fac);
_game->popState();
_game->pushState(new BasescapeState(_game, _base, _globe));
}
示例4: viewMouseOver
/**
* Displays the name of the facility the mouse is over.
* @param action Pointer to an action.
*/
void BasescapeState::viewMouseOver(Action *action)
{
BaseFacility *f = _view->getSelectedFacility();
if (f == 0)
_txtFacility->setText(L"");
else
_txtFacility->setText(_game->getLanguage()->getString(f->getRules()->getType()));
}
示例5: BaseFacility
/**
* Processes clicking on facilities.
* @param action Pointer to an action.
*/
void PlaceLiftState::viewClick(Action *)
{
BaseFacility *fac = new BaseFacility(_game->getRuleset()->getBaseFacility("STR_ACCESS_LIFT"), _base);
fac->setX(_view->getGridX());
fac->setY(_view->getGridY());
_base->getFacilities()->push_back(fac);
_game->popState();
BasescapeState *bState = new BasescapeState(_game, _base, _globe);
_game->pushState(bState);
if (_first)
{
_game->pushState(new SelectStartFacilityState(_game, _base, bState, _globe));
}
}
示例6: viewLeftClick
/**
* Processes clicking on facilities.
* @param action Pointer to an action.
*/
void BasescapeState::viewLeftClick(Action *)
{
BaseFacility *fac = _view->getSelectedFacility();
if (fac != 0)
{
// Is facility in use?
if (fac->inUse())
{
_game->pushState(new ErrorMessageState(_game, "STR_FACILITY_IN_USE", Palette::blockOffset(15)+1, "BACK13.SCR", 6));
}
// Would base become disconnected?
else if (!_base->getDisconnectedFacilities(fac).empty())
{
_game->pushState(new ErrorMessageState(_game, "STR_CANNOT_DISMANTLE_FACILITY", Palette::blockOffset(15)+1, "BACK13.SCR", 6));
}
else
{
_game->pushState(new DismantleFacilityState(_game, _base, _view, fac));
}
}
}
示例7: viewLeftClick
/**
* Processes clicking on facilities.
* @param action Pointer to an action.
*/
void BasescapeState::viewLeftClick(Action *)
{
BaseFacility *fac = _view->getSelectedFacility();
if (fac != 0)
{
// Is facility in use?
if (fac->inUse())
{
_game->pushState(new ErrorMessageState(tr("STR_FACILITY_IN_USE"), _palette, _game->getMod()->getInterface("basescape")->getElement("errorMessage")->color, "BACK13.SCR", _game->getMod()->getInterface("basescape")->getElement("errorPalette")->color));
}
// Would base become disconnected?
else if (!_base->getDisconnectedFacilities(fac).empty())
{
_game->pushState(new ErrorMessageState(tr("STR_CANNOT_DISMANTLE_FACILITY"), _palette, _game->getMod()->getInterface("basescape")->getElement("errorMessage")->color, "BACK13.SCR", _game->getMod()->getInterface("basescape")->getElement("errorPalette")->color));
}
else
{
_game->pushState(new DismantleFacilityState(_base, _view, fac));
}
}
}
示例8: BasescapeErrorState
/**
* Processes clicking on facilities.
* @param action Pointer to an action.
*/
void PlaceFacilityState::viewClick(Action *action)
{
if (!_view->isPlaceable(_rule))
{
_game->popState();
_game->pushState(new BasescapeErrorState(_game, "STR_CANNOT_BUILD_HERE"));
}
else if (_game->getSavedGame()->getFunds() < _rule->getBuildCost())
{
_game->popState();
_game->pushState(new BasescapeErrorState(_game, "STR_NOT_ENOUGH_MONEY"));
}
else
{
BaseFacility *fac = new BaseFacility(_rule, _base, _view->getGridX(), _view->getGridY());
fac->setBuildTime(_rule->getBuildTime());
_base->getFacilities()->push_back(fac);
_game->getSavedGame()->setFunds(_game->getSavedGame()->getFunds() - _rule->getBuildCost());
_game->popState();
}
}
示例9: ErrorMessageState
/**
* Processes clicking on facilities.
* @param action Pointer to an action.
*/
void PlaceFacilityState::viewClick(Action *action)
{
if (!_view->isPlaceable(_rule))
{
_game->popState();
_game->pushState(new ErrorMessageState(_game, "STR_CANNOT_BUILD_HERE", Palette::blockOffset(15)+1, "BACK01.SCR", 6));
}
else if (_game->getSavedGame()->getFunds() < _rule->getBuildCost())
{
_game->popState();
_game->pushState(new ErrorMessageState(_game, "STR_NOT_ENOUGH_MONEY", Palette::blockOffset(15)+1, "BACK01.SCR", 6));
}
else
{
BaseFacility *fac = new BaseFacility(_rule, _base);
fac->setX(_view->getGridX());
fac->setY(_view->getGridY());
fac->setBuildTime(_rule->getBuildTime());
_base->getFacilities()->push_back(fac);
_game->getSavedGame()->setFunds(_game->getSavedGame()->getFunds() - _rule->getBuildCost());
_game->popState();
}
}
示例10: viewMouseOver
/**
* Displays the name of the facility the mouse is over.
* @param action Pointer to an action.
*/
void BasescapeState::viewMouseOver(Action *)
{
BaseFacility *f = _view->getSelectedFacility();
std::wostringstream ss;
if (f != 0)
{
if (f->getRules()->getCrafts() == 0 || f->getBuildTime() > 0)
{
ss << tr(f->getRules()->getType());
}
else
{
ss << tr(f->getRules()->getType());
if (f->getCraft() != 0)
{
ss << L" " << tr("STR_CRAFT_").arg(f->getCraft()->getName(_game->getLanguage()));
}
}
}
_txtFacility->setText(ss.str());
}
示例11: viewRightClick
/**
* Processes right clicking on facilities.
* @param action Pointer to an action.
*/
void BasescapeState::viewRightClick(Action *)
{
BaseFacility *f = _view->getSelectedFacility();
if (f == 0)
{
_game->pushState(new BaseInfoState(_game, _base, this));
}
else if (f->getRules()->getCrafts() > 0)
{
if (f->getCraft() == 0)
{
_game->pushState(new CraftsState(_game, _base));
}
else
for (size_t craft = 0; craft < _base->getCrafts()->size(); ++craft)
{
if (f->getCraft() == _base->getCrafts()->at(craft))
{
_game->pushState(new CraftInfoState(_game, _base, craft));
break;
}
}
}
else if (f->getRules()->getStorage() > 0)
{
_game->pushState(new SellState(_game, _base));
}
else if (f->getRules()->getPersonnel() > 0)
{
_game->pushState(new SoldiersState(_game, _base));
}
else if (f->getRules()->getPsiLaboratories() > 0 && Options::anytimePsiTraining && _base->getAvailablePsiLabs() > 0)
{
_game->pushState(new AllocatePsiTrainingState(_game, _base));
}
else if (f->getRules()->getLaboratories() > 0)
{
_game->pushState(new ResearchState(_game, _base));
}
else if (f->getRules()->getWorkshops() > 0)
{
_game->pushState(new ManufactureState(_game, _base));
}
else if (f->getRules()->getAliens() > 0)
{
_game->pushState(new ManageAlienContainmentState(_game, _base, OPT_GEOSCAPE));
}
else if (f->getRules()->isLift() || f->getRules()->getRadarRange() > 0)
{
_game->popState();
}
}
示例12: BaseFacility
/**
* Loads the base from a YAML file.
* @param node YAML node.
* @param save Pointer to saved game.
*/
void Base::load(const YAML::Node &node, SavedGame *save, bool newGame, bool newBattleGame)
{
Target::load(node);
_name = Language::utf8ToWstr(node["name"].as<std::string>(""));
if (!newGame || !Options::getBool("customInitialBase") || newBattleGame)
{
for (YAML::const_iterator i = node["facilities"].begin(); i != node["facilities"].end(); ++i)
{
std::string type = (*i)["type"].as<std::string>();
BaseFacility *f = new BaseFacility(_rule->getBaseFacility(type), this);
f->load(*i);
_facilities.push_back(f);
}
}
for (YAML::const_iterator i = node["crafts"].begin(); i != node["crafts"].end(); ++i)
{
std::string type = (*i)["type"].as<std::string>();
Craft *c = new Craft(_rule->getCraft(type), this);
c->load(*i, _rule, save);
_crafts.push_back(c);
}
for (YAML::const_iterator i = node["soldiers"].begin(); i != node["soldiers"].end(); ++i)
{
Soldier *s = new Soldier(_rule->getSoldier("XCOM"), _rule->getArmor("STR_NONE_UC"));
s->load(*i, _rule);
if (const YAML::Node &craft = (*i)["craft"])
{
std::string type = craft["type"].as<std::string>();
int id = craft["id"].as<int>();
for (std::vector<Craft*>::iterator j = _crafts.begin(); j != _crafts.end(); ++j)
{
if ((*j)->getRules()->getType() == type && (*j)->getId() == id)
{
s->setCraft(*j);
break;
}
}
}
else
{
s->setCraft(0);
}
_soldiers.push_back(s);
}
_items->load(node["items"]);
// Some old saves have bad items, better get rid of them to avoid further bugs
for (std::map<std::string, int>::iterator i = _items->getContents()->begin(); i != _items->getContents()->end();)
{
if (std::find(_rule->getItemsList().begin(), _rule->getItemsList().end(), i->first) == _rule->getItemsList().end())
{
_items->getContents()->erase(i++);
}
else
{
++i;
}
}
_scientists = node["scientists"].as<int>(_scientists);
_engineers = node["engineers"].as<int>(_engineers);
_inBattlescape = node["inBattlescape"].as<bool>(_inBattlescape);
for (YAML::const_iterator i = node["transfers"].begin(); i != node["transfers"].end(); ++i)
{
int hours = (*i)["hours"].as<int>();
Transfer *t = new Transfer(hours);
t->load(*i, this, _rule);
_transfers.push_back(t);
}
for (YAML::const_iterator i = node["research"].begin(); i != node["research"].end(); ++i)
{
std::string research = (*i)["project"].as<std::string>();
ResearchProject *r = new ResearchProject(_rule->getResearch(research));
r->load(*i);
_research.push_back(r);
}
for (YAML::const_iterator i = node["productions"].begin(); i != node["productions"].end(); ++i)
{
std::string item = (*i)["item"].as<std::string>();
Production *p = new Production(_rule->getManufacture(item), 0);
p->load(*i);
_productions.push_back(p);
}
_retaliationTarget = node["retaliationTarget"].as<bool>(_retaliationTarget);
}