Navigation
API > API/Plugins > API/Plugins/MassReplication
Template for replication traits. Specialize this for each replicated data type. The specialization defines how to convert between fragments and replicated data, with fragment types handled via function overloading.
Required members in specialization:
- static void ExtractData(const TFragment& Fragment, TReplicatedDataType& OutData) One overload per fragment type that contributes data. If not provided for a fragment, TReplicatedDataType::operator=(const TFragment&) will be used.
- static void ApplyData(TFragment& Fragment, const TReplicatedDataType& Data) One overload per fragment type that receives data. If not provided for a fragment, TFragment::operator=(const TReplicatedDataType&) will be used.
Optional members:
- static bool IsDirty(const TReplicatedDataType& OldData, const TReplicatedDataType& NewData) Custom dirty checking. If not provided, will use TReplicatedDataType::IsDirty() member or fall back to operator!=.
- static constexpr bool bSkipEntityModification = true/false If true then SetModifiedEntityData calls won't be executed for that fragment (use for "set once" data like visualization). Not defining SetModifiedEntityData will have the same result as SetModifiedEntityData = false.
Note that missing both a specialized trait and member functions expected in default cases will result in compilation errors.
Example: template<> struct TReplicationTraits
| Name | TReplicationTraits |
| Type | struct |
| Header File | /Engine/Plugins/Runtime/MassGameplay/Source/MassReplication/Public/MassReplicationTemplates.h |
| Include Path | #include "MassReplicationTemplates.h" |
Syntax
template<typename TReplicatedDataType>
struct TReplicationTraits