Added delta replication and stat tracking to vector and array network property container types, + some minor cleanup I ran into when looking for the best hook points for this functionality

Signed-off-by: kberg-amzn <karlberg@amazon.com>
This commit is contained in:
kberg-amzn
2021-08-30 12:05:53 -07:00
parent 86770deefa
commit 99d71cfbc5
8 changed files with 144 additions and 52 deletions
@@ -636,7 +636,6 @@ bool {{ ClassName }}::Serialize{{ AutoComponentMacros.GetNetPropertiesSetName(Re
{% if networkPropertyCount.value > 0 %}
[[maybe_unused]] Multiplayer::MultiplayerStats& stats = Multiplayer::GetMultiplayer()->GetStats();
// We modify the record if we are writing an update so that we don't notify for a change that really didn't change the value (just a duplicated send from the server)
[[maybe_unused]] bool modifyRecord = serializer.GetSerializerMode() == AzNetworking::SerializerMode::WriteToObject;
{% call(Property) AutoComponentMacros.ParseNetworkProperties(Component, ReplicateFrom, ReplicateTo) %}
{% if Property.attrib['Container'] != 'None' and Property.attrib['Container'] != 'Object' %}
{ // Serialization for Vector and Array Network Properties
@@ -651,17 +650,24 @@ bool {{ ClassName }}::Serialize{{ AutoComponentMacros.GetNetPropertiesSetName(Re
if (deltaRecord.AnySet())
{
{% if Property.attrib['Container'] == 'Vector' %}
serializer.Serialize<AZStd::fixed_vector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>>(m_{{ LowerFirst(Property.attrib['Name']) }}, "{{ LowerFirst(Property.attrib['Name']) }}");
Multiplayer::SerializeNetworkPropertyHelperVector
{% elif Property.attrib['Container'] == 'Array' %}
serializer.Serialize<AZStd::array<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>>(m_{{ LowerFirst(Property.attrib['Name']) }}, "{{ LowerFirst(Property.attrib['Name']) }}");
Multiplayer::SerializeNetworkPropertyHelperArray
{% endif %}
(
serializer,
deltaRecord,
m_{{ LowerFirst(Property.attrib['Name']) }},
GetNetComponentId(),
static_cast<Multiplayer::PropertyIndex>({{ UpperFirst(Component.attrib['Name']) }}Internal::NetworkProperties::{{ UpperFirst(Property.attrib['Name']) }}),
stats
);
}
}
{% else %}
Multiplayer::SerializeNetworkPropertyHelper
(
serializer,
modifyRecord,
replicationRecord.m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }},
static_cast<int32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property) }}),
m_{{ LowerFirst(Property.attrib['Name']) }},