The asset can’t, but the data asset type can.
Okay, I think I see what you’re suggesting that’s different from what I am. I’m not suggesting that the data-asset is the command object. I’m suggesting that the data asset would hold the command object or objects.
Here’s the pattern from Midnight Suns I was talking about:
The primary data asset is something like UAbilityDefinition. It would have properties like:
UPROPERTY(EditDefaultOnly, Instanced)
TArray< const UCommand* > Actions;
UPROPERTY(EditDefaultOnly, Instanced)
const UCommand* OnSomethingAction;
That command is a specific instance of the command pattern, so you can configure specific data members of it for the ability that it’s a part of. But as part of data asset, these aren’t bound to any world. So any function you call on them, you’d have to pass in a WorldContext to do any world things.
This is also meant as a pattern, not a type. So you wouldn’t have one UCommand type. But multiples, each with an API specific to the context they were being used. For example at home, I have one, UAbilityEffect, that are things that an ability can do and so it has an API around doing things with a source & target & such. But I also have a UTargetingStyle that has it’s own API for starting, stopping, previewing, gathering, etc. There isn’t a generic type that all these “command pattern” objects use and is trying to support API’s for all derived types.
I’m also share the command objects when appropriate. For example, my status effects have their own primary data type, but reuse the UAbilityEffect object for actions that should be taken on apply or removal or tick. Because the types of things that the status effects should be able to do at those times are the same as when activating an ability. (and why in my actual code base why that object has a more generic name than UAbilityEffect)
I think of these as bit of a hybrid between the strategy and command patterns. There’s a little bit of both in how it works. But, one upside is that you’re always dealing with instances and never CDO’s. Though they still can’t be used as world contexts.
The topic’s drifted a bit from the original question. Feel free to hit me up in DM’s if you would like to discuss more details how to put this sort of thing into practice.