feat: RP Data Assets
This commit is contained in:
@@ -14,15 +14,27 @@ class REFINEDRDAPI_API URRDABoilerDataAsset : public URRDADataAssetBase
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Fuel item that this heater uses
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Turbine", meta=( UIMin = "1", UIMax = "2" ))
|
||||
int32 mTier = 1;
|
||||
|
||||
/**
|
||||
* Fuel item that this heater uses
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Boiler")
|
||||
FItemAmount mItem;
|
||||
FItemAmount mInput;
|
||||
|
||||
/**
|
||||
* What this boiler produces
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Boiler")
|
||||
FItemAmount mOutputItem;
|
||||
FItemAmount mOutput;
|
||||
|
||||
/**
|
||||
* Duration for one production
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Boiler")
|
||||
float mDuration = 6.f;
|
||||
};
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "ItemAmount.h"
|
||||
#include "RRDADataAssetBase.h"
|
||||
#include "Enums/RRDARPEnums.h"
|
||||
|
||||
#include "RRDACoolerDataAsset.generated.h"
|
||||
|
||||
@@ -14,9 +15,27 @@ class REFINEDRDAPI_API URRDACoolerDataAsset : public URRDADataAssetBase
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* What type of heater this is
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Heater")
|
||||
ERRDACoolerType mType = ERRDACoolerType::Chemical;
|
||||
|
||||
/**
|
||||
* Fuel item that this heater uses
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cooler")
|
||||
FItemAmount mItem;
|
||||
TSubclassOf<UFGItemDescriptor> mItem;
|
||||
|
||||
/**
|
||||
* How much of the item is used
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cooler")
|
||||
int32 mAmount = 1000;
|
||||
|
||||
/**
|
||||
* Duration for one production
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Boiler")
|
||||
float mDuration = 6.f;
|
||||
};
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
* What type of heater this is
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Heater")
|
||||
ERRDAHeaterType mHeaterType;
|
||||
ERRDAHeaterType mType = ERRDAHeaterType::Biomass;
|
||||
|
||||
/**
|
||||
* Fuel item that this heater uses
|
||||
@@ -33,4 +33,10 @@ public:
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Heater")
|
||||
FItemAmount mOutput;
|
||||
|
||||
/**
|
||||
* Duration for one production
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Heater")
|
||||
float mDuration = 6.f;
|
||||
};
|
||||
@@ -14,6 +14,12 @@ class REFINEDRDAPI_API URRDATurbineDataAsset : public URRDADataAssetBase
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Fuel item that this heater uses
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Turbine", meta=( UIMin = "1", UIMax = "2" ))
|
||||
int32 mTier = 1;
|
||||
|
||||
/**
|
||||
* Fuel item that this heater uses
|
||||
*/
|
||||
@@ -26,4 +32,10 @@ public:
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Turbine")
|
||||
FItemAmount mWasteItem;
|
||||
|
||||
/**
|
||||
* Duration for one production
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Turbine")
|
||||
float mDuration = 6.f;
|
||||
};
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "AssetRegistry/AssetRegistryModule.h"
|
||||
#include "DataAssets/RRDADataAssetBase.h"
|
||||
#include "DataAssets/RRDADirtDataAsset.h"
|
||||
#include "Engine/AssetManager.h"
|
||||
#include "Enums/RRDARPEnums.h"
|
||||
#include "Resources/FGItemDescriptor.h"
|
||||
|
||||
@@ -59,6 +58,13 @@ public:
|
||||
template<class T>
|
||||
bool FindAllDataAssetsOfClass(TSet<T*>& OutDataAssets);
|
||||
|
||||
/**
|
||||
* @note For testing purposes only it currently finds 0 assets
|
||||
* @deprecated Use FindAllDataAssetsOfClass instead it uses GetDerivedClasses and get all assets of a specific class
|
||||
*/
|
||||
template<class T>
|
||||
bool FindAllDataAssetsOfClassUseRegistry(TSet<T*>& OutDataAssets);
|
||||
|
||||
private:
|
||||
UPROPERTY()
|
||||
TMap<TSubclassOf<UFGItemDescriptor>, class URRDADirtDataAsset*> mDirtAssets;
|
||||
@@ -73,42 +79,12 @@ public:
|
||||
TSet<URRDADataAssetBase*> mDisabledDataAssets;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Transient, Category = "RRDA|DataAsset")
|
||||
TSet<URRDADataAssetBase*> mAllDataAssets;
|
||||
TSet<URRDADataAssetBase*> mEnabledDataAssets;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
bool URRDADataAssetSubsystem::FindAllDataAssetsOfClass(TSet<T*>& OutDataAssets)
|
||||
{
|
||||
OutDataAssets.Empty();
|
||||
|
||||
// This doesn't work the AssetDatas are always invalid
|
||||
/*UAssetManager& Manager = UAssetManager::Get();
|
||||
|
||||
TArray<FAssetData> AssetDatas;
|
||||
Manager.GetPrimaryAssetDataList(FPrimaryAssetType("RRDADataAsset"), AssetDatas);
|
||||
|
||||
for (FAssetData AssetData : AssetDatas)
|
||||
{
|
||||
if(AssetData.IsValid())
|
||||
{
|
||||
if(URRDADataAssetBase* Asset = Cast<URRDADataAssetBase>(AssetData.GetAsset()))
|
||||
{
|
||||
if(!URRDADataAssetBase::IsEnabled(Asset, GetWorld()))
|
||||
{
|
||||
UE_LOG(LogRRDApi, Error, TEXT("Asset Disabled: %s"), *AssetData.AssetName.ToString());
|
||||
continue;
|
||||
}
|
||||
|
||||
OutDataAssets.Add(Cast<T>(Asset));
|
||||
UE_LOG(LogRRDApi, Log, TEXT("Found %s"), *AssetData.GetAsset()->GetPathName());
|
||||
}
|
||||
} else
|
||||
{
|
||||
UE_LOG(LogRRDApi, Error, TEXT("Invalid AssetData: %s"), *AssetData.AssetName.ToString());
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
TArray<UClass*> FoundClasses;
|
||||
GetDerivedClasses(T::StaticClass(), FoundClasses, true);
|
||||
|
||||
@@ -130,3 +106,36 @@ bool URRDADataAssetSubsystem::FindAllDataAssetsOfClass(TSet<T*>& OutDataAssets)
|
||||
|
||||
return OutDataAssets.Num() > 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool URRDADataAssetSubsystem::FindAllDataAssetsOfClassUseRegistry(TSet<T*>& OutDataAssets)
|
||||
{
|
||||
OutDataAssets.Empty();
|
||||
|
||||
// Find list of all UStat, and USkill assets in Content Browser.
|
||||
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(FName("AssetRegistry"));
|
||||
IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
|
||||
|
||||
TArray<FAssetData> AssetList;
|
||||
AssetRegistry.GetAssetsByClass(URRDADataAssetBase::StaticClass()->GetClassPathName(), AssetList, true);
|
||||
|
||||
// Split assets into separate arrays.
|
||||
for (const FAssetData& Asset : AssetList) {
|
||||
UObject* Obj = Asset.GetAsset();
|
||||
|
||||
if(URRDADataAssetBase* BaseAsset = Cast<URRDADataAssetBase>(Obj))
|
||||
{
|
||||
if(URRDADataAssetBase::IsEnabled(BaseAsset, GetWorld()))
|
||||
{
|
||||
UE_LOG(LogRRDApi, Log, TEXT("Found %s"), *BaseAsset->GetPathName());
|
||||
OutDataAssets.Add(Cast<T>(BaseAsset));
|
||||
mEnabledDataAssets.Add(BaseAsset);
|
||||
}
|
||||
|
||||
UE_LOG(LogRRDApi, Warning, TEXT("Asset Disabled: %s"), *BaseAsset->GetPathName());
|
||||
mDisabledDataAssets.Add(BaseAsset);
|
||||
}
|
||||
}
|
||||
|
||||
return OutDataAssets.Num() > 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user