本文整理汇总了C++中CUnit::HasInventory方法的典型用法代码示例。如果您正苦于以下问题:C++ CUnit::HasInventory方法的具体用法?C++ CUnit::HasInventory怎么用?C++ CUnit::HasInventory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUnit
的用法示例。
在下文中一共展示了CUnit::HasInventory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawUnitInfo
/**
** Draw the unit info into top-panel.
**
** @param unit Pointer to unit.
*/
static void DrawUnitInfo(CUnit &unit)
{
UpdateUnitVariables(unit);
for (size_t i = 0; i != UI.InfoPanelContents.size(); ++i) {
if (CanShowContent(UI.InfoPanelContents[i]->Condition, unit)) {
for (std::vector<CContentType *>::const_iterator content = UI.InfoPanelContents[i]->Contents.begin();
content != UI.InfoPanelContents[i]->Contents.end(); ++content) {
if (CanShowContent((*content)->Condition, unit)) {
(*content)->Draw(unit, UI.InfoPanelContents[i]->DefaultFont);
}
}
}
}
const CUnitType &type = *unit.Type;
Assert(&type);
// Draw IconUnit
DrawUnitInfo_portrait(unit);
//Wyrmgus start
// if (unit.Player != ThisPlayer && !ThisPlayer->IsAllied(*unit.Player)) {
if (unit.Player != ThisPlayer && !ThisPlayer->IsAllied(*unit.Player) && unit.Player->Type != PlayerNeutral) {
//Wyrmgus end
return;
}
// Show progress if they are selected.
if (IsOnlySelected(unit)) {
if (DrawUnitInfo_single_selection(unit)) {
return;
}
}
// Transporting units.
if (type.CanTransport() && unit.BoardCount && CurrentButtonLevel == unit.Type->ButtonLevelForTransporter) {
DrawUnitInfo_transporter(unit);
return;
}
//Wyrmgus start
if (unit.HasInventory() && unit.InsideCount && CurrentButtonLevel == unit.Type->ButtonLevelForInventory) {
DrawUnitInfo_inventory(unit);
return;
}
//Wyrmgus end
}
示例2: PickUpItem
/**
** PickUpItem
**
** @return true if the unit picks up an item, false otherwise
*/
static bool PickUpItem(CUnit &unit)
{
if (
!unit.Type->BoolFlag[ORGANIC_INDEX].value
|| !unit.Player->AiEnabled
) {
return false;
}
if (unit.Variable[HP_INDEX].Value == unit.GetModifiedVariable(HP_INDEX, VariableMax) && !unit.HasInventory()) { //only look for items to pick up if the unit is damaged or has an inventory
return false;
}
// look for nearby items to pick up
std::vector<CUnit *> table;
SelectAroundUnit(unit, unit.GetReactionRange(), table);
for (size_t i = 0; i != table.size(); ++i) {
if (!table[i]->Removed) {
if (CanPickUp(unit, *table[i])) {
if (table[i]->Variable[HITPOINTHEALING_INDEX].Value > 0 && (unit.GetModifiedVariable(HP_INDEX, VariableMax) - unit.Variable[HP_INDEX].Value) > 0) {
if (UnitReachable(unit, *table[i], 1, unit.GetReactionRange() * 8)) {
CommandPickUp(unit, *table[i], FlushCommands);
return true;
}
}
}
}
}
return false;
}