Hi, I have been doing some experiments with the MassEntity and MassGameplay plugins, mostly c++ but today I tried BP integration.
For the most part, this went smoothly, I have a little library that lets me pass in a Mass Agent Component on an actor and get the value of a fragment as a copy of the fragment struct. The fragment struct was made BlueprintType and its properties BlueprintReadWrite. I could easily break the fragment and make it, and pass it into functions. One I made sets the fragment value for the entity paired with an agent Component. Wonderful!
However, this was only adequate for this little test I’d set up, which gets the value of a fragment for the entity paired with the player pawn’s agent component. For BP access to entities the getters and setters need to be able to take a Mass Entity Handle struct. They should be able to break or make an entity handle struct in BP, and store them as variables.
If the struct could just have these specifiers set it would be very trivial to add BP script support to a game using Mass.
Additionally, making it BP compatible would allow the GetAgentHandle function on Mass Agent Component to be blueprint callable. Yet another reason to do this is the RaiseSignalForEntities/Entity functions on the Mass Signals Subsystem could also be blueprint callable. This would allow BP scripts to fire off signals to entities.
Of course, future launcher version users can wrap the handles in a blueprint type struct and all source builds have the option of changing it locally, but why shouldn’t handles be BP friendly by default? Unless you want to do 100% of the game logic in c++ blueprints are going to become involved. Mass hasn’t been written to preclude BP, it just makes it harder than it has to be.
With all that in place the authors of fragments would need only enable BP support in the specifiers, write some getters and setters taking an array of entity handles, and a context object/world/Mass Entity Subsystem pointer, returning/taking an array of the fragment structs. Really, the fragments that come with the modules of each plugin should have bp callable static function libraries to do these for those types. Or some kind of blueprint magic using DeterminesOutputType?
FYI: I have set up a UMG widget that gets and sets a fragment from the entity database using the pawns agent component, it totally worked and I am confident that Mass will not be unfriendly to designers. I also tried raising a signal from the widget and that worked too!
Also, thank you for writing these plugins, I had a great need for this exact thing and it is better than anything I would have written.