Hi
Currently I am trying to learn Mass system, I understand concepts like Fragment, Tag, Processor, Subsystem, but I am having truble understanding what purpose has Trait. Is some way to encapsulete multiple fragments and tag?
Given code below Trait just encapsulates Fragments and Tag.
void UMoverMassTrait::BuildTemplate(FMassEntityTemplateBuildContext& BuildContext, const UWorld& World) const
{
BuildContext.RequireFragment<FTransformFragment>();
BuildContext.RequireFragment<FMassVelocityFragment>();
BuildContext.AddFragment_GetRef<FMassForceFragment>().Value = StartingForce;
BuildContext.AddTag<FMSBasicMovement>();
}
I can create manualy Entety by this simple code
FMassEntityHandle ReserverdEntity = EntityManager->ReserveEntity();
FLocationFragment location;
location.position = FVector(Index * 100, 0, 120);
location.rotation = FVector::ZeroVector;
EntityManager->Defer().PushCommand<FMassCommandBuildEntity>(ReserverdEntity, location);
In this given example I define entety that has only FLocationFragment and then create it, but what i can do is in simillar fashon add moree Fragments and Tags to given entity.
Can I do simillar thing with traits?
like
UMoverMassTrait.FTransformFragment = FVector();
UMoverMassTrait.FMassVelocityFragment = FVEctor();
EntityManager->Defer().PushCommand<FMassCommandBuildEntity>(ReserverdEntity, UMoverMassTrait);