From b4e8796e74cca35c3089f53391a5d3556baba746 Mon Sep 17 00:00:00 2001 From: Kyrium Date: Sun, 27 Oct 2024 13:48:39 +0100 Subject: [PATCH] feat: functions for cooler data --- .../Subsystems/RRDADataAssetSubsystem.cpp | 41 +++++++++++++++---- .../Public/DataAssets/RRDACoolerDataAsset.h | 2 +- .../Subsystems/RRDADataAssetSubsystem.h | 13 ++++++ 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/Source/RefinedRDApi/Private/Subsystems/RRDADataAssetSubsystem.cpp b/Source/RefinedRDApi/Private/Subsystems/RRDADataAssetSubsystem.cpp index b4b6191..0dc7a81 100644 --- a/Source/RefinedRDApi/Private/Subsystems/RRDADataAssetSubsystem.cpp +++ b/Source/RefinedRDApi/Private/Subsystems/RRDADataAssetSubsystem.cpp @@ -254,15 +254,7 @@ TArray URRDADataAssetSubsystem::GetAllTurbineAssets(int3 } URRDATurbineDataAsset* URRDADataAssetSubsystem::GetDefaultTurbineAsset(int32 Tier) const { - if(!mTurbineAssets.Contains(Tier)) { - return nullptr; - } - - TArray Assets; - mTurbineAssets[Tier].GenerateValueArray(Assets); - - // Return the first item in the tier - return Assets[0]; + return GetAllTurbineAssets(Tier)[0]; } URRDATurbineDataAsset* URRDADataAssetSubsystem::GetTurbineItemData(TSubclassOf Item, int32 Tier) const @@ -274,3 +266,34 @@ URRDATurbineDataAsset* URRDADataAssetSubsystem::GetTurbineItemData(TSubclassOf>& Items, ERRDACoolerType Type) const +{ + if(!mCoolerAssets.Contains(Type)) return false; + + Items.Empty(); + mCoolerAssets[Type].GetKeys(Items); + + return true; +} + +URRDACoolerDataAsset* URRDADataAssetSubsystem::GetCoolerItemData(TSubclassOf Item, ERRDACoolerType Type) const +{ + if(!mCoolerAssets.Contains(Type)) return nullptr; + return mCoolerAssets[Type].FindRef(Item); +} + +URRDACoolerDataAsset* URRDADataAssetSubsystem::GetDefaultCoolerAsset(ERRDACoolerType Type) const +{ + return GetAllCoolerAssets(Type)[0]; +} + +TArray URRDADataAssetSubsystem::GetAllCoolerAssets(ERRDACoolerType Type) const +{ + if(!mCoolerAssets.Contains(Type)) return TArray(); + + TArray Assets; + mCoolerAssets[Type].GenerateValueArray(Assets); + + return Assets; +} diff --git a/Source/RefinedRDApi/Public/DataAssets/RRDACoolerDataAsset.h b/Source/RefinedRDApi/Public/DataAssets/RRDACoolerDataAsset.h index 99731e6..180970c 100644 --- a/Source/RefinedRDApi/Public/DataAssets/RRDACoolerDataAsset.h +++ b/Source/RefinedRDApi/Public/DataAssets/RRDACoolerDataAsset.h @@ -36,6 +36,6 @@ public: /** * Duration for one production */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Boiler") + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cooler") float mDuration = 6.f; }; \ No newline at end of file diff --git a/Source/RefinedRDApi/Public/Subsystems/RRDADataAssetSubsystem.h b/Source/RefinedRDApi/Public/Subsystems/RRDADataAssetSubsystem.h index 7b5e44e..3897f6f 100644 --- a/Source/RefinedRDApi/Public/Subsystems/RRDADataAssetSubsystem.h +++ b/Source/RefinedRDApi/Public/Subsystems/RRDADataAssetSubsystem.h @@ -75,6 +75,19 @@ public: UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP") TArray GetAllTurbineAssets(int32 Tier) const; + // Cooler Functions + UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP") + bool GetAllCoolerItems(TArray>& Items, ERRDACoolerType Type) const; + + UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP") + URRDACoolerDataAsset* GetCoolerItemData(TSubclassOfItem, ERRDACoolerType Type) const; + + UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP") + URRDACoolerDataAsset* GetDefaultCoolerAsset(ERRDACoolerType Type) const; + + UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP") + TArray GetAllCoolerAssets(ERRDACoolerType Type) const; + public: /** * Find all data assets of a specific class