CARLA
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
UCarlaContentPackManager Class Reference

Mounts CARLA content packs (content-only Unreal plugins cooked as DLC against a base release, wrapped with a carla-pack.json manifest) into the running process, editor or cooked game alike. More...

#include <ContentPackManager.h>

+ Inheritance diagram for UCarlaContentPackManager:

Public Member Functions

virtual void Deinitialize () override
 
void Discover ()
 Mount every pack found in <ProjectDir>/Packs/*‍/carla-pack.json, the directories listed in -carla-packs=<dir>[;<dir>] and $CARLA_PACKS, and adopt every plugin the engine already mounted at startup that carries a carla-pack.json next to its .uplugin (drop-in under Plugins/).
 
FString FindMapPackage (const FString &MapName) const
 Long package name of a map declared by a mounted pack, or empty.
 
const FCarlaContentPack * FindPack (const FString &Name) const
 
TArray< FString > GetPackContentDirs () const
 Content dirs of all mounted packs, in mount order.
 
TArray< FString > GetPackMapNames () const
 Map names declared by all mounted packs.
 
const TArray< FCarlaContentPack > & GetPacks () const
 
virtual void Initialize (FSubsystemCollectionBase &Collection) override
 
bool Mount (const FString &Path, FString &OutError, const FCarlaContentPack **OutPack=nullptr)
 Mount a pack.
 
bool Unmount (const FString &Name, FString &OutError)
 Unmount a pack by name.
 

Static Public Member Functions

static TArray< FString > FindPackCatalogFiles (const FString &RelativeName)
 <ContentDir>/Config/<RelativeName> of every mounted pack where the file exists, in mount order (later packs override earlier ones by id).
 
static UCarlaContentPackManager * Get ()
 
static FString GetBaseReleaseStamp ()
 Base release stamp of this binary (<ProjectDir>/BaseRelease), empty in editor/dev builds.
 
template<typename T , typename KeyFn >
static void MergeCatalog (TArray< T > &Into, const TArray< T > &From, KeyFn Key)
 Merge catalog entries: an entry whose key already exists replaces it in place (later files override by id), new keys are appended.
 

Public Attributes

FCarlaContentPackEvent OnPackMounted
 
FCarlaContentPackEvent OnPackUnmounted
 

Private Member Functions

bool ArePackObjectsAlive (const FCarlaContentPack &Pack, FString &OutReason)
 Objects under "/<Pack>/" survive a garbage collection (GC only runs when something from the pack was loaded at all).
 
bool CheckCompatibility (const FCarlaContentPackManifest &Manifest, FString &OutError) const
 
TArray< FString > GetDiscoveryDirs () const
 
bool IsPackInUse (const FCarlaContentPack &Pack, FString &OutReason) const
 The pack map or one of its levels is loaded in some world (no GC).
 
bool MountPaks (FCarlaContentPack &Pack, FString &OutError)
 
bool MountPlugin (FCarlaContentPack &Pack, FString &OutError)
 
void RegisterAssetRegistry (FCarlaContentPack &Pack)
 
void UnmountPaks (FCarlaContentPack &Pack)
 

Private Attributes

bool bDiscovered = false
 
TArray< FCarlaContentPack > Packs
 

Detailed Description

Mounts CARLA content packs (content-only Unreal plugins cooked as DLC against a base release, wrapped with a carla-pack.json manifest) into the running process, editor or cooked game alike.

Implemented as a UEngineSubsystem: it outlives game instances and worlds, so packs survive load_world, and it exists before the first map loads. Auto-discovery runs from Initialize() in game processes (packaged binary or editor -game); FCarlaEngine::NotifyInitGame calls Discover() again as a no-op safety net so the RPC server never starts before the packs are in. The full editor and commandlets (the cooker) do not auto-mount packs.

Definition at line 60 of file ContentPackManager.h.

Member Function Documentation

◆ ArePackObjectsAlive()

bool UCarlaContentPackManager::ArePackObjectsAlive ( const FCarlaContentPack &  Pack,
FString &  OutReason 
)
private

Objects under "/<Pack>/" survive a garbage collection (GC only runs when something from the pack was loaded at all).

Definition at line 774 of file ContentPackManager.cpp.

References UCarlaContentPackManager_LoadedPackages(), and UCarlaContentPackManager_PackagePrefixes().

Referenced by Unmount().

◆ CheckCompatibility()

bool UCarlaContentPackManager::CheckCompatibility ( const FCarlaContentPackManifest &  Manifest,
FString &  OutError 
) const
private

◆ Deinitialize()

void UCarlaContentPackManager::Deinitialize ( )
overridevirtual

Definition at line 62 of file ContentPackManager.cpp.

◆ Discover()

void UCarlaContentPackManager::Discover ( )

Mount every pack found in <ProjectDir>/Packs/*‍/carla-pack.json, the directories listed in -carla-packs=<dir>[;<dir>] and $CARLA_PACKS, and adopt every plugin the engine already mounted at startup that carries a carla-pack.json next to its .uplugin (drop-in under Plugins/).

Idempotent; failures are logged, not fatal.

Definition at line 108 of file ContentPackManager.cpp.

References bDiscovered, CARLA_PACK_MANIFEST_NAME, FindPack(), GetBaseReleaseStamp(), GetDiscoveryDirs(), FCarlaContentPackManifest::LoadFromFile(), Mount(), and FCarlaContentPackManifest::Name.

Referenced by Initialize().

◆ FindMapPackage()

FString UCarlaContentPackManager::FindMapPackage ( const FString &  MapName) const

Long package name of a map declared by a mounted pack, or empty.

Definition at line 195 of file ContentPackManager.cpp.

References Packs.

◆ FindPack()

const FCarlaContentPack * UCarlaContentPackManager::FindPack ( const FString &  Name) const

Definition at line 183 of file ContentPackManager.cpp.

References Packs.

Referenced by FCarlaServer::FPimpl::BindActions(), and Discover().

◆ FindPackCatalogFiles()

TArray< FString > UCarlaContentPackManager::FindPackCatalogFiles ( const FString &  RelativeName)
static

<ContentDir>/Config/<RelativeName> of every mounted pack where the file exists, in mount order (later packs override earlier ones by id).

Definition at line 243 of file ContentPackManager.cpp.

References Get(), and GetPackContentDirs().

Referenced by ABlueprintActorFactory::GetDefinitions(), APropActorFactory::GetDefinitions(), AVehicleActorFactory::GetDefinitions(), and AWalkerActorFactory::GetDefinitions().

◆ Get()

UCarlaContentPackManager * UCarlaContentPackManager::Get ( )
static

◆ GetBaseReleaseStamp()

FString UCarlaContentPackManager::GetBaseReleaseStamp ( )
static

Base release stamp of this binary (<ProjectDir>/BaseRelease), empty in editor/dev builds.

Definition at line 262 of file ContentPackManager.cpp.

Referenced by CheckCompatibility(), and Discover().

◆ GetDiscoveryDirs()

TArray< FString > UCarlaContentPackManager::GetDiscoveryDirs ( ) const
private

Definition at line 71 of file ContentPackManager.cpp.

Referenced by Discover().

◆ GetPackContentDirs()

TArray< FString > UCarlaContentPackManager::GetPackContentDirs ( ) const

Content dirs of all mounted packs, in mount order.

Definition at line 230 of file ContentPackManager.cpp.

References Packs.

Referenced by FindPackCatalogFiles().

◆ GetPackMapNames()

TArray< FString > UCarlaContentPackManager::GetPackMapNames ( ) const

Map names declared by all mounted packs.

Definition at line 214 of file ContentPackManager.cpp.

References Packs.

◆ GetPacks()

const TArray< FCarlaContentPack > & UCarlaContentPackManager::GetPacks ( ) const
inline

Definition at line 88 of file ContentPackManager.h.

Referenced by FCarlaServer::FPimpl::BindActions().

◆ Initialize()

void UCarlaContentPackManager::Initialize ( FSubsystemCollectionBase &  Collection)
overridevirtual

Definition at line 47 of file ContentPackManager.cpp.

References Discover().

◆ IsPackInUse()

bool UCarlaContentPackManager::IsPackInUse ( const FCarlaContentPack &  Pack,
FString &  OutReason 
) const
private

The pack map or one of its levels is loaded in some world (no GC).

Definition at line 721 of file ContentPackManager.cpp.

References UCarlaContentPackManager_IsPackPackage(), and UCarlaContentPackManager_PackagePrefixes().

Referenced by Unmount().

◆ MergeCatalog()

template<typename T , typename KeyFn >
static void UCarlaContentPackManager::MergeCatalog ( TArray< T > &  Into,
const TArray< T > &  From,
KeyFn  Key 
)
inlinestatic

Merge catalog entries: an entry whose key already exists replaces it in place (later files override by id), new keys are appended.

Definition at line 108 of file ContentPackManager.h.

References Other.

Referenced by ABlueprintActorFactory::GetDefinitions(), APropActorFactory::GetDefinitions(), AVehicleActorFactory::GetDefinitions(), and AWalkerActorFactory::GetDefinitions().

◆ Mount()

bool UCarlaContentPackManager::Mount ( const FString &  Path,
FString &  OutError,
const FCarlaContentPack **  OutPack = nullptr 
)

◆ MountPaks()

bool UCarlaContentPackManager::MountPaks ( FCarlaContentPack &  Pack,
FString &  OutError 
)
private

◆ MountPlugin()

bool UCarlaContentPackManager::MountPlugin ( FCarlaContentPack &  Pack,
FString &  OutError 
)
private

◆ RegisterAssetRegistry()

void UCarlaContentPackManager::RegisterAssetRegistry ( FCarlaContentPack &  Pack)
private

Definition at line 483 of file ContentPackManager.cpp.

References FCarlaContentPack::GetName(), FCarlaContentPack::PackDir, and State.

Referenced by Mount().

◆ Unmount()

bool UCarlaContentPackManager::Unmount ( const FString &  Name,
FString &  OutError 
)

Unmount a pack by name.

Refused while a world of the pack is loaded or any object under "/<Name>/" survives a garbage collection.

Definition at line 798 of file ContentPackManager.cpp.

References ArePackObjectsAlive(), FCarlaContentPack::bEngineMounted, FCarlaContentPack::bMounted, FCarlaContentPack::GetName(), UCarlaStatics::InvalidateMapCache(), IsPackInUse(), IsValid(), OnPackUnmounted, Packs, and UnmountPaks().

Referenced by FCarlaServer::FPimpl::BindActions().

◆ UnmountPaks()

void UCarlaContentPackManager::UnmountPaks ( FCarlaContentPack &  Pack)
private

Definition at line 401 of file ContentPackManager.cpp.

References FCarlaContentPack::GetName(), and FCarlaContentPack::MountedPaks.

Referenced by Mount(), MountPaks(), and Unmount().

Member Data Documentation

◆ bDiscovered

bool UCarlaContentPackManager::bDiscovered = false
private

Definition at line 159 of file ContentPackManager.h.

Referenced by Discover().

◆ OnPackMounted

FCarlaContentPackEvent UCarlaContentPackManager::OnPackMounted

Definition at line 132 of file ContentPackManager.h.

Referenced by Mount().

◆ OnPackUnmounted

FCarlaContentPackEvent UCarlaContentPackManager::OnPackUnmounted

Definition at line 134 of file ContentPackManager.h.

Referenced by Unmount().

◆ Packs

TArray<FCarlaContentPack> UCarlaContentPackManager::Packs
private

The documentation for this class was generated from the following files: