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:
@@ -5,12 +5,12 @@
|
||||
#}
|
||||
{%- macro ParseRpcParams(property, outNames, outTypes, outDefines, use_default_value=False) -%}
|
||||
{%- for Param in property.iter('Param') -%}
|
||||
{%- do outNames.append(Param.attrib['Name']) -%}
|
||||
{%- do outNames.append(LowerFirst(Param.attrib['Name'])) -%}
|
||||
{%- do outTypes.append(Param.attrib['Type']) -%}
|
||||
{%- if use_default_value and Param.attrib['DefaultValue'] -%}
|
||||
{%- do outDefines.append('const ' ~ Param.attrib['Type'] ~ '& ' + Param.attrib['Name'] + ' = ' + Param.attrib['DefaultValue']) -%}
|
||||
{%- do outDefines.append('const ' ~ Param.attrib['Type'] ~ '& ' + LowerFirst(Param.attrib['Name']) + ' = ' + Param.attrib['DefaultValue']) -%}
|
||||
{%- else -%}
|
||||
{%- do outDefines.append('const ' ~ Param.attrib['Type'] ~ '& ' ~ Param.attrib['Name']) -%}
|
||||
{%- do outDefines.append('const ' ~ Param.attrib['Type'] ~ '& ' ~ LowerFirst(Param.attrib['Name'])) -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
@@ -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']) }},
|
||||
|
||||
Reference in New Issue
Block a user