FPrimaryAssetManager
The Asset Manager (UE's UAssetManager, ROADMAP §23.3): which assets are primary — the roots a game loads by id and a cook starts from — and the rules that hang off them, chunk and cook rule. Configured the UE way, in DefaultGame.ini:
- Module
- AssetSystem
- Header
#include "AssetSystem/PrimaryAssetManager.h"- Namespace
Mowo
[/Script/Mowo.AssetManagerSettings] +PrimaryAssetTypesToScan=(PrimaryAssetType="Map",AssetClass="World",Directories=("Content/Maps"),Rules=(ChunkId=1,CookRule=AlwaysCook))
A primary asset's chunk spreads over its hard dependencies (soft ones load on demand and may live anywhere); an asset two chunks reach goes to the lower one, the rule the cook's chunk split already applies.
Properties
| Type | Name | Description |
|---|---|---|
static constexpr const char* | SettingsSection | Default "/Script/Mowo.AssetManagerSettings". |
static constexpr const char* | ChunkManifestFile | Default "Chunks.ini". |
static constexpr const char* | LegacyChunkManifestFile | Default "Chunks.mdf". |
static constexpr const char* | ChunkManifestHeader | Default "; Generated from DefaultGame.ini". |
static constexpr const char* | BundleTagPrefix | Bundles come from two places: a package's registry tags bundle.<Name> (';'-separated paths, written with the asset) and +PrimaryAssetBundles=(PrimaryAssetId="Map:Rooftop",BundleName="UI",Assets=("Content/UI/HUD.ui")) rows in the settings section, for assets that are not packages yet. Default "bundle.". |
Public functions
| Returns | Name | Description |
|---|---|---|
bool | ParseStruct | UE's struct spelling, "(Key=Value,Key=(Nested),Key="Text")", into its top-level fields; nested parentheses and quotes are kept whole. |
std::vector<std::string> | ParseList | A parenthesised list, "(a,"b",(c))", into its elements, unquoted. |
const char* | CookRuleName | |
EPrimaryAssetCookRule | CookRuleFromString | |
uint32_t | LoadSettings | Reads every PrimaryAssetTypesToScan row of the settings section. |
void | AddType | |
const std::vector<FPrimaryAssetTypeInfo>& | GetTypes | |
uint32_t | Scan | Finds every registry entry a type claims. |
std::vector<FPrimaryAssetId> | GetPrimaryAssetIdList | |
const FPrimaryAssetData* | Find | |
std::map<uint64_t, int32_t> | ComputeChunkAssignment | UUID value -> chunk, for every primary asset with a chunk and everything it hard-references. |
std::string | BuildChunkManifest | Config/Chunks.ini text the cook reads: World primaries as +Scenes=, the directories of every other chunked type as +Dirs=, under the generator's header line: ; Generated from DefaultGame.ini [...] — edit the primary asset rules, not this file. |
bool | IsGeneratedChunkManifest | Whether the generator may replace a manifest whose first line is this: its own header, in the INI or the legacy MDF spelling. |
bool | ConvertLegacyChunkManifest | The legacy Chunks.mdf (Chunk "N" { scene: dir: plugin: budget_mb: }) as Chunks.ini text. |
std::filesystem::path | ResolveChunkManifest | <configDir>/Chunks.ini, after converting a legacy Chunks.mdf beside it (the original moves to Saved/MigratedSources/Config). |
std::vector<std::string> | GetCookPaths | The paths of the primary assets with exactly this cook rule — what a cook must include (AlwaysCook) or leave out (NeverCook). |
std::string | BuildCookRules | The rules as the cook reads them (mbt cook / mbt package shell MowoGame --primary-assets= --cook-rules-out=), one per line: never <path> leave the asset out even though Content/ holds it always <path> ship it even though no cooked level references it AlwaysCook and DevelopmentAlwaysCook primaries are always with every bundle asset; a NeverCook primary is never, its bundles untouched (a bundle may be shared with a primary that does ship). |
std::vector<std::string> | GetBundlePaths | |
std::vector<UUID> | CollectLoadSet | What LoadPrimaryAsset loads: the primary asset and every asset of the named bundles, as registry ids. |
void | LoadPrimaryAsset | UE's LoadPrimaryAsset: every id of CollectLoadSet through the runtime asset manager's async path; onDone runs on the main thread once each has called back, true when all of them loaded. |
Function details
ParseStruct
static bool ParseStruct(const std::string& text, std::vector<std::pair<std::string, std::string>>& out)UE's struct spelling, "(Key=Value,Key=(Nested),Key="Text")", into its top-level fields; nested parentheses and quotes are kept whole.
ParseList
static std::vector<std::string> ParseList(const std::string& text)A parenthesised list, "(a,"b",(c))", into its elements, unquoted.
CookRuleName
static const char* CookRuleName(EPrimaryAssetCookRule rule)CookRuleFromString
static EPrimaryAssetCookRule CookRuleFromString(const std::string& text)LoadSettings
uint32_t LoadSettings(const FConfigIniFile& gameIni, std::vector<std::string>* errors = nullptr)Reads every PrimaryAssetTypesToScan row of the settings section. Returns how many types were added; a malformed row is skipped and named in errors.
AddType
void AddType(const FPrimaryAssetTypeInfo& type)GetTypes
const std::vector<FPrimaryAssetTypeInfo>& GetTypes() constScan
uint32_t Scan(const AssetRegistry& registry, std::vector<std::string>* errors = nullptr)Finds every registry entry a type claims. A name two assets of one type would share keeps the first by path and reports the second.
GetPrimaryAssetIdList
std::vector<FPrimaryAssetId> GetPrimaryAssetIdList(const std::string& type) constFind
const FPrimaryAssetData* Find(const FPrimaryAssetId& id) constComputeChunkAssignment
std::map<uint64_t, int32_t> ComputeChunkAssignment(const AssetRegistry& registry) constUUID value -> chunk, for every primary asset with a chunk and everything it hard-references.
BuildChunkManifest
std::string BuildChunkManifest() constConfig/Chunks.ini text the cook reads: World primaries as +Scenes=, the directories of every other chunked type as +Dirs=, under the generator's header line: ; Generated from DefaultGame.ini [...] — edit the primary asset rules, not this file. [Chunk 1] +Scenes=Content/Maps/Expansion.mmap +Dirs=Content/Weapons A hand-written manifest adds +Plugins= and BudgetMB=.
IsGeneratedChunkManifest
static bool IsGeneratedChunkManifest(const std::string& firstLine)Whether the generator may replace a manifest whose first line is this: its own header, in the INI or the legacy MDF spelling. Anything else was written by a person.
ConvertLegacyChunkManifest
static bool ConvertLegacyChunkManifest(const std::string& legacyText, std::string& outIni, std::string* error = nullptr)The legacy Chunks.mdf (Chunk "N" { scene: dir: plugin: budget_mb: }) as Chunks.ini text. Read line by line, not through MdfDocument: one chunk repeats a key, and a document node holds a key once.
ResolveChunkManifest
static std::filesystem::path ResolveChunkManifest(const std::filesystem::path& projectConfigDir)<configDir>/Chunks.ini, after converting a legacy Chunks.mdf beside it (the original moves to Saved/MigratedSources/Config). The cook reads either; the editor and --write-chunks convert before they write.
GetCookPaths
std::vector<std::string> GetCookPaths(EPrimaryAssetCookRule rule) constThe paths of the primary assets with exactly this cook rule — what a cook must include (AlwaysCook) or leave out (NeverCook).
BuildCookRules
std::string BuildCookRules() constThe rules as the cook reads them (mbt cook / mbt package shell MowoGame --primary-assets= --cook-rules-out=), one per line: never <path> leave the asset out even though Content/ holds it always <path> ship it even though no cooked level references it AlwaysCook and DevelopmentAlwaysCook primaries are always with every bundle asset; a NeverCook primary is never, its bundles untouched (a bundle may be shared with a primary that does ship).
GetBundlePaths
std::vector<std::string> GetBundlePaths(const FPrimaryAssetId& id, const std::string& bundle) constCollectLoadSet
std::vector<UUID> CollectLoadSet(const FPrimaryAssetId& id, const std::vector<std::string>& bundles, const AssetRegistry& registry, std::vector<std::string>* missing = nullptr) constWhat LoadPrimaryAsset loads: the primary asset and every asset of the named bundles, as registry ids. A bundle path the registry does not know is reported in missing rather than skipped silently.
LoadPrimaryAsset
void LoadPrimaryAsset(const FPrimaryAssetId& id, const std::vector<std::string>& bundles, RuntimeAssetManager& assets, std::function<void(bool)> onDone) constUE's LoadPrimaryAsset: every id of CollectLoadSet through the runtime asset manager's async path; onDone runs on the main thread once each has called back, true when all of them loaded.