feat: functions for cooler data

This commit is contained in:
Kyrium 2024-10-27 13:48:39 +01:00
parent ce944794dc
commit b4e8796e74
3 changed files with 46 additions and 10 deletions

View File

@ -254,15 +254,7 @@ TArray<URRDATurbineDataAsset*> URRDADataAssetSubsystem::GetAllTurbineAssets(int3
}
URRDATurbineDataAsset* URRDADataAssetSubsystem::GetDefaultTurbineAsset(int32 Tier) const {
if(!mTurbineAssets.Contains(Tier)) {
return nullptr;
}
TArray<URRDATurbineDataAsset*> Assets;
mTurbineAssets[Tier].GenerateValueArray(Assets);
// Return the first item in the tier
return Assets[0];
return GetAllTurbineAssets(Tier)[0];
}
URRDATurbineDataAsset* URRDADataAssetSubsystem::GetTurbineItemData(TSubclassOf<UFGItemDescriptor> Item, int32 Tier) const
@ -274,3 +266,34 @@ URRDATurbineDataAsset* URRDADataAssetSubsystem::GetTurbineItemData(TSubclassOf<U
return mTurbineAssets[Tier].FindRef(Item);
}
bool URRDADataAssetSubsystem::GetAllCoolerItems(TArray<TSubclassOf<UFGItemDescriptor>>& Items, ERRDACoolerType Type) const
{
if(!mCoolerAssets.Contains(Type)) return false;
Items.Empty();
mCoolerAssets[Type].GetKeys(Items);
return true;
}
URRDACoolerDataAsset* URRDADataAssetSubsystem::GetCoolerItemData(TSubclassOf<UFGItemDescriptor> 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<URRDACoolerDataAsset*> URRDADataAssetSubsystem::GetAllCoolerAssets(ERRDACoolerType Type) const
{
if(!mCoolerAssets.Contains(Type)) return TArray<URRDACoolerDataAsset*>();
TArray<URRDACoolerDataAsset*> Assets;
mCoolerAssets[Type].GenerateValueArray(Assets);
return Assets;
}

View File

@ -36,6 +36,6 @@ public:
/**
* Duration for one production
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Boiler")
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cooler")
float mDuration = 6.f;
};

View File

@ -75,6 +75,19 @@ public:
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
TArray<URRDATurbineDataAsset*> GetAllTurbineAssets(int32 Tier) const;
// Cooler Functions
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
bool GetAllCoolerItems(TArray<TSubclassOf<UFGItemDescriptor>>& Items, ERRDACoolerType Type) const;
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
URRDACoolerDataAsset* GetCoolerItemData(TSubclassOf<UFGItemDescriptor>Item, ERRDACoolerType Type) const;
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
URRDACoolerDataAsset* GetDefaultCoolerAsset(ERRDACoolerType Type) const;
UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|RP|MP")
TArray<URRDACoolerDataAsset*> GetAllCoolerAssets(ERRDACoolerType Type) const;
public:
/**
* Find all data assets of a specific class