I have an ActorComponent which is used by multiple actors. The ActorComponent acts on data (TArray) which is meant to be replicated, but the type of replication differs depending on the Actor. Some Actors want to replicate the data to all, and others only want to replicate using COND_OwnerOnly.
With that in mind, I have the data itself stored on the Actors so they can specify the type of replication in their AMyActor::GetLifetimeReplicatedProps() functions. Now different Actors can replicate their TArray data in different ways depending on their needs.
The only problem left is allowing the ActorComponent to access the data (TArray) stored in their owning Actor classes. This sounds like a good place where a reference would come in handy. If the ActorComponent had a TArray<>& member, the problem would be solved if I could initialize the reference in the ActorComponent constructor. But based on what I have seen so far, it doesn't seem possible to use references in this way with Unreal.
The temporary solution that I have come up with is for the ActorComponent to have a member:
Code:
TArray<>* Data;
Code:
(*Data)[1];
Is there any way to solve this problem using references?
As far as I know, it's not possible to have the TArray be a member of the ActorComponent with my requirement that different actors be able to replicate the data in different ways.