I’m trying to make a data table with an array of floats based on an enum size. Let me explain. I have damage types:
UENUM(BlueprintType)
enum class EDamageTypes : uint8
{
DT_None UMETA(DisplayName = "None"),
DT_Fire UMETA(DisplayName = "Fire"),
DT_Lightning UMETA(DisplayName = "Lightning"),
...
};
This displays just fine in the editor and blueprints and such. I want to have what is essentially a TMap or TArray of TPairs that has the element type and a float value associated with it (for amount of damage and amount of resistances and whatnot). However, TMaps and TPairs are not supported by UPROPERTY.
USTRUCT(BlueprintType)
struct FTestArrayStruct : public FTableRowBase
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray<TPair<EItemTypes, float>> testArray;
FTestArrayStruct(){}
};
That leads to a compilation error, as does a TMap, saying only UCLASS, USTRUCT or UENUM types are accepted.
Going forward, I see two options:
-
Simply make it an array and add in the values as needed, 0 values for those before the index of the desired damage type. This could lead to some messy complications if put in the wrong spot and some wild errors in damage calculations.
-
Make a USTRUCT that contains the Enum and the float value and have an array of those. But then if I wanted other enums for the same use, I’d have to make another struct for them.
Does anyone see a solution that I’m missing?