|
|
|
@@ -3,7 +3,11 @@
|
|
|
|
|
{% macro LowerFirst(text) %}{{ text[0] | lower}}{{ text[1:] }}{% endmacro %}
|
|
|
|
|
{% macro DefineNetworkPropertyGet(ClassName, Property, Prefix = '') %}
|
|
|
|
|
{% if Property.attrib['Container'] == 'Array' %}
|
|
|
|
|
const AZStd::array<{% if Property.attrib['IsRewindable']|booleanTrue %}Multiplayer::RewindableObject<{% endif %}{{ Property.attrib['Type'] }}{% if Property.attrib['IsRewindable']|booleanTrue %}, Multiplayer::RewindHistorySize>{% endif %}, {{ Property.attrib['Count'] }}>& {{ ClassName }}::Get{{ UpperFirst(Property.attrib['Name']) }}Array() const
|
|
|
|
|
{% if Property.attrib['IsRewindable']|booleanTrue %}
|
|
|
|
|
const RewindableArray<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& {{ ClassName }}::Get{{ UpperFirst(Property.attrib['Name']) }}Array() const
|
|
|
|
|
{% else %}
|
|
|
|
|
const AZStd::array<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& {{ ClassName }}::Get{{ UpperFirst(Property.attrib['Name']) }}Array() const
|
|
|
|
|
{% endif %}
|
|
|
|
|
{
|
|
|
|
|
return {{ Prefix }}m_{{ LowerFirst(Property.attrib['Name']) }};
|
|
|
|
|
}
|
|
|
|
@@ -21,7 +25,11 @@ void {{ ClassName }}::{{ UpperFirst(Property.attrib['Name']) }}AddEvent(AZ::Even
|
|
|
|
|
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% elif Property.attrib['Container'] == 'Vector' %}
|
|
|
|
|
{% if Property.attrib['IsRewindable']|booleanTrue %}
|
|
|
|
|
const RewindableFixedVector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& {{ ClassName }}::Get{{ UpperFirst(Property.attrib['Name']) }}Vector() const
|
|
|
|
|
{% else %}
|
|
|
|
|
const AZStd::fixed_vector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& {{ ClassName }}::Get{{ UpperFirst(Property.attrib['Name']) }}Vector() const
|
|
|
|
|
{% endif %}
|
|
|
|
|
{
|
|
|
|
|
return {{ Prefix }}m_{{ LowerFirst(Property.attrib['Name']) }};
|
|
|
|
|
}
|
|
|
|
@@ -110,25 +118,26 @@ void {{ ClassName }}::Set{{ UpperFirst(Property.attrib['Name']) }}(int32_t index
|
|
|
|
|
|
|
|
|
|
bool {{ ClassName }}::{{ UpperFirst(Property.attrib['Name']) }}PushBack(const {{ Property.attrib['Type'] }} &value)
|
|
|
|
|
{
|
|
|
|
|
int32_t indexToSet = GetParent().m_{{ LowerFirst(Property.attrib['Name']) }}.size();
|
|
|
|
|
GetParent().m_{{ LowerFirst(Property.attrib['Name']) }}.push_back(value);
|
|
|
|
|
int32_t bitIndex = indexToSet + static_cast<int32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Start') }});
|
|
|
|
|
GetParent().m_currentRecord->m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}.SetBit(bitIndex, true);
|
|
|
|
|
GetParent().m_currentRecord->m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}.SetBit(static_cast<int32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Size') }}), true);
|
|
|
|
|
GetParent().MarkDirty();
|
|
|
|
|
return true;
|
|
|
|
|
if (GetParent().m_{{ LowerFirst(Property.attrib['Name']) }}.push_back(value))
|
|
|
|
|
{
|
|
|
|
|
int32_t indexToSet = GetParent().m_{{ LowerFirst(Property.attrib['Name']) }}.size();
|
|
|
|
|
int32_t bitIndex = indexToSet + static_cast<int32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Start') }});
|
|
|
|
|
GetParent().m_currentRecord->m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}.SetBit(bitIndex, true);
|
|
|
|
|
GetParent().m_currentRecord->m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}.SetBit(static_cast<int32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Size') }}), true);
|
|
|
|
|
GetParent().MarkDirty();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool {{ ClassName }}::{{ UpperFirst(Property.attrib['Name']) }}PopBack(const Multiplayer::NetworkInput&)
|
|
|
|
|
{
|
|
|
|
|
if (GetParent().m_{{ LowerFirst(Property.attrib['Name']) }}.empty())
|
|
|
|
|
if (GetParent().m_{{ LowerFirst(Property.attrib['Name']) }}.pop_back())
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
GetParent().m_currentRecord->m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}.SetBit(static_cast<int32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Size') }}), true);
|
|
|
|
|
GetParent().MarkDirty();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
GetParent().m_currentRecord->m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}.SetBit(static_cast<int32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Size') }}), true);
|
|
|
|
|
GetParent().MarkDirty();
|
|
|
|
|
GetParent().m_{{ LowerFirst(Property.attrib['Name']) }}.pop_back();
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void {{ ClassName }}::{{ UpperFirst(Property.attrib['Name']) }}Clear(const Multiplayer::NetworkInput&)
|
|
|
|
@@ -207,25 +216,27 @@ void {{ ClassName }}::Set{{ UpperFirst(Property.attrib['Name']) }}(int32_t index
|
|
|
|
|
|
|
|
|
|
bool {{ ClassName }}::{{ UpperFirst(Property.attrib['Name']) }}PushBack(const {{ Property.attrib['Type'] }} &value)
|
|
|
|
|
{
|
|
|
|
|
uint32_t indexToSet = aznumeric_cast<uint32_t>(GetParent().m_{{ LowerFirst(Property.attrib['Name']) }}.size());
|
|
|
|
|
GetParent().m_{{ LowerFirst(Property.attrib['Name']) }}.push_back(value);
|
|
|
|
|
uint32_t bitIndex = indexToSet + aznumeric_cast<uint32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Start') }});
|
|
|
|
|
GetParent().m_currentRecord->m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}.SetBit(bitIndex, true);
|
|
|
|
|
GetParent().m_currentRecord->m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}.SetBit(aznumeric_cast<uint32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Size') }}), true);
|
|
|
|
|
GetParent().MarkDirty();
|
|
|
|
|
return true;
|
|
|
|
|
if (GetParent().m_{{ LowerFirst(Property.attrib['Name']) }}.push_back(value))
|
|
|
|
|
{
|
|
|
|
|
uint32_t indexToSet = aznumeric_cast<uint32_t>(GetParent().m_{{ LowerFirst(Property.attrib['Name']) }}.size());
|
|
|
|
|
uint32_t bitIndex = indexToSet + aznumeric_cast<uint32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Start') }});
|
|
|
|
|
GetParent().m_currentRecord->m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}.SetBit(bitIndex, true);
|
|
|
|
|
GetParent().m_currentRecord->m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}.SetBit(aznumeric_cast<uint32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Size') }}), true);
|
|
|
|
|
GetParent().MarkDirty();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool {{ ClassName }}::{{ UpperFirst(Property.attrib['Name']) }}PopBack()
|
|
|
|
|
{
|
|
|
|
|
if (GetParent().m_{{ LowerFirst(Property.attrib['Name']) }}.empty())
|
|
|
|
|
if (GetParent().m_{{ LowerFirst(Property.attrib['Name']) }}.pop_back())
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
GetParent().m_currentRecord->m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}.SetBit(static_cast<int32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Size') }}), true);
|
|
|
|
|
GetParent().MarkDirty();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
GetParent().m_currentRecord->m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}.SetBit(static_cast<int32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Size') }}), true);
|
|
|
|
|
GetParent().MarkDirty();
|
|
|
|
|
GetParent().m_{{ LowerFirst(Property.attrib['Name']) }}.pop_back();
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void {{ ClassName }}::{{ UpperFirst(Property.attrib['Name']) }}Clear()
|
|
|
|
@@ -562,12 +573,12 @@ bool {{ ClassName }}::Serialize{{ AutoComponentMacros.GetNetPropertiesSetName(Re
|
|
|
|
|
{%- if networkPropertyCount.update({'value': networkPropertyCount.value + 1}) %}{% endif -%}
|
|
|
|
|
{% endcall %}
|
|
|
|
|
{% if networkPropertyCount.value > 0 %}
|
|
|
|
|
Multiplayer::MultiplayerStats& stats = Multiplayer::GetMultiplayer()->GetStats();
|
|
|
|
|
[[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' %}
|
|
|
|
|
{ /* @todo Implement serialization for Vector and Array Network Properties
|
|
|
|
|
{ // Serialization for Vector and Array Network Properties
|
|
|
|
|
const uint32_t firstBit = static_cast<uint32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Start') }});
|
|
|
|
|
{% if Property.attrib['Container'] == 'Vector' %}
|
|
|
|
|
const uint32_t lastBit = static_cast<uint32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Size') }});
|
|
|
|
@@ -575,17 +586,8 @@ bool {{ ClassName }}::Serialize{{ AutoComponentMacros.GetNetPropertiesSetName(Re
|
|
|
|
|
const uint32_t lastBit = static_cast<uint32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'End') }});
|
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
|
|
AzNetworking::BitsetView deltaRecord(replicationRecord.m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}, firstBit, lastBit - firstBit + 1);
|
|
|
|
|
if (deltaRecord.AnySet())
|
|
|
|
|
{
|
|
|
|
|
{% if Property.attrib['Container'] == 'Vector' %}
|
|
|
|
|
Multiplayer::SerializableFixedSizeVectorDeltaStruct<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}> deltaStruct(m_{{ LowerFirst(Property.attrib['Name']) }}, deltaRecord);
|
|
|
|
|
{% else %}
|
|
|
|
|
Multiplayer::SerializableFixedSizeArrayDeltaStruct<{% if Property.attrib['IsRewindable']|booleanTrue %}Multiplayer::RewindableObject<{% endif %}{{ Property.attrib['Type'] }}{% if Property.attrib['IsRewindable']|booleanTrue %}, Multiplayer::RewindHistorySize>{% endif %}, {{ Property.attrib['Count'] }}> deltaStruct(m_{{ Property.attrib['Name'] }}, deltaRecord);
|
|
|
|
|
{% endif %}
|
|
|
|
|
serializer.Serialize(deltaStruct, "{{ UpperFirst(Property.attrib['Name']) }}");
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
AzNetworking::FixedSizeBitsetView deltaRecord(replicationRecord.m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}, firstBit, lastBit - firstBit + 1);
|
|
|
|
|
m_{{ LowerFirst(Property.attrib['Name']) }}.Serialize(serializer, deltaRecord);
|
|
|
|
|
}
|
|
|
|
|
{% else %}
|
|
|
|
|
Multiplayer::SerializeNetworkPropertyHelper
|
|
|
|
@@ -615,7 +617,7 @@ void {{ ClassName }}::NotifyChanges{{ AutoComponentMacros.GetNetPropertiesSetNam
|
|
|
|
|
{% call(Property) AutoComponentMacros.ParseNetworkProperties(Component, ReplicateFrom, ReplicateTo) %}
|
|
|
|
|
{% if (Property.attrib['GenerateEventBindings']|booleanTrue) %}
|
|
|
|
|
{% if Property.attrib['Container'] != 'None' and Property.attrib['Container'] != 'Object' %}
|
|
|
|
|
/* todo Implement NotifyChangesAuthorityToClientProperties for Arrays and Vectors
|
|
|
|
|
// NotifyChangesAuthorityToClientProperties for Arrays and Vectors
|
|
|
|
|
for (uint32_t bitIndex = static_cast<int32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Start') }}), elementIndex = 0; bitIndex <= static_cast<int32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component, ReplicateFrom, ReplicateTo, Property, 'End') }}); ++bitIndex, ++elementIndex)
|
|
|
|
|
{
|
|
|
|
|
if (replicationRecord.m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}.GetBit(bitIndex){% if Property.attrib['Container'] == 'Vector' %} && elementIndex < m_{{ Property.attrib['Name'] }}.GetSize(){% endif %})
|
|
|
|
@@ -627,7 +629,7 @@ void {{ ClassName }}::NotifyChanges{{ AutoComponentMacros.GetNetPropertiesSetNam
|
|
|
|
|
if (replicationRecord.m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}.GetBit(static_cast<int32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property, 'Size') }})))
|
|
|
|
|
{
|
|
|
|
|
m_{{ LowerFirst(Property.attrib['Name']) }}SizeChangedEvent.Signal(m_{{ LowerFirst(Property.attrib['Name']) }}.size());
|
|
|
|
|
} */
|
|
|
|
|
}
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% else %}
|
|
|
|
|
if (replicationRecord.m_{{ LowerFirst(AutoComponentMacros.GetNetPropertiesSetName(ReplicateFrom, ReplicateTo)) }}.GetBit(static_cast<int32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property) }})))
|
|
|
|
@@ -645,7 +647,11 @@ void {{ ClassName }}::NotifyChanges{{ AutoComponentMacros.GetNetPropertiesSetNam
|
|
|
|
|
{% macro DefineArchetypePropertyGet(Property, ClassType, ClassName, Prefix = '') %}
|
|
|
|
|
{% if ClassType == '' or Property.attrib['ExportTo'] == ClassType or Property.attrib['ExportTo'] == "Common" %}
|
|
|
|
|
{% if Property.attrib['Container'] == 'Array' %}
|
|
|
|
|
{% if Property.attrib['IsRewindable']|booleanTrue %}
|
|
|
|
|
const RewindableArray<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& {{ ClassName }}::Get{{ UpperFirst(Property.attrib['Name']) }}Array() const
|
|
|
|
|
{% else %}
|
|
|
|
|
const AZStd::array<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& {{ ClassName }}::Get{{ UpperFirst(Property.attrib['Name']) }}Array() const
|
|
|
|
|
{% endif %}
|
|
|
|
|
{
|
|
|
|
|
return {{ Prefix }}m_{{ LowerFirst(Property.attrib['Name']) }};
|
|
|
|
|
}
|
|
|
|
@@ -656,7 +662,11 @@ const {{ Property.attrib['Type'] }}& {{ ClassName }}::Get{{ UpperFirst(Property.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{% elif Property.attrib['Container'] == 'Vector' %}
|
|
|
|
|
{% if Property.attrib['IsRewindable']|booleanTrue %}
|
|
|
|
|
const RewindableFixedVector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& {{ ClassName }}::Get{{ UpperFirst(Property.attrib['Name']) }}Vector() const
|
|
|
|
|
{% else %}
|
|
|
|
|
const AZStd::fixed_vector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& {{ ClassName }}::Get{{ UpperFirst(Property.attrib['Name']) }}Vector() const
|
|
|
|
|
{% endif %}
|
|
|
|
|
{
|
|
|
|
|
return {{ Prefix }}m_{{ LowerFirst(Property.attrib['Name']) }};
|
|
|
|
|
}
|
|
|
|
@@ -1472,7 +1482,14 @@ namespace {{ Component.attrib['Namespace'] }}
|
|
|
|
|
{
|
|
|
|
|
{% for Property in Component.iter('NetworkProperty') %}
|
|
|
|
|
{% if Property.attrib['IsRewindable']|booleanTrue %}
|
|
|
|
|
{% if Property.attrib['Container'] == 'Vector' or Property.attrib['Container'] == 'Array' %}
|
|
|
|
|
for ( auto& element: m_{{ LowerFirst(Property.attrib['Name']) }})
|
|
|
|
|
{
|
|
|
|
|
element.SetOwningConnectionId(connectionId);
|
|
|
|
|
}
|
|
|
|
|
{% else %}
|
|
|
|
|
m_{{ LowerFirst(Property.attrib['Name']) }}.SetOwningConnectionId(connectionId);
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% endfor %}
|
|
|
|
|
}
|
|
|
|
|