feat: RP asset functions

This commit is contained in:
2024-10-27 19:49:15 +01:00
parent b4e8796e74
commit 86362e2658
9 changed files with 281 additions and 79 deletions

View File

@@ -17,7 +17,42 @@
#include "RRDADataAssetSubsystem.generated.h"
class IAssetRegistry;
// We need this otherwise some of the cache will GC'd
USTRUCT(BlueprintType)
struct FRRDADataHolderTurbineData
{
GENERATED_BODY()
UPROPERTY(BlueprintReadOnly)
TMap<TSubclassOf<UFGItemDescriptor>, URRDATurbineDataAsset*> Data;
};
USTRUCT(BlueprintType)
struct FRRDADataHolderBoilerData
{
GENERATED_BODY()
UPROPERTY(BlueprintReadOnly)
TMap<TSubclassOf<UFGItemDescriptor>, URRDABoilerDataAsset*> Data;
};
USTRUCT(BlueprintType)
struct FRRDADataHolderCoolerData
{
GENERATED_BODY()
UPROPERTY(BlueprintReadOnly)
TMap<TSubclassOf<UFGItemDescriptor>, URRDACoolerDataAsset*> Data;
};
USTRUCT(BlueprintType)
struct FRRDADataHolderHeaterData
{
GENERATED_BODY()
UPROPERTY(BlueprintReadOnly)
TMap<TSubclassOf<UFGItemDescriptor>, URRDAHeaterDataAsset*> Data;
};
UCLASS()
class REFINEDRDAPI_API URRDADataAssetSubsystem : public UGameInstanceSubsystem
@@ -88,6 +123,42 @@ public:
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
TArray<URRDACoolerDataAsset*> GetAllCoolerAssets(ERRDACoolerType Type) const;
// Generator Functions
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
URRDAGeneratorDataAsset* GetGeneratorItemData(int32 Tier) const;
// Boiler Functions
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
bool GetAllBoilerItems(TArray<TSubclassOf<UFGItemDescriptor>>& Items, int32 Tier) const;
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
URRDABoilerDataAsset* GetBoilerItemData(TSubclassOf<UFGItemDescriptor>Item, int32 Tier) const;
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
bool GetAllBoilerRelevantItems(TArray<TSubclassOf<UFGItemDescriptor>>& Items, int32 Tier) const;
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
URRDABoilerDataAsset* GetDefaultBoilerAsset(int32 Tier) const;
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
TArray<URRDABoilerDataAsset*> GetAllBoilerAssets(int32 Tier) const;
// Heater Functions
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
bool GetAllHeaterItems(TArray<TSubclassOf<UFGItemDescriptor>>& Items, ERRDAHeaterType Type) const;
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
URRDAHeaterDataAsset* GetHeaterItemData(TSubclassOf<UFGItemDescriptor>Item, ERRDAHeaterType Type) const;
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
bool GetAllHeaterRelevantItems(TArray<TSubclassOf<UFGItemDescriptor>>& Items, ERRDAHeaterType Type) const;
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
URRDAHeaterDataAsset* GetDefaultHeaterAsset(ERRDAHeaterType Type) const;
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
TArray<URRDAHeaterDataAsset*> GetAllHeaterAssets(ERRDAHeaterType Type) const;
public:
/**
* Find all data assets of a specific class
@@ -97,23 +168,29 @@ public:
template<class T>
bool FindAllDataAssetsOfClass(TSet<T*>& OutDataAssets);
private:
UPROPERTY()
public:
UPROPERTY(BlueprintReadOnly, Category = "RRDA|DataAsset")
TMap<TSubclassOf<UFGItemDescriptor>, URRDADirtDataAsset*> mDirtAssets;
UPROPERTY()
UPROPERTY(BlueprintReadOnly, Category = "RRDA|DataAsset")
TMap<int32, URRDAGeneratorDataAsset*> mGeneratorAssets;
TMap<int32, TMap<TSubclassOf<UFGItemDescriptor>, URRDATurbineDataAsset*>> mTurbineAssets;
TMap<int32, TMap<TSubclassOf<UFGItemDescriptor>, URRDABoilerDataAsset*>> mBoilerAssets;
TMap<ERRDACoolerType, TMap<TSubclassOf<UFGItemDescriptor>, URRDACoolerDataAsset*>> mCoolerAssets;
TMap<ERRDAHeaterType, TMap<TSubclassOf<UFGItemDescriptor>, URRDAHeaterDataAsset*>> mHeaterAssets;
UPROPERTY(BlueprintReadOnly, Category = "RRDA|DataAsset")
TMap<int32, FRRDADataHolderTurbineData> mTurbineAssets;
UPROPERTY(BlueprintReadOnly, Category = "RRDA|DataAsset")
TMap<int32, FRRDADataHolderBoilerData> mBoilerAssets;
UPROPERTY(BlueprintReadOnly, Category = "RRDA|DataAsset")
TMap<ERRDACoolerType, FRRDADataHolderCoolerData> mCoolerAssets;
UPROPERTY(BlueprintReadOnly, Category = "RRDA|DataAsset")
TMap<ERRDAHeaterType, FRRDADataHolderHeaterData> mHeaterAssets;
public:
UPROPERTY(BlueprintReadOnly, Transient, Category = "RRDA|DataAsset")
UPROPERTY(BlueprintReadOnly, Category = "RRDA|DataAsset")
TSet<URRDADataAssetBase*> mDisabledDataAssets;
UPROPERTY(BlueprintReadOnly, Transient, Category = "RRDA|DataAsset")
UPROPERTY(BlueprintReadOnly, Category = "RRDA|DataAsset")
TSet<URRDADataAssetBase*> mEnabledDataAssets;
};
@@ -155,5 +232,6 @@ bool URRDADataAssetSubsystem::FindAllDataAssetsOfClass(TSet<T*>& OutDataAssets)
}
}
UE_LOG(LogRRDApi, Warning, TEXT("Found %d of: %s"), OutDataAssets.Num(), *T::StaticClass()->GetPathName());
return OutDataAssets.Num() > 0;
}