Files
integration/Source/Integration/AssetLookup.h

87 lines
2.8 KiB
C
Raw Normal View History

////////////////////////////////////////////////////////////
//
// AssetLookup.h
//
// Provides asset loading by short name. At
// initialization, scans asset directories and builds
// a lookup table mapping (class, short name) pairs
// to full asset paths. Blueprint-callable functions
// let blueprints load assets by short name.
//
////////////////////////////////////////////////////////////
#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
2026-02-25 14:48:14 -05:00
#include "Subsystems/GameInstanceSubsystem.h"
2025-11-14 02:41:44 -05:00
#include "Templates/Tuple.h"
2026-02-25 14:48:14 -05:00
#include "Common.h"
#include "AssetLookup.generated.h"
2025-04-07 16:48:27 -04:00
class AActor;
class UUserWidget;
class UlxLookAtWidget;
class UStaticMesh;
2026-02-09 13:54:00 -05:00
class USkeletalMesh;
2025-11-14 02:41:44 -05:00
class UAnimSequence;
2025-04-07 16:48:27 -04:00
////////////////////////////////////////////////////////////
//
// UlxAssetLookup
//
////////////////////////////////////////////////////////////
UCLASS(MinimalAPI)
2026-02-25 14:48:14 -05:00
class UlxAssetLookup : public UGameInstanceSubsystem
{
GENERATED_BODY()
2026-02-25 14:48:14 -05:00
public:
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
private:
TMap<TTuple<FString, FName>, FString> AssetPaths;
2025-04-07 16:48:27 -04:00
private:
void AddAssets(const TCHAR *Path, UClass *Class, const TCHAR *NamePrefix);
static void ReportFailedLoad(const FString &ClassName, const FString &Name, const FString &Reason);
static UObject *LoadAsset(const UObject *Context, UClass *Class, UClass *ChildOf, const FString &Name);
2025-11-14 02:41:44 -05:00
public:
void RebuildIndex();
// Get a static mesh by name.
//
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context", ExpandEnumAsExecs="ReturnValue"), Category = "Luprex|Asset Loading")
static ElxValidOrNotValid LoadStaticMeshAsset(
UStaticMesh *&Result, const UObject *Context, const FString &Name);
// Get a skeletal mesh by name.
//
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context", ExpandEnumAsExecs="ReturnValue"), Category = "Luprex|Asset Loading")
static ElxValidOrNotValid LoadSkeletalMeshAsset(
USkeletalMesh *&Result, const UObject *Context, const FString &Name);
// Get an animation sequence by name.
//
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context", ExpandEnumAsExecs="ReturnValue"), Category = "Luprex|Asset Loading")
static ElxValidOrNotValid LoadAnimSequenceAsset(
UAnimSequence *&Result, const UObject *Context, const FString &Name);
// Get a tangible class by name.
//
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context", ExpandEnumAsExecs="ReturnValue"), Category = "Luprex|Asset Loading")
static ElxValidOrNotValid LoadTangibleBlueprintAsset(
TSubclassOf<AActor> &Result, const UObject *Context, const FString &Name);
// Get a widget blueprint by name.
//
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context", ExpandEnumAsExecs="ReturnValue"), Category = "Luprex|Asset Loading")
static ElxValidOrNotValid LoadUserWidgetAsset(
TSubclassOf<UUserWidget> &Result, const UObject *Context, const FString &Name);
};