Replicate Condition based on bool

Hi, I would like to have a variable to be replicated to OwnerOnly or to Everyone based on a bool (IsContainer) set on Blueprint Defaults. I did this in .cpp :

void UAC_Inventory::GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);

	if (IsContainer)
	{
		DOREPLIFETIME(UAC_Inventory, Slots);
		UE_LOG(LogTemp, Error, TEXT("Is Container"));
	}
	else
	{
		DOREPLIFETIME_CONDITION(UAC_Inventory, Slots, COND_OwnerOnly);
		UE_LOG(LogTemp, Error, TEXT("Is not Container"));
	}	
}

It seems that the bool IsContainer is set AFTER the function GetLifetimeReplicatedProps, so it always return false (maybe because it’s set in Blueprint Defaults).

I thought about making a c++ child class and Override GetLifetimeReplicatedProps, so Slots is replicated to OwnerOnly on Parent, and replicated to everyone on child class. Is it correct to do this?

I am unaware of a way to dynamically change where the property is replicating. A very very dangerous hack is for every derived class to not call Super on the base class, like Super::Super::GetLifetimeReplicatedProps() and replicate the Slots.

What i would really do is, re-think your design pattern. I have seen many inventory systems/slots systems, and i have never seen anyone needing to do this, but then again, i don’t really know your use case.