本文整理汇总了C++中CShipClass::FindDeviceSlotDesc方法的典型用法代码示例。如果您正苦于以下问题:C++ CShipClass::FindDeviceSlotDesc方法的具体用法?C++ CShipClass::FindDeviceSlotDesc怎么用?C++ CShipClass::FindDeviceSlotDesc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CShipClass
的用法示例。
在下文中一共展示了CShipClass::FindDeviceSlotDesc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetRegionsFromWeapons
void CGSelectorArea::SetRegionsFromWeapons (CSpaceObject *pSource)
// SetRegionsFromWeapons
//
// Creates regions based on installed weapons.
{
int i;
ASSERT(pSource);
if (pSource == NULL)
return;
CShip *pShip = pSource->AsShip();
if (pShip == NULL)
return;
CShipClass *pClass = pShip->GetClass();
// Keep track of layouts that have already been used.
TArray<bool> SlotStatus;
SlotStatus.InsertEmpty(MISC_DEVICES_LAYOUT_COUNT);
for (i = 0; i < MISC_DEVICES_LAYOUT_COUNT; i++)
SlotStatus[i] = true;
// If we don't have a launcher, we place the launcher slot first because we
// want it to take precedence (position-wise).
int iIndex;
bool bHasLauncher = (pShip->GetNamedDevice(devMissileWeapon) != NULL);
if (!bHasLauncher)
{
// See if we can figure out the proper position for the launcher based
// on the class slots
CVector vLauncherPos;
SDeviceDesc DeviceDesc;
if (pClass->FindDeviceSlotDesc(devMissileWeapon, &DeviceDesc))
vLauncherPos = pClass->GetPosOffset(DeviceDesc.iPosAngle, DeviceDesc.iPosRadius, DeviceDesc.iPosZ, DeviceDesc.b3DPosition);
// Find a layout
if (FindLayoutForPos(vLauncherPos, SlotStatus, &iIndex))
{
const SLayoutDesc *pLayout = &g_MiscDevicesLayout[iIndex];
SEntry *pEntry = m_Regions.Insert();
pEntry->iType = typeEmptySlot;
pEntry->iSlotType = devMissileWeapon;
pEntry->iSlotPosIndex = iIndex;
pEntry->rcRect.left = pLayout->xLeft;
pEntry->rcRect.top = pLayout->yTop;
pEntry->rcRect.right = pEntry->rcRect.left + ITEM_ENTRY_WIDTH;
pEntry->rcRect.bottom = pEntry->rcRect.top + ITEM_ENTRY_HEIGHT;
SlotStatus[iIndex] = false;
}
}
// Create a region for each weapon.
for (i = 0; i < pShip->GetDeviceCount(); i++)
{
CInstalledDevice *pDevice = pShip->GetDevice(i);
if (pDevice->IsEmpty()
|| (pDevice->GetCategory() != itemcatWeapon
&& pDevice->GetCategory() != itemcatLauncher))
continue;
if (pDevice->GetCategory() == itemcatLauncher)
bHasLauncher = true;
// If the device already has a position index, then use that (assuming
// it's free).
iIndex = pDevice->GetSlotPosIndex();
if (iIndex < 0 || iIndex >= SlotStatus.GetCount() || !SlotStatus[iIndex])
iIndex = -1;
// If we don't have an assigned slot, figure it out.
if (iIndex == -1)
{
if (!FindLayoutForPos(pDevice->GetPosOffset(pShip), SlotStatus, &iIndex))
continue;
// Remember so we stay in this location.
pDevice->SetSlotPosIndex(iIndex);
}
// Create the region
const SLayoutDesc *pLayout = &g_MiscDevicesLayout[iIndex];
SEntry *pEntry = m_Regions.Insert();
pEntry->iType = typeInstalledItem;
pEntry->pItemCtx = new CItemCtx(pShip, pDevice);
//.........这里部分代码省略.........