> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Intelligent Delivery：功能與配方

> Intelligent Delivery：功能與配方

本主題說明如何使用功能和配方來改善使用者初次及後續安裝遊戲的時間。功能和配方會共同定義基礎遊戲中的內容群組，讓使用者可以在初次安裝期間新增和移除，之後也可以從殼層中新增和移除。您也可以使用執行階段 API 動態查詢功能的安裝狀態，並觸發功能的新增和移除。

功能是一個 XML 元素，會指定開發人員使用的 ID 字串屬性。它也會指定可在殼層中顯示、面向使用者且可當地語系化的顯示名稱和影像。功能會指定一或多個標籤。在安裝和更新時，系統會找出已安裝功能所參照的所有標籤，並安裝包含這些標籤的所有區塊。

配方是一個 XML 元素，會指定應安裝的功能清單。一律會有一個預設配方，而該配方包含的功能一律會被安裝。您也可以定義其他配方。如果使用者或目前主機擁有任何指定 `StoreIds` 的權利，這些配方就會在安裝時啟用，如下列程式碼所示。

```xml theme={null}
<Recipes>
    <!-- A recipe is always active if it has no child StoreId elements—the name "default" is a convention. -->
    <Recipe Id="default" IncludedFeatures="CampaignFeature;MultiPlayerFeature"/>

    <!-- This recipe is active by default, but only on Xbox Series X hardware.  -->
    <Recipe Id="default-anaconda" IncludedFeatures="HDFeature" Devices="Xbox-Anaconda"/>

    <!-- PremiumProduct recipe is active, which means PremiumFeature installs if user owns 9PXXXXXXXXXX. -->
    <Recipe Id="PremiumProduct" IncludedFeatures="PremiumFeature">
        <StoreId>9PXXXXXXXXXX</StoreId>
    </Recipe>
</Recipes>
<Features>
    <Feature Id="CampaignFeature" DisplayName="ms-resource:CampaignFeatureName" Image="campaignlogo.png" Tags="Campaign1;Campaign2"/>
    <Feature Id="MultiPlayerFeature" DisplayName="ms-resource:MultiPlayerFeatureName" Image="MPlogo.png" Tags="Multiplayer1;Multiplayer2" />
    <Feature Id="HDFeature" DisplayName="ms-resource:HDTexturesFeatureName" Image="HDlogo.png" Tags="hd"/>
    <Feature Id="PremiumFeature" DisplayName="ms-resource:PremiumFeatureName" Image="Premiumlogo.png" Tags="extras"/>
</Features>


<Chunk Id="8000" Tags="Campaign1">
<Chunk Id="8001" Tags="Campaign2">
<!-- This chunk uses the # character, so it's only installed if both the Campaign and HD features are active. -->
<Chunk Id="8001" Tags="Campaign1#hd"> 

<Chunk Id="9000" Tags="Multiplayer1">
<!-- This chunk uses the # character, so it's only installed if both the Multiplayer and HD features are active. -->
<Chunk Id="9001" Tags="Multiplayer1#hd"> 

<!-- This chunk is installed if either the Multiplayer or SinglePlayer features are active. -->
<Chunk Id="10000" Tags="Multiplayer1;Campaign1">
<!-- This chunk is installed if either the (Multiplayer feature and HD feature) or (SinglePlayer feature and HD feature) are active. -->
<Chunk Id="10001" Tags="Multiplayer1#hd;Campaign1#hd">

<Chunk Id="11000" Tags="extras">
<!-- This chunk uses the # character, so it's only installed if both the Premium and HD features are active. -->
<Chunk Id="11001" Tags="extras#hd"> 
```

<Note>功能可以包含多個標籤屬性，以分號分隔。如果區塊中的任何標籤被作用中的功能所包含，該區塊就會納入安裝。`#` 符號會在 `#` 兩側的標籤都處於作用中時安裝標籤。</Note>

## 當地語系化功能顯示名稱

`DisplayNames` 的當地語系化方式與 *MicrosoftGame.config* 檔案中名稱屬性的當地語系化方式相同。做法是使用 `ms-resource:name` 格式，搭配遊戲 strings 目錄中的 *.resw* 檔案，以及位於適當命名子目錄中的各地區設定字串。如需詳細資訊，請參閱 [MicrosoftGame.Config 當地語系化](/zh-TW/build/core-features/common/game-config/MicrosoftGameConfig-Localization)

<Note>搭配 MicrosoftGame.config 和 Intelligent Delivery 使用的當地語系化字串值和影像，在已發佈的套件中不會加密，無論是在開發人員沙箱或零售環境中皆然。請在遊戲中針對標題、圖示及任何敏感內容使用預留位置值。敏感內容包括在開發期間、遊戲公開揭露之前由 Intelligent Delivery 參照的任何內容，或遊戲中的特定內容。</Note>

## 隱藏功能

功能可標記為隱藏，這會讓使用者無法決定在安裝時或在遊戲安裝後透過殼層管理時，是否要將其顯示為可選取的選項。使用隱藏功能時請小心，因為新增或移除它們的唯一方式是使用遊戲內的 API。遊戲中發現的任何錯誤都可能導致內容無法存取，直到您提供內容更新來修正這些錯誤為止。下列程式碼是標記為隱藏之功能的範例。

```xml theme={null}
  <Feature Id="HiddenFeature" Hidden="true" Tags="HiddenFeature1" />
```

## 檢查功能安裝狀態

您可以使用功能來檢查是否存在具有該功能所指定標籤的所有區塊。執行這些執行階段查詢時，會將裝置和語言規範納入考量。如果您的功能中有裝置或語言專用的內容，只要已安裝一種語言以及該功能中適用於目前裝置的所有區塊，仍會傳回 `true`。

例如，如果 Campaign Feature 的資產包含在區塊 8000、8001 和 8002 中，您不必呼叫 [XPackageFindChunkAvailability](/zh-TW/reference/system/xpackage/functions/xpackagefindchunkavailability) 方法來判斷該組區塊是否已完整安裝且可遊玩，而是可以將這三個區塊都加上自訂標籤 "campaign1"，並在 Campaign Feature 中參照 "campaign1"。接著，您可以使用搭配 Campaign Feature ID 的 [XPackageChunkSelector](/zh-TW/reference/system/xpackage/structs/xpackagechunkselector) 呼叫 [XPackageFindChunkAvailability](/zh-TW/reference/system/xpackage/functions/xpackagefindchunkavailability) 方法，輕鬆取得該組資料的安裝狀態。

<a id="ID4EHB" />

## 參考 API 文件

* [XPackage (API 內容)](/zh-TW/reference/system/xpackage/xpackage_members)
  * 函式
    * [XPackageFindChunkAvailability](/zh-TW/reference/system/xpackage/functions/xpackagefindchunkavailability)
    * [XPackageInstallChunks](/zh-TW/reference/system/xpackage/functions/xpackageinstallchunks)
  * 結構
    * [XPackageChunkSelector](/zh-TW/reference/system/xpackage/structs/xpackagechunkselector)

## 另請參閱

[Intelligent Delivery 簡介](/zh-TW/build/core-features/common/packaging/overviews/intelligentdelivery)
[XPackageChunkSelector](/zh-TW/reference/system/xpackage/structs/xpackagechunkselector)
[XPackageInstallChunks](/zh-TW/reference/system/xpackage/functions/xpackageinstallchunks)
[MicrosoftGame.Config 當地語系化](/zh-TW/build/core-features/common/game-config/MicrosoftGameConfig-Localization)


## Related topics

- [Intelligent Delivery](/zh-CN/build/core-features/common/packaging/overviews/intelligentdelivery.md)
- [GDK 名詞與縮寫詞彙表](/zh-TW/home/glossary.md)
- [多光盘功能](/zh-CN/build/core-features/common/packaging/packaging-multi-disc.md)
- [Play Anywhere(主機 + PC)總覽](/zh-TW/paths/play-anywhere/overview.md)
- [Intelligent Delivery: device specifiers](/build/core-features/common/packaging/intelligentdelivery-device.md)
