Addressing PR feedback

main
karlberg 5 years ago
parent 138b10c902
commit 2fc710d73b

@ -75,26 +75,26 @@ namespace Multiplayer
virtual void AddSessionShutdownHandler(SessionShutdownEvent::Handler& handler) = 0; virtual void AddSessionShutdownHandler(SessionShutdownEvent::Handler& handler) = 0;
//! Returns the gem name associated with the provided component index. //! Returns the gem name associated with the provided component index.
//! @param netComponentIndex the component index to return the gem name of //! @param netComponentId the componentId to return the gem name of
//! @return the name of the gem that contains the requested component //! @return the name of the gem that contains the requested component
virtual const char* GetComponentGemName(uint16_t netComponentIndex) const = 0; virtual const char* GetComponentGemName(NetComponentId netComponentId) const = 0;
//! Returns the component name associated with the provided component index. //! Returns the component name associated with the provided component index.
//! @param netComponentIndex the component index to return the component name of //! @param netComponentId the componentId to return the component name of
//! @return the name of the component //! @return the name of the component
virtual const char* GetComponentName(uint16_t netComponentIndex) const = 0; virtual const char* GetComponentName(NetComponentId netComponentId) const = 0;
//! Returns the property name associated with the provided component index and property index. //! Returns the property name associated with the provided component index and property index.
//! @param netComponentIndex the component index to return the property name of //! @param netComponentId the component index to return the property name of
//! @param propertyIndex the index off the network property to return the property name of //! @param propertyIndex the index of the network property to return the property name of
//! @return the name of the network property //! @return the name of the network property
virtual const char* GetComponentPropertyName(uint16_t netComponentIndex, uint16_t propertyIndex) const = 0; virtual const char* GetComponentPropertyName(NetComponentId netComponentId, PropertyIndex propertyIndex) const = 0;
//! Returns the Rpc name associated with the provided component index and rpc index. //! Returns the Rpc name associated with the provided component index and rpc index.
//! @param netComponentIndex the component index to return the property name of //! @param netComponentId the componentId to return the property name of
//! @param rpcIndex the index off the rpc to return the rpc name of //! @param rpcIndex the index of the rpc to return the rpc name of
//! @return the name of the requested rpc //! @return the name of the requested rpc
virtual const char* GetComponentRpcName(uint16_t netComponentIndex, uint16_t rpcIndex) const = 0; virtual const char* GetComponentRpcName(NetComponentId netComponentId, RpcIndex rpcIndex) const = 0;
//! Retrieve the stats object bound to this multiplayer instance. //! Retrieve the stats object bound to this multiplayer instance.
//! @return the stats object bound to this multiplayer instance //! @return the stats object bound to this multiplayer instance

@ -14,48 +14,57 @@
namespace Multiplayer namespace Multiplayer
{ {
void MultiplayerStats::ReserveComponentStats(uint16_t netComponentId, uint16_t propertyCount, uint16_t rpcCount) void MultiplayerStats::ReserveComponentStats(NetComponentId netComponentId, uint16_t propertyCount, uint16_t rpcCount)
{ {
if (m_componentStats.size() <= netComponentId) const uint16_t netComponentIndex = aznumeric_cast<uint16_t>(netComponentId);
if (m_componentStats.size() <= netComponentIndex)
{ {
m_componentStats.resize(netComponentId + 1); m_componentStats.resize(netComponentIndex + 1);
} }
m_componentStats[netComponentId].m_propertyUpdatesSent.resize(propertyCount); m_componentStats[netComponentIndex].m_propertyUpdatesSent.resize(propertyCount);
m_componentStats[netComponentId].m_propertyUpdatesRecv.resize(propertyCount); m_componentStats[netComponentIndex].m_propertyUpdatesRecv.resize(propertyCount);
m_componentStats[netComponentId].m_rpcsSent.resize(rpcCount); m_componentStats[netComponentIndex].m_rpcsSent.resize(rpcCount);
m_componentStats[netComponentId].m_rpcsRecv.resize(rpcCount); m_componentStats[netComponentIndex].m_rpcsRecv.resize(rpcCount);
} }
void MultiplayerStats::RecordPropertySent(uint16_t netComponentId, uint16_t propertyId, uint32_t totalBytes) void MultiplayerStats::RecordPropertySent(NetComponentId netComponentId, PropertyIndex propertyId, uint32_t totalBytes)
{ {
m_componentStats[netComponentId].m_propertyUpdatesSent[propertyId].m_totalCalls++; const uint16_t netComponentIndex = aznumeric_cast<uint16_t>(netComponentId);
m_componentStats[netComponentId].m_propertyUpdatesSent[propertyId].m_totalBytes += totalBytes; const uint16_t propertyIndex = aznumeric_cast<uint16_t>(propertyId);
m_componentStats[netComponentId].m_propertyUpdatesSent[propertyId].m_callHistory[m_recordMetricIndex]++; m_componentStats[netComponentIndex].m_propertyUpdatesSent[propertyIndex].m_totalCalls++;
m_componentStats[netComponentId].m_propertyUpdatesSent[propertyId].m_byteHistory[m_recordMetricIndex] += totalBytes; m_componentStats[netComponentIndex].m_propertyUpdatesSent[propertyIndex].m_totalBytes += totalBytes;
m_componentStats[netComponentIndex].m_propertyUpdatesSent[propertyIndex].m_callHistory[m_recordMetricIndex]++;
m_componentStats[netComponentIndex].m_propertyUpdatesSent[propertyIndex].m_byteHistory[m_recordMetricIndex] += totalBytes;
} }
void MultiplayerStats::RecordPropertyReceived(uint16_t netComponentId, uint16_t propertyId, uint32_t totalBytes) void MultiplayerStats::RecordPropertyReceived(NetComponentId netComponentId, PropertyIndex propertyId, uint32_t totalBytes)
{ {
m_componentStats[netComponentId].m_propertyUpdatesRecv[propertyId].m_totalCalls++; const uint16_t netComponentIndex = aznumeric_cast<uint16_t>(netComponentId);
m_componentStats[netComponentId].m_propertyUpdatesRecv[propertyId].m_totalBytes += totalBytes; const uint16_t propertyIndex = aznumeric_cast<uint16_t>(propertyId);
m_componentStats[netComponentId].m_propertyUpdatesRecv[propertyId].m_callHistory[m_recordMetricIndex]++; m_componentStats[netComponentIndex].m_propertyUpdatesRecv[propertyIndex].m_totalCalls++;
m_componentStats[netComponentId].m_propertyUpdatesRecv[propertyId].m_byteHistory[m_recordMetricIndex] += totalBytes; m_componentStats[netComponentIndex].m_propertyUpdatesRecv[propertyIndex].m_totalBytes += totalBytes;
m_componentStats[netComponentIndex].m_propertyUpdatesRecv[propertyIndex].m_callHistory[m_recordMetricIndex]++;
m_componentStats[netComponentIndex].m_propertyUpdatesRecv[propertyIndex].m_byteHistory[m_recordMetricIndex] += totalBytes;
} }
void MultiplayerStats::RecordRpcSent(uint16_t netComponentId, uint16_t rpcId, uint32_t totalBytes) void MultiplayerStats::RecordRpcSent(NetComponentId netComponentId, RpcIndex rpcId, uint32_t totalBytes)
{ {
m_componentStats[netComponentId].m_rpcsSent[rpcId].m_totalCalls++; const uint16_t netComponentIndex = aznumeric_cast<uint16_t>(netComponentId);
m_componentStats[netComponentId].m_rpcsSent[rpcId].m_totalBytes += totalBytes; const uint16_t rpcIndex = aznumeric_cast<uint16_t>(rpcId);
m_componentStats[netComponentId].m_rpcsSent[rpcId].m_callHistory[m_recordMetricIndex]++; m_componentStats[netComponentIndex].m_rpcsSent[rpcIndex].m_totalCalls++;
m_componentStats[netComponentId].m_rpcsSent[rpcId].m_byteHistory[m_recordMetricIndex] += totalBytes; m_componentStats[netComponentIndex].m_rpcsSent[rpcIndex].m_totalBytes += totalBytes;
m_componentStats[netComponentIndex].m_rpcsSent[rpcIndex].m_callHistory[m_recordMetricIndex]++;
m_componentStats[netComponentIndex].m_rpcsSent[rpcIndex].m_byteHistory[m_recordMetricIndex] += totalBytes;
} }
void MultiplayerStats::RecordRpcReceived(uint16_t netComponentId, uint16_t rpcId, uint32_t totalBytes) void MultiplayerStats::RecordRpcReceived(NetComponentId netComponentId, RpcIndex rpcId, uint32_t totalBytes)
{ {
m_componentStats[netComponentId].m_rpcsRecv[rpcId].m_totalCalls++; const uint16_t netComponentIndex = aznumeric_cast<uint16_t>(netComponentId);
m_componentStats[netComponentId].m_rpcsRecv[rpcId].m_totalBytes += totalBytes; const uint16_t rpcIndex = aznumeric_cast<uint16_t>(rpcId);
m_componentStats[netComponentId].m_rpcsRecv[rpcId].m_callHistory[m_recordMetricIndex]++; m_componentStats[netComponentIndex].m_rpcsRecv[rpcIndex].m_totalCalls++;
m_componentStats[netComponentId].m_rpcsRecv[rpcId].m_byteHistory[m_recordMetricIndex] += totalBytes; m_componentStats[netComponentIndex].m_rpcsRecv[rpcIndex].m_totalBytes += totalBytes;
m_componentStats[netComponentIndex].m_rpcsRecv[rpcIndex].m_callHistory[m_recordMetricIndex]++;
m_componentStats[netComponentIndex].m_rpcsRecv[rpcIndex].m_byteHistory[m_recordMetricIndex] += totalBytes;
} }
void MultiplayerStats::TickStats(AZ::TimeMs metricFrameTimeMs) void MultiplayerStats::TickStats(AZ::TimeMs metricFrameTimeMs)
@ -85,24 +94,28 @@ namespace Multiplayer
return result; return result;
} }
MultiplayerStats::Metric MultiplayerStats::CalculateComponentPropertyUpdateSentMetrics(uint16_t netComponentId) const MultiplayerStats::Metric MultiplayerStats::CalculateComponentPropertyUpdateSentMetrics(NetComponentId netComponentId) const
{ {
return SumMetricVector(m_componentStats[netComponentId].m_propertyUpdatesSent); const uint16_t netComponentIndex = aznumeric_cast<uint16_t>(netComponentId);
return SumMetricVector(m_componentStats[netComponentIndex].m_propertyUpdatesSent);
} }
MultiplayerStats::Metric MultiplayerStats::CalculateComponentPropertyUpdateRecvMetrics(uint16_t netComponentId) const MultiplayerStats::Metric MultiplayerStats::CalculateComponentPropertyUpdateRecvMetrics(NetComponentId netComponentId) const
{ {
return SumMetricVector(m_componentStats[netComponentId].m_propertyUpdatesRecv); const uint16_t netComponentIndex = aznumeric_cast<uint16_t>(netComponentId);
return SumMetricVector(m_componentStats[netComponentIndex].m_propertyUpdatesRecv);
} }
MultiplayerStats::Metric MultiplayerStats::CalculateComponentRpcsSentMetrics(uint16_t netComponentId) const MultiplayerStats::Metric MultiplayerStats::CalculateComponentRpcsSentMetrics(NetComponentId netComponentId) const
{ {
return SumMetricVector(m_componentStats[netComponentId].m_rpcsSent); const uint16_t netComponentIndex = aznumeric_cast<uint16_t>(netComponentId);
return SumMetricVector(m_componentStats[netComponentIndex].m_rpcsSent);
} }
MultiplayerStats::Metric MultiplayerStats::CalculateComponentRpcsRecvMetrics(uint16_t netComponentId) const MultiplayerStats::Metric MultiplayerStats::CalculateComponentRpcsRecvMetrics(NetComponentId netComponentId) const
{ {
return SumMetricVector(m_componentStats[netComponentId].m_rpcsRecv); const uint16_t netComponentIndex = aznumeric_cast<uint16_t>(netComponentId);
return SumMetricVector(m_componentStats[netComponentIndex].m_rpcsRecv);
} }
MultiplayerStats::Metric MultiplayerStats::CalculateTotalPropertyUpdateSentMetrics() const MultiplayerStats::Metric MultiplayerStats::CalculateTotalPropertyUpdateSentMetrics() const
@ -110,7 +123,8 @@ namespace Multiplayer
Metric result; Metric result;
for (AZStd::size_t index = 0; index < m_componentStats.size(); ++index) for (AZStd::size_t index = 0; index < m_componentStats.size(); ++index)
{ {
CombineMetrics(result, CalculateComponentPropertyUpdateSentMetrics(index)); const NetComponentId netComponentId = aznumeric_cast<NetComponentId>(index);
CombineMetrics(result, CalculateComponentPropertyUpdateSentMetrics(netComponentId));
} }
return result; return result;
} }
@ -120,7 +134,8 @@ namespace Multiplayer
Metric result; Metric result;
for (AZStd::size_t index = 0; index < m_componentStats.size(); ++index) for (AZStd::size_t index = 0; index < m_componentStats.size(); ++index)
{ {
CombineMetrics(result, CalculateComponentPropertyUpdateRecvMetrics(index)); const NetComponentId netComponentId = aznumeric_cast<NetComponentId>(index);
CombineMetrics(result, CalculateComponentPropertyUpdateRecvMetrics(netComponentId));
} }
return result; return result;
} }
@ -130,7 +145,8 @@ namespace Multiplayer
Metric result; Metric result;
for (AZStd::size_t index = 0; index < m_componentStats.size(); ++index) for (AZStd::size_t index = 0; index < m_componentStats.size(); ++index)
{ {
CombineMetrics(result, CalculateComponentRpcsSentMetrics(index)); const NetComponentId netComponentId = aznumeric_cast<NetComponentId>(index);
CombineMetrics(result, CalculateComponentRpcsSentMetrics(netComponentId));
} }
return result; return result;
} }
@ -140,7 +156,8 @@ namespace Multiplayer
Metric result; Metric result;
for (AZStd::size_t index = 0; index < m_componentStats.size(); ++index) for (AZStd::size_t index = 0; index < m_componentStats.size(); ++index)
{ {
CombineMetrics(result, CalculateComponentRpcsRecvMetrics(index)); const NetComponentId netComponentId = aznumeric_cast<NetComponentId>(index);
CombineMetrics(result, CalculateComponentRpcsRecvMetrics(netComponentId));
} }
return result; return result;
} }

@ -15,6 +15,7 @@
#include <AzCore/Time/ITime.h> #include <AzCore/Time/ITime.h>
#include <AzCore/std/containers/vector.h> #include <AzCore/std/containers/vector.h>
#include <AzCore/std/containers/array.h> #include <AzCore/std/containers/array.h>
#include <Include/MultiplayerTypes.h>
namespace AzNetworking namespace AzNetworking
{ {
@ -51,17 +52,17 @@ namespace Multiplayer
}; };
AZStd::vector<ComponentStats> m_componentStats; AZStd::vector<ComponentStats> m_componentStats;
void ReserveComponentStats(uint16_t netComponentId, uint16_t propertyCount, uint16_t rpcCount); void ReserveComponentStats(NetComponentId netComponentId, uint16_t propertyCount, uint16_t rpcCount);
void RecordPropertySent(uint16_t netComponentId, uint16_t propertyId, uint32_t totalBytes); void RecordPropertySent(NetComponentId netComponentId, PropertyIndex propertyId, uint32_t totalBytes);
void RecordPropertyReceived(uint16_t netComponentId, uint16_t propertyId, uint32_t totalBytes); void RecordPropertyReceived(NetComponentId netComponentId, PropertyIndex propertyId, uint32_t totalBytes);
void RecordRpcSent(uint16_t netComponentId, uint16_t rpcId, uint32_t totalBytes); void RecordRpcSent(NetComponentId netComponentId, RpcIndex rpcId, uint32_t totalBytes);
void RecordRpcReceived(uint16_t netComponentId, uint16_t rpcId, uint32_t totalBytes); void RecordRpcReceived(NetComponentId netComponentId, RpcIndex rpcId, uint32_t totalBytes);
void TickStats(AZ::TimeMs metricFrameTimeMs); void TickStats(AZ::TimeMs metricFrameTimeMs);
Metric CalculateComponentPropertyUpdateSentMetrics(uint16_t netComponentId) const; Metric CalculateComponentPropertyUpdateSentMetrics(NetComponentId netComponentId) const;
Metric CalculateComponentPropertyUpdateRecvMetrics(uint16_t netComponentId) const; Metric CalculateComponentPropertyUpdateRecvMetrics(NetComponentId netComponentId) const;
Metric CalculateComponentRpcsSentMetrics(uint16_t netComponentId) const; Metric CalculateComponentRpcsSentMetrics(NetComponentId netComponentId) const;
Metric CalculateComponentRpcsRecvMetrics(uint16_t netComponentId) const; Metric CalculateComponentRpcsRecvMetrics(NetComponentId netComponentId) const;
Metric CalculateTotalPropertyUpdateSentMetrics() const; Metric CalculateTotalPropertyUpdateSentMetrics() const;
Metric CalculateTotalPropertyUpdateRecvMetrics() const; Metric CalculateTotalPropertyUpdateRecvMetrics() const;
Metric CalculateTotalRpcsSentMetrics() const; Metric CalculateTotalRpcsSentMetrics() const;

@ -0,0 +1,118 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/EBus/Event.h>
#include <AzCore/Name/Name.h>
#include <AzCore/RTTI/TypeSafeIntegral.h>
#include <AzCore/std/string/fixed_string.h>
#include <AzNetworking/Serialization/ISerializer.h>
#include <AzNetworking/ConnectionLayer/ConnectionEnums.h>
namespace Multiplayer
{
//! The default number of rewindable samples for us to store.
static constexpr uint32_t RewindHistorySize = 128;
AZ_TYPE_SAFE_INTEGRAL(HostId, uint32_t);
static constexpr HostId InvalidHostId = static_cast<HostId>(-1);
AZ_TYPE_SAFE_INTEGRAL(NetEntityId, uint32_t);
static constexpr NetEntityId InvalidNetEntityId = static_cast<NetEntityId>(-1);
AZ_TYPE_SAFE_INTEGRAL(NetComponentId, uint16_t);
static constexpr NetComponentId InvalidNetComponentId = static_cast<NetComponentId>(-1);
AZ_TYPE_SAFE_INTEGRAL(PropertyIndex, uint16_t);
AZ_TYPE_SAFE_INTEGRAL(RpcIndex, uint16_t);
using LongNetworkString = AZ::CVarFixedString;
using ReliabilityType = AzNetworking::ReliabilityType;
class NetworkEntityRpcMessage;
using RpcSendEvent = AZ::Event<NetworkEntityRpcMessage&>;
// Note that we explicitly set storage classes so that sizeof() is accurate for serialized size
enum class RpcDeliveryType : uint8_t
{
None,
AuthorityToClient, // Invoked from Authority, handled on Client
AuthorityToAutonomous, // Invoked from Authority, handled on Autonomous
AutonomousToAuthority, // Invoked from Autonomous, handled on Authority
ServerToAuthority // Invoked from Server, handled on Authority
};
enum class NetEntityRole : uint8_t
{
InvalidRole, // No role
Client, // A simulated proxy on a client
Autonomous, // An autonomous proxy on a client (can execute local prediction)
Server, // A simulated proxy on a server
Authority // An authoritative proxy on a server (full authority)
};
enum class ComponentSerializationType : uint8_t
{
Properties,
Correction
};
enum class EntityIsMigrating : uint8_t
{
False,
True
};
// This is just a placeholder
// The level/prefab cooking will devise the actual solution for identifying a dynamically spawnable entity within a prefab
struct PrefabEntityId
{
AZ_TYPE_INFO(PrefabEntityId, "{EFD37465-CCAC-4E87-A825-41B4010A2C75}");
static constexpr uint32_t AllIndices = AZStd::numeric_limits<uint32_t>::max();
AZ::Name m_prefabName;
uint32_t m_entityOffset = AllIndices;
PrefabEntityId() = default;
explicit PrefabEntityId(AZ::Name name, uint32_t entityOffset = AllIndices)
: m_prefabName(name)
, m_entityOffset(entityOffset)
{
}
bool operator==(const PrefabEntityId& rhs) const
{
return m_prefabName == rhs.m_prefabName && m_entityOffset == rhs.m_entityOffset;
}
bool operator!=(const PrefabEntityId& rhs) const
{
return !(*this == rhs);
}
bool Serialize(AzNetworking::ISerializer& serializer)
{
serializer.Serialize(m_prefabName, "prefabName");
serializer.Serialize(m_entityOffset, "entityOffset");
return serializer.IsValid();
}
};
}
AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(Multiplayer::HostId);
AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(Multiplayer::NetEntityId);
AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(Multiplayer::NetComponentId);
AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(Multiplayer::PropertyIndex);
AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(Multiplayer::RpcIndex);

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <AzCore/std/containers/list.h> #include <AzCore/std/containers/list.h>
#include <Source/MultiplayerTypes.h> #include <Include/MultiplayerTypes.h>
namespace AZ namespace AZ
{ {

@ -39,7 +39,7 @@ namespace {{ Namespace }}
componentData.m_componentPropertyNameLookupFunction = {{ ComponentBaseName }}::GetNetworkPropertyName; componentData.m_componentPropertyNameLookupFunction = {{ ComponentBaseName }}::GetNetworkPropertyName;
componentData.m_componentRpcNameLookupFunction = {{ ComponentBaseName }}::GetRpcName; componentData.m_componentRpcNameLookupFunction = {{ ComponentBaseName }}::GetRpcName;
{{ ComponentBaseName }}::s_netComponentId = multiplayerComponentRegistry->RegisterMultiplayerComponent(componentData); {{ ComponentBaseName }}::s_netComponentId = multiplayerComponentRegistry->RegisterMultiplayerComponent(componentData);
stats.ReserveComponentStats(static_cast<uint16_t>({{ ComponentBaseName }}::s_netComponentId), static_cast<uint16_t>({{ NetworkPropertyCount }}), static_cast<uint16_t>({{ RpcCount }})); stats.ReserveComponentStats({{ ComponentBaseName }}::s_netComponentId, static_cast<uint16_t>({{ NetworkPropertyCount }}), static_cast<uint16_t>({{ RpcCount }}));
} }
{% endfor %} {% endfor %}
} }

@ -227,7 +227,7 @@ AZStd::fixed_vector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }
#include <Source/Components/MultiplayerController.h> #include <Source/Components/MultiplayerController.h>
#include <Source/NetworkInput/IMultiplayerComponentInput.h> #include <Source/NetworkInput/IMultiplayerComponentInput.h>
#include <Source/NetworkTime/RewindableObject.h> #include <Source/NetworkTime/RewindableObject.h>
#include <Source/MultiplayerTypes.h> #include <Include/MultiplayerTypes.h>
{% call(Include) AutoComponentMacros.ParseIncludes(Component) %} {% call(Include) AutoComponentMacros.ParseIncludes(Component) %}
#include <{{ Include.attrib['File'] }}> #include <{{ Include.attrib['File'] }}>
{% endcall %} {% endcall %}
@ -251,9 +251,6 @@ namespace {{ Component.attrib['Namespace'] }}
class {{ ComponentName }}; class {{ ComponentName }};
class {{ ControllerName }}; class {{ ControllerName }};
//! Returns a human readable name for the provided remoteProcedureId.
const char* GetRemoteProcedureName(uint16_t remoteProcedureId);
{% set RecordName = ComponentName + "Record" %} {% set RecordName = ComponentName + "Record" %}
//! @class {{RecordName }} //! @class {{RecordName }}
//! @brief A record of the changed bits in the NetworkProperties for component {{ ComponentName }}. //! @brief A record of the changed bits in the NetworkProperties for component {{ ComponentName }}.
@ -487,8 +484,8 @@ namespace {{ Component.attrib['Namespace'] }}
void NotifyChangesAutonomousToAuthorityProperties(const {{ RecordName }}& replicationRecord) const; void NotifyChangesAutonomousToAuthorityProperties(const {{ RecordName }}& replicationRecord) const;
//! Debug name helpers //! Debug name helpers
static const char* GetNetworkPropertyName(uint16_t propertyIndex); static const char* GetNetworkPropertyName(PropertyIndex propertyIndex);
static const char* GetRpcName(uint16_t rpcIndex); static const char* GetRpcName(RpcIndex rpcIndex);
AZStd::unique_ptr<{{ RecordName }}> m_currentRecord; AZStd::unique_ptr<{{ RecordName }}> m_currentRecord;
AZStd::unique_ptr<{{ ControllerName }}> m_controller; AZStd::unique_ptr<{{ ControllerName }}> m_controller;

@ -285,7 +285,7 @@ void {{ ClassName }}::Set{{ UpperFirst(Property.attrib['Name']) }}(const {{ Prop
{{ AutoComponentMacros.ParseRpcParams(Property, paramNames, paramTypes, paramDefines) }} {{ AutoComponentMacros.ParseRpcParams(Property, paramNames, paramTypes, paramDefines) }}
void {{ ClassName }}::{{ UpperFirst(Property.attrib['Name']) }}({{ ', '.join(paramDefines) }}) void {{ ClassName }}::{{ UpperFirst(Property.attrib['Name']) }}({{ ', '.join(paramDefines) }})
{ {
constexpr uint16_t rpcId = static_cast<uint16_t>({{ UpperFirst(Component.attrib['Name']) }}Internal::RemoteProcedure::{{ UpperFirst(Property.attrib['Name']) }}); constexpr RpcIndex rpcId = static_cast<RpcIndex>({{ UpperFirst(Component.attrib['Name']) }}Internal::RemoteProcedure::{{ UpperFirst(Property.attrib['Name']) }});
{% if Property.attrib['IsReliable']|booleanTrue %} {% if Property.attrib['IsReliable']|booleanTrue %}
constexpr AzNetworking::ReliabilityType isReliable = Multiplayer::ReliabilityType::Reliable; constexpr AzNetworking::ReliabilityType isReliable = Multiplayer::ReliabilityType::Reliable;
{% else %} {% else %}
@ -508,8 +508,8 @@ bool {{ ClassName }}::Serialize{{ AutoComponentMacros.GetNetPropertiesSetName(Re
static_cast<int32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property) }}), static_cast<int32_t>({{ AutoComponentMacros.GetNetPropertiesQualifiedPropertyDirtyEnum(Component.attrib['Name'], ReplicateFrom, ReplicateTo, Property) }}),
m_{{ LowerFirst(Property.attrib['Name']) }}, m_{{ LowerFirst(Property.attrib['Name']) }},
"{{ Property.attrib['Name'] }}", "{{ Property.attrib['Name'] }}",
static_cast<uint16_t>(GetNetComponentId()), GetNetComponentId(),
static_cast<uint16_t>({{ UpperFirst(Component.attrib['Name']) }}Internal::NetworkProperties::{{ UpperFirst(Property.attrib['Name']) }}), static_cast<PropertyIndex>({{ UpperFirst(Component.attrib['Name']) }}Internal::NetworkProperties::{{ UpperFirst(Property.attrib['Name']) }}),
stats stats
); );
{% endif %} {% endif %}
@ -1253,7 +1253,7 @@ namespace {{ Component.attrib['Namespace'] }}
#pragma warning(disable: 4065) // switch statement contains 'default' but no 'case' labels #pragma warning(disable: 4065) // switch statement contains 'default' but no 'case' labels
bool {{ ComponentBaseName }}::HandleRpcMessage([[maybe_unused]] Multiplayer::NetEntityRole remoteRole, Multiplayer::NetworkEntityRpcMessage& message) bool {{ ComponentBaseName }}::HandleRpcMessage([[maybe_unused]] Multiplayer::NetEntityRole remoteRole, Multiplayer::NetworkEntityRpcMessage& message)
{ {
const {{ UpperFirst(Component.attrib['Name']) }}Internal::RemoteProcedure rpcType = static_cast<{{ UpperFirst(Component.attrib['Name']) }}Internal::RemoteProcedure>(message.GetRpcMessageType()); const {{ UpperFirst(Component.attrib['Name']) }}Internal::RemoteProcedure rpcType = static_cast<{{ UpperFirst(Component.attrib['Name']) }}Internal::RemoteProcedure>(message.GetRpcIndex());
switch (rpcType) switch (rpcType)
{ {
{{ DeclareRpcHandleCases(Component, ComponentDerived, 'Server', 'Authority', "(remoteRole == Multiplayer::NetEntityRole::Authority || remoteRole == Multiplayer::NetEntityRole::Server)" )|indent(8) }} {{ DeclareRpcHandleCases(Component, ComponentDerived, 'Server', 'Authority', "(remoteRole == Multiplayer::NetEntityRole::Authority || remoteRole == Multiplayer::NetEntityRole::Server)" )|indent(8) }}
@ -1396,7 +1396,7 @@ namespace {{ Component.attrib['Namespace'] }}
} }
{% endif %} {% endif %}
const char* {{ ComponentBaseName }}::GetNetworkPropertyName([[maybe_unused]] uint16_t propertyIndex) const char* {{ ComponentBaseName }}::GetNetworkPropertyName([[maybe_unused]] PropertyIndex propertyIndex)
{ {
{% if NetworkPropertyCount > 0 %} {% if NetworkPropertyCount > 0 %}
const {{ UpperFirst(Component.attrib['Name']) }}Internal::NetworkProperties propertyId = static_cast<{{ UpperFirst(Component.attrib['Name']) }}Internal::NetworkProperties>(propertyIndex); const {{ UpperFirst(Component.attrib['Name']) }}Internal::NetworkProperties propertyId = static_cast<{{ UpperFirst(Component.attrib['Name']) }}Internal::NetworkProperties>(propertyIndex);
@ -1411,7 +1411,7 @@ namespace {{ Component.attrib['Namespace'] }}
return "Unknown network property"; return "Unknown network property";
} }
const char* {{ ComponentBaseName }}::GetRpcName([[maybe_unused]] uint16_t rpcIndex) const char* {{ ComponentBaseName }}::GetRpcName([[maybe_unused]] RpcIndex rpcIndex)
{ {
{% if RpcCount > 0 %} {% if RpcCount > 0 %}
const {{ UpperFirst(Component.attrib['Name']) }}Internal::RemoteProcedure rpcId = static_cast<{{ UpperFirst(Component.attrib['Name']) }}Internal::RemoteProcedure>(rpcIndex); const {{ UpperFirst(Component.attrib['Name']) }}Internal::RemoteProcedure rpcId = static_cast<{{ UpperFirst(Component.attrib['Name']) }}Internal::RemoteProcedure>(rpcIndex);

@ -10,7 +10,7 @@
<ComponentRelation Constraint="Weak" HasController="true" Name="NetworkTransformComponent" Namespace="Multiplayer" Include="Source/Components/NetworkTransformComponent.h" /> <ComponentRelation Constraint="Weak" HasController="true" Name="NetworkTransformComponent" Namespace="Multiplayer" Include="Source/Components/NetworkTransformComponent.h" />
<Include File="Source/MultiplayerTypes.h"/> <Include File="Include/MultiplayerTypes.h"/>
<Include File="Source/NetworkInput/NetworkInput.h"/> <Include File="Source/NetworkInput/NetworkInput.h"/>
<Include File="Source/NetworkInput/NetworkInputHistory.h"/> <Include File="Source/NetworkInput/NetworkInputHistory.h"/>
<Include File="Source/NetworkInput/NetworkInputVector.h"/> <Include File="Source/NetworkInput/NetworkInputVector.h"/>

@ -2,7 +2,7 @@
<PacketGroup Name="MultiplayerPackets" PacketStart="CorePackets::PacketType::MAX"> <PacketGroup Name="MultiplayerPackets" PacketStart="CorePackets::PacketType::MAX">
<Include File="AzNetworking/AutoGen/CorePackets.AutoPackets.h" /> <Include File="AzNetworking/AutoGen/CorePackets.AutoPackets.h" />
<Include File="Source/MultiplayerTypes.h" /> <Include File="Include/MultiplayerTypes.h" />
<Include File="Source/NetworkEntity/NetworkEntityRpcMessage.h" /> <Include File="Source/NetworkEntity/NetworkEntityRpcMessage.h" />
<Include File="Source/NetworkEntity/NetworkEntityUpdateMessage.h" /> <Include File="Source/NetworkEntity/NetworkEntityUpdateMessage.h" />

@ -10,7 +10,7 @@
<ComponentRelation Constraint="Weak" HasController="false" Name="TransformComponent" Namespace="AzFramework" Include="AzFramework/Components/TransformComponent.h" /> <ComponentRelation Constraint="Weak" HasController="false" Name="TransformComponent" Namespace="AzFramework" Include="AzFramework/Components/TransformComponent.h" />
<Include File="Source/MultiplayerTypes.h"/> <Include File="Include/MultiplayerTypes.h"/>
<NetworkProperty Type="AZ::Quaternion" Name="rotation" Init="AZ::Quaternion::CreateIdentity()" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" GenerateEventBindings="true" /> <NetworkProperty Type="AZ::Quaternion" Name="rotation" Init="AZ::Quaternion::CreateIdentity()" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" GenerateEventBindings="true" />
<NetworkProperty Type="AZ::Vector3" Name="translation" Init="AZ::Vector3::CreateZero()" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" GenerateEventBindings="true" /> <NetworkProperty Type="AZ::Vector3" Name="translation" Init="AZ::Vector3::CreateZero()" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" GenerateEventBindings="true" />

@ -16,7 +16,7 @@
#include <AzNetworking/Serialization/ISerializer.h> #include <AzNetworking/Serialization/ISerializer.h>
#include <AzNetworking/DataStructures/FixedSizeBitsetView.h> #include <AzNetworking/DataStructures/FixedSizeBitsetView.h>
#include <Source/NetworkEntity/NetworkEntityHandle.h> #include <Source/NetworkEntity/NetworkEntityHandle.h>
#include <Source/MultiplayerTypes.h> #include <Include/MultiplayerTypes.h>
#include <Include/IMultiplayer.h> #include <Include/IMultiplayer.h>
//! Macro to declare bindings for a multiplayer component inheriting from MultiplayerComponent //! Macro to declare bindings for a multiplayer component inheriting from MultiplayerComponent
@ -110,8 +110,8 @@ namespace Multiplayer
int32_t bitIndex, int32_t bitIndex,
TYPE& value, TYPE& value,
const char* name, const char* name,
uint16_t componentId, NetComponentId componentId,
uint16_t propertyId, PropertyIndex propertyIndex,
MultiplayerStats& stats MultiplayerStats& stats
) )
{ {
@ -132,11 +132,11 @@ namespace Multiplayer
{ {
if (modifyRecord) if (modifyRecord)
{ {
stats.RecordPropertyReceived(componentId, propertyId, updateSize); stats.RecordPropertyReceived(componentId, propertyIndex, updateSize);
} }
else else
{ {
stats.RecordPropertySent(componentId, propertyId, updateSize); stats.RecordPropertySent(componentId, propertyIndex, updateSize);
} }
} }
} }

@ -33,13 +33,13 @@ namespace Multiplayer
return componentData.m_componentName.GetCStr(); return componentData.m_componentName.GetCStr();
} }
const char* MultiplayerComponentRegistry::GetComponentPropertyName(NetComponentId netComponentId, uint16_t propertyIndex) const const char* MultiplayerComponentRegistry::GetComponentPropertyName(NetComponentId netComponentId, PropertyIndex propertyIndex) const
{ {
const ComponentData& componentData = GetMultiplayerComponentData(netComponentId); const ComponentData& componentData = GetMultiplayerComponentData(netComponentId);
return componentData.m_componentPropertyNameLookupFunction(propertyIndex); return componentData.m_componentPropertyNameLookupFunction(propertyIndex);
} }
const char* MultiplayerComponentRegistry::GetComponentRpcName(NetComponentId netComponentId, uint16_t rpcIndex) const const char* MultiplayerComponentRegistry::GetComponentRpcName(NetComponentId netComponentId, RpcIndex rpcIndex) const
{ {
const ComponentData& componentData = GetMultiplayerComponentData(netComponentId); const ComponentData& componentData = GetMultiplayerComponentData(netComponentId);
return componentData.m_componentRpcNameLookupFunction(rpcIndex); return componentData.m_componentRpcNameLookupFunction(rpcIndex);

@ -21,13 +21,14 @@ namespace Multiplayer
class MultiplayerComponentRegistry class MultiplayerComponentRegistry
{ {
public: public:
using NameLookupFunction = AZStd::function<const char*(uint16_t index)>; using PropertyNameLookupFunction = AZStd::function<const char*(PropertyIndex index)>;
using RpcNameLookupFunction = AZStd::function<const char* (RpcIndex index)>;
struct ComponentData struct ComponentData
{ {
AZ::Name m_gemName; AZ::Name m_gemName;
AZ::Name m_componentName; AZ::Name m_componentName;
NameLookupFunction m_componentPropertyNameLookupFunction; PropertyNameLookupFunction m_componentPropertyNameLookupFunction;
NameLookupFunction m_componentRpcNameLookupFunction; RpcNameLookupFunction m_componentRpcNameLookupFunction;
}; };
//! Registers a multiplayer component with the multiplayer system. //! Registers a multiplayer component with the multiplayer system.
@ -49,13 +50,13 @@ namespace Multiplayer
//! @param netComponentId the NetComponentId to return the property name of //! @param netComponentId the NetComponentId to return the property name of
//! @param propertyIndex the index off the network property to return the property name of //! @param propertyIndex the index off the network property to return the property name of
//! @return the name of the network property //! @return the name of the network property
const char* GetComponentPropertyName(NetComponentId netComponentId, uint16_t propertyIndex) const; const char* GetComponentPropertyName(NetComponentId netComponentId, PropertyIndex propertyIndex) const;
//! Returns the Rpc name associated with the provided NetComponentId and rpcId. //! Returns the Rpc name associated with the provided NetComponentId and rpcId.
//! @param netComponentId the NetComponentId to return the property name of //! @param netComponentId the NetComponentId to return the property name of
//! @param rpcIndex the index of the rpc to return the rpc name of //! @param rpcIndex the index of the rpc to return the rpc name of
//! @return the name of the requested rpc //! @return the name of the requested rpc
const char* GetComponentRpcName(NetComponentId netComponentId, uint16_t rpcIndex) const; const char* GetComponentRpcName(NetComponentId netComponentId, RpcIndex rpcIndex) const;
//! Retrieves the stored component data for a given NetComponentId. //! Retrieves the stored component data for a given NetComponentId.
//! @param netComponentId the NetComponentId to return component data for //! @param netComponentId the NetComponentId to return component data for

@ -23,7 +23,7 @@
#include <Source/NetworkEntity/EntityReplication/ReplicationRecord.h> #include <Source/NetworkEntity/EntityReplication/ReplicationRecord.h>
#include <Source/NetworkEntity/NetworkEntityHandle.h> #include <Source/NetworkEntity/NetworkEntityHandle.h>
#include <Source/NetworkInput/IMultiplayerComponentInput.h> #include <Source/NetworkInput/IMultiplayerComponentInput.h>
#include <Source/MultiplayerTypes.h> #include <Include/MultiplayerTypes.h>
#include <AzCore/EBus/Event.h> #include <AzCore/EBus/Event.h>
namespace Multiplayer namespace Multiplayer

@ -60,36 +60,6 @@ namespace Multiplayer
{ {
if (ImGui::BeginMenu("Multiplayer")) if (ImGui::BeginMenu("Multiplayer"))
{ {
//{
// static int lossPercent{ 0 };
// lossPercent = static_cast<int>(net_UdpDebugLossPercent);
// if (ImGui::SliderInt("UDP Loss Percent", &lossPercent, 0, 100))
// {
// net_UdpDebugLossPercent = lossPercent;
// m_ClientAgent.UpdateConnectionCvars(net_UdpDebugLossPercent);
// }
//}
//
//{
// static int latency{ 0 };
// latency = static_cast<int>(net_UdpDebugLatencyMs);
// if (ImGui::SliderInt("UDP Latency Ms", &latency, 0, 3000))
// {
// net_UdpDebugLatencyMs = latency;
// m_ClientAgent.UpdateConnectionCvars(net_UdpDebugLatencyMs);
// }
//}
//
//{
// static int variance{ 0 };
// variance = static_cast<int>(net_UdpDebugVarianceMs);
// if (ImGui::SliderInt("UDP Variance Ms", &variance, 0, 1000))
// {
// net_UdpDebugVarianceMs = variance;
// m_ClientAgent.UpdateConnectionCvars(net_UdpDebugVarianceMs);
// }
//}
ImGui::Checkbox("Networking Stats", &m_displayNetworkingStats); ImGui::Checkbox("Networking Stats", &m_displayNetworkingStats);
ImGui::Checkbox("Multiplayer Stats", &m_displayMultiplayerStats); ImGui::Checkbox("Multiplayer Stats", &m_displayMultiplayerStats);
ImGui::EndMenu(); ImGui::EndMenu();
@ -147,12 +117,12 @@ namespace Multiplayer
return DrawMetricsRow(name, true, totalCalls, totalBytes, callsPerSecond, bytesPerSecond); return DrawMetricsRow(name, true, totalCalls, totalBytes, callsPerSecond, bytesPerSecond);
} }
bool DrawComponentRow(const char* name, const MultiplayerStats& stats, uint16_t componentIndex) bool DrawComponentRow(const char* name, const MultiplayerStats& stats, NetComponentId netComponentId)
{ {
const MultiplayerStats::Metric propertyUpdatesSent = stats.CalculateComponentPropertyUpdateSentMetrics(componentIndex); const MultiplayerStats::Metric propertyUpdatesSent = stats.CalculateComponentPropertyUpdateSentMetrics(netComponentId);
const MultiplayerStats::Metric propertyUpdatesRecv = stats.CalculateComponentPropertyUpdateRecvMetrics(componentIndex); const MultiplayerStats::Metric propertyUpdatesRecv = stats.CalculateComponentPropertyUpdateRecvMetrics(netComponentId);
const MultiplayerStats::Metric rpcsSent = stats.CalculateComponentRpcsSentMetrics(componentIndex); const MultiplayerStats::Metric rpcsSent = stats.CalculateComponentRpcsSentMetrics(netComponentId);
const MultiplayerStats::Metric rpcsRecv = stats.CalculateComponentRpcsRecvMetrics(componentIndex); const MultiplayerStats::Metric rpcsRecv = stats.CalculateComponentRpcsRecvMetrics(netComponentId);
const uint64_t totalCalls = propertyUpdatesSent.m_totalCalls + propertyUpdatesRecv.m_totalCalls + rpcsSent.m_totalCalls + rpcsRecv.m_totalCalls; const uint64_t totalCalls = propertyUpdatesSent.m_totalCalls + propertyUpdatesRecv.m_totalCalls + rpcsSent.m_totalCalls + rpcsRecv.m_totalCalls;
const uint64_t totalBytes = propertyUpdatesSent.m_totalBytes + propertyUpdatesRecv.m_totalBytes + rpcsSent.m_totalBytes + rpcsRecv.m_totalBytes; const uint64_t totalBytes = propertyUpdatesSent.m_totalBytes + propertyUpdatesRecv.m_totalBytes + rpcsSent.m_totalBytes + rpcsRecv.m_totalBytes;
@ -166,20 +136,21 @@ namespace Multiplayer
return DrawMetricsRow(name, true, totalCalls, totalBytes, callsPerSecond, bytesPerSecond); return DrawMetricsRow(name, true, totalCalls, totalBytes, callsPerSecond, bytesPerSecond);
} }
void DrawComponentDetails(const MultiplayerStats& stats, uint16_t componentIndex) void DrawComponentDetails(const MultiplayerStats& stats, NetComponentId netComponentId)
{ {
IMultiplayer* multiplayer = AZ::Interface<IMultiplayer>::Get(); IMultiplayer* multiplayer = AZ::Interface<IMultiplayer>::Get();
{ {
const MultiplayerStats::Metric metric = stats.CalculateComponentPropertyUpdateSentMetrics(componentIndex); const MultiplayerStats::Metric metric = stats.CalculateComponentPropertyUpdateSentMetrics(netComponentId);
float callsPerSecond = 0.0f; float callsPerSecond = 0.0f;
float bytesPerSecond = 0.0f; float bytesPerSecond = 0.0f;
AccumulatePerSecondValues(stats, metric, callsPerSecond, bytesPerSecond); AccumulatePerSecondValues(stats, metric, callsPerSecond, bytesPerSecond);
if (DrawMetricsRow("PropertyUpdates Sent", true, metric.m_totalCalls, metric.m_totalBytes, callsPerSecond, bytesPerSecond)) if (DrawMetricsRow("PropertyUpdates Sent", true, metric.m_totalCalls, metric.m_totalBytes, callsPerSecond, bytesPerSecond))
{ {
const MultiplayerStats::ComponentStats& componentStats = stats.m_componentStats[componentIndex]; const MultiplayerStats::ComponentStats& componentStats = stats.m_componentStats[aznumeric_cast<AZStd::size_t>(netComponentId)];
for (AZStd::size_t index = 0; index < componentStats.m_propertyUpdatesSent.size(); ++index) for (AZStd::size_t index = 0; index < componentStats.m_propertyUpdatesSent.size(); ++index)
{ {
const char* propertyName = multiplayer->GetComponentPropertyName(componentIndex, aznumeric_cast<uint16_t>(index)); const PropertyIndex propertyIndex = aznumeric_cast<PropertyIndex>(index);
const char* propertyName = multiplayer->GetComponentPropertyName(netComponentId, propertyIndex);
const MultiplayerStats::Metric& subMetric = componentStats.m_propertyUpdatesSent[index]; const MultiplayerStats::Metric& subMetric = componentStats.m_propertyUpdatesSent[index];
callsPerSecond = 0.0f; callsPerSecond = 0.0f;
bytesPerSecond = 0.0f; bytesPerSecond = 0.0f;
@ -191,16 +162,17 @@ namespace Multiplayer
} }
{ {
const MultiplayerStats::Metric metric = stats.CalculateComponentPropertyUpdateRecvMetrics(componentIndex); const MultiplayerStats::Metric metric = stats.CalculateComponentPropertyUpdateRecvMetrics(netComponentId);
float callsPerSecond = 0.0f; float callsPerSecond = 0.0f;
float bytesPerSecond = 0.0f; float bytesPerSecond = 0.0f;
AccumulatePerSecondValues(stats, metric, callsPerSecond, bytesPerSecond); AccumulatePerSecondValues(stats, metric, callsPerSecond, bytesPerSecond);
if (DrawMetricsRow("PropertyUpdates Recv", true, metric.m_totalCalls, metric.m_totalBytes, callsPerSecond, bytesPerSecond)) if (DrawMetricsRow("PropertyUpdates Recv", true, metric.m_totalCalls, metric.m_totalBytes, callsPerSecond, bytesPerSecond))
{ {
const MultiplayerStats::ComponentStats& componentStats = stats.m_componentStats[componentIndex]; const MultiplayerStats::ComponentStats& componentStats = stats.m_componentStats[aznumeric_cast<AZStd::size_t>(netComponentId)];
for (AZStd::size_t index = 0; index < componentStats.m_propertyUpdatesRecv.size(); ++index) for (AZStd::size_t index = 0; index < componentStats.m_propertyUpdatesRecv.size(); ++index)
{ {
const char* propertyName = multiplayer->GetComponentPropertyName(componentIndex, aznumeric_cast<uint16_t>(index)); const PropertyIndex propertyIndex = aznumeric_cast<PropertyIndex>(index);
const char* propertyName = multiplayer->GetComponentPropertyName(netComponentId, propertyIndex);
const MultiplayerStats::Metric& subMetric = componentStats.m_propertyUpdatesRecv[index]; const MultiplayerStats::Metric& subMetric = componentStats.m_propertyUpdatesRecv[index];
callsPerSecond = 0.0f; callsPerSecond = 0.0f;
bytesPerSecond = 0.0f; bytesPerSecond = 0.0f;
@ -212,16 +184,17 @@ namespace Multiplayer
} }
{ {
const MultiplayerStats::Metric metric = stats.CalculateComponentRpcsSentMetrics(componentIndex); const MultiplayerStats::Metric metric = stats.CalculateComponentRpcsSentMetrics(netComponentId);
float callsPerSecond = 0.0f; float callsPerSecond = 0.0f;
float bytesPerSecond = 0.0f; float bytesPerSecond = 0.0f;
AccumulatePerSecondValues(stats, metric, callsPerSecond, bytesPerSecond); AccumulatePerSecondValues(stats, metric, callsPerSecond, bytesPerSecond);
if (DrawMetricsRow("RemoteProcedures Sent", true, metric.m_totalCalls, metric.m_totalBytes, callsPerSecond, bytesPerSecond)) if (DrawMetricsRow("RemoteProcedures Sent", true, metric.m_totalCalls, metric.m_totalBytes, callsPerSecond, bytesPerSecond))
{ {
const MultiplayerStats::ComponentStats& componentStats = stats.m_componentStats[componentIndex]; const MultiplayerStats::ComponentStats& componentStats = stats.m_componentStats[aznumeric_cast<AZStd::size_t>(netComponentId)];
for (AZStd::size_t index = 0; index < componentStats.m_rpcsSent.size(); ++index) for (AZStd::size_t index = 0; index < componentStats.m_rpcsSent.size(); ++index)
{ {
const char* rpcName = multiplayer->GetComponentRpcName(componentIndex, aznumeric_cast<uint16_t>(index)); const RpcIndex rpcIndex = aznumeric_cast<RpcIndex>(index);
const char* rpcName = multiplayer->GetComponentRpcName(netComponentId, rpcIndex);
const MultiplayerStats::Metric& subMetric = componentStats.m_rpcsSent[index]; const MultiplayerStats::Metric& subMetric = componentStats.m_rpcsSent[index];
callsPerSecond = 0.0f; callsPerSecond = 0.0f;
bytesPerSecond = 0.0f; bytesPerSecond = 0.0f;
@ -233,16 +206,17 @@ namespace Multiplayer
} }
{ {
const MultiplayerStats::Metric metric = stats.CalculateComponentRpcsRecvMetrics(componentIndex); const MultiplayerStats::Metric metric = stats.CalculateComponentRpcsRecvMetrics(netComponentId);
float callsPerSecond = 0.0f; float callsPerSecond = 0.0f;
float bytesPerSecond = 0.0f; float bytesPerSecond = 0.0f;
AccumulatePerSecondValues(stats, metric, callsPerSecond, bytesPerSecond); AccumulatePerSecondValues(stats, metric, callsPerSecond, bytesPerSecond);
if (DrawMetricsRow("RemoteProcedures Recv", true, metric.m_totalCalls, metric.m_totalBytes, callsPerSecond, bytesPerSecond)) if (DrawMetricsRow("RemoteProcedures Recv", true, metric.m_totalCalls, metric.m_totalBytes, callsPerSecond, bytesPerSecond))
{ {
const MultiplayerStats::ComponentStats& componentStats = stats.m_componentStats[componentIndex]; const MultiplayerStats::ComponentStats& componentStats = stats.m_componentStats[aznumeric_cast<AZStd::size_t>(netComponentId)];
for (AZStd::size_t index = 0; index < componentStats.m_rpcsRecv.size(); ++index) for (AZStd::size_t index = 0; index < componentStats.m_rpcsRecv.size(); ++index)
{ {
const char* rpcName = multiplayer->GetComponentRpcName(componentIndex, aznumeric_cast<uint16_t>(index)); const RpcIndex rpcIndex = aznumeric_cast<RpcIndex>(index);
const char* rpcName = multiplayer->GetComponentRpcName(netComponentId, rpcIndex);
const MultiplayerStats::Metric& subMetric = componentStats.m_rpcsRecv[index]; const MultiplayerStats::Metric& subMetric = componentStats.m_rpcsRecv[index];
callsPerSecond = 0.0f; callsPerSecond = 0.0f;
bytesPerSecond = 0.0f; bytesPerSecond = 0.0f;
@ -259,11 +233,6 @@ namespace Multiplayer
const float TEXT_BASE_WIDTH = ImGui::CalcTextSize("A").x; const float TEXT_BASE_WIDTH = ImGui::CalcTextSize("A").x;
const float TEXT_BASE_HEIGHT = ImGui::GetTextLineHeightWithSpacing(); const float TEXT_BASE_HEIGHT = ImGui::GetTextLineHeightWithSpacing();
if (m_displayNetworkingStats)
{
}
if (m_displayMultiplayerStats) if (m_displayMultiplayerStats)
{ {
if (ImGui::Begin("Multiplayer Stats", &m_displayMultiplayerStats, ImGuiWindowFlags_HorizontalScrollbar)) if (ImGui::Begin("Multiplayer Stats", &m_displayMultiplayerStats, ImGuiWindowFlags_HorizontalScrollbar))
@ -296,14 +265,14 @@ namespace Multiplayer
{ {
for (AZStd::size_t index = 0; index < stats.m_componentStats.size(); ++index) for (AZStd::size_t index = 0; index < stats.m_componentStats.size(); ++index)
{ {
const uint16_t componentIndex = aznumeric_cast<uint16_t>(index); const NetComponentId netComponentId = aznumeric_cast<NetComponentId>(index);
using StringLabel = AZStd::fixed_string<128>; using StringLabel = AZStd::fixed_string<128>;
const StringLabel gemName = multiplayer->GetComponentGemName(componentIndex); const StringLabel gemName = multiplayer->GetComponentGemName(netComponentId);
const StringLabel componentName = multiplayer->GetComponentName(componentIndex); const StringLabel componentName = multiplayer->GetComponentName(netComponentId);
const StringLabel label = gemName + "::" + componentName; const StringLabel label = gemName + "::" + componentName;
if (DrawComponentRow(label.c_str(), stats, componentIndex)) if (DrawComponentRow(label.c_str(), stats, netComponentId))
{ {
DrawComponentDetails(stats, componentIndex); DrawComponentDetails(stats, netComponentId);
ImGui::TreePop(); ImGui::TreePop();
} }
} }

@ -506,24 +506,24 @@ namespace Multiplayer
handler.Connect(m_shutdownEvent); handler.Connect(m_shutdownEvent);
} }
const char* MultiplayerSystemComponent::GetComponentGemName(uint16_t netComponentIndex) const const char* MultiplayerSystemComponent::GetComponentGemName(NetComponentId netComponentId) const
{ {
return GetMultiplayerComponentRegistry()->GetComponentGemName(static_cast<NetComponentId>(netComponentIndex)); return GetMultiplayerComponentRegistry()->GetComponentGemName(netComponentId);
} }
const char* MultiplayerSystemComponent::GetComponentName(uint16_t netComponentIndex) const const char* MultiplayerSystemComponent::GetComponentName(NetComponentId netComponentId) const
{ {
return GetMultiplayerComponentRegistry()->GetComponentName(static_cast<NetComponentId>(netComponentIndex)); return GetMultiplayerComponentRegistry()->GetComponentName(netComponentId);
} }
const char* MultiplayerSystemComponent::GetComponentPropertyName(uint16_t netComponentIndex, uint16_t propertyIndex) const const char* MultiplayerSystemComponent::GetComponentPropertyName(NetComponentId netComponentId, PropertyIndex propertyIndex) const
{ {
return GetMultiplayerComponentRegistry()->GetComponentPropertyName(static_cast<NetComponentId>(netComponentIndex), propertyIndex); return GetMultiplayerComponentRegistry()->GetComponentPropertyName(netComponentId, propertyIndex);
} }
const char* MultiplayerSystemComponent::GetComponentRpcName(uint16_t netComponentIndex, uint16_t rpcIndex) const const char* MultiplayerSystemComponent::GetComponentRpcName(NetComponentId netComponentId, RpcIndex rpcIndex) const
{ {
return GetMultiplayerComponentRegistry()->GetComponentRpcName(static_cast<NetComponentId>(netComponentIndex), rpcIndex); return GetMultiplayerComponentRegistry()->GetComponentRpcName(netComponentId, rpcIndex);
} }
void MultiplayerSystemComponent::DumpStats([[maybe_unused]] const AZ::ConsoleCommandContainer& arguments) void MultiplayerSystemComponent::DumpStats([[maybe_unused]] const AZ::ConsoleCommandContainer& arguments)

@ -88,10 +88,10 @@ namespace Multiplayer
void AddConnectionAcquiredHandler(ConnectionAcquiredEvent::Handler& handler) override; void AddConnectionAcquiredHandler(ConnectionAcquiredEvent::Handler& handler) override;
void AddSessionInitHandler(SessionInitEvent::Handler& handler) override; void AddSessionInitHandler(SessionInitEvent::Handler& handler) override;
void AddSessionShutdownHandler(SessionShutdownEvent::Handler& handler) override; void AddSessionShutdownHandler(SessionShutdownEvent::Handler& handler) override;
const char* GetComponentGemName(uint16_t netComponentIndex) const override; const char* GetComponentGemName(NetComponentId netComponentId) const override;
const char* GetComponentName(uint16_t netComponentIndex) const override; const char* GetComponentName(NetComponentId netComponentId) const override;
const char* GetComponentPropertyName(uint16_t netComponentIndex, uint16_t propertyIndex) const override; const char* GetComponentPropertyName(NetComponentId netComponentId, PropertyIndex propertyIndex) const override;
const char* GetComponentRpcName(uint16_t netComponentIndex, uint16_t rpcIndex) const override; const char* GetComponentRpcName(NetComponentId netComponentId, RpcIndex rpcIndex) const override;
//! @} //! @}
//! Console commands. //! Console commands.

@ -33,6 +33,9 @@ namespace Multiplayer
AZ_TYPE_SAFE_INTEGRAL(NetComponentId, uint16_t); AZ_TYPE_SAFE_INTEGRAL(NetComponentId, uint16_t);
static constexpr NetComponentId InvalidNetComponentId = static_cast<NetComponentId>(-1); static constexpr NetComponentId InvalidNetComponentId = static_cast<NetComponentId>(-1);
AZ_TYPE_SAFE_INTEGRAL(PropertyIndex, uint16_t);
AZ_TYPE_SAFE_INTEGRAL(RpcIndex, uint16_t);
using LongNetworkString = AZ::CVarFixedString; using LongNetworkString = AZ::CVarFixedString;
using ReliabilityType = AzNetworking::ReliabilityType; using ReliabilityType = AzNetworking::ReliabilityType;
@ -111,3 +114,5 @@ namespace Multiplayer
AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(Multiplayer::HostId); AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(Multiplayer::HostId);
AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(Multiplayer::NetEntityId); AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(Multiplayer::NetEntityId);
AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(Multiplayer::NetComponentId); AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(Multiplayer::NetComponentId);
AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(Multiplayer::PropertyIndex);
AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(Multiplayer::RpcIndex);

@ -21,6 +21,7 @@
#include <Source/NetworkEntity/INetworkEntityManager.h> #include <Source/NetworkEntity/INetworkEntityManager.h>
#include <Source/Components/NetBindComponent.h> #include <Source/Components/NetBindComponent.h>
#include <Source/AutoGen/Multiplayer.AutoPackets.h> #include <Source/AutoGen/Multiplayer.AutoPackets.h>
#include <Include/IMultiplayer.h>
#include <AzNetworking/ConnectionLayer/IConnection.h> #include <AzNetworking/ConnectionLayer/IConnection.h>
#include <AzNetworking/ConnectionLayer/IConnectionListener.h> #include <AzNetworking/ConnectionLayer/IConnectionListener.h>
#include <AzNetworking/PacketLayer/IPacketHeader.h> #include <AzNetworking/PacketLayer/IPacketHeader.h>
@ -825,11 +826,12 @@ namespace Multiplayer
{ {
if (entityReplicator == nullptr) if (entityReplicator == nullptr)
{ {
IMultiplayer* multiplayer = AZ::Interface<IMultiplayer>::Get();
AZLOG_INFO AZLOG_INFO
( (
"EntityReplicationManager: Dropping remote RPC message for component %u of rpc type %d, entityId %u has already been deleted", "EntityReplicationManager: Dropping remote RPC message for component %s of rpc index %s, entityId %u has already been deleted",
aznumeric_cast<uint32_t>(message.GetComponentId()), multiplayer->GetComponentName(message.GetComponentId()),
message.GetRpcMessageType(), multiplayer->GetComponentRpcName(message.GetComponentId(), message.GetRpcIndex()),
message.GetEntityId() message.GetEntityId()
); );
return false; return false;

@ -449,7 +449,7 @@ namespace Multiplayer
{ {
// Received rpc metrics, log rpc sent, number of bytes, and the componentId/rpcId for bandwidth metrics // Received rpc metrics, log rpc sent, number of bytes, and the componentId/rpcId for bandwidth metrics
MultiplayerStats& stats = AZ::Interface<IMultiplayer>::Get()->GetStats(); MultiplayerStats& stats = AZ::Interface<IMultiplayer>::Get()->GetStats();
stats.RecordRpcSent(static_cast<uint16_t>(entityRpcMessage.GetComponentId()), entityRpcMessage.GetRpcMessageType(), entityRpcMessage.GetEstimatedSerializeSize()); stats.RecordRpcSent(entityRpcMessage.GetComponentId(), entityRpcMessage.GetRpcIndex(), entityRpcMessage.GetEstimatedSerializeSize());
m_replicationManager.AddDeferredRpcMessage(entityRpcMessage); m_replicationManager.AddDeferredRpcMessage(entityRpcMessage);
} }
@ -603,7 +603,7 @@ namespace Multiplayer
aznumeric_cast<uint32_t>(GetRemoteNetworkRole()), aznumeric_cast<uint32_t>(GetRemoteNetworkRole()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcDeliveryType()), aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcDeliveryType()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetComponentId()), aznumeric_cast<uint32_t>(entityRpcMessage.GetComponentId()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcMessageType()), aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcIndex()),
entityRpcMessage.GetReliability() == ReliabilityType::Reliable ? "true" : "false", entityRpcMessage.GetReliability() == ReliabilityType::Reliable ? "true" : "false",
IsMarkedForRemoval() ? "true" : "false" IsMarkedForRemoval() ? "true" : "false"
); );
@ -620,7 +620,7 @@ namespace Multiplayer
aznumeric_cast<uint32_t>(GetRemoteNetworkRole()), aznumeric_cast<uint32_t>(GetRemoteNetworkRole()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcDeliveryType()), aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcDeliveryType()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetComponentId()), aznumeric_cast<uint32_t>(entityRpcMessage.GetComponentId()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcMessageType()), aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcIndex()),
entityRpcMessage.GetReliability() == ReliabilityType::Reliable ? "true" : "false", entityRpcMessage.GetReliability() == ReliabilityType::Reliable ? "true" : "false",
IsMarkedForRemoval() ? "true" : "false" IsMarkedForRemoval() ? "true" : "false"
); );
@ -632,7 +632,7 @@ namespace Multiplayer
{ {
// Received rpc metrics, log rpc received, time spent, number of bytes, and the componentId/rpcId for bandwidth metrics // Received rpc metrics, log rpc received, time spent, number of bytes, and the componentId/rpcId for bandwidth metrics
MultiplayerStats& stats = AZ::Interface<IMultiplayer>::Get()->GetStats(); MultiplayerStats& stats = AZ::Interface<IMultiplayer>::Get()->GetStats();
stats.RecordRpcReceived(static_cast<uint16_t>(entityRpcMessage.GetComponentId()), entityRpcMessage.GetRpcMessageType(), entityRpcMessage.GetEstimatedSerializeSize()); stats.RecordRpcReceived(entityRpcMessage.GetComponentId(), entityRpcMessage.GetRpcIndex(), entityRpcMessage.GetEstimatedSerializeSize());
if (!m_netBindComponent) if (!m_netBindComponent)
{ {
@ -644,7 +644,7 @@ namespace Multiplayer
aznumeric_cast<uint32_t>(GetRemoteNetworkRole()), aznumeric_cast<uint32_t>(GetRemoteNetworkRole()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcDeliveryType()), aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcDeliveryType()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetComponentId()), aznumeric_cast<uint32_t>(entityRpcMessage.GetComponentId()),
aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcMessageType()), aznumeric_cast<uint32_t>(entityRpcMessage.GetRpcIndex()),
entityRpcMessage.GetReliability() == ReliabilityType::Reliable ? "true" : "false", entityRpcMessage.GetReliability() == ReliabilityType::Reliable ? "true" : "false",
IsMarkedForRemoval() ? "true" : "false" IsMarkedForRemoval() ? "true" : "false"
); );

@ -15,7 +15,7 @@
#include <AzNetworking/DataStructures/FixedSizeVectorBitset.h> #include <AzNetworking/DataStructures/FixedSizeVectorBitset.h>
#include <AzNetworking/Serialization/ISerializer.h> #include <AzNetworking/Serialization/ISerializer.h>
#include <AzNetworking/Utilities/NetworkCommon.h> #include <AzNetworking/Utilities/NetworkCommon.h>
#include <Source/MultiplayerTypes.h> #include <Include/MultiplayerTypes.h>
namespace Multiplayer namespace Multiplayer
{ {

@ -12,7 +12,7 @@
#pragma once #pragma once
#include <Source/MultiplayerTypes.h> #include <Include/MultiplayerTypes.h>
#include <Source/NetworkEntity/NetworkEntityHandle.h> #include <Source/NetworkEntity/NetworkEntityHandle.h>
#include <AzCore/Component/Entity.h> #include <AzCore/Component/Entity.h>
#include <AzCore/EBus/Event.h> #include <AzCore/EBus/Event.h>

@ -13,7 +13,7 @@
#pragma once #pragma once
#include <AzCore/Component/Entity.h> #include <AzCore/Component/Entity.h>
#include <Source/MultiplayerTypes.h> #include <Include/MultiplayerTypes.h>
namespace Multiplayer namespace Multiplayer
{ {

@ -21,7 +21,7 @@ namespace Multiplayer
: m_rpcDeliveryType(rhs.m_rpcDeliveryType) : m_rpcDeliveryType(rhs.m_rpcDeliveryType)
, m_entityId(rhs.m_entityId) , m_entityId(rhs.m_entityId)
, m_componentId(rhs.m_componentId) , m_componentId(rhs.m_componentId)
, m_rpcMessageType(rhs.m_rpcMessageType) , m_rpcIndex(rhs.m_rpcIndex)
, m_data(AZStd::move(rhs.m_data)) , m_data(AZStd::move(rhs.m_data))
, m_isReliable(rhs.m_isReliable) , m_isReliable(rhs.m_isReliable)
{ {
@ -32,7 +32,7 @@ namespace Multiplayer
: m_rpcDeliveryType(rhs.m_rpcDeliveryType) : m_rpcDeliveryType(rhs.m_rpcDeliveryType)
, m_entityId(rhs.m_entityId) , m_entityId(rhs.m_entityId)
, m_componentId(rhs.m_componentId) , m_componentId(rhs.m_componentId)
, m_rpcMessageType(rhs.m_rpcMessageType) , m_rpcIndex(rhs.m_rpcIndex)
, m_isReliable(rhs.m_isReliable) , m_isReliable(rhs.m_isReliable)
{ {
if (rhs.m_data != nullptr) if (rhs.m_data != nullptr)
@ -42,11 +42,11 @@ namespace Multiplayer
} }
} }
NetworkEntityRpcMessage::NetworkEntityRpcMessage(RpcDeliveryType rpcDeliveryType, NetEntityId entityId, NetComponentId componentId, uint16_t rpcMessageType, ReliabilityType isReliable) NetworkEntityRpcMessage::NetworkEntityRpcMessage(RpcDeliveryType rpcDeliveryType, NetEntityId entityId, NetComponentId componentId, RpcIndex rpcIndex, ReliabilityType isReliable)
: m_rpcDeliveryType(rpcDeliveryType) : m_rpcDeliveryType(rpcDeliveryType)
, m_entityId(entityId) , m_entityId(entityId)
, m_componentId(componentId) , m_componentId(componentId)
, m_rpcMessageType(rpcMessageType) , m_rpcIndex(rpcIndex)
, m_isReliable(isReliable) , m_isReliable(isReliable)
{ {
; ;
@ -57,7 +57,7 @@ namespace Multiplayer
m_rpcDeliveryType = rhs.m_rpcDeliveryType; m_rpcDeliveryType = rhs.m_rpcDeliveryType;
m_entityId = rhs.m_entityId; m_entityId = rhs.m_entityId;
m_componentId = rhs.m_componentId; m_componentId = rhs.m_componentId;
m_rpcMessageType = rhs.m_rpcMessageType; m_rpcIndex = rhs.m_rpcIndex;
m_isReliable = rhs.m_isReliable; m_isReliable = rhs.m_isReliable;
m_data = AZStd::move(rhs.m_data); m_data = AZStd::move(rhs.m_data);
return *this; return *this;
@ -68,7 +68,7 @@ namespace Multiplayer
m_rpcDeliveryType = rhs.m_rpcDeliveryType; m_rpcDeliveryType = rhs.m_rpcDeliveryType;
m_entityId = rhs.m_entityId; m_entityId = rhs.m_entityId;
m_componentId = rhs.m_componentId; m_componentId = rhs.m_componentId;
m_rpcMessageType = rhs.m_rpcMessageType; m_rpcIndex = rhs.m_rpcIndex;
m_isReliable = rhs.m_isReliable; m_isReliable = rhs.m_isReliable;
if (rhs.m_data != nullptr) if (rhs.m_data != nullptr)
{ {
@ -85,7 +85,7 @@ namespace Multiplayer
return ((m_rpcDeliveryType == rhs.m_rpcDeliveryType) return ((m_rpcDeliveryType == rhs.m_rpcDeliveryType)
&& (m_entityId == rhs.m_entityId) && (m_entityId == rhs.m_entityId)
&& (m_componentId == rhs.m_componentId) && (m_componentId == rhs.m_componentId)
&& (m_rpcMessageType == rhs.m_rpcMessageType)); && (m_rpcIndex == rhs.m_rpcIndex));
} }
bool NetworkEntityRpcMessage::operator !=(const NetworkEntityRpcMessage& rhs) const bool NetworkEntityRpcMessage::operator !=(const NetworkEntityRpcMessage& rhs) const
@ -101,7 +101,7 @@ namespace Multiplayer
+ sizeof(uint16_t); + sizeof(uint16_t);
// 2-byte size header + the actual blob payload itself // 2-byte size header + the actual blob payload itself
const uint32_t sizeOfBlob = (m_data != nullptr) ? sizeof(uint16_t) + m_data->GetSize() : 0; const uint32_t sizeOfBlob = (m_data != nullptr) ? sizeof(RpcIndex) + m_data->GetSize() : 0;
// No sliceId, remote replicator already exists so we don't need to know what type of entity this is // No sliceId, remote replicator already exists so we don't need to know what type of entity this is
return sizeOfFields + sizeOfBlob; return sizeOfFields + sizeOfBlob;
@ -127,9 +127,9 @@ namespace Multiplayer
return m_componentId; return m_componentId;
} }
uint16_t NetworkEntityRpcMessage::GetRpcMessageType() const RpcIndex NetworkEntityRpcMessage::GetRpcIndex() const
{ {
return m_rpcMessageType; return m_rpcIndex;
} }
bool NetworkEntityRpcMessage::SetRpcParams(IRpcParamStruct& params) bool NetworkEntityRpcMessage::SetRpcParams(IRpcParamStruct& params)
@ -167,7 +167,7 @@ namespace Multiplayer
serializer.Serialize(m_rpcDeliveryType, "RpcDeliveryType"); serializer.Serialize(m_rpcDeliveryType, "RpcDeliveryType");
serializer.Serialize(m_entityId, "EntityId"); serializer.Serialize(m_entityId, "EntityId");
serializer.Serialize(m_componentId, "ComponentId"); serializer.Serialize(m_componentId, "ComponentId");
serializer.Serialize(m_rpcMessageType, "RpcMessageType"); serializer.Serialize(m_rpcIndex, "RpcIndex");
// m_data should never be nullptr, it contains serialized data for our Rpc params struct // m_data should never be nullptr, it contains serialized data for our Rpc params struct
if (m_data == nullptr) if (m_data == nullptr)

@ -14,7 +14,7 @@
#include <AzNetworking/Serialization/ISerializer.h> #include <AzNetworking/Serialization/ISerializer.h>
#include <AzNetworking/DataStructures/ByteBuffer.h> #include <AzNetworking/DataStructures/ByteBuffer.h>
#include <Source/MultiplayerTypes.h> #include <Include/MultiplayerTypes.h>
namespace Multiplayer namespace Multiplayer
{ {
@ -35,12 +35,12 @@ namespace Multiplayer
NetworkEntityRpcMessage(const NetworkEntityRpcMessage& rhs); NetworkEntityRpcMessage(const NetworkEntityRpcMessage& rhs);
//! Fill explicit constructor. //! Fill explicit constructor.
//! @param rpcDeliveryType the delivery type (origin and target) for this RPC //! @param rpcDeliveryType the delivery type (origin and target) for this rpc
//! @param entityId the networked entityId of the entity handling this RPC //! @param entityId the networked entityId of the entity handling this rpc
//! @param componentType the networked componentId of the component handling this RPC //! @param componentType the networked componentId of the component handling this rpc
//! @param rpcMessageType the component defined RPC type, so the component knows which RPC this message corresponds to //! @param rpcIndex the component defined rpc index, so the component knows which rpc this message corresponds to
//! @param isReliable whether or not this RPC should be sent reliably //! @param isReliable whether or not this rpc should be sent reliably
explicit NetworkEntityRpcMessage(RpcDeliveryType rpcDeliveryType, NetEntityId entityId, NetComponentId componentId, uint16_t rpcMessageType, ReliabilityType isReliable); explicit NetworkEntityRpcMessage(RpcDeliveryType rpcDeliveryType, NetEntityId entityId, NetComponentId componentId, RpcIndex rpcIndex, ReliabilityType isReliable);
NetworkEntityRpcMessage& operator =(NetworkEntityRpcMessage&& rhs); NetworkEntityRpcMessage& operator =(NetworkEntityRpcMessage&& rhs);
NetworkEntityRpcMessage& operator =(const NetworkEntityRpcMessage& rhs); NetworkEntityRpcMessage& operator =(const NetworkEntityRpcMessage& rhs);
@ -67,9 +67,9 @@ namespace Multiplayer
//! @return the current value of EntityComponentType //! @return the current value of EntityComponentType
NetComponentId GetComponentId() const; NetComponentId GetComponentId() const;
//! Gets the current value of RpcMessageType. //! Gets the current value of RpcIndex.
//! @return the current value of RpcMessageType //! @return the current value of RpcIndex
uint16_t GetRpcMessageType() const; RpcIndex GetRpcIndex() const;
//! Writes the data contained inside a_Params to this NetworkEntityRpcMessage's blob buffer. //! Writes the data contained inside a_Params to this NetworkEntityRpcMessage's blob buffer.
//! @param params the parameters to save inside this NetworkEntityRpcMessage instance //! @param params the parameters to save inside this NetworkEntityRpcMessage instance
@ -98,7 +98,7 @@ namespace Multiplayer
RpcDeliveryType m_rpcDeliveryType = RpcDeliveryType::None; RpcDeliveryType m_rpcDeliveryType = RpcDeliveryType::None;
NetEntityId m_entityId = InvalidNetEntityId; NetEntityId m_entityId = InvalidNetEntityId;
NetComponentId m_componentId = InvalidNetComponentId; NetComponentId m_componentId = InvalidNetComponentId;
uint16_t m_rpcMessageType = 0; RpcIndex m_rpcIndex = RpcIndex{ 0 };
// Only allocated if we actually have data // Only allocated if we actually have data
// This is to prevent blowing out stack memory if we declare an array of these EntityUpdateMessages // This is to prevent blowing out stack memory if we declare an array of these EntityUpdateMessages

@ -12,7 +12,7 @@
#pragma once #pragma once
#include <Source/MultiplayerTypes.h> #include <Include/MultiplayerTypes.h>
#include <Source/NetworkEntity/NetworkEntityHandle.h> #include <Source/NetworkEntity/NetworkEntityHandle.h>
#include <AzCore/std/containers/unordered_map.h> #include <AzCore/std/containers/unordered_map.h>
#include <AzCore/Component/Entity.h> #include <AzCore/Component/Entity.h>

@ -131,7 +131,7 @@ namespace Multiplayer
} }
// 2-byte size header + the actual blob payload itself // 2-byte size header + the actual blob payload itself
const uint32_t sizeOfBlob = (m_data != nullptr) ? sizeof(uint16_t) + m_data->GetSize() : 0; const uint32_t sizeOfBlob = (m_data != nullptr) ? sizeof(PropertyIndex) + m_data->GetSize() : 0;
if (m_hasValidPrefabId) if (m_hasValidPrefabId)
{ {

@ -15,7 +15,7 @@
#include <AzNetworking/Serialization/ISerializer.h> #include <AzNetworking/Serialization/ISerializer.h>
#include <AzNetworking/DataStructures/ByteBuffer.h> #include <AzNetworking/DataStructures/ByteBuffer.h>
#include <AzCore/Name/Name.h> #include <AzCore/Name/Name.h>
#include <Source/MultiplayerTypes.h> #include <Include/MultiplayerTypes.h>
namespace Multiplayer namespace Multiplayer
{ {

@ -12,7 +12,7 @@
#pragma once #pragma once
#include <Source/MultiplayerTypes.h> #include <Include/MultiplayerTypes.h>
#include <AzNetworking/DataStructures/FixedSizeBitset.h> #include <AzNetworking/DataStructures/FixedSizeBitset.h>
#include <AzCore/std/containers/vector.h> #include <AzCore/std/containers/vector.h>
#include <AzCore/std/smart_ptr/unique_ptr.h> #include <AzCore/std/smart_ptr/unique_ptr.h>

@ -12,7 +12,7 @@
#pragma once #pragma once
#include <Source/MultiplayerTypes.h> #include <Include/MultiplayerTypes.h>
#include <Source/NetworkEntity/NetworkEntityHandle.h> #include <Source/NetworkEntity/NetworkEntityHandle.h>
#include <AzCore/std/containers/unordered_map.h> #include <AzCore/std/containers/unordered_map.h>

@ -13,11 +13,11 @@ set(FILES
Include/IMultiplayer.h Include/IMultiplayer.h
Include/MultiplayerStats.cpp Include/MultiplayerStats.cpp
Include/MultiplayerStats.h Include/MultiplayerStats.h
Include/MultiplayerTypes.h
Source/Multiplayer_precompiled.cpp Source/Multiplayer_precompiled.cpp
Source/Multiplayer_precompiled.h Source/Multiplayer_precompiled.h
Source/MultiplayerSystemComponent.cpp Source/MultiplayerSystemComponent.cpp
Source/MultiplayerSystemComponent.h Source/MultiplayerSystemComponent.h
Source/MultiplayerTypes.h
Source/AutoGen/AutoComponent_Header.jinja Source/AutoGen/AutoComponent_Header.jinja
Source/AutoGen/AutoComponent_Source.jinja Source/AutoGen/AutoComponent_Source.jinja
Source/AutoGen/AutoComponent_Common.jinja Source/AutoGen/AutoComponent_Common.jinja

Loading…
Cancel
Save