Well for me the fact there there might 100 possible attributes in single class is not an problem. I never access them directly, I access them trough function and by specifing their name like:
GetAttribute(“Health”);
If that still doesn’t suit you, you can pack attributes into structs like:
USTRUCT(BlueprintType)
struct FMyAttribute
{
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Attribute")
float Health;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Attribute")
float Mana;
}
And then just declare them as:
FMyAttribute MyAttribute:
Believe me it’s better solution, that trying to over abstract and over organize everything ;). I’ve tried the more generic the better approach before, and all it does it. increase complexity in exponentially.
You can also create hierarchy of Componenets like:
MyAttributeComponent : UActorComponent
MyAwsomeAttribute : MyAttributeComponent;
etc.
But it will require some planning ahead of what you want at each level of hierarchy.
Least but not least. You can create nested Subobjects when you use UObject instead of ActorComponent.
But this makes it hard to expose back to blueprint and edit properties inside editor.