You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation/sample project would get much more beneficial if there was a section for accessing entities/their fragments from outside the system. For example: Setting destination point for certain entities that move torwards points.
The text was updated successfully, but these errors were encountered:
If by "outside the system" do you mean not the entity being processed on? So far, It looks like entity fragment data can be accessed in two different way outside the processing execution context:
Accessing fragment data with an FMassEntityHandle called Entity: through the subsystem directly:
EntitySystem = World->GetSubsystem<UMassEntitySubsystem>();
//Get a reference
EntitySystem->GetFragmentDataChecked<FSampleColorFragment>(Entity).Color = FColor::Blue;
//Get a pointer
EntitySystem->GetFragmentDataPtr<FSampleColorFragment>(Entity)->Color = FColor::Blue;
//FStructView is kind of like a pointer to an instanced struct
FStructView StructView = EntitySystem->GetFragmentDataStruct(Entity, FSampleColorFragment::StaticStruct());
StructView.GetMutable<FSampleColorFragment>().Color = FColor::Blue;
Accessing fragment data with a new FMassEntityView. This is a struct that stores the archetype data too so it has some nice extra functionality:
EntitySystem = World->GetSubsystem<UMassEntitySubsystem>();
FMassEntityView EntityView(*EntitySystem,Entity);
EntityView.GetFragmentDataPtr<FSampleColorFragment>(Entity)->Color = FColor::Blue;
//The Entityview can also get the entity's shared fragments and even check for tag presence:
EntityView.GetSharedFragmentData<FSharedNiagaraSystemFragment>().ParticlePositions = Whatever;
if(EntityView.HasTag<FSampleMoverTag>())
DoStuff();
It's also probably slightly faster to do the whole FMassEntityView thing if you need to change more than a single fragment on the entity as it caches the archetype data, saving some extra work. (I think)
I'll document this stuff soon! I'm still learning stuff on the go as I use the API more.
The documentation/sample project would get much more beneficial if there was a section for accessing entities/their fragments from outside the system. For example: Setting destination point for certain entities that move torwards points.
The text was updated successfully, but these errors were encountered: